cancel
Showing results for 
Search instead for 
Did you mean: 

ADC CAL problem

Nick-
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

2 REPLIES 2

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

Thank you. Now it works perfectly