我选择的是AZ32A+MC33989来进行CAN接收与发送,我的部分程序代码如下:
void CAN_Transmit(void){
unsigned char emptytest;
unsigned char emptytest0;
unsigned char emptytest1;
unsigned char emptytest2;
emptytest = CTFLG;
emptytest0 = emptytest&0x01; //判断接受区为空
emptytest1 = emptytest&0x02;
emptytest2 = emptytest&0x04;
//EnterCritical();
if(emptytest0!=0)
{
DLR0 = 0x08;
DSR00 = 0xff;
DSR10 = 0x00;
DSR20 = 0xff;
DSR30 = 0x00;
DSR40 = 0xff;
DSR50 = 0x00;
DSR60 = 0xff;
DSR70 = 0x00;
IDR00 = 0x33; // DP256:0x11; AZ60:0x33; GZ16:0x22; MPC555:0x44
IDR10 = 0xFF;
IDR20 = 0xFF;
IDR30 = 0xFE; //extended identifers
TBPR0 = 0x01;
//CTCR = 0x01;
CTFLG = 0x01; //buffer0 启动发送
}
else if(emptytest1!=0)
{
DLR1 = 0x08;
DSR01 = 0xff;
DSR11 = 0x00;
DSR21 = 0xff;
DSR31 = 0x00;
DSR41 = 0xff;
DSR51 = 0x00;
DSR61 = 0xff;
DSR71 = 0x00;
IDR01 = 0x33; // DP256:0x11; AZ60:0x33; GZ16:0x22; MPC555:0x44
IDR11 = 0xFF;
IDR21 = 0xFF;
IDR31 = 0xFE; //extended identifers
TBPR1 = 0x01;
//CTCR = 0x02;
CTFLG = 0x02; //buffer1 启动发送
}
else if(emptytest2!=0)
{
DLR2 = 0x08;
DSR02 = 0xff;
DSR12 = 0x00;
DSR22 = 0xff;
DSR32 = 0x00;
DSR42 = 0xff;
DSR52 = 0x00;
DSR62 = 0xff;
DSR72 = 0x00;
IDR02 = 0x33; // DP256:0x11; AZ60:0x33; GZ16:0x22; MPC555:0x44
IDR12 = 0xFF;
IDR22 = 0xFF;
IDR32 = 0xFE; //extended identifers
TBPR2 = 0x01;
//CTCR = 0x04;
CTFLG = 0x04; //buffer2 启动发送
}
//ExitCritical();
}
可是我就是无法把数据发送出去,经过我的调试我发现寄存器CTFLG的值有7变成6再变成4再变成2最后停止在0.最后为各缓冲区都已满,无法在加载数据了,其实就是我的三个缓冲区的数据根本没有发送出去,最终导致了三个缓冲区为满,也就是CTFLG始终为0.
请哪位有经验的高手指点一下本人,再此不甚感激!
[此贴子已经被作者于2006-4-18 15:42:41编辑过]
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |