cancel
Showing results for 
Search instead for 
Did you mean: 

Timer and DMA

John Doe1
Associate III

I've been trying to configure the dma and pwm timer for 5 days with no luck...

There are a few things that I do not understand.

As far i know timer must be connected to a DMA to push the data.

1) In a timer there must be set a autoreload register (specified numer). What does that number means to dma? If I set autoreload to 8 it means 8 bits for dma?

2) What value should have pulse mode in PWM? Is PWM pulse set by a DMA in this case?

3) if I have uint32_t data = 0xAABBCC00 how I set that 0xAA will be send to PA0, 0xBB to PA1, 0xCC to PA2 and ignore 0x00?

4) How i can make it synchronous? Dma to gpio should be synchronous with a clock pin. I think i should use timer OC mode - am I right? If yes, pulse value of pulse should be set for OC?

I can not understand how I should configure the timer and what values for autopreload, pwm pulse, oc pulse should be set. Timers are sooo complicated :(

2 REPLIES 2

The ARR of the timer determines the period, Update is when CNT==0, the cycle after ARR==CNT

If you want the TIM to generate 8 pulses,use an Advanced TIM (TIM1/TIM8 on most parts), set the Repetition Count.

You don't want to access the TIM or GPIO 8-bit wide

To drive periodic signals onto GPIO use DMA to write the 32-bit wide GPIO->BSRR, use a DMA than is trigger from a TIM UPDATE or CCx signal of choice. Set the period to control how the APB/TIMCLK is divided down to the signal placement interval. The trigger doesn't need to be a pin, you can just set the TIM up as a timebase and use the TIMx_UP connected DMA channel/stream.

The BSRR allows you to control single or multiple pins on a bank going high or low.

You will need to make a "pattern buffer" describing the sequencing of the pins, you'd need to make 8 entries to turn the 0xAA to PA0 pattern sideways, high bits at position 0, low bits at position 16, ie 0x00000001 PA0=High, 0x00010000 PA0=Low

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Khouloud GARSI
Lead II

Hi @Community member​ ,

You may refer to "TIM_DMA" example provided under Cube package.

You may take this example as a reference to correctly configure your peripheral.

Khouloud.