我用的是周立功LPC2100模板 外部中断怎么老进不去啊 请大家帮忙看看阿 先谢谢了 #include "config.h"
uint16 Fdiv; uint8 p; uint8 flag_ri; uint32 T1temp0,T1temp1,T1diff; uint32 T2temp0,T2temp1,T2diff; uint8 flag_t1,flag_t2; float freqnd1,freqnd2; uint8 end1,end2;
void init_ic(void)
{ //================================IO初始化 PINSEL0=0x800000c5; PINSEL1=0x15454000; PINSEL2=0x00000000; //=======================设置T1用于做时间轴 T1TC=0; T1PR=0; T1MR1=0Xffffffff; T1MCR=0X00; T1TCR=0X01; //=========================串口设置 U0LCR=0X83; //U0DLL=0X12; // U0DLM=0X00; Fdiv = (Fpclk / 16) / 9600; // 设置波特率 U0DLM = Fdiv>>8; U0DLL = Fdiv&0xff; U0LCR=0X03; // U0FCR=0X07; // U0IER=0x01; //======================设置中断向量 VICIntSelect=0x00000000; VICVectCntl1 = 0x2F; // EINT1通道分配到IRQ slot 1,即优先级1 VICVectAddr1 = (uint32)IRQ_Eint1; // 设置EINT1向量地址 VICVectCntl2 = 0x30; // EINT2通道分配到IRQ slot 2,即优先级2 VICVectAddr2 = (uint32)IRQ_Eint2;
//====================外部中断设置 EXTMODE = 0x0f; //外部中断边沿触发 EXTPOLAR = 0x00; //下降沿触发 EXTINT=0x07; //clear INT0, INT1 and INT2 interrupt flag 清外部中断标志 外部中断低电平有效,对其写1是复位 VICIntEnable=0x00018000;//enable INT1 and INT2 interrupt }
void DelayNS(uint32 dly) { uint32 i; for (;dly>0;dly--) for (i=0;i<50000;i++); }
int main (void) { end1=0x31; end2=0x32; IO1DIR=0x00030000; IO1SET=0x00030000; init_ic();
for(;;) { if(flag_t1) { freqnd1=12000000.0/T1diff; if(freqnd1>45 && freqnd1<60) { end1=50; } else end1=100; } if(flag_t2) { IO1SET=0x00020000; freqnd2=12000000.0/T2diff; if(freqnd2>45 && freqnd2<60) { end2=50; } else end2=100; } p=end1; // p=0x31; U0THR=p; while( (U0LSR&0x20)==0 ); DelayNS(50); p=end2; //p=0x32; U0THR=p; while( (U0LSR&0x20)==0 );
// return 0; } }
void __irq IRQ_UART0(void) {
VICVectAddr=0x00; }
void __irq IRQ_Eint1(void) { T1temp0=T1temp1; T1temp1=T1TC; T1diff=T1temp1-T1temp0; flag_t1=1; /* EXTINT=0x02; end1=0x33;*/ VICVectAddr=0x00; } void __irq IRQ_Eint2(void) { /* EXTINT = 0x04; // 清除中断标志 外部中断2 IRQ中断 IO1CLR= 0x00020000; T2temp0=T2temp1; T2temp1=T1TC; if(T2temp1>T2temp0) { flag_t2=1; T2diff=T2temp1-T2temp0; }*/ EXTINT = 0x04; end2=0x35; VICVectAddr=0x00; }
可是2100模板还要配置呢?在那里配置?如何配置呢?期待大家的回复阿。。。 |