can发送失败

2019-07-26 18:53发布

测试2812片子CAN通信时,用的是从TI网站下的ECAN通信源代码,但无论如何CAN通信都调试不通,查看寄存器的时候是TA无法置1,求助各位了
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
14条回答
G21372
2019-07-26 23:58
#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 */

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 ++;                             
    }   

}

恳请各位指教,多谢了啊!!!!!!!

一周热门 更多>