2022-03-10 02:21 AM
Hi, I'm trying to calibrate the ADC3 on my STM32F303RE microcontroller. In according to the REF MANUAL, I enabled the ADC voltage regulator and then started the calibration but code get stuck in the while loop forever (ADCAL is always 1). I put the for loop just to make sure the VREG got stabilized appropriately but nothing changed
RCC->AHBENR |= RCC_AHBENR_ADC34EN;
ADC3->CR &= ~ADC_CR_ADEN;
ADC3->CR &= ~(0b11<<28); //ADC voltage regulator enable
ADC3->CR |= (0b01<<28); //ADC voltage regulator enable
for(int i=1; i<10000;i++){}//delay
ADC3->CR &= ~ADC_CR_ADCALDIF;//calibration in Single-ended inputs Mode
ADC3->CR |= ADC_CR_ADCAL; //start ADC calibration
while (ADC3->CR & ADC_CR_ADCAL){}//calibration in progress
I'm new into the world of ARM microcontroller, so forgive me if I make a lot of mistakes.
Thanks in advance
Solved! Go to Solution.
2022-03-10 03:25 AM
You have to select/set up a "kernel clock" first - read the Clocks subchapter of ADC chapter in RM.
By default, the kernel clock is set in ADCx_CCR.CKMODE to 0b00, i.e. the clock from RCC.
That in turn is set by default in RCC_CFGR2.ADC34PRES=0b0000 => disabled.
The easiest way for an initial test is to set ADCx_CCR.CKMODE to nonzero, i.e. derive kernel clock from AHB clock.
JW
2022-03-10 03:25 AM
You have to select/set up a "kernel clock" first - read the Clocks subchapter of ADC chapter in RM.
By default, the kernel clock is set in ADCx_CCR.CKMODE to 0b00, i.e. the clock from RCC.
That in turn is set by default in RCC_CFGR2.ADC34PRES=0b0000 => disabled.
The easiest way for an initial test is to set ADCx_CCR.CKMODE to nonzero, i.e. derive kernel clock from AHB clock.
JW
2022-03-11 12:42 AM
Thank you. Now it works perfectly