各位大侠,帮我看个程序,我用的是IAR5.2编译器,不知道怎么写外部中断,不知道这样写行不,还有IAR里面启动文件时怎么加进来的。
#include <NXP/iolpc2103.h>
#include <intrinsics.h>
__irq __arm void f_in(void);
#define IRQV 0x18
#pragma vector=IRQV
__irq __arm void irq_handler (void)
{
void (*interrupt_)();
unsigned int vector;
vector = VICVectAddr; // Get interrupt vector.
interrupt_ = (void(*)())vector;
if(interrupt_ != 0)
{
interrupt_(); // Call vectored interrupt .
}
else
{
VICVectAddr = 0; // Clear interrupt in VIC.
}
}
int main()
{
__disable_interrupt();
PINSEL0= 0x00000000;
PINSEL1 |=0x0000002;
IODIR |= 0x1<<17;
IOCLR |= 0x1<<17;
EXTMODE |=0x00;
EXTPOLAR|=0x00;
VICIntSelect |= 0x00000000;
VICIntEnClear|= 0xFFFFFFFF;
VICProtection = 0;
VICVectAddr = 0x00000000;
VICIntEnable |= 0x1<<14;
VICVectCntl0 = 0x20 | 14;
VICVectAddr0 = (unsigned int)&f_in;
__enable_interrupt();
while(1);
}
__irq __arm void f_in()
{
/*if((IOPIN&0x00000001)==1)
IOCLR |= 0x00000001;
else
IOSET |= 0x00000001; */
IOSET |=0x1<<17;
while((IOPIN&0x00010000)==0);//等待按键放开
EXTINT |= 0x01;
VICVectAddr=0x00;
}