/*------------------------------------ nRF401无线收发串口中断服务程序
HotPower@126.com 2004.7.18 ------------------------------------*/ void sioproc() interrupt SIO_VECTOR// using 1 { unsigned char i; unsigned int crc; if (RI) {//接收中断 RI = 0; if (!nRFTXEN && SioBuffers.RXCount) {//每次接收20个数据 i = SBUF; SioBuffers.RXCount --; SioBuffers.RXBuffers[19 - SioBuffers.RXCount] = i; switch(SioBuffers.RXCount) { case 19: if (i != 0x55) SioBuffers.RXCount = 20; break; case 18: if (i != 0xaa) SioBuffers.RXCount = 20; break; case 0: crc = 0; for (i = 1; i <= 8; i ++) { crc = crc16r(GetRXBuffWord(i + i), crc); } if (crc != GetRXBuffWord(18)) SioBuffers.RXCount = 20; else { nRFTXEN = 1;//发送 for (i = 0; i < 20; i ++) { SioBuffers.TXBuffers = SioBuffers.RXBuffers; } SioBuffers.TXMAXCount = TX_MAXCount; SioBuffers.TXCount = TX_Count + 32; TI = 1;//接收结束立即转为发送 } break; } } } if (TI) {//发送中断 TI = 0; if (nRFTXEN && SioBuffers.TXCount) { SioBuffers.TXCount --; if (SioBuffers.TXCount > 19) { SBUF = 0x00; } else { SBUF = SioBuffers.TXBuffers[19 - SioBuffers.TXCount]; } if (SioBuffers.TXCount == 0) { if (SioBuffers.TXMAXCount) { SioBuffers.TXMAXCount --; SioBuffers.TXCount = TX_Count; } else { nRFTXEN = 0;//发送结束立即转为接收 SioBuffers.RXCount = 20; } } } } }
|
|
用户1479663 2012-2-3 09:44
用户882386 2009-10-7 13:11
用户1008998 2007-11-29 16:07
看过;
用户741296 2007-11-9 08:44
是啊!
有同感!
用户15552 2007-8-20 15:29
菜农老师,我是AVR新人,能不能问你个问题?
用了一片AT90CAN128的片子?但为什么它的第二串口不能工作?