Causes for ADC calibration not finishing?
I am porting a working project from an STM32F0 to an L0.
For that I let CubeIDE generate init code for the new MCU and replaced stuff that changed in my code. (next to adapting my modified linker script and all that)
The code gets stuck on waiting for the calibration to finish.
while (adc->CR & ADC_CR_ADCAL) {}At first it looked like the ADC had no clock, judging from the clock tree depiction in CubeIDE, so I changed the ADC clock to async and it's getting the internal 16MHz RC oscillator signal now.
That didn't help, though.
Some register bits I think might be relevant, when breaking into that loop with the debugger:
- ISR: is completely 0, i.e. also ADRDY and EOCAL
- CR: ADEN=0, ADDIS=1, ADSTART=0, ADSTP=0, ADVREGEN=1, ADCAL=1
- CFGR1:
DMAEN=1, all else 0- old note. I found that already, it should be 0. Setting it to 0 before calibration still does not make it complete
- CFGR2; OVSE=1, OVSR=3, rest 0
- CCR: LFMEN=0 - and async clock is 16MHz, VREFEN=1, rest 0
So as in the project for the F0, the ADC is not enabled during calibration, as is demanded in the reference manual.
Anything else wrong?
I wonder why ADDIS is still 1, if I read the reference correctly, the disabling of the ADC is ongoing when this is 1?
Edit: Funny. Before calibration, the code sets CR ADDIS to disable the thing - just for good measure, as it needs to be disabled. This worked in the old project. But here now, apparently, when the ADC is not enabled and this is done, this prevents the calibration from completing.
I wonder why that is. The calibration procedure in the reference does not mention something like that. The description of the ADDIS bit says "only effective if ADEN=1", ok, but "only effective" does not sound like "trashes other operations" to me ;)
