MOD5213 DMA timer problem

Discussion to talk about software related topics only.
Post Reply
Haiyang
Posts: 11
Joined: Wed Mar 09, 2011 8:45 am

MOD5213 DMA timer problem

Post by Haiyang »

I am having problems with my DMA timer on my Netburner Mod5213. The timer glitches once a while when I used it to output PWM signal.

The DMA3 is set to generate a 50Hz PWM signal. However, I got servo glitches after about 5 min after bootup. I used Larry's StopWatch (DMA0) to measure the time between interrupts (Thanks Larry). I found out that the DMA timer is somehow messed up. For example, it goes to 1.2ms although it should be a solid 1.1 ms pulse width. The strange thing is that it comes back to solid 1.1 ms after about 1 second.

Can somebody help me check if I am setting my DMA correctly? or maybe it is something else?
-------------------------------------------
My dma3 is set up as following
void Initdma3() {
sim.timer[3].dtmr = 0;
sim.timer[3].dtrr = VAR_20ms;
sim.timer[3].dtmr = 0x03D;
SetIntc((long) &dt3Input, 22, 6, 1);
}


INTERRUPT( dma3int, 0x2600)
{
sim.timer[3].dter = 0x03;
if (Flag) {
Flag = 0;
Pins[PWM] = 1;
sim.timer[3].dtrr = VAR_1_3ms;
}else{
Flag = 1;
Pins[PWM_CH0] = 0;
sim.timer[3].dtrr = VAR_20ms - VAR_1_3ms;
}
sim.timer[3].dtmr = 0x03D;
}


Thanks
Haiyang
User avatar
lgitlitz
Posts: 331
Joined: Wed Apr 23, 2008 11:43 am
Location: San Diego, CA
Contact:

Re: MOD5213 DMA timer problem

Post by lgitlitz »

Hi Haiyang,

I see that you configure the dtmr register to be 0x3D. This set the clk to be divided by 16, with a 32-bit timer there is no need for this unless you need a timeout over 3 minutes. More importantly the reference manual states the clock/16 is not synchronized with the timer and successive timeouts may vary slightly. Not familiar with this but I would definitely switch your clock to the system clock divided by 1, or dtmr = 0x3B. Also there is no need to rewrite this register at the end of the interrupt though I do not thing it should matter. Try this and see if it works any better.

The MOD5213 also has a very nice PWM peripheral that is much better suited for generating PWM then the DMA timer. This peripheral will perform PWM without any interrupts or processor intervention like the DMA timer. This peripheral also has 8 channels you can output on.
edit: There is an application note for the PWM peripheral here: http://www.netburner.com/downloads/mod5 ... 13-PWM.pdf

-Larry
Haiyang
Posts: 11
Joined: Wed Mar 09, 2011 8:45 am

Re: MOD5213 DMA timer problem

Post by Haiyang »

Hi, Larry. Thanks for your prompt response and your suggestion. I really appreciate that.

I followed your advice to use the original system clock instead dividing by 16. Then the problem was gone for at least the two 10 minutes test I did. I need to do more tests to get a confirmation on that.
Hopefully that is the reason. I didn't notice the line on clock/16 in the manual until you pointed to me. I don't know why Netburner will provide a unsynchronized clock anyway.

The reason that we use DMA for PWM generation is because I need 9 ch PWM instead of 8 for our applications.

Best
Haiyang
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: MOD5213 DMA timer problem

Post by rnixon »

I don't think NetBurner has a choice on the clock sync., its handled by the Freescale processor.
Post Reply