led_p-15
#include<lpc214x.h>
// Function prototypes
void lcd_init(void);
void wr_cn(void);
void clr_disp(void);
void delay(unsigned int);
void lcd_com(void);
void wr_dn(void);
void lcd_data(void);
void LCD(void);
void Extint1_Isr(void) __irq; //declaration of ISR
unsigned char int_flag, flag;
int main(void)
{
IO1DIR |= 0X02000000; //P1.25 int led
IO1SET = 0X02000000;
PINSEL0 =0X000000c0; //P0.3 EINT1
EXTMODE =0x01; //edge i.e falling egge trigger and active low
EXTPOLAR= 0X00;
VICVectAddr0 = (unsigned long) Extint1_Isr; //Assign the EINT0 ISR function
VICVectCntl0 = 0x20 | 15; //Assign the VIC channel EINT1 to interrupt priority 0
VICIntEnable |= 0x00008000; //Enable the EINT1 interrupt
while(1) //waiting for interrupt to occur
{
if(int_flag == 0x01)
{
if(flag == 0)
{
IO1CLR = 0X02000000;
flag = 1;
}
else if(flag == 1)
{
IO1SET = 0x02000000;
flag = 0;
}
int_flag = 0x00;
}
}
}
void Extint1_Isr(void)__irq //whenever there is a low edge on EINT0
{
EXTINT = 0x02; //clear the interrupt
int_flag = 0x01;
VICVectAddr=0; //Acknowledge Interrupt
}
Comments
Post a Comment