最近研究这个,可是红外接收就是没有产生中断,不知道怎么回事,
下面是我写的红外接收解码程序,大家帮忙给看看哪错啦
#include <ioCC2530.h>
#define IR P1_0 #define LED P1_1 #define uchar unsigned char #define uint unsigned int
uchar A,Q; uchar M[4];
void main() {
A=Q=0; P1SEL =0x01;//设置P1_0为外设 P1DIR &= 0x00;//P1_0为输入 P1DIR |= 0x02;//P1_1为输出 P1IFG |= 0x00;//状态清零 P1IEN |= 0x01;//中断使能 PICTL = 0x02;//下降沿引起中断 LED = 0; EA = 1; while(1) {
} } #pragma vector = P1INT_VECTOR __interrupt void P1_ISR(void) { uint cnt=0; uchar i; P1IFG =0x00; while(!IR) cnt++; if(cnt < 1000) { P1IEN = 0x01; return; } cnt = 0; while(IR) if(cnt++ > 400) { P1IEN = 0x01; return; } if(cnt < 200) { P1IEN = 0x01; return; } for(i=0; i<32; i++) { cnt = 0; while(!IR); while(IR) if(cnt++ > 200) { P1IEN = 0x01; return; } M[i/8] >>= 1; if(cnt > 60) M[i/8] |= 0x80; } if(M[0] == ~M[1] && M[2] == ~M[3]) { A = M[0]; Q = M[2]; while(1) { LED = !LED; } } P1IEN = 0x01; }
|