This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

External interrups stops Match Interrupts

Hello experts,

With LPC2138 I am developing a control system hardware and software for a packaging machine industry. I am unable to understand the below described behavior.

I am using Proteus to simulate my code.
I have connected a 50Hz square wave signal at EINT2 and digital switch at EINT1 as Interrupts.
Three LEDs and scopes at P0.0, 1 and 2 along with oscilloscopes to analyze.
I have noticed three behaviors which I am unable to understand.
Please help me.

P0.0 is at logic 1 just after around 0.5ms. Then it is toggled as per the digital input.
I think __irq void eint1_srv is executed once at first without any interrupt.
P0.1 toggles correctly from input square wave first edge and works without any issue.

When I give interrupts at digital switch, with second interrupt the frequency of P0.2 increases or at third interrupt P0.2 stays at logic 0 or 1 permanently. I think capture interrupt __irq void T0MR0_ISR is not called further.

Please help me.

__irq void eint1_srv (void);
__irq void eint2_srv (void);
__irq void T0MR0_ISR (void);

unsigned long op1=0, op2=0, vib=0;

unsigned long temp=0;

#include <LPC21xx.H>

int main(void)
{

IODIR0 = 0x0000FFFF;

/*Initialization of EINT1 and EINT2*/

EXTMODE = 0x0F;

EXTPOLAR = 0x0F;

PINSEL0 = 0xA0000000;

VICVectAddr1 = (unsigned long) eint1_srv;

VICVectCntl1 = 0x20 | 15;

VICVectAddr2 = (unsigned long) eint2_srv;

VICVectCntl2 = 0x20 | 16;

VICIntEnable = (1<<15) | (1<<16);

/*Initialization of Match OP*/

T0MR0 = 75000L;

T0PR = 0x00000000;

T0MCR = 0x00000003;

VICVectAddr4 = (unsigned long)T0MR0_ISR;

VICVectCntl4 = 0x20|4;

VICIntEnable = 1<<4;

T0TCR = 0x00000001;

while(1)

{

++temp;

if (temp>1000) temp=0; }
}

__irq void eint1_srv (void)
{

if(op1==0)

{

op1=1;

IO0SET = 1<<0;

}

else

{

op1=0;

IO0CLR = 1<<0;

T0MR0 = 30000L;

}

EXTINT = 1<<1; // Clear EINT1 interrupt flag
VICVectAddr = 0; // Acknowledge Interrupt

}

__irq void eint2_srv (void)
{

if(op2==0)

{

op2=1;

IO0SET = 1<<1;

// T0MR0 = 15000L;

}

else

{

op2=0;

IO0CLR = 1<<1;

// T0MR0 = 50000L;

}

EXTINT = 1<<2; // Clear EINT2 interrupt flag

VICVectAddr = 0; // Acknowledge Interrupt

}

__irq void T0MR0_ISR (void)

{

if (vib==0)

{

vib = 1;

IO0SET = 1<<2;

}

else

{

vib = 0;

IO0CLR = 1<<2;

}

T0IR = 1<<0;

VICVectAddr = 0;

}

0