cpu/sam0_common/periph_adc: add work around for errata 2.1.6#20994
cpu/sam0_common/periph_adc: add work around for errata 2.1.6#20994maribu merged 1 commit intoRIOT-OS:masterfrom
Conversation
dylad
left a comment
There was a problem hiding this comment.
Quick review from the phone.
Can't test right now but this looks good.
cpu/sam0_common/periph/adc.c
Outdated
| ztimer_sleep(ZTIMER_USEC, 1); | ||
| # else | ||
| /* let's rather be safe than sorry */ | ||
| busy_wait_us(100); |
There was a problem hiding this comment.
Any reason to wait 100 us here but 40 us with ztimer_usec ?
There was a problem hiding this comment.
The busy_wait_us() is just counting CPU cycles and not that precise. I make the comment above a bit more specific.
There was a problem hiding this comment.
I also reduced it two twice the specified amount. That turns out to work reliably on my "bad MCU" affected by the bug and there should be enough safety margin.
This adds a delay between enabling the ADC and starting to sample on the SAMD5x MCUs when the internal bandgap reference is used. Co-authored-by: Dylan Laduranty <[email protected]>
51329dd to
a89c924
Compare
dylad
left a comment
There was a problem hiding this comment.
ACK.
Tested on my same54-xpro with tests/periph/adc which is stuck if
#define ADC_REF_DEFAULT ADC_REFCTRL_REFSEL_INTREF
is used.
With this PR, it works as expected.
|
Thx :) |
Contribution description
This adds a delay between enabling the ADC and starting to sample on the SAMD5x MCUs when the internal bandgap reference is used.
Testing procedure
Before,
adc_sample()on one of the SAMD5x MCUs I have at hands got stuck when the internal bandgap reference was used by never leaving this loop:Now, it works also on the "special" MCU that got stuck before:
Issues/PRs references
None