cancel
Showing results for 
Search instead for 
Did you mean: 

DMA settings for timer channels in pwm mode

zeboss49
Associate III

Hello,

when enabling DMA for a Timer channel in PWM mode, the transfer direction is set to Memory to Peripheral.

This s very questionnable.

Is it a deliberate choice or a bug?

It does not make sense to select Peripheral to Memory for the DMA channel as it is used to wrtie to the device.

I fell in the trap several time, wasting time to look up for an issue in my code...

Very boring.

STM32 device is STM32F429, CubeIDE version 1.19.0 (same problem with all versions since I started using CubeIDE a couple of years before.)

 

3 REPLIES 3
TDK
Super User

This allows the PWM duty cycle to be changed. That seems the only sensible option here. Intentional and not a bug.

 

Why should it go from peripheral to memory? Are you perhaps looking for input capture mode instead?

If you feel a post has answered your question, please click "Accept as Solution".
Bermingham
Associate

You’re right—this can be confusing at first. For PWM output, DMA is intentionally set as Memory → Peripheral because you’re writing the duty cycle values from memory to the timer. Peripheral → Memory would be used for reading input data, like in Input Capture mode. Understanding the direction helps avoid wasted debugging time.

zeboss49
Associate III

Hello,

let me make things clear,

I know that the right direction is Memory to Peripheral.

My questionning was about CubeIDe which set the direction as Peripheral to Memory, requiring a change to make things work properly.