在线时间0 小时
UID257690
注册时间2011-1-2
NXP金币0
该用户从未签到
新手上路

- 积分
- 80
- 最后登录
- 1970-1-1
|
在进行仿真时,出现这句话MSCAN Error - Transmit Buffer #0 not initialized,使程序不能跑起来,请问这是什么原因?
unsigned char cantxdbuffer[8];
void CANTxD(unsigned long id, unsigned short datalen, void *buf) {
unsigned char *dbuffer = (unsigned char *)buf;
unsigned short i2 = 0;
if(!CANTFLG){
return;
}
if (datalen > 8) {
return;
}
for (i2 = 0 ; i2 < datalen ; i2 ++) {
cantxdbuffer[i2] = dbuffer[i2];
}
CANTBSEL = 0x01;/* CAN0TFLG; */
//sel = CANTBSEL;
CANTIDR0 = (unsigned char)((id >> 24) & 0xFF);
CANTIDR1 = (unsigned char)((id >> 16) & 0xFF);
CANTIDR2 = (unsigned char)((id >> 8) & 0xFF);
CANTIDR3 = (unsigned char)(id & 0xFF);
CANTDSR0 = cantxdbuffer[0];
CANTDSR1 = cantxdbuffer[1];
CANTDSR2 = cantxdbuffer[2];
CANTDSR3 = cantxdbuffer[3];
CANTDSR4 = cantxdbuffer[4];
CANTDSR5 = cantxdbuffer[5];
CANTDSR6 = cantxdbuffer[6];
CANTDSR7 = cantxdbuffer[7];
CANTDLR = (unsigned char)datalen;
CANTFLG = CANTBSEL;
for ( i2 = 0 ; i2 < 2048 ; i2 ++ ) {
if ( ( CANTFLG & 0X01) == 1 ) {
break;
}
}
}
|
|