多个CAN节点无法通信

2019-03-26 15:13发布

现在手里有三块板子,两块BeagleBone板,一块TMS320F2812的自制板,发现这三块板子两两连接时能够互通,但是三个板子连接后无法通信,目前可以确定的是连线没有错误。

测试时使用DSP板发送数据帧,两个BB板上接收,结果是BB板上无法收到数据帧。观察到DSP板的发送位TRSn置位后没有复位,一直为1,CANES寄存器里的应答位ACKE也置一,有应答错误位,错误计数器显示为128,说明数据并没有发送成功。然后将其中的一个BB断开,退出CAN总线连接,测试DSP板和一块BB板收发,结果是收发正常。

下面是DSP上的CAN配置,BB上移植了linux,使用的是candump、cansend

void InitECana(void)
{
EALLOW;

/* Configure eCAN pins using GPIO regs */
GpioMuxRegs.GPFMUX.bit.CANTXA_GPIOF6 = 1;
GpioMuxRegs.GPFMUX.bit.CANRXA_GPIOF7 = 1;

ECanaRegs.CANRIOC.bit.RXFUNC = 1;
ECanaRegs.CANTIOC.bit.TXFUNC = 1;

/* Configure eCAN for HECC mode , enable 0~31 mailboxes */
ECanaRegs.CANMC.bit.SCB = 1;
ECanaRegs.CANES.all
/* Initialzation the master control register of mailbox to zero (CANMCTRL) */
ECanaMboxes.MBOX0.MCF.all = 0x00000000;

/* Configure bit timing parameters */
ECanaRegs.CANMC.bit.CCR = 1;

while(ECanaRegs.CANES.bit.CCE != 1){}

ECanaRegs.CANBTC.bit.BRP = 14;
ECanaRegs.CANBTC.bit.TSEG1 = 13;
ECanaRegs.CANBTC.bit.TSEG2 = 4;

ECanaRegs.CANMC.bit.CCR = 0;
while(ECanaRegs.CANES.bit.CCE != 0){}

/* Disable all the mailboxes */
ECanaRegs.CANME.all = 0x00000000;

/* 开中断 */
ECanaRegs.CANGIM.bit.I0EN = 1;
ECanaRegs.CANGIM.bit.I1EN = 1;
ECanaRegs.CANGIM.bit.SIL = 1;

ECanaRegs.CANMIL.all = 0x00000000;
ECanaRegs.CANMIM.all = 0xffffffff;

EDIS;
}

void ConfigCAN(void)
{
EALLOW;

/* Write to the MSGID filed of Transmit Mailbox 0~15 */
ECanaMboxes.MBOX0.MID.all = 0x91111111;
ECanaMboxes.MBOX1.MID.all = 0x91111112;
ECanaMboxes.MBOX2.MID.all = 0x91111113;
ECanaMboxes.MBOX3.MID.all = 0x91111114;
ECanaMboxes.MBOX4.MID.all = 0x91111115;
ECanaMboxes.MBOX5.MID.all = 0x91111116;
ECanaMboxes.MBOX6.MID.all = 0x91111117;


ECanaMboxes.MBOX25.MID.all = 0x91111121;
ECanaMboxes.MBOX26.MID.all = 0x91111122;
ECanaMboxes.MBOX27.MID.all = 0x91111123;
ECanaMboxes.MBOX28.MID.all = 0x91111124;
ECanaMboxes.MBOX29.MID.all = 0x91111125;
ECanaMboxes.MBOX30.MID.all = 0x91111126;
ECanaMboxes.MBOX31.MID.all = 0x91111127;
/* set the DLC field of the Transmit Mailboxes MSCTRL */
ECanaMboxes.MBOX0.MCF.bit.DLC = 0x8;
ECanaMboxes.MBOX1.MCF.bit.DLC = 0x8;
ECanaMboxes.MBOX2.MCF.bit.DLC = 0x8;
ECanaMboxes.MBOX3.MCF.bit.DLC = 0x8;
ECanaMboxes.MBOX4.MCF.bit.DLC = 0x8;
ECanaMboxes.MBOX5.MCF.bit.DLC = 0x8;
ECanaMboxes.MBOX6.MCF.bit.DLC = 0x8;
ECanaMboxes.MBOX25.MCF.bit.DLC = 0x8;
ECanaMboxes.MBOX26.MCF.bit.DLC = 0x8;
ECanaMboxes.MBOX27.MCF.bit.DLC = 0x8;
ECanaMboxes.MBOX28.MCF.bit.DLC = 0x8;
ECanaMboxes.MBOX29.MCF.bit.DLC = 0x8;
ECanaMboxes.MBOX30.MCF.bit.DLC = 0x8;
ECanaMboxes.MBOX31.MCF.bit.DLC = 0x8;

/* Write the data field of the Transmit Mailboxes */
ECanaMboxes.MBOX0.MDRH.all = 0x00000000;
ECanaMboxes.MBOX0.MDRL.all = 0x00000000;
ECanaMboxes.MBOX1.MDRH.all = 0x00000000;
ECanaMboxes.MBOX1.MDRL.all = 0x00000000;
ECanaMboxes.MBOX2.MDRH.all = 0x00000000;
ECanaMboxes.MBOX2.MDRL.all = 0x00000000;
ECanaMboxes.MBOX3.MDRH.all = 0x00000000;
ECanaMboxes.MBOX3.MDRL.all = 0x00000000;
ECanaMboxes.MBOX4.MDRH.all = 0x00000000;
ECanaMboxes.MBOX4.MDRL.all = 0x00000000;
ECanaMboxes.MBOX5.MDRH.all = 0x00000000;
ECanaMboxes.MBOX5.MDRL.all = 0x00000000;
ECanaMboxes.MBOX6.MDRH.all = 0x00000000;
ECanaMboxes.MBOX6.MDRL.all = 0x00000000;
ECanaMboxes.MBOX25.MDRH.all = 0x00000000;
ECanaMboxes.MBOX25.MDRL.all = 0x00000000;
ECanaMboxes.MBOX26.MDRH.all = 0x00000000;
ECanaMboxes.MBOX26.MDRL.all = 0x00000000;
ECanaMboxes.MBOX27.MDRH.all = 0x00000000;
ECanaMboxes.MBOX27.MDRL.all = 0x00000000;
ECanaMboxes.MBOX28.MDRH.all = 0x00000000;
ECanaMboxes.MBOX28.MDRL.all = 0x00000000;
ECanaMboxes.MBOX29.MDRH.all = 0x00000000;
ECanaMboxes.MBOX29.MDRL.all = 0x00000000;
ECanaMboxes.MBOX30.MDRH.all = 0x00000000;
ECanaMboxes.MBOX30.MDRL.all = 0x00000000;
ECanaMboxes.MBOX31.MDRH.all = 0x00000000;
ECanaMboxes.MBOX31.MDRL.all = 0x00000000;

/* Enable all Mailboxes */
ECanaRegs.CANME.all = 0xFE00007F;
ECanaRegs.CANMD.all = 0xFE000000;


ECanaRegs.CANTA.all = 0xffffffff;
ECanaRegs.CANRMP.all = 0xffffffff;
ECanaRegs.CANGIF0.all = 0xffffffff;
ECanaRegs.CANGIF1.all = 0xffffffff;
EDIS;
}

有谁遇到这样的问题吗,望帮忙解答,谢谢! 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
7条回答
zmicky
2019-03-27 11:21
你好,之后将一个终端电阻卸掉后,四块板子通信没有出现应答错误,但是在后来的实验中(即总线上只有一个120欧的终端电阻)发现,出现了填充位错误,现在还没有找到原因。

一周热门 更多>