调试时发现while (ECanaRegs.CANTA.all == 0);卡在这一句了,我的CAN上接了一个USB转CAN的分析仪,可以用作接收节点,请问这是为什么
Susan Yang:
请问您调试的是例程还是您自己的工程?能否给出相关代码或工程,谢谢
user5197967:
回复 Susan Yang:
如下是我的配置代码,请帮忙看一下struct ECAN_REGS ECanaShadow;EALLOW;// EALLOW enables access to protected bitsGpioCtrlRegs.GPAPUD.bit.GPIO18 = 0; // Enable pull-up for GPIO18 (CANRXA)GpioCtrlRegs.GPAPUD.bit.GPIO19 = 1;//Enable pull-up for GPIO19 (CANTXA)GpioCtrlRegs.GPAQSEL2.bit.GPIO18 = 3;// Asynch qual for GPIO18 (CANRXA)GpioCtrlRegs.GPAMUX2.bit.GPIO18 = 3; // Configure GPIO18 for CANRXAGpioCtrlRegs.GPAMUX2.bit.GPIO19 = 3; // Configure GPIO19 for CANTXA
//配置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;
ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;ECanaShadow.CANMC.bit.STM = 0;//工作在正常模式ECanaShadow.CANMC.bit.SCB = 1;ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;//初始化所有主设备控制区域为0,MCF所有的位都初始化为0ECanaMboxes.MBOX0.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX1.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX2.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX3.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX4.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX5.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX6.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX7.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX8.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX9.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX10.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX11.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX12.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX13.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX14.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX15.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX16.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX17.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX18.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX19.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX20.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX21.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX22.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX23.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX24.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX25.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX26.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX27.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX28.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX29.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX30.MSGCTRL.all = 0x00000000;ECanaMboxes.MBOX31.MSGCTRL.all = 0x00000000;
// TAn, RMPn, GIFn bits are all zero upon reset and are cleared again// as a matter of precaution.
ECanaShadow.CANTA.all = ECanaRegs.CANTA.all;ECanaShadow.CANTA.all = 0xFFFFFFFF;ECanaRegs.CANTA.all = ECanaShadow.CANTA.all;
ECanaShadow.CANRMP.all = ECanaRegs.CANRMP.all;ECanaShadow.CANRMP.all = 0xFFFFFFFF;ECanaRegs.CANRMP.all = ECanaShadow.CANRMP.all;ECanaShadow.CANGIF0.all = ECanaRegs.CANGIF0.all;ECanaShadow.CANGIF0.all = 0xFFFFFFFF;ECanaRegs.CANGIF0.all = ECanaShadow.CANGIF0.all;
ECanaShadow.CANGIF1.all = ECanaRegs.CANGIF1.all;ECanaShadow.CANGIF1.all = 0xFFFFFFFF;ECanaRegs.CANGIF1.all = ECanaShadow.CANGIF1.all;
/* Configure bit timing parameters for eCANB*/
ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;ECanaShadow.CANMC.bit.CCR = 1 ;// Set CCR = 1ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;
ECanaShadow.CANES.all = ECanaRegs.CANES.all;do{ECanaShadow.CANES.all=ECanaRegs.CANES.all;}while (ECanaShadow.CANES.bit.CCE != 1 ) ;// Wait for CCE bit to be set..ECanaShadow.CANBTC.all = ECanaRegs.CANBTC.all;ECanaShadow.CANBTC.bit.BRPREG = 9;/*150/10=15*/ECanaShadow.CANBTC.bit.TSEG2REG = 2;ECanaShadow.CANBTC.bit.TSEG1REG = 10;ECanaRegs.CANBTC.all = ECanaShadow.CANBTC.all;
ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;ECanaShadow.CANMC.bit.CCR = 0 ;// Set CCR = 0ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;
do{ECanaShadow.CANES.all = ECanaRegs.CANES.all;}while (ECanaShadow.CANES.bit.CCE != 0 );// Wait for CCE bit to becleared..ECanaShadow.CANME.all = ECanaRegs.CANME.all;ECanaShadow.CANME.all = 0;// Required before writing the MSGIDsECanaRegs.CANME.all = ECanaShadow.CANME.all;
/*发送邮箱的ID号*/ECanaMboxes.MBOX0.MSGID.all = 0x00C80000;/*接收邮箱的ID号*/ECanaMboxes.MBOX16.MSGID.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.MSGCTRL.bit.DLC = 8;ECanaMboxes.MBOX16.MSGCTRL.bit.DLC = 8;
//设置发送优先级2009.3.15 AddECanaMboxes.MBOX0.MSGCTRL.bit.TPL = 0;ECanaMboxes.MBOX16.MSGCTRL.bit.TPL = 0;
/*没有远方应答帧被请求*/ECanaMboxes.MBOX0.MSGCTRL.bit.RTR = 0;ECanaMboxes.MBOX16.MSGCTRL.bit.RTR = 0;
//向邮箱RAM区写数据ECanaMboxes.MBOX0.MDL.all = 0x01234567;ECanaMboxes.MBOX0.MDH.all = 0x89ABCDEF;
//邮箱使能Mailbox0ECanaShadow.CANME.all = ECanaRegs.CANME.all;ECanaShadow.CANME.bit.ME0 =1;ECanaShadow.CANME.bit.ME16 =1;ECanaRegs.CANME.all = ECanaShadow.CANME.all;
EDIS;
Susan Yang:
回复 user5197967:
您的 while (ECanaRegs.CANTA.all == 0); 是在哪里处理的?若是可以的话,还是请您私信工程,谢谢
现在28335用作接收节点,使用CAN测试软件来发送can数据?
user5197967:
回复 Susan Yang:
现在是两个板子用CAN通讯,一个是发送节点,一个是接收节点,我现在私信您工程
user5197967:
回复 Susan Yang:
不好意思,私信贴不过去,我贴在这里can_tx.zip
Susan Yang:
回复 user5197967:
参考您最新的帖子 e2echina.ti.com/…/195076
现在可以发送了?
user5197967:
回复 Susan Yang:
是可以发送了,是因为我接收节点没有处理好,导致卡在判断那里
Susan Yang:
回复 user5197967:
好的 谢谢您的反馈