embassy
embassy copied to clipboard
stm32f1 ADC example does not work
I run ADC example on stm32f103c8
but seems it does not works as expected.
It just awaits infinitely here: https://github.com/embassy-rs/embassy/blob/94586576a06cf5869d0cdea6d678a0448bb1fdf8/examples/stm32f1/src/bin/adc.rs#L26
GDB shows me that wfe
instruction was executed last but seems no events happening.
I run into the same problem but actually only if I use the crates. If I use the dependencies from path it works fine for me. Did you fix it for you?
Same issue here on a stm32f103c6
(Infinite wait on adc.read()
).
I run into the same problem but actually only if I use the crates. If I use the dependencies from path it works fine for me. Did you fix it for you?
Using the suggested method with 3638df789e4f498b9058bbeb27bdddab4a80bd49 I can read the adc value one time for each ADC.
On the second invocation it hangs again.
The output of the ADC-example for stm32f1
is:
0.000000 TRACE BDCR ok: 00008200
└─ embassy_stm32::rcc::bd::{impl#2}::init @ /home/paulz/src/embedded/embassy/embassy-stm32/src/fmt.rs:117
0.000000 DEBUG rcc: Clocks { hclk1: Some(Hertz(8000000)), pclk1: Some(Hertz(8000000)), pclk1_tim: Some(Hertz(8000000)), pclk2: Some(Hertz(8000000)), pclk2_tim: Some(Hertz(8000000)), rtc: Some(Hertz(40000)), sys: Some(Hertz(8000000)), usb: None }
└─ embassy_stm32::rcc::set_freqs @ /home/paulz/src/embedded/embassy/embassy-stm32/src/fmt.rs:130
0.000030 INFO Hello World!
└─ embassy_stm32f1_examples::____embassy_main_task::{async_fn#0} @ src/main.rs:19
The code hangs on the first loop iteration because read
got called for vref
.
The issue seems to be timing related.
Adding a Timer::after_ticks(1).await;
to https://github.com/embassy-rs/embassy/blob/3638df789e4f498b9058bbeb27bdddab4a80bd49/embassy-stm32/src/adc/f1.rs#L126 fixed the issue xD
Edit: even a Timer::after_ticks(1).await;
in L124 fixes the issue.