|
哪位亲做过 两块 DSP2812 对接 CAN通信,一片 做接收,一片做发送file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/X1%60E@%60R9LLX~6VHSWO%60NXY0.gif
我目前通信失败,找不出因由,望指教 ,既不发送成功,也不能接收成功
我两片 DSP的ECAN的初始化都是这样的,是个例程里面的, 我对照过TI的文档,初始化的顺序也是对的:
void InitECan(void)
{
struct ECAN_REGS ECanaShadow;
EALLOW;
//配置GPIO引脚工作在eCAN功能
GpioMuxRegs.GPFMUX.bit.CANRXA_GPIOF7=1;
GpioMuxRegs.GPFMUX.bit.CANTXA_GPIOF6=1;
//配置eCAN的RX和TX分别为eCAN的接收和发送引脚
ECanaShadow.CANTIOC.all = ECanaRegs.CANTIOC.all;
ECanaShadow.CANTIOC.bit.TXFUNC = 1;
ECanaRegs.CANTIOC.all = ECanaShadow.CANTIOC.all;
ECanaShadow.CANRIOC.all = ECanaRegs.CANRIOC.all;
ECanaShadow.CANRIOC.bit.RXFUNC = 1;
ECanaRegs.CANRIOC.all = ECanaShadow.CANRIOC.all;
EDIS;
EALLOW;
ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
ECanaShadow.CANMC.bit.STM = 0; //工作在正常模式
ECanaShadow.CANMC.bit.SCM = 1; //工作在ecan模式
ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;
EDIS;
//初始化所有主设备控制区域为0,MCF所有的位都初始化为0
ECanaMboxes.MBOX0.MCF.all = 0x00000000;
ECanaMboxes.MBOX1.MCF.all = 0x00000000;
ECanaMboxes.MBOX2.MCF.all = 0x00000000;
ECanaMboxes.MBOX3.MCF.all = 0x00000000;
ECanaMboxes.MBOX4.MCF.all = 0x00000000;
ECanaMboxes.MBOX5.MCF.all = 0x00000000;
ECanaMboxes.MBOX6.MCF.all = 0x00000000;
ECanaMboxes.MBOX7.MCF.all = 0x00000000;
ECanaMboxes.MBOX8.MCF.all = 0x00000000;
ECanaMboxes.MBOX9.MCF.all = 0x00000000;
ECanaMboxes.MBOX10.MCF.all = 0x00000000;
ECanaMboxes.MBOX11.MCF.all = 0x00000000;
ECanaMboxes.MBOX12.MCF.all = 0x00000000;
ECanaMboxes.MBOX13.MCF.all = 0x00000000;
ECanaMboxes.MBOX14.MCF.all = 0x00000000;
ECanaMboxes.MBOX15.MCF.all = 0x00000000;
ECanaMboxes.MBOX16.MCF.all = 0x00000000;
ECanaMboxes.MBOX17.MCF.all = 0x00000000;
ECanaMboxes.MBOX18.MCF.all = 0x00000000;
ECanaMboxes.MBOX19.MCF.all = 0x00000000;
ECanaMboxes.MBOX20.MCF.all = 0x00000000;
ECanaMboxes.MBOX21.MCF.all = 0x00000000;
ECanaMboxes.MBOX22.MCF.all = 0x00000000;
ECanaMboxes.MBOX23.MCF.all = 0x00000000;
ECanaMboxes.MBOX24.MCF.all = 0x00000000;
ECanaMboxes.MBOX25.MCF.all = 0x00000000;
ECanaMboxes.MBOX26.MCF.all = 0x00000000;
ECanaMboxes.MBOX27.MCF.all = 0x00000000;
ECanaMboxes.MBOX28.MCF.all = 0x00000000;
ECanaMboxes.MBOX29.MCF.all = 0x00000000;
ECanaMboxes.MBOX30.MCF.all = 0x00000000;
ECanaMboxes.MBOX31.MCF.all = 0x00000000;
/* Clear all TAn bits */
ECanaRegs.CANTA.all = 0xFFFFFFFF;
/* Clear all RMPn bits */
ECanaRegs.CANRMP.all = 0xFFFFFFFF;
/* Clear all interrupt flag bits */
ECanaRegs.CANGIF0.all = 0xFFFFFFFF;
ECanaRegs.CANGIF1.all = 0xFFFFFFFF;
/* Configure bit timing parameters */
EALLOW;
//ECanaRegs.CANMIM.all = 0xFFFFFFFF; /*邮箱中断使能*/
ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
ECanaShadow.CANMC.bit.CCR = 1;
ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;
EDIS;
//CPU请求向CANBTC和CANGAM写配置信息,该位置1后必须等到CANED.CCE为1,才能
//对CANBTC进行操作。
do
{
ECanaShadow.CANES.all = ECanaRegs.CANES.all;
}while(ECanaShadow.CANES.bit.CCE != 1);
EALLOW;
/*(BRPREG+1)=10 feeds a 15MHz CAN clock*/
ECanaShadow.CANBTC.bit.BRP = 9;
/*150/10=15*/
ECanaShadow.CANBTC.bit.TSEG2 = 2;
ECanaShadow.CANBTC.bit.TSEG1 = 10;
ECanaRegs.CANBTC.all = ECanaShadow.CANBTC.all;
ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
ECanaShadow.CANMC.bit.CCR = 0;
ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;
EDIS;
do
{
ECanaShadow.CANES.all = ECanaRegs.CANES.all;
}while(ECanaShadow.CANES.bit.CCE != 0); //等待CCE位清零
//屏蔽所有邮箱
ECanaRegs.CANME.all = 0; //在写MSGID之前要完成该操作
/*发送邮箱的ID号*/
ECanaMboxes.MBOX0.MID.all = 0x00C80000;
/*接收邮箱的ID号*/
ECanaMboxes.MBOX16.MID.all = 0x00C80000;
/*邮箱0为TX,16为RX*/
ECanaShadow.CANMD.all = ECanaRegs.CANMD.all;
ECanaShadow.CANMD.bit.MD0 =0;
ECanaShadow.CANMD.bit.MD16 =1;
ECanaRegs.CANMD.all = ECanaShadow.CANMD.all;
/*数据长度 8个BYTE*/
ECanaMboxes.MBOX0.MCF.bit.DLC = 8;
ECanaMboxes.MBOX16.MCF.bit.DLC = 8;
//设置发送优先级 2009.3.15 Add
ECanaMboxes.MBOX0.MCF.bit.TPL = 0;
ECanaMboxes.MBOX16.MCF.bit.TPL = 0;
/*没有远方应答帧被请求*/
ECanaMboxes.MBOX0.MCF.bit.RTR = 0;
ECanaMboxes.MBOX16.MCF.bit.RTR = 0;
//向邮箱RAM区写数据
ECanaMboxes.MBOX0.MDRL.all = 0x01234567;
ECanaMboxes.MBOX0.MDRH.all = 0x89ABCDEF;
//邮箱使能Mailbox0
ECanaShadow.CANME.all = ECanaRegs.CANME.all;
ECanaShadow.CANME.bit.ME0 =1;
ECanaShadow.CANME.bit.ME16 =1;
ECanaRegs.CANME.all = ECanaShadow.CANME.all;
}
|
|