Page 1 of 1
calibrating ADC stm32F0
Posted: Fri Mar 11, 2016 10:45 am
by enrico.dallavia
Hi, on the ST manual I read that calibrating the ADC is recommended, since this involve accessing a register before start the ADC, I'm wondering if this is implemented on chibios by default when I start the driver or if I have to do it manually.
Re: calibrating ADC stm32F0
Posted: Fri Mar 11, 2016 10:51 am
by enrico.dallavia
found the answer by myself,
inside file adc_lld.c on function adc_lld_init
there is the code I hoped for
Code: Select all
/* Calibration procedure.*/
rccEnableADC1(FALSE);
osalDbgAssert(ADC1->CR == 0, "invalid register state");
ADC1->CR |= ADC_CR_ADCAL;
osalDbgAssert(ADC1->CR != 0, "invalid register state");
while (ADC1->CR & ADC_CR_ADCAL)
;
rccDisableADC1(FALSE);
ChibiOs rules!
Re: calibrating ADC stm32F0
Posted: Fri Mar 11, 2016 11:00 am
by enrico.dallavia
only a question, from manual also I read
The calibration is initiated by software by setting bit ADCAL=1. Calibration can only be
initiated when the ADC is disabled (when ADEN=0). ADCAL bit stays at 1 during all the
calibration sequence. It is then cleared by hardware as soon the calibration completes. After
this, the calibration factor can be read from the ADC_DR register (from bits 6 to 0).
that means I have to manage the calibration factor on my own? or it is an information kept inside the chip that compensate the reading by itself?
Thanks
Re: calibrating ADC stm32F0
Posted: Fri Mar 11, 2016 11:35 am
by Giovanni
No, it is done automatically.
Giovanni
Re: calibrating ADC stm32F0
Posted: Fri Mar 11, 2016 2:14 pm
by enrico.dallavia
awesome!
thanks!!!