PWM generation with DMA using stm32f4xx_hal

Does anyone have some up-to-date example code for taking a buffer of duty values, and outputting them with PWM using stm32f4xx_hal? All the code I’ve found is a little out of date, and the biggest thing I’m not sure about is how I specify what pin to output the signal on. Any help is appreciated, I’m completely new to embedded rust

(It would help if you specify if you are new to Rust, embedded, both or just the combination.)

While I haven't worked with that chip, in general I would expect that you construct an instance of a PWM peripheral which will take ownership of a suitably configured pin. That is how the ESP32 HAL works for example.

However, looking at stm32f4xx_hal - Rust I don't see a PWM module. What exact peripheral are you trying to use? And is it mapped in the HAL? Or are you trying to manually bit bang the PWM signal?

EDIT: I don't see anything PWM in the lower layer PAC either (stm32f4xx_hal::pac - Rust)

EDIT 2: Ah, seems like it is tied to the timers: stm32f4xx_hal::timer::pwm - Rust (which includes an example).

I'm not new to rust, although I haven't done anything huge in it. I'm relatively new to embedded, and completely new to the combination. I've found what I need to create PWM signals, it's just creating them with duty cycles pulled from a buffer using DMA. I think my best bet at the moment is just to get a board and start testing it.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.