Forums

PWM isr

Started by icapapindi April 25, 2006
Hi !!

I'm trying to generate a PWM interrupt on match MR0 with this code:

PCB_PINSEL0 |= 0x00028000;
GPIO0_IODIR = 0x00008000;
GPIO0_IOSET = 0x00008000;

VICVectAddr8 = (unsigned)IRQ_Routine;
VICVectCntl8 = 0x00000028;
VICIntEnable = 0x00000100;

PCB_PINSEL0 |= 0x00028008;
PWM_PR = 0x00000000;

PWM_PCR = 0x00000C0C;
PWM_MCR = 0x00000003;
PWM_MR0 = 0x400;
PWM_MR1 = 0;
PWM_MR2 = 0x200;
PWM_MR3 = 0x400;
PWM_LER = 0xF;
PWM_TCR = 0x00000002;
PWM_TCR = 0x00000009;

void __attribute__ ((interrupt("IRQ"))) IRQ_Routine()
{
static BOOLEAN bFlagSE;
if (!bFlag)
{
bFlagSE;
GPIO0_IOCLR=0x00008000;
}
else
{
bFlag=TRUE;
GPIO0_IOSET=0x00008000;
}

PWM_IR |= 0x00000001;
VICVectAddr = 0x00000000;
}
The PWM is generate correctly but the interrupt not,have you got any
idea, the code is from Keil I think. Have you got any idea?

Thanks

An Engineer's Guide to the LPC2100 Series

--- In l..., "icapapindi" wrote:
>
> Hi !!
>
> I'm trying to generate a PWM interrupt on match MR0 with this code:
>
> PCB_PINSEL0 |= 0x00028000;
> GPIO0_IODIR = 0x00008000;
> GPIO0_IOSET = 0x00008000;
>
> VICVectAddr8 = (unsigned)IRQ_Routine;
> VICVectCntl8 = 0x00000028;
> VICIntEnable = 0x00000100;
>
> PCB_PINSEL0 |= 0x00028008;
> PWM_PR = 0x00000000;
>
> PWM_PCR = 0x00000C0C;
> PWM_MCR = 0x00000003;
> PWM_MR0 = 0x400;
> PWM_MR1 = 0;
> PWM_MR2 = 0x200;
> PWM_MR3 = 0x400;
> PWM_LER = 0xF;
> PWM_TCR = 0x00000002;
> PWM_TCR = 0x00000009;
>
> void __attribute__ ((interrupt("IRQ"))) IRQ_Routine()
> {
> static BOOLEAN bFlagSE;
> if (!bFlag)
> {
> bFlagSE;
> GPIO0_IOCLR=0x00008000;
> }
> else
> {
> bFlag=TRUE;
> GPIO0_IOSET=0x00008000;
> }
>
> PWM_IR |= 0x00000001;
> VICVectAddr = 0x00000000;
> }
> The PWM is generate correctly but the interrupt not,have you got any
> idea, the code is from Keil I think. Have you got any idea?
>
> Thanks
>

Hi !! I have solved it, I forgot to activate isr

Now I'm trying to generate single PWM but it doesn't work, has anybody
done it?

Thanks