mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-19 06:15:45 +01:00
Add ADC example for STM32F411 (#952)
* Add ADC example for STM32F411 * Update dependencies * Update RTIC version * example: f411-adc: prefer text over picture * example: f411-adc: nit: typo --------- Co-authored-by: Milton Eduardo Sosa <milton@Miltons-MacBook-Pro.local> Co-authored-by: Henrik Tjäder <henrik@tjaders.com>
This commit is contained in:
parent
861a63dbe3
commit
35891f4559
7 changed files with 959 additions and 0 deletions
36
examples/stm32f411_adc/README.md
Normal file
36
examples/stm32f411_adc/README.md
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
# STM32F411CEU6 ADC example
|
||||
Working example to work with the internal ADC of the STM32F411CEU6 present on a Blackpill board.
|
||||
|
||||
The `#init` task configures the ADC module for single-shot conversion and `PA1` as analog pin.
|
||||
|
||||
Afterwards, the analog pin stored in a Potentiometer struct is set as a **local** resource to the hardware task associated to `EXTI0`.
|
||||
|
||||
The `Adc<ADC1>` instance on the other hand, is set as a **shared** resource. The reason behind this approach is to allow other tasks make use of the only ADC module present on this microcontroller.
|
||||
|
||||
|
||||
|
||||
## How-to
|
||||
|
||||
### Build
|
||||
Run `cargo build --release` to compile the code. If you run it for the first time, it will take some time to download and compile dependencies.
|
||||
|
||||
### Run
|
||||
Install `probe-rs` and configure it using the [debugging extension for VScode](https://probe.rs/docs/tools/debugger/).
|
||||
The output should look like this:
|
||||
|
||||
```
|
||||
INFO Current delay value 1900
|
||||
INFO Current ADC value 665
|
||||
|
||||
INFO Current delay value 1800
|
||||
INFO Current ADC value 1138
|
||||
|
||||
INFO Current delay value 1700
|
||||
INFO Current ADC value 1136
|
||||
|
||||
INFO Current delay value 1600
|
||||
INFO Current ADC value 811
|
||||
|
||||
INFO Current delay value 1500
|
||||
INFO Current ADC value 1752
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue