interrupt 20 void sci0_isr(void) {
unsigned char p1 = 0x00;
unsigned char charnums = 0;
if(TDRE_0 == 1) {
p1 = SC0SR1;
SC0DRL = 0x55;
}
return;
}
interrupt 21 void sci1_isr(void) {
unsigned char p2 = 0x00;
if(RDRF_1 == 1) {
//PIB7 =0;
//delay(100);
p2 = SC1SR1;
szchar = SC1DRL;
if(szchar ==0x55) {
PE4 =1;
delay(500);
}
}
return;
}
void init_sci0(void) {
unsigned char readsc0sr =0x00;
SC0BDL = 0x1a; //baud rate :9600
SC0CR1 = 0x00; //8 bits
readsc0sr = SC0SR1; //clear Transmit flag
SC0DRL = 0x00;
SC0CR2 = 0xac; //interrupt close 0xac open
}
void init_sci1(void){
unsigned char writesc0sr =0x00;
SC1BDL = 0x1a;
SC1CR1 = 0x00;
SC1CR2 = 0xac;
writesc0sr = SC1SR1;
writesc0sr = SC1DRL;
}
上面代码会出现死循环,而且前两次收到的不是我发的0X55,从第三次才能收到。。。。为什么呢? |