前两天作了2812的Can通讯发现,发送端已经发送数据,并且接收端已经接到数据但是发送端TA寄存器不置位。发送端发送如下: EALLOW; ECanaShadow.CANBTC.all = ECanaRegs.CANBTC.all; ECanaShadow.CANBTC.bit.BRPREG = 9; // (BRPREG + 1) = 10 feeds a 15 MHz CAN clock ECanaShadow.CANBTC.bit.TSEG2REG = 5 ; // to the CAN module. (150 / 10 = 15) ECanaShadow.CANBTC.bit.TSEG1REG = 7; // Bit time = 15 ECanaRegs.CANBTC.all = ECanaShadow.CANBTC.all; ECanaShadow.CANMC.all =0; //zzzECanaShadow.CANMC.all = ECanaRegs.CANMC.all; ECanaShadow.CANMC.bit.CCR = 0; ECanaRegs.CANMC.all = ECanaShadow.CANMC.all; EDIS; // Wait until the CPU no longer has permission to change the // configuration registers do { ECanaShadow.CANES.all = ECanaRegs.CANES.all; } while(ECanaShadow.CANES.bit.CCE != 0 ); // Configure the eCAN for self test mode // Enable the enhanced features of the eCAN. EALLOW; ECanaShadow.CANMC.all = ECanaRegs.CANMC.all; ECanaShadow.CANMC.bit.STM = 0; // Configure CAN for self-test mode ECanaShadow.CANMC.bit.SCB = 1; // eCAN mode (reqd to access 32 mailboxes) ECanaRegs.CANMC.all = ECanaShadow.CANMC.all; EDIS; // Begin transmitting if(CanSend) { ECanaRegs.CANTRS.all=0; ECanaRegs.CANTRS.bit.TRS0 = 1; // Set TRS for all transmit mailboxes while(ECanaRegs.CANTA.all != 0x00000001 ) {} // Wait for all TAn bits to be set.. ECanaRegs.CANTA.all = 0x00000001; // Clear all TAn } 接收端 do { ECanaShadow.CANRMP.all=ECanaRegs.CANRMP.all; } while(ECanaShadow.CANRMP.bit.RMP6!=1); ECanaShadow.CANRMP.bit.RMP6=1; ECanaRegs.CANRMP.all=ECanaShadow.CANRMP.all; ECanaMboxes.MBOX0.MDL.all = ECanaMboxes.MBOX6.MDL.all+1; ECanaMboxes.MBOX0.MDH.all = ECanaMboxes.MBOX6.MDH.all; 调试了两天还是不行最后发现是波特率的问题,后来设置 ECanaShadow.CANBTC.bit.BRPREG = 99; ECanaShadow.CANBTC.bit.TSEG2REG = 2 ; ECanaShadow.CANBTC.bit.TSEG1REG = 10; 问题解决!后来经过分析,怀疑发送速度速度已经大于波特率造成的!