Skip to content

EthanJamesLew/pwm-ctrl-stm32

Repository files navigation

16 Channel Sinusoidal PWM Controller

pwm waveforms viewed on an oscilloscope

An experiment to make a PWM controller in embedded Rust for the STM32F407 Discovery board.

Usage

Build

A release build is preferred for the optimizations. Run

cargo build --release

Note that the build may not fit in the processor if the debug config is used.

Development

Setup OpenOCD and run

openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -l /tmp/openocd.log

To run with semihosting,

gdb-multiarch -q target/thumbv7em-none-eabihf/release/stm32f4-hello --command=.gdbinit

and run c to continue.

Resources

This project is a chance for me to learn more about embedded Rust. Here are some helpful resources

Rust Resources

Embedded-Friendly Libraries

  • heapless embedded-friendly data structures that don't require dynamic memory allocation.
  • light-cli heapless CLI parser. I used this to make a simple CLI to control the device over serial TTL.
  • micromath embedded-friendly math functions library. I used this for LUT generation.

STM32F4xx Resources

  • STM32F407 Reference Manual complete information of how to use the processor and its peripheral devices. I referred to it when learning how to configure DMA for USART. I also use it for debugging, looking up what the status registers mean.
  • STM32F4 Discovery Board Manual reference for external devices that come with the development board. I referred to this when finding which GPIO blocks are connected to the LEDs. I also discovered that one pin gave filtered results because it was connected to a bypass cap.

STM32F4xx Peripheral Resources

  • UART using DMA useful for understanding serial using DMA and the tradeoffs of the various configurations.

Notes

Releases

No releases published

Packages

No packages published