芯片是使用N32G430C8L7,在初始化ADC的时候轮询ADC上电
状态位,一直无法读回。代码如下:
void InitADC (void)
{
ADC_InitType ADC_InitStructure;
GPIO_InitType GPIO_InitStructure;
RCC_AHB_Peripheral_Clock_Enable(RCC_AHB_PERIPH_GPIOA | RCC_AHB_PERIPH_ADC);
ADC_Clock_Mode_Config(ADC_CKMOD_AHB, RCC_ADCHCLK_DIV16);
RCC_ADC_1M_Clock_Config(RCC_ADC1MCLK_SRC_HSE, RCC_ADC1MCLK_DIV8);
GPIO_Structure_Initialize(&GPIO_InitStructure);
GPIO_InitStructure.Pin = GPIO_PIN_6 | GPIO_PIN_7;
GPIO_InitStructure.GPIO_Mode = GPIO_MODE_ANALOG;
GPIO_Peripheral_Initialize(GPIOA, &GPIO_InitStructure);
ADC_Initializes_Structure(&ADC_InitStructure);
ADC_InitStructure.MultiChEn = DISABLE;
ADC_InitStructure.ContinueConvEn = DISABLE;
ADC_InitStructure.ExtTrigSelect = ADC_EXT_TRIGCONV_REGULAR_SWSTRRCH;
ADC_InitStructure.DatAlign = ADC_DAT_ALIGN_R;
ADC_InitStructure.ChsNumber = ADC_REGULAR_LEN_1;
ADC_Initializes(&ADC_InitStructure);
ADC_Data_Resolution_Config(ADC_RST_BIT_10);
ADC_ON();
while(ADC_Flag_Status_Get(ADC_RD_FLAG ,ADC_FLAG_AWDG ,ADC_FLAG_RDY) == RESET);
ADC_Calibration_Operation(ADC_CALIBRATION_ENABLE);
while (ADC_Calibration_Operation(ADC_CALIBRATION_STS) == SET);
} |