|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2006-7-5 14:48:39
|
显示全部楼层
找到解决办法了,采用查询方式来发送数据.把从 while(!(read_sja(SR)&0x04)); 开始的一段代码改为:
if((read_sja(SR)&0x04) != 0); //reg2^2==1 ,即判断发送缓冲器的状态
{
write_sja(TXEFF,TransBuffer[0]); //扩展帧,数据长度为8个字节
write_sja(TXID0,TransBuffer[1]);
write_sja(TXID1,TransBuffer[2]);
write_sja(TXID2,TransBuffer[3]);
write_sja(TXID3,TransBuffer[4]);
write_sja(TXDATA0,TransBuffer[5]);
write_sja(TXDATA1,TransBuffer[6]);
write_sja(TXDATA2,TransBuffer[7]);
write_sja(TXDATA3,TransBuffer[8]);
write_sja(TXDATA4,TransBuffer[9]);
write_sja(TXDATA5,TransBuffer[10]);
write_sja(TXDATA6,TransBuffer[11]);
write_sja(TXDATA7,TransBuffer[12]);
write_sja(CMR,0x01); //发送请求命令
SEI(); //开中断
CanTxSucFlag=1; //置发送成功标志位
}
然后在主程序查询CanTxSucFlag的状态,即知道数据是否发送成功了.
-----此内容被LOVEMCU于2006-07-05,14:50:20编辑过 |
|