Possible bug in ADC lld

Report here problems in any of ChibiOS components. This forum is NOT for support.
Post Reply
mmccoo
Posts: 3
Joined: Wed Apr 25, 2018 8:50 am

Possible bug in ADC lld

Post 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
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Possible bug in ADC lld

Post by Giovanni »

Moved in bug reports.

Giovanni
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Possible bug in ADC lld

Post by Giovanni »

Hi,

Is it the STM32F1 driver, right?

Giovanni
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Possible bug in ADC lld

Post by Giovanni »

bump
User avatar
wurstnase
Posts: 121
Joined: Tue Oct 17, 2017 2:24 pm
Has thanked: 43 times
Been thanked: 30 times

Re: Possible bug in ADC lld

Post 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.
Post Reply