-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 #20994
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to wait 100 us here but 40 us with ztimer_usec ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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