lpcware

LPC824 + SCTimer + DMA = PWM out as sinus signal

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by vrm-janis on Tue Jul 28 05:44:56 MST 2015
Hello there.

I have solution for generation sine wave with variable base frequency, from PWM (LPC824 and SCTimer).

Simplifiedly:
SCTimer -> event which generate interrupt, reload matchrel[x] register from sine table (in RAM memory) in this interrupt and event x related to matchrel[x] is connected to out.set/clr to change pin state = PWM generate sine wave.

Interrupt routine:

void SCT_IRQHandler(void)
{
__disable_irq();
if (LPC_SCT->EVFLAG & 0x01)                                            // event 1 interrupt request?
{
if(Sin_Step0++ > SIN_STEPS) Sin_Step0 = 0;
LPC_SCT->MATCHREL[1].U = SinTable[Sin_Step0];// reload for match 1 - clear the OUT0
LPC_SCT->EVFLAG |= 0x01;                                    // clear flag
}
NVIC_ClearPendingIRQ(SCT_IRQn);
__enable_irq();
}



But, I have too much load in interrupt and processor time (generally in higher freq. of course) .

I have idea how to lighten it:

1. don't use SCT_IRQ
2. configure DMA transfer from SinTable[0] to LPC_SCT->MATCHREL[1].U, with length of uint32, with src autoincrement. This will be trigerred from event 1 of SCTimer.
3 configure event 1 of SCTimer for triggering DMA.
Run it.

Think I right?

Theoretically without any core intervention, will be functional ! - but one period only :-(

How to reload DMA transfer at end of sinetable from zero again (with minimal MCU core load) ?????

Thank you.

p.

Outcomes