#include "DSP28_Device.h"
#define TXCOUNT 10000 // Transmission will take place (TXCOUNT) times..
long i;
long loopcount = 0;
void InitECan(void);
main()
{
/* Create a shadow register structure for the CAN control registers. This is
needed, since, only 32-bit access is allowed to these registers. 16-bit access
to these registers could potentially corrupt the register contents. This is
especially true while writing to a bit (or group of bits) among bits 16 - 31 */
// while(1) // Uncomment this line for infinite transmissions
for(i=0; i < TXCOUNT; i++) // Uncomment this line for finite transmissions
{
ECanaShadow.CANTRS.all = 0;
ECanaShadow.CANTRS.bit.TRS5 = 1; // Set TRS for mailbox under test
ECanaRegs.CANTRS.all = ECanaShadow.CANTRS.all;
while(ECanaRegs.CANTA.bit.TA5 == 0 ) {} // Wait for TA5 bit to be set..
//***问题就出在这里,TA5无法置1所以CAN通信怎么也不通*****************
**********************************************************
**********************************************************
#define TXCOUNT 10000 // Transmission will take place (TXCOUNT) times..
long i;
long loopcount = 0;
void InitECan(void);
main()
{
/* Create a shadow register structure for the CAN control registers. This is
needed, since, only 32-bit access is allowed to these registers. 16-bit access
to these registers could potentially corrupt the register contents. This is
especially true while writing to a bit (or group of bits) among bits 16 - 31 */
struct ECAN_REGS ECanaShadow;
/* Initialize the CAN module */
InitECan();
/* Write to the MSGID field */
ECanaMboxes.MBOX5.MSGID.all = 0x9FFFFFFF; // Extended Identifier
/* Configure Mailbox under test as a Transmit mailbox */
ECanaShadow.CANMD.all = ECanaRegs.CANMD.all;
ECanaShadow.CANMD.bit.MD5 = 0;
ECanaRegs.CANMD.all = ECanaShadow.CANMD.all;
/* Enable Mailbox under test */
ECanaShadow.CANME.all = ECanaRegs.CANME.all;
ECanaShadow.CANME.bit.ME5 = 1;
ECanaRegs.CANME.all = ECanaShadow.CANME.all;
/* Write to DLC field in Master Control reg */
ECanaMboxes.MBOX5.MCF.bit.DLC = 8;
/* Write to the mailbox RAM field */
ECanaMboxes.MBOX5.MDRL.all = 0x01234567;
ECanaMboxes.MBOX5.MDRH.all = 0x89ABCDEF;
/* Begin transmitting */
// while(1) // Uncomment this line for infinite transmissions
for(i=0; i < TXCOUNT; i++) // Uncomment this line for finite transmissions
{
ECanaShadow.CANTRS.all = 0;
ECanaShadow.CANTRS.bit.TRS5 = 1; // Set TRS for mailbox under test
ECanaRegs.CANTRS.all = ECanaShadow.CANTRS.all;
while(ECanaRegs.CANTA.bit.TA5 == 0 ) {} // Wait for TA5 bit to be set..
//***问题就出在这里,TA5无法置1所以CAN通信怎么也不通*****************
**********************************************************
**********************************************************
ECanaShadow.CANTA.all = 0;
ECanaShadow.CANTA.bit.TA5 = 1; // Clear TA5
ECanaRegs.CANTA.all = ECanaShadow.CANTA.all;
loopcount ++;
}
}
恳请各位指教,多谢了啊!!!!!!!
不知道你是在环回模式下测试还是正常工作模式下测试的,如果是环回模式的话,只要发送和接受邮箱的设置一致肯定不会有问题的,如果你是正常模式下测试的话,首先检查你的Can总线信号是不是正常的,总线如果正常,就需要看总线上的另外can节点的邮箱设置和你的设置是不是一样的.
邮箱设置的时候需要注意接受扩展帧还是标准帧,还是两者都接受.仔细检查一下寄存器有没有配对.
一周热门 更多>