cancel
Showing results for 
Search instead for 
Did you mean: 

How to Trigger DMA from a TIM with HAL

FKopp.1
Associate II

Hi,

I am trying to have a DMA move one unit of data every time the timer finishes it's counting period. The DMA would be circular so it would continually do this. I am going to be moving from a buffer to the CCR register of a pwm output.

I saw a HAL_TIM_PWM_Start_DMA function but this does not allow me to specify the DMA to be circular or whether the memory side is stored in bytes/words/etc. How would I go about triggering a DMA on every cycle of a timer with hal?

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

This example does exactly what you're looking for:

https://github.com/STMicroelectronics/STM32CubeF4/tree/b5abca20c9676b04f8d2885a668a9b653ee65705/Projects/STM324x9I_EVAL/Examples/TIM/TIM_DMA

The DMA parameters you mentioned (circular mode, memory width) are initialized before the call to HAL_TIM_PWM_Start_DMA, within HAL_TIM_PWM_Init:

https://github.com/STMicroelectronics/STM32CubeF4/blob/b5abca20c9676b04f8d2885a668a9b653ee65705/Projects/STM324x9I_EVAL/Examples/TIM/TIM_DMA/Src/stm32f4xx_hal_msp.c#L69

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

View solution in original post

2 REPLIES 2
TDK
Guru

This example does exactly what you're looking for:

https://github.com/STMicroelectronics/STM32CubeF4/tree/b5abca20c9676b04f8d2885a668a9b653ee65705/Projects/STM324x9I_EVAL/Examples/TIM/TIM_DMA

The DMA parameters you mentioned (circular mode, memory width) are initialized before the call to HAL_TIM_PWM_Start_DMA, within HAL_TIM_PWM_Init:

https://github.com/STMicroelectronics/STM32CubeF4/blob/b5abca20c9676b04f8d2885a668a9b653ee65705/Projects/STM324x9I_EVAL/Examples/TIM/TIM_DMA/Src/stm32f4xx_hal_msp.c#L69

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

how to set up the same thing through the cube?