Possible bug in ADC lld

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

Possible bug in ADC lld

Postby mmccoo » Wed Apr 25, 2018 9:26 am

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: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Possible bug in ADC lld

Postby Giovanni » Wed Jun 06, 2018 5:29 pm

Moved in bug reports.

Giovanni

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Possible bug in ADC lld

Postby Giovanni » Fri Jul 27, 2018 2:54 pm

Hi,

Is it the STM32F1 driver, right?

Giovanni

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Possible bug in ADC lld

Postby Giovanni » Sun Nov 10, 2019 10:30 am

bump

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

Re: Possible bug in ADC lld

Postby wurstnase » Sun Nov 10, 2019 3:50 pm

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.
\o/ Nico


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 58 guests