专家
公告
财富商城
电子网
旗下网站
首页
问题库
专栏
标签库
话题
专家
NEW
门户
发布
提问题
发文章
TI
求助两块 DSP2812 对接 CAN通信 求助
2019-08-03 18:16
发布
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
站内问答
/
TI MCU
13193
2
1075
哪位亲做过 两块 DSP2812 对接 CAN通信,一片 做接收,一片做发送file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/X1%60E@%60R9LLX~6VHSWO%60NXY0.gif
我目前通信失败,找不出因由,望指教 ,既不发送成功,也不能接收成功
友情提示:
此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
2条回答
G21372
1楼-- · 2019-08-03 22:09
两片 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;
}
加载中...
拿起书本
2楼-- · 2019-08-03 22:32
建议您先做DSP与PC机之间的CAN通信,因为这样容易比较判断DSP的CAN这部分在硬件方面是否有问题,如果有,也能判断出哪块板子的有问题。
加载中...
一周热门
更多
>
相关问题
CPLD的方波输出
4 个回答
11个版本Quartus II 软件下载,安装包网盘合集,附教程,47G!
20 个回答
请大家帮忙到21IC发展大家谈支持我申请新版面
20 个回答
【通知】21ic中国电子网服务条款 (所有人员必读)
1 个回答
满载而归乙亥年,大展鸿途庚子年---集签赢好礼
20 个回答
携手ADI,踏上电子工程师之巅—车辆电气化视频,答题领奖!
1 个回答
如何提升论坛质量,看你了!
20 个回答
【最终名单】二姨家喊你来拿100份新年大礼啦~
20 个回答
相关文章
×
关闭
采纳回答
向帮助了您的网友说句感谢的话吧!
非常感谢!
确 认
×
关闭
编辑标签
最多设置5个标签!
TI
保存
关闭
×
关闭
举报内容
检举类型
检举内容
检举用户
检举原因
广告推广
恶意灌水
回答内容与提问无关
抄袭答案
其他
检举说明(必填)
提交
关闭
×
关闭
您已邀请
15
人回答
查看邀请
擅长该话题的人
回答过该话题的人
我关注的人
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;
}
一周热门 更多>