py32-rs / py32-hal

Rust HAL implementation for py32 mcu.
4 stars 1 forks source link

The ADC reading of Vrefint may be incorrect on each power-up. #6

Closed decaday closed 2 weeks ago

decaday commented 3 weeks ago

When reading the internal Vrefint after powering up, the value can be a random number between 1.2V and 1.9V, such as 2072, 2160, 1500.

There’s about a 30% chance that the value is correct upon power-up.

The external channels work fine.

Delaying power-up doesn’t help, and adding a delay after enabling Vref doesn’t help either. External power supply does not resolve the issue.

https://github.com/py32-rs/py32-hal/blob/5586cfc9c99d5fb1e78bf9033177b74508fec828/examples/py32f030/src/bin/adc.rs#L18-L40

The ADC of PY32 is indeed different from STM32, and some parts I have already tried to implement in Rust, such as: When the ADC is in single-shot mode, after the conversion is complete, the ADC module needs to be re-enabled (ADC_EN = 1) to start the next conversion. The special calibration of PY32.

decaday commented 2 weeks ago

I can't reproduce this issue now. Everything is working fine.