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

STM32 ADC with async () seems to be incompatible with DMA #3819

Open
felipec84 opened this issue Jan 28, 2025 · 1 comment
Open

STM32 ADC with async () seems to be incompatible with DMA #3819

felipec84 opened this issue Jan 28, 2025 · 1 comment

Comments

@felipec84
Copy link

Hello, I'm starting with embassy and stm32f030c8, and I have a question with ADC and DMA.

It seems that there a two forms of implement async for the ADC depending of the STM32 device:

One uses the ADC IRQ: v1.rs, f1.rs, f3.rs, in this case the examples uses for example
adc.read(&mut pin).await;

  • examples/stm32f0/src/bin/adc.rs
  • examples/stm32f1/src/bin/adc.rs

The other uses the ADC in blocking mode and uses DMA to get async, there are examples in:

  • examples/stm32g0/src/bin/adc_dma.rs
  • examples/stm32g4/src/bin/adc_dma.rs
  • examples/stm32h7/src/bin/adc_dma.rs

It seems to me that both implementations should work in all the STM32 family, but that they don't seems to be too compatible between them.

Is there a way to use the DMA implementation in the stm32f0 (or stm32f1), is there a way to allow both implementations?

What would be the embassy way, the async without DMA, the one requiring DMA of there will be both allowed?

@Gerharddc
Copy link
Contributor

Interesting, it would indeed be useful to have the simple async API available on the whole STM32 family. Since I did not want to use the blocking API, I ended up using the DMA API on an STM32F4 in an situation where it is complete overkill and would have preferred the simple async API.

Curiously, I also could not get the DMA system to reliably deliver samples in the correct order in the ring buffer. The documentation warns that this will happen when the buffer overflows, but this is not supposed to happen and I do not get any errors about overflow either.

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

No branches or pull requests

2 participants