现在手里有三块板子,两块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;
}
有谁遇到这样的问题吗,望帮忙解答,谢谢!
此帖出自
小平头技术问答
邮箱标识符??没明白
用两块BB板和一块DSP板进行CAN通信出现上面的错误,可是拔掉一个BB板后,一对一收发时正确的。
谢谢你的回复,我后来测试发现使用两块DSP板和一块BB板进行收发,结果是正常的,然后我看了下之前的错误是应答错误,应答是接收器在正确接收到数据帧后在应答间隙回复一个显性位,这个是硬件自动回复,还没有到标识符过滤的,所以问题出现在BB板的CAN收发器上,可是不知道CAN收发器有什么区别,都是3.3V的SN65HVD230,为什么还不能正常收发呢?
一周热门 更多>