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
Possible bug in ADC lld
- 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:
- 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:
- 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:
- 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
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.
Unfortunately it is sometimes at some tools. Not anytime at any tool.
\o/ Nico
Who is online
Users browsing this forum: No registered users and 58 guests