Skip to content

stm32/machine_adc: Enable ADC re-read errata handling for STM32WB55. #17230

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

andrewleech
Copy link
Contributor

Summary

For STM32WB errata 2.7.1:
"Wrong ADC result if conversion done late after calibration or previous conversion"
states an incorrect reading is returned if more than 1ms has elapsed since the last
reading or calibration. According to the errata, this can be avoided by performing
two consecutive ADC conversions and keeping the second result.

This matches existing handling for a comparable STM32G4 errata 2.7.7

Testing

Before this change the first read from an ADC channel often looked wrong, it turns out we'd previously added what was essentially a double-read in our application "to help the adc stabilise". Fixing it here in micropython is far more reliable and efficient.

Trade-offs and Alternatives

I initially though it would be better to add some timing checks / "how long since last read" and only re-read if needed, however I temporarily added some timing checks with ticks_us/ticks_diff and on my STM32WB55 @ 64Mhz and each ADC read seemed to take only ~ 3us, certainly not worth the overhead of storing and checking the time of last read.

Copy link

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
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