calibrating ADC stm32F0
Moderator: RoccoMarco
-
enrico.dallavia
- Posts: 105
- Joined: Thu Mar 12, 2015 10:15 am
- Has thanked: 2 times
calibrating ADC stm32F0
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.
-
enrico.dallavia
- Posts: 105
- Joined: Thu Mar 12, 2015 10:15 am
- Has thanked: 2 times
Re: calibrating ADC stm32F0
found the answer by myself,
inside file adc_lld.c on function adc_lld_init
there is the code I hoped for
ChibiOs rules!
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!
-
enrico.dallavia
- Posts: 105
- Joined: Thu Mar 12, 2015 10:15 am
- Has thanked: 2 times
Re: calibrating ADC stm32F0
only a question, from manual also I read
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
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
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
-
enrico.dallavia
- Posts: 105
- Joined: Thu Mar 12, 2015 10:15 am
- Has thanked: 2 times