cancel
Showing results for 
Search instead for 
Did you mean: 

Timer 2 PWM and DMA not working

yoma1993
Associate II
Posted on May 27, 2015 at 01:16

 

 

The original post was too long to process during our migration. Please click on the attachment to read the original post.
7 REPLIES 7
Posted on May 27, 2015 at 01:33

Ok, you can't make random associations between TIM and DMA

TIM2_UP is DMA1 Channel 2 per RM0008

You could associate TIM2_CH3 (CC3) with DMA1 Channel 1, but I wouldn't advise that.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 27, 2015 at 01:41

Specifically, not

TIM_DMACmd(TIM2, TIM_DMA_CC1, ENABLE); // CC3 ? 

Pulse = 0; // Something >=1
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
yoma1993
Associate II
Posted on May 27, 2015 at 02:07

Thanks clive1, I knew it was something stupid! Is there a reason why you would not recommend the TIM2CH3 and DMA1CH1 combo? is there another combo you would recommend? 

Edit: Just for clarification for other users, the issue was resolved by changing the following.

DMA_InitStruct.DMA_PeripheralBaseAddr = (uint32_t)&TIM2->CCR1;

to

DMA_InitStruct.DMA_PeripheralBaseAddr = (uint32_t)&TIM2->CCR3;

and 

TIM_DMACmd(TIM2, TIM_DMA_CC1, ENABLE);

to

TIM_DMACmd(TIM2, TIM_DMA_CC3, ENABLE);

Posted on May 27, 2015 at 02:20

I prefer the Update trigger. With CCx you're going to have to be careful about the preload mode, and if you just advance the current count vs the next iteration of the timer period.

At the end of the day it might come down to the TIM/DMA resources you have available.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
yoma1993
Associate II
Posted on May 27, 2015 at 02:38

I see. This is my first time using DMA so i'll have to read up on that later. In the mean time i need to figure out how to get the PWM wave working properly for these LEDs. Thanks so much for your help!

yoma1993
Associate II
Posted on May 27, 2015 at 05:37

Can someone explain why im getting impulses instead of a PWM signal?

Here is a picture: 

http://i.imgur.com/QNntfWf.png

Posted on June 01, 2015 at 07:16

I'm pretty sure 50 K sample per second is not going to do well with a signal at 800 KHz, try 2 MSps

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