Thursday, February 21, 2008

Enabling interupt in LPC2212

/* This hold entire Application notes */
http://www.nxp.com/pip/LPC2212_2214_4.html

/* Manual : http://www.keil.com/dd/chip/3649.htm */
TN06002_LPC2000_EINT.pdf contains Below Code
int main (void)
{
IODIR1 = 0x00010000; // P1.16 defined as GPO
PINSEL1 |= 0x00000001; // P0.16 as EINT0 interrupt pin
VPBDIV = 0;
EXTMODE = 0x01; // EINT0 is (falling) edge-sensitive
// VPBDIV = 0x01; // additional step see errata
// VPB clock = CPU clock
VICVectAddr0 = (unsigned int) &EINT0_Isr;
EXTINT = 0x01; // Clear the peripheral interrupt flag
VICVectCntl0 = 0x2E; // Channel0 on Source# 14 == 0xE... enabled
/* Channel0 - high priority
Channel15 - low priority */
VICIntEnable = 0x4000; // 14th bit is EINT0
while (1) ;
}
void EINT0_Isr(void) __irq // for external interrupt 0
{
VICIntEnClr = 0x00004000; // Disable EINT0 in the VIC
/*.............
Our code
....*/
EXTINT = 0x01; // Clear the peripheral interrupt flag
VICIntEnable = 0x00004000; // Enable EINT0 in the VIC I.e 14 bit ==VIC# 14
VICVectAddr = 0; // reset VIC
}

No comments: