略费解 这个ADC 为何一直往串口发数据

2019-07-21 01:17发布

[mw_shl_code=c,true]int main() { double temp=0; uint16_t times=0,decimal=0; uint32_t integer=0; Delay_Init(168); Uart_Init( 115200); LED_Init( ); ADC1_Init(); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//?è????????????????·?×é2 for(times=1;times<21;times++) { ADC_RegularChannelConfig( ADC1, ADC_Channel_5, 1, ADC_SampleTime_480Cycles); ADC_SoftwareStartConv(ADC1); while(ADC_GetFlagStatus( ADC1, ADC_FLAG_EOC)!=SET); integer+=ADC_GetConversionValue( ADC1); delay_ms(5); } integer/=(times-1); temp=integer*3.3/4096;//×????????? ?????????????á ???????????ò?? integer=temp;//??????·? decimal=(temp-integer)*1000;//??????·? //printf("?????? "); USART_SendData( USART2, integer+0x30); while(USART_GetFlagStatus(USART2,USART_FLAG_TC)!=SET); USART_SendData( USART2, '.'); while(USART_GetFlagStatus(USART2,USART_FLAG_TC)!=SET); USART_SendData( USART2, decimal/100+0x30); while(USART_GetFlagStatus(USART2,USART_FLAG_TC)!=SET); USART_SendData( USART2, decimal%100/10+0x30); while(USART_GetFlagStatus(USART2,USART_FLAG_TC)!=SET); USART_SendData( USART2, decimal%10+0x30); while(USART_GetFlagStatus(USART2,USART_FLAG_TC)!=SET); USART_SendData( USART2, 'V'); while(USART_GetFlagStatus(USART2,USART_FLAG_TC)!=SET); USART_SendData( USART2, ' '); while(USART_GetFlagStatus(USART2,USART_FLAG_TC)!=SET); USART_SendData( USART2, ' '); while(USART_GetFlagStatus(USART2,USART_FLAG_TC)!=SET); //while(1); } [/mw_shl_code] 这是main函数部分
[mw_shl_code=c,true] void ADC1_Init() { ADC_InitTypeDef ADC_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; ADC_CommonInitTypeDef ADC_CommonInitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); GPIO_InitStructure.GPIO_Mode= GPIO_Mode_AN;//???????? GPIO_InitStructure.GPIO_Pin=GPIO_Pin_5; GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_NOPULL;//???????? GPIO_Init( GPIOA, &GPIO_InitStructure);//GPIO???????? ADC_CommonInitStructure.ADC_DMAAccessMode= ADC_DMAAccessMode_Disabled;//??DMA ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;//???????? ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div4;//±??¤??????????36MHZ?? ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles;//???± ADC_CommonInit( &ADC_CommonInitStructure); ADC_InitStructure.ADC_DataAlign= ADC_DataAlign_Right;//?????? ADC_InitStructure.ADC_ScanConvMode = DISABLE;//·??¨?è ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;//·????????? ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;//????·? ADC_InitStructure.ADC_NbrOfConversion = 1; ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;//12?? //ADC_InitStructure.ADC_ExternalTrigConv = ADC_Init( ADC1, &ADC_InitStructure); ADC_Cmd( ADC1, ENABLE); } [/mw_shl_code] 这是ADC部分   这个不知道为什么我如果把那句 [mw_shl_code=c,true]printf("?????? ");屏蔽掉 ADC就一直往串口发数据 虽说数据是正确的。。。表示很费解 而且不屏蔽那句话 就正常了 只发一次数据。。求各路大神解答 [/mw_shl_code]
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。