今天学习STM32的AD转换,在数据手册中看到这样一句话“启动校准前,ADC必须处于关电状态(ADON=’0’)超过至少两个ADC时钟周期。”,英文原句是这样的“Before starting a calibration, the ADC must have been in power-off state(ADON bit = '0') for at least two ADC clock cycles.”。然而,STM32固件库中给出的例程代码如下所示。
/* Enable ADC1 */
ADC_Cmd(ADC1, ENABLE);
/* Enable ADC1 reset calibration register */
ADC_ResetCalibration(ADC1);
/* Check the end of ADC1 reset calibration register */
while(ADC_GetResetCalibrationStatus(ADC1));
/* Start ADC1 calibration */
ADC_StartCalibration(ADC1);
/* Check the end of ADC1 calibration */
while(ADC_GetCalibrationStatus(ADC1));
/* Start ADC1 Software Conversion */
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
程序中使用ADC_Cmd(ADC1, ENABLE);使能了ADC1,即将ADON位设置为了1,然后复位并启动了校准,这样看来是与手册上相违背的,于是我把上面代码的第一条语句放到了最后一条语句之前,结果运行后程序停在了while(ADC_GetResetCalibrationStatus(ADC1