INTERRUPT using LPC2148 (ARM):
Interrupt 0(INT0):
#include<lpc214x.h>
#define PLLE 0
#define PLLC 1
#define PLOCK 10
void delay(int );
void intinterrupt();
void plll0();
void interrupt_0()__irq
{
IO0SET=(0XFF<<17);
delay(100);
IO0CLR=(0XFF<<17);
delay(10);
EXTINT|=0XFF;
VICVectAddr=0x00;
}
void main()
{
PINSEL0=0X00000000; // port0.0 to port0.15 used as gpio mode
PINSEL1=0X00000000; // port0.16 to port0.31 used as gpio mode
PINSEL2=0X00000000; // port1.16 to port1.32 used as gpio mode
IO0DIR=0X0fFFFFFF; // direction of port0.0 to port0.31 worked as output mode
IO1DIR=0XFFFFFFFF;
plll0();
intinterrupt();
while(1)
{
IO1SET=0XFFFF0000;
delay(10);
IO1CLR=0XFFFF0000;
delay(10);
}
}
void delay(int ms)
{
T1CTCR=0x00;
T1TC=0;
T1PC=0;
T1PR=59999;
T1TCR=0x02;
T1TCR=0x01;
while( T1TC != ms);
T1TCR=0;
}
void plll0()
{
PLL0CFG=0x24;
PLL0CON=PLL0CON|(1<<PLLE);
PLL0FEED=0xAA;
PLL0FEED=0x55;
while( (PLL0STAT & (1<<PLOCK))==0);
PLL0CON=PLL0CON|3;
PLL0FEED=0xAA;
PLL0FEED=0x55;
VPBDIV=0x01;
}
void intinterrupt()
{
PINSEL0|=0x0c;
INTWAKE=INTWAKE|(1<<0);
EXTMODE=0X00;//edge
//EXTMODE=0X00;//edge
//EXTPOLAR=EXTPOLAR|(1<<0);//L2H
EXTPOLAR=0X00;
VICVectAddr0=(unsigned)interrupt_0;//32 //bit memory assign.
VICVectCntl0=0x20|14;
VICIntEnable|=(1<<14);
}
Simulation:
Interrupt 0(INT0):
#include<lpc214x.h>
#define PLLE 0
#define PLLC 1
#define PLOCK 10
void delay(int );
void intinterrupt();
void plll0();
void interrupt_0()__irq
{
IO0SET=(0XFF<<17);
delay(100);
IO0CLR=(0XFF<<17);
delay(10);
EXTINT|=0XFF;
VICVectAddr=0x00;
}
void main()
{
PINSEL0=0X00000000; // port0.0 to port0.15 used as gpio mode
PINSEL1=0X00000000; // port0.16 to port0.31 used as gpio mode
PINSEL2=0X00000000; // port1.16 to port1.32 used as gpio mode
IO0DIR=0X0fFFFFFF; // direction of port0.0 to port0.31 worked as output mode
IO1DIR=0XFFFFFFFF;
plll0();
intinterrupt();
while(1)
{
IO1SET=0XFFFF0000;
delay(10);
IO1CLR=0XFFFF0000;
delay(10);
}
}
void delay(int ms)
{
T1CTCR=0x00;
T1TC=0;
T1PC=0;
T1PR=59999;
T1TCR=0x02;
T1TCR=0x01;
while( T1TC != ms);
T1TCR=0;
}
void plll0()
{
PLL0CFG=0x24;
PLL0CON=PLL0CON|(1<<PLLE);
PLL0FEED=0xAA;
PLL0FEED=0x55;
while( (PLL0STAT & (1<<PLOCK))==0);
PLL0CON=PLL0CON|3;
PLL0FEED=0xAA;
PLL0FEED=0x55;
VPBDIV=0x01;
}
void intinterrupt()
{
PINSEL0|=0x0c;
INTWAKE=INTWAKE|(1<<0);
EXTMODE=0X00;//edge
//EXTMODE=0X00;//edge
//EXTPOLAR=EXTPOLAR|(1<<0);//L2H
EXTPOLAR=0X00;
VICVectAddr0=(unsigned)interrupt_0;//32 //bit memory assign.
VICVectCntl0=0x20|14;
VICIntEnable|=(1<<14);
}
Simulation:
0 comments:
Post a Comment
if you have any doubt please let me know