program getting stuck in PWM interrupt (tools- lpc1768, keil)

Thread Starter

raju bhosle

Joined Nov 8, 2017
1
I am generating Sine PWM using pwm of lpc1768 . My program is getting stuck in pwm interrupt even when i am clearing the interrupt at the end of handler .


void PWM1_IRQHandler (void)
{
NVIC_DisableIRQ (EINT3_IRQn);

NVIC_DisableIRQ (PWM1_IRQn);

regVal = LPC_PWM1->IR;



LPC_PWM1->MR6 = sineLookupTable[amp][pwmoffset];
LPC_PWM1->LER = LER6_EN;

if(sineLookupTable[amp][pwmoffset]==0)
{
pwmoffset=0;

LOOPTIME_COUNT++;
if((loadreg15==1)||(loadreg1==1)||(loadreg2==1)||(overvoltage_flag==1)||(undervoltage_flag==1))
{
n1++;
}
else
n1=0;

flag50hz = !flag50hz;

firingAngle =scrAngle;//((scrAngle/100) * 125);// scrAngle;

LPC_PWM1->IR |= regVal; /* clear interrupt flag on match 0 */

}

pwmoffset++;

if(pwmoffset==126)
{
pwmoffset=0;

}


if(flag50hz==0)//510,250, 17.36khz=346
{

LPC_GPIO0->FIOCLR=(1<<20);
LPC_GPIO1->FIOSET =(1<<21);


}
else
{
// LPC_GPIO0->FIOSET =0x00000001;
LPC_GPIO0->FIOSET =(1<<20);
LPC_GPIO1->FIOCLR=(1<<21);

}


if((pwmoffset <= (firingAngle+5))&&(pwmoffset >= firingAngle) )
{
//TEMP = firingAngle + 4;
LPC_GPIO0->FIOSET =(1<<5);
}
else
LPC_GPIO0->FIOCLR =(1<<5);



///////////////////////////
LPC_PWM1->IR |= regVal; /* clear interrupt flag on match 0 */
if(n1 >= 50)
{
n++;
n1=0;

}

if((undervoltage_flag==1) && (n== volttime))
{
voltageloopcount_flag=1;
}
else
voltageloopcount_flag=0;

if((overvoltage_flag==1) && (n== volttime))
{
voltageloopcount_flag=1;
}
else
voltageloopcount_flag=0;


if((loadreg15==1) && (n==900))
{
min15_flag=0;
n=0;
n1=0;
}
LPC_PWM1->IR |= regVal; /* clear interrupt flag on match 0 */
if((loadreg1==1) && (n==60))
{
min1_flag=0;
n=0;
n1=0;
}

if((loadreg2==1) && (n==10))
{
sec10_flag=0;
n=0;
n1=0;
}


LPC_PWM1->IR |= regVal; /* clear interrupt flag on match 0 */

NVIC_EnableIRQ (EINT3_IRQn);
NVIC_EnableIRQ (PWM1_IRQn);

return;
}
 
Top