-
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: adc: implement 16 bit mode by oversampling #19165
Conversation
9e3bd93
to
ab81e33
Compare
ab81e33
to
6917b90
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.
Overall changes looks good to me.
But using tests/periph_adc
with RES set to ADC_RES_16BIT doesn't work as expected.
Works fine as long as the ADC line is below VCC_REF / 2 but it returns an error when we're above VCC_REF / 2.
I guess this is because this variable is set as int16_t
Good catch! |
Works as expected now ! |
4b12799
to
470bee5
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
bors merge |
🕐 Waiting for PR status (GitHub check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set. |
bors merge |
Already running a review |
Build succeeded: |
Contribution description
The precision of measurements can be increased by taking multiple measurements.
For this, the ADC implements an summation/averaging mode in hardware.
The best way I found to expose this in our ADC API is via the 16 bit resolution mode.
We can take up to 16 samples without exceeding the internal ADC register (after which 'automatic right shifts' happen - the result gets truncated).
Testing procedure
Issues/PRs references