Interrupt

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Interrupt

585 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by pinkesh on Thu Jul 24 06:00:30 MST 2014
Hello ,

This is Pinkesh .I am novice to LPC family. Currently I am using LPC2129 and I have written the following interrupt based  program .Please let me know what is wrong with it.

#include <LPC21xx.H>

void extinterrupt(void)__irq ;
void delay(unsigned int no);

int main()
{
IO1DIR |= (1<<16);
PINSEL0  |= 0x000000C0;
VICVectCntl0 = 0x0000002F;
VICVectAddr0 = (unsigned) extinterrupt;
VICIntEnable = 0x00008000;
while(1)
{
}
}

void extinterrupt(void) __irq
{
IO1SET |= 0x00010000;
delay(1000);
IO1CLR  |= 0x00010000;
EXTINT = 0x00000002;
}

Original Attachment has been moved to: Interrupt.c.zip

Labels (1)
0 Kudos
1 Reply

430 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Tomas Rysavy on Mon Aug 18 04:45:16 MST 2014
Hello, what kind of compiler are you using (Keil, Crossworks, ...). Every type of compiler need specific syntax for interrupt handling.
For example - Crosswork (part of real running code for external interrupt):

int en;

void init_EXTINT2(void)
{
    EXTINT |= 0x04;                              //Set EXT INT behaviour on edge
    EXTMODE = 0x04;                        
    EXTPOLAR = 0x00;                       
    VICIntSelect &= ~(1 << 16);            //Make EINT2 a IRQ interrupt
    VICIntEnable |= 1<<16;                   //Enable EINT2 interrupt
    VICVectCntl0 = (1 << 5) | 16;          //use it for EINT2
    VICVectAddr0 = (unsigned)IRQ_Routine;   //set interrupt vector in 0
    en = libarm_set_irq(1);                 //Enable Global IRQ interrupts
}  

void IRQ_Routine (void)
{
   if (EInt1_toggle==0)
   {
    P0A21_OFF;
    EInt1_toggle=1;
    EXTPOLAR = 0x04;                      // EINT2 is sensitive on falling edge
   }
    else
   {
   P0A21_ON;
   EInt1_toggle=0;
   EXTPOLAR = 0x00;                      // EINT2 is sensitive on incerasing edge
   }
   EXTINT = 4;                                  // clear interrupt flag
   libarm_set_irq(en);                        // re-enable interrupts
}
0 Kudos