-
AT32F403A 使用ADC时候出的问题。
使用ADC双模式时,程序卡在判断CAL控制位为零的循环中,在使用ADC双模式时,由于硬件不会清除CAL控制位,可能导致程序会卡在ADC校准函数while(ADC_GetCalibrationStatus(ADC1));我没有双使用ADC,还事卡住。#defineChannel_Num2#defineSample_Num1u16ADC_ConvertedValue[Sample_Num][Channel_Num];voidADC_DMA_Config(void){DMA_InitTypeDefDMA_InitStructure;RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1,ENABLE);DMA_DeInit(DMA1_Channel1);DMA_InitStructure.DMA_PeripheralBaseAddr=(uint32_t)&ADC1->DR;DMA_InitStructure.DMA_MemoryBaseAddr=(u32)&ADC_ConvertedValue;DMA_InitStructure.DMA_DIR=DMA_DIR_PeripheralSRC;DMA_InitStructure.DMA_BufferSize=Sample_Num*Channel_Num;DMA_InitStructure.DMA_PeripheralInc=DMA_PeripheralInc_Disable;//外设地址不变DMA_InitStructure.DMA_MemoryInc=DMA_MemoryInc_Enable;//内存地址递增DMA_InitStructure.DMA_PeripheralDataSize=DMA_PeripheralDataSize_HalfWord;DMA_InitStructure.DMA_MemoryDataSize=DMA_MemoryDataSize_HalfWord;DMA_InitStructure.DMA_Mode=DMA_Mode_Circular;DMA_InitStructure.DMA_Priority=DMA_Priority_High;DMA_InitStructure.DMA_M2M=DMA_M2M_Disable;DMA_Init(DMA1_Channel1,&DMA_InitStructure);//DMA_Cmd(DMA1_Channel1,ENABLE);DMA_ClearITPendingBit(DMA1_IT_TC1);//清除DMA通道x中断待处理标志位DMA_ITConfig(DMA1_Channel1,DMA_IT_TC,ENABLE);}//ADC配置函数voidADC_Configuration(void){u16i;ADC_InitTypeDefADC_InitStructure;RCC_ADCCLKConfig(RCC_PCLK2_Div6);//第二步:设置分频因子ADC最大速率14M72/6=12MADC_DeInit(ADC1);//将外设ADC1的全部寄存器重设为默认值//配置ADC1ADC_InitStructure.ADC_Mode=ADC_Mode_Independent;//独立模式ADC_InitStructure.ADC_ScanConvMode=ENABLE;//扫描ADC_InitStructure.ADC_ContinuousConvM
2021-01-07 2