Page 1 of 1

MOD5213 DMA timer problem

Posted: Tue Jul 12, 2011 7:24 pm
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

Re: MOD5213 DMA timer problem

Posted: Wed Jul 13, 2011 11:31 am
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

Re: MOD5213 DMA timer problem

Posted: Wed Jul 13, 2011 4:11 pm
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

Re: MOD5213 DMA timer problem

Posted: Wed Jul 13, 2011 4:33 pm
by rnixon
I don't think NetBurner has a choice on the clock sync., its handled by the Freescale processor.