Page 1 of 1

Possible bug in ADC lld

Posted: Wed Apr 25, 2018 9:26 am
by mmccoo
given this code, with stuff deleted:

void adc_lld_start_conversion(ADCDriver *adcp) {
uint32_t mode, cr2;

adcp->adc->CR2 = grpp->cr2 | cr2;


/* ADC start by writing ADC_CR2_ADON a second time.*/
adcp->adc->CR2 = cr2;
}


and quoting from the STM32 reference manual RM0008:
Bit 0 ADON: A/D converter ON / OFF
Note: If any other bit in this register apart from ADON is changed at the same time, then
conversion is not triggered
. This is to prevent triggering an erroneous conversion.



If the conversion group structure has a CR2 bit set, then the ADC won't start (ADON a second time). In many cases, that's a good thing (like the ext trigger stuff), but...

TSVREFE: Temperature sensor and VREFINT enable
SWSTART: Start conversion of regular channels
ALIGN: Data alignment


In my case, SWSTART was in my conversion group due to this article http://www.playembedded.org/blog/en/2015/02/16/sampling-and-dimming/ and ADC wasn't happening. Yes, I know that article says it's deprecated, but I figured that since it was written only a couple years ago, it should be close to still relevant.


Seems like the second CR2 assignment should match the first

Fixing this may be tricky for legacy reasons?


Miles

Re: Possible bug in ADC lld

Posted: Wed Jun 06, 2018 5:29 pm
by Giovanni
Moved in bug reports.

Giovanni

Re: Possible bug in ADC lld

Posted: Fri Jul 27, 2018 2:54 pm
by Giovanni
Hi,

Is it the STM32F1 driver, right?

Giovanni

Re: Possible bug in ADC lld

Posted: Sun Nov 10, 2019 10:30 am
by Giovanni
bump

Re: Possible bug in ADC lld

Posted: Sun Nov 10, 2019 3:50 pm
by wurstnase
I've seen that sometimes my ADC will not start. Could this be an issue with that part of code?

Unfortunately it is sometimes at some tools. Not anytime at any tool.