目前在调试STM32U575的ADC驱动,系统时钟及ADC初始化接口相同,但是从单驱动调试OK情况下移植至业务代码中出现ADC校准超时,有知道什么原因吗? ADC Init Failed. Error happened in the adc calibration process. How to solve it- HAL_StatusTypeDef HAL_ADCEx_Calibration_Start(ADC_HandleTypeDef *hadc, uint32_t CalibrationMode, uint32_t SingleDiff)
- {
- HAL_StatusTypeDef tmp_hal_status;
- __IO uint32_t wait_loop_index = 0UL;
- UNUSED(SingleDiff); /* STM32U5 calibration is not making difference between Single and Diff ended */
- /* We keep this to be inligne with old products API and for any further use */
- /* Check the parameters */
- assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
- assert_param(IS_ADC_SINGLE_DIFFERENTIAL(SingleDiff));
- __HAL_LOCK(hadc);
- /* Calibration prerequisite: ADC must be disabled. */
- /* Disable the ADC (if not already disabled) */
- tmp_hal_status = ADC_Disable(hadc);
- /* Check if ADC is effectively disabled */
- if (tmp_hal_status == HAL_OK)
- {
- /* Set ADC state */
- ADC_STATE_CLR_SET(hadc->State, HAL_ADC_STATE_REG_BUSY | HAL_ADC_STATE_INJ_BUSY, HAL_ADC_STATE_BUSY_INTERNAL);
- /* Start ADC calibration in mode single-ended or differential */
- LL_ADC_StartCalibration(hadc->Instance, CalibrationMode);
- /* Wait for calibration completion */
- while (LL_ADC_IsCalibrationOnGoing(hadc->Instance) != 0UL)
- {
- wait_loop_index++;
- if (wait_loop_index >= ADC_CALIBRATION_TIMEOUT)
- {
- /* Update ADC state machine to error */
- ADC_STATE_CLR_SET(hadc->State, HAL_ADC_STATE_BUSY_INTERNAL, HAL_ADC_STATE_ERROR_INTERNAL);
- __HAL_UNLOCK(hadc);
- return HAL_ERROR;
- }
- }
- /* Set ADC state */
- ADC_STATE_CLR_SET(hadc->State, HAL_ADC_STATE_BUSY_INTERNAL, HAL_ADC_STATE_READY);
- }
- else
- {
- SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_INTERNAL);
- /* Note: No need to update variable "tmp_hal_status" here: already set */
- /* to state "HAL_ERROR" by function disabling the ADC. */
- }
- __HAL_UNLOCK(hadc);
- return tmp_hal_status;
- }
复制代码
|
您好,我和您遇到了同样的问题,只是我是开发板遇到的。没太明白您说的VDD没有打开是什么意思,是VDDA没有连接到3.3V吗?麻烦您解答一下可以吗