- 论坛徽章:
- 0
|
前辈你好,我写了一下我自己的程序,也测了一下,我把传输的部份写好了,写了传输的ISR也确定有传输成功了,但是接收的部份一直有问题,写了接收的ISR,一直都没反应,我看了很久,不知道是那里的问题,可以请前辈指导吗?
谢谢
void SendMsg(char msg[]) {
byte i=0;
char nxt_char;
SCI1C2 = 0x08; // enable Tx
SCI1C2_TCIE =1; //Transmission complete interrupt enable
nxt_char = msg[i++];
while(nxt_char != 0x00) {
while(!SCI1S1_TDRE){}
SCI1D = (byte) nxt_char; // 2nd half of TDRE clear procedure
nxt_char = msg[i++];
} //end while((SCI1D
} //end SendMsg
char RecChar() {
byte rec_char;
char next_char;
if (SCI1S1_RDRF) // 1st half of RDRF clear procedure
rec_char = SCI1D; // 2nd half of RDRF clear procedure
SCI1C2_RE = 1; // enable Rx
SCI1C2_RIE =1; //Receive Interrupt enable
while(!SCI1S1_RDRF){ };
rec_char = SCI1D; // get recieved character
SendMsg((char) rec_char); // echo received character
return (char) SCI1D;
} //end RecChar |
|