Skip to main content
Nick-
Associate II
March 10, 2022
Solved

ADC CAL problem

  • March 10, 2022
  • 1 reply
  • 1068 views

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

This topic has been closed for replies.
Best answer by waclawek.jan

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

1 reply

waclawek.jan
waclawek.janBest answer
Super User
March 10, 2022

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

Nick-
Nick-Author
Associate II
March 11, 2022

Thank you. Now it works perfectly