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 board revision detection in firmware #112

Merged
merged 2 commits into from
Aug 1, 2024

Conversation

mossmann
Copy link
Member

  • Read ADC twice and discard first reading
  • Fix bug in board revision detection for non-gsg_production boards

I believe the double ADC read is the correct fix for greatscottgadgets/cynthion#138. A previous fix in #109 may have been unnecessary, but we will keep it for now to be safe.

mossmann added 2 commits July 31, 2024 15:56
Previously we added a fixed value to the ADC reading before
right-shifting. This corrected truncation error, allowing integer
comparison values to match a whole percentage number in the table of
expected ranges. This correction worked when gsg_production was true,
but it was incorrect in the other case.

We now do the math with per mille values rather than percent values, so
it is simpler to eliminate the truncation correction and instead compare
against an expected value between two whole percents. For example, we
compare the per mille value with 225 to determine whether it is closer
to 22 percent or 23 percent.
@mossmann mossmann requested a review from mndza July 31, 2024 20:29
@mossmann mossmann requested a review from mndza August 1, 2024 13:54
@mossmann mossmann merged commit 9cab9f2 into greatscottgadgets:main Aug 1, 2024
11 checks passed
@mossmann mossmann deleted the adc-fix branch August 1, 2024 14:51
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.

2 participants