Skip to content
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

fix #362: ADC voltage conversion might be incorrect #397

Merged
merged 1 commit into from
Dec 11, 2021

Conversation

gernoteger
Copy link
Contributor

since the discussion in #362 seems to come to a conclusion, and my personal measurements supported that, I think it's time to actually fix it.
This will change max_sample from 1<<n-1 to 1<<n,
After this PR ADC readings will change, but will be more accurate than before. Users might be confused since they won't get a reading of 3300mV, but this is correct behaviour.

@burrbull
Copy link
Member

burrbull commented Dec 8, 2021

Maybe add some description about convertion rules in adc.rs docs?

@gernoteger
Copy link
Contributor Author

Ok, will do that

jordens
jordens previously approved these changes Dec 8, 2021
Copy link
Member

@jordens jordens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
This makes the Debug::fmt() output a bit confusing as now that max_sample is exclusive. But it says nowhere that max_sample must be inclusive so I'm absolutely fine with it. Maybe a small comment in on the struct field would help though.

@gernoteger
Copy link
Contributor Author

@jordens Sorry, I don't understand the comment about Debug::fmt(), this PR doesn't change anything there. Sure you commented on the right PR?

@jordens
Copy link
Member

jordens commented Dec 9, 2021

The PR does affects the string that it printed. It would now say e.g. ... max_sample: 4096, ... while in fact 4096 is not a valid sample. The inclusive maximum is max_sample - 1.

@gernoteger
Copy link
Contributor Author

gernoteger commented Dec 9, 2021 via email

@burrbull
Copy link
Member

bors r+

@bors bors bot merged commit 9424a37 into stm32-rs:master Dec 11, 2021
@gernoteger gernoteger deleted the fix_adc_voltage branch December 11, 2021 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants