This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TMS320F28035: CAN communication between 2 TMS320F28035

Part Number: TMS320F28035

Tool/software: Code Composer Studio

Hi 

I am trying to transmit data from one MCU0 to MCU1 using CAN.MCU0is able to transmit the data but MCU1 is unable to receive the same data. Could you help me with this? I am attaching the transmitter and receiver codes along with this.

Regards,

Silpa

//###########################################################################
//
// FILE:    Example_2803xECanBack2Back.c
//
// TITLE:   eCAN back to back example
//
//! \addtogroup f2803x_example_list
//! <h1>eCAN back to back (ecan_back2back)</h1>
//!
//! This example tests eCAN by transmitting data back-to-back at high speed
//! without stopping. The received data is verified. Any error is flagged.
//! MBX0 transmits to MBX16, MBX1 transmits to MBX17 and so on....
//!
//! This example uses the self-test mode of the CAN module. i.e. the
//! transmission/reception happens within the module itself (even the required
//! ACKnowldege is generated internally in the module). Therefore, there is no
//! need for a CAN transceiver to run this particular test case and no activity
//! will be seen in the CAN pins/bus. Because everything is internal, there is
//! no need for a 120-ohm termination resistor. Note that a real-world CAN
//! application needs a CAN transceiver and termination resistors on both ends
//! of the bus.
//!
//! \b Watch \b Variables \n
//! - PassCount
//! - ErrorCount
//! - MessageReceivedCount
//
//
//###########################################################################
// $TI Release: F2803x Support Library v2.01.00.00 $
// $Release Date: Thu Oct 18 15:46:42 CDT 2018 $
// $Copyright:
// Copyright (C) 2009-2018 Texas Instruments Incorporated - http://www.ti.com/
//
// Redistribution and use in source and binary forms, with or without 
// modification, are permitted provided that the following conditions 
// are met:
// 
//   Redistributions of source code must retain the above copyright 
//   notice, this list of conditions and the following disclaimer.
// 
//   Redistributions in binary form must reproduce the above copyright
//   notice, this list of conditions and the following disclaimer in the 
//   documentation and/or other materials provided with the   
//   distribution.
// 
//   Neither the name of Texas Instruments Incorporated nor the names of
//   its contributors may be used to endorse or promote products derived
//   from this software without specific prior written permission.
// 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// $
//###########################################################################

//
// Included Files
//
#include "DSP28x_Project.h"     // Device Headerfile and Examples Include File

//
// Prototype statements
//
void mailbox_check(int32 T1, int32 T2, int32 T3);
void mailbox_read(int16 i);

//
// Globals
//
Uint32  ErrorCount;
Uint32  PassCount;
Uint32  MessageReceivedCount;

Uint32  TestMbox1 = 0;
Uint32  TestMbox2 = 0;
Uint32  TestMbox3 = 0;

//
// Main
//
void main(void)
{
    Uint16  j;

   struct ECAN_REGS ECanaShadow;

   InitSysCtrl();

   InitECanGpio();

   DINT;

   InitPieCtrl();

   IER = 0x0000;
   IFR = 0x0000;

   InitPieVectTable();

    MessageReceivedCount = 0;
    ErrorCount = 0;
    PassCount = 0;

    InitECana();                                  // Initialize eCAN-A module

    // Mailboxes can be written to 16-bits or 32-bits at a time
    // Write to the MSGID field of TRANSMIT mailboxe MBOX0

    ECanaMboxes.MBOX0.MSGID.all = 0x9555AAA0;

    // Configure Mailboxes 0 as Tx, 16 as Rx
    // Since this write is to the entire register (instead of a bit
    // field) a shadow register is not required.
    ECanaRegs.CANMD.all = 0xFFFF0000;

    // Enable all Mailboxes */
    // Since this write is to the entire register (instead of a bit
    // field) a shadow register is not required.
    ECanaRegs.CANME.all = 0xFFFFFFFF;

    // Specify that 8 bits will be sent/received
    ECanaMboxes.MBOX0.MSGCTRL.bit.DLC = 8;


    // Write to the mailbox RAM field of MBOX0 - 15
    ECanaMboxes.MBOX0.MDL.all = 0x9555AAA0;
    ECanaMboxes.MBOX0.MDH.all = 0x89ABCDEF;

    // Since this write is to the entire register (instead of a bit
    // field) a shadow register is not required.
    EALLOW;
    ECanaRegs.CANMIM.all = 0xFFFFFFFF;

    // Configure the eCAN for self test mode
    // Enable the enhanced features of the eCAN.
    EALLOW;
    ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
    ECanaShadow.CANMC.bit.STM = 0;    // Configure CAN for self-test mode
    ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;
    EDIS;

    // Begin transmitting
    for(;;)
    {
       ECanaRegs.CANTRS.all = 0x0000FFFF;  // Set TRS for all transmit mailboxes
       while(ECanaRegs.CANTA.all != 0x0000FFFF ) {}  // Wait for all TAn bits to be set..
       ECanaRegs.CANTA.all = 0x0000FFFF;   // Clear all TAn
       MessageReceivedCount++;

       DELAY_US(900000);

  }}

void main(void)
{
    Uint16  j;

   struct ECAN_REGS ECanaShadow;

   InitSysCtrl();

   InitECanGpio();

   DINT;

   InitPieCtrl();

   IER = 0x0000;
   IFR = 0x0000;

   InitPieVectTable();

    MessageReceivedCount = 0;
    ErrorCount = 0;
    PassCount = 0;

    InitECana();                                  // Initialize eCAN-A module

   
    // Write to the MSGID field of RECEIVE mailboxe MBOX16


    ECanaMboxes.MBOX16.MSGID.all = 0x9555AAA0;
   

    // Configure Mailboxes 0 as Tx, 16 as Rx
    // Since this write is to the entire register (instead of a bit
    // field) a shadow register is not required.
    ECanaRegs.CANMD.all = 0xFFFF0000;

    // Enable all Mailboxes */
    // Since this write is to the entire register (instead of a bit
    // field) a shadow register is not required.
    ECanaRegs.CANME.all = 0xFFFFFFFF;

    // Specify that 8 bits will be sent/received
    ECanaMboxes.MBOX0.MSGCTRL.bit.DLC = 8;
  
    // Since this write is to the entire register (instead of a bit
    // field) a shadow register is not required.
    EALLOW;
    ECanaRegs.CANMIM.all = 0xFFFFFFFF;

    // Configure the eCAN for self test mode
    // Enable the enhanced features of the eCAN.
    EALLOW;
    ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
    ECanaShadow.CANMC.bit.STM = 0;    // Configure CAN for self-test mode
    ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;
    EDIS;

    // Begin receiving
    for(;;)
    {
       //Read from Receive mailboxes and begin checking for data */
       for(j=16; j<17; j++)         // Read & check 16 mailboxes
       {
          mailbox_read(j);         // This func reads the indicated mailbox data
          mailbox_check(TestMbox1,TestMbox2,TestMbox3); // Checks the received data
       }

       Delay_us(900000)  ;

  }
}
// This function reads out the contents of the indicated
// by the Mailbox number (MBXnbr).
void mailbox_read(int16 MBXnbr)
{
   volatile struct MBOX *Mailbox;
   Mailbox = &ECanaMboxes.MBOX0 + MBXnbr;
   TestMbox1 = Mailbox->MDL.all; // = 0x9555AAAn (n is the MBX number)
   TestMbox2 = Mailbox->MDH.all; // = 0x89ABCDEF (a constant)
   TestMbox3 = Mailbox->MSGID.all;// = 0x9555AAAn (n is the MBX number)
} // MSGID of a rcv MBX is transmitted as the MDL data.

void mailbox_check(int32 T1, int32 T2, int32 T3)
{
    if((T1 != T3) || ( T2 != 0x89ABCDEF))
    {
       ErrorCount++;
    }
    else
    {
       PassCount++;
    }
}

  • Have you taken a look at the examples in SPRA876? Also the Debugging Tips in the same document?
  • Yes, Hareesh, I have modified the examples(CAN_TXLOOP, CAN_RXLOOP) in SPRA876 according to my requirements but still, the receiving MCU doesn't get any data. I tried to see the data at the CANL and CANH pins of the transceiver on both the transmitting and receiving MCUs using an oscilloscope and I am able to see some data at both ends when I run the transmitter code alone. Once I start running the receiver side code the data just vanishes on both the MCUs transceiver side. I am attaching the modified codes. Could you check whether it works at your end?

    Regards,

    Silpa

    // TI Release: 28xx eCAN programming example
    // Release Date: Fri Aug 4 2017
    // Copyright:
    // Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
    //
    // Redistribution and use in source and binary forms, with or without 
    // modification, are permitted provided that the following conditions 
    // are met:
    // 
    //   Redistributions of source code must retain the above copyright 
    //   notice, this list of conditions and the following disclaimer.
    // 
    //   Redistributions in binary form must reproduce the above copyright
    //   notice, this list of conditions and the following disclaimer in the 
    //   documentation and/or other materials provided with the   
    //   distribution.
    // 
    //   Neither the name of Texas Instruments Incorporated nor the names of
    //   its contributors may be used to endorse or promote products derived
    //   from this software without specific prior written permission.
    // 
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    //
    
    /*********************************************************************
    * Filename: TXLOOP_A.c                                                 *
    *                                                                    *
    * Description: TXLOOP - Transmit loop using any mailbox
    *
    * Mailbox 25 is shown as an example...
    * This example TRANSMITS data to another CAN module using MAILBOX25
    * This program could either loop forever or transmit "n" # of times,
    * where "n" is the TXCOUNT value.
    *
    *********************************************************************/
    
    //
    // Included Files
    //
    #include "DSP28x_Project.h"     // Device Headerfile and Examples Include File
    
    #define TXCOUNT  100000  // Transmission will take place (TXCOUNT) times..
    
    long      i;
    long      loopcount = 0;
    
    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;
    
    /* Kill Watchdog, Init PLL, Enable peripheral clocks */
    
        InitSysCtrl();
    
    /* Initialize the CAN module */
    
        InitECana();
        InitECanGpio();
    
        EALLOW;
    
    /* Write to the MSGID field  */
    
        ECanaMboxes.MBOX25.MSGID.all = 0x95555555; // Extended Identifier
    
    /* Configure Mailbox under test as a Transmit mailbox */
    
        ECanaShadow.CANMD.all = ECanaRegs.CANMD.all;
        ECanaShadow.CANMD.bit.MD25 = 0;
        ECanaRegs.CANMD.all = ECanaShadow.CANMD.all;
    
    /* Enable Mailbox under test */
    
        ECanaShadow.CANME.all = ECanaRegs.CANME.all;
        ECanaShadow.CANME.bit.ME25 = 1;
        ECanaRegs.CANME.all = ECanaShadow.CANME.all;
    
    /* Write to DLC field in Message Control reg */
    
        ECanaMboxes.MBOX25.MSGCTRL.bit.DLC = 8;
    
    /* Write to the mailbox RAM field */
    
         ECanaMboxes.MBOX25.MDL.all = 0x55555555;
         ECanaMboxes.MBOX25.MDH.all = 0x55555555;
    
    /* 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.TRS25 = 1;     // Set TRS for mailbox under test
         ECanaRegs.CANTRS.all = ECanaShadow.CANTRS.all;
    
         ECanaShadow.CANTA.all = ECanaRegs.CANTA.all;
            do {ECanaShadow.CANTA.all = ECanaRegs.CANTA.all;}   // Wait for TA25 bit to be set..
             while(ECanaShadow.CANTA.bit.TA25 == 0 );
    
         ECanaShadow.CANTA.all = 0;
         ECanaShadow.CANTA.bit.TA25 = 1;         // Clear TA5
         ECanaRegs.CANTA.all = ECanaShadow.CANTA.all;
    
         loopcount ++;
        }
         asm(" ESTOP0");
    }
    
    
    /* Notes:
    A simple testcase that could be used to transmit data out of a mailbox
    
    
    Last update: 7/22/2017     (Tested)
    */
    
    
    // TI Release: 28xx eCAN programming example
    // Release Date: Fri Aug 4 2017
    // Copyright:
    // Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
    //
    // Redistribution and use in source and binary forms, with or without
    // modification, are permitted provided that the following conditions
    // are met:
    //
    //   Redistributions of source code must retain the above copyright
    //   notice, this list of conditions and the following disclaimer.
    //
    //   Redistributions in binary form must reproduce the above copyright
    //   notice, this list of conditions and the following disclaimer in the
    //   documentation and/or other materials provided with the
    //   distribution.
    //
    //   Neither the name of Texas Instruments Incorporated nor the names of
    //   its contributors may be used to endorse or promote products derived
    //   from this software without specific prior written permission.
    //
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    //
    
    /*********************************************************************
    * Filename: RXLOOP.c                                                 *
    *                                                                    *
    * Description: This is a simple example of how data may be received
    *
    * All mailboxes in CAN-A are configured as receive mailboxes. Each mailbox
    * has a different ID. All mailboxes in node B are allowed to transmit
    * in a sequence to mailboxes in node A. Once the cycle is complete,
    * the cycle is started all over again.
    
    * This program loops forever. The # of times the receive loop is executed
    * is stored in the RXCOUNT value.
    *
    *********************************************************************/
    
    //
    // Included Files
    //
    #include "DSP28x_Project.h"     // Device Headerfile and Examples Include File
    
    long      RXCOUNT = 0;
    long      i;
    
    void MBXwrA(void);                 // This function initializes all 32 MBOXes of CAN-A
    
    
    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;
    
    
    // Step 1. Initialize System Control:
    // PLL, WatchDog, enable Peripheral Clocks
    // This example function is found in the DSP280x_SysCtrl.c file.
       InitSysCtrl();
    
    /* Initialize the CAN module */
    
        InitECan();
        InitECanGpio();
        EALLOW;
    
    /* Zero out (or initialize) the entire MBX RAM area */
    
        MBXwrA();
    
    
    /* Write to the MSGID field 0f CAN-A - MBX number is written as its MSGID */
    
        ECanaMboxes.MBOX0.MSGID.all = 0x9555AA0;
    
    
    
    /* Configure CAN-A Mailboxes as Receive mailboxes */
    
        ECanaShadow.CANMD.all = ECanaRegs.CANMD.all;
        ECanaShadow.CANMD.all = 0xFFFFFFFF;
        ECanaRegs.CANMD.all = ECanaShadow.CANMD.all;
    
    
    
    /* Enable Mailboxes */
    
        ECanaShadow.CANME.all = ECanaRegs.CANME.all;
        ECanaShadow.CANME.all = 0xFFFFFFFF;
        ECanaRegs.CANME.all = ECanaShadow.CANME.all;
    
    
    
    /* Begin receiving */
    
        while(1)
        {
    
         while(ECanaRegs.CANRMP.all != 0xFFFFFFFF) {}  // Wait for all RMPn to be set..
         ECanaRegs.CANRMP.all = 0xFFFFFFFF;            // Clear all RMPn bits and start
         RXCOUNT++ ;                                   // all over again...
         if(RXCOUNT==1000){break;}
        }
    
    }
    
    
    /* Zero-out the MBX RAM of CAN-A */
    
    void MBXwrA()
        {
        int j;
        volatile struct MBOX *Mailbox  = (void *) 0x6100;
    
            for(j=0; j<32; j++)
            {
                Mailbox->MSGID.all = 0;
                Mailbox->MSGCTRL.all = 0;
                Mailbox->MDH.all = 0;
                Mailbox->MDL.all = 0;
                Mailbox = Mailbox + 1;
    
            }
        }
    
    
    
    /*
        Note: If writing only to the 11-bit identifier as by
        "ECanaMboxes.MBOX1.MSGID.bit.STDMSGID = 1;", IDE, AME & AAM bit fields also
        need to be initialized. Otherwise, they may assume random values. This could
        be done by just initializing the entire register to zero first and then writing
        the STD MSG ID.
    
    */
    

  • Silpa,

                   You are using different MSGIDs on the transmitter & receiver. Since you are not using filtering, the MSGIDs must match exactly. 

    On the transmitter side, you are using:

    ECanaMboxes.MBOX25.MSGID.all = 0x95555555; 

    On the receiver side, you are using:

    ECanaMboxes.MBOX0.MSGID.all = 0x9555AA0; 

    This will not work. Change it to:

    ECanaMboxes.MBOX0.MSGID.all = 0x95555555;  

    This is part of the Debug checklist in my app.note SPRA876: Do not use Acceptance Mask Filtering initially. Transmit the same MSGID. Filtering could be added later once it is confirmed there are no hardware issues with the bus. 

    Also, you are polling all bits in CANRMP, but only configuring MBX0. Your code will be stuck waiting for CANRMP to become FFFFFFFF, which will never happen. Modify it as follows:

    /* Begin receiving */
    
        while(1)
        {
    
         while(ECanaRegs.CANRMP.all != 0x00000001) {}  // Wait for RMP0 to be set..
         ECanaRegs.CANRMP.all = 0x00000001;            // Clear RMP0 bit 
         RXCOUNT++ ;                                   
        }
    

  • Hareesh,

    I have changed the code as per you suggested, but still receiving end mailbox MBOX0 is showing 0x00000000 for all the fields except the MSGID(which we are assigning). I am attaching the modified code along with this.

    // TI Release: 28xx eCAN programming example
    // Release Date: Fri Aug 4 2017
    // Copyright:
    // Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
    //
    // Redistribution and use in source and binary forms, with or without
    // modification, are permitted provided that the following conditions
    // are met:
    //
    //   Redistributions of source code must retain the above copyright
    //   notice, this list of conditions and the following disclaimer.
    //
    //   Redistributions in binary form must reproduce the above copyright
    //   notice, this list of conditions and the following disclaimer in the
    //   documentation and/or other materials provided with the
    //   distribution.
    //
    //   Neither the name of Texas Instruments Incorporated nor the names of
    //   its contributors may be used to endorse or promote products derived
    //   from this software without specific prior written permission.
    //
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    //
    
    /*********************************************************************
    * Filename: TXLOOP_A.c                                                 *
    *                                                                    *
    * Description: TXLOOP - Transmit loop using any mailbox
    *
    * Mailbox 25 is shown as an example...
    * This example TRANSMITS data to another CAN module using MAILBOX25
    * This program could either loop forever or transmit "n" # of times,
    * where "n" is the TXCOUNT value.
    *
    *********************************************************************/
    
    //
    // Included Files
    //
    #include "DSP28x_Project.h"     // Device Headerfile and Examples Include File
    
    #define TXCOUNT  100000  // Transmission will take place (TXCOUNT) times..
    
    long      i;
    long      loopcount = 0;
    
    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;
    
    /* Kill Watchdog, Init PLL, Enable peripheral clocks */
    
        InitSysCtrl();
    
    /* Initialize the CAN module */
    
        InitECana();
        InitECanGpio();
    
        EALLOW;
    
    /* Write to the MSGID field  */
    
        ECanaMboxes.MBOX0.MSGID.all = 0x9555AAA0; // Extended Identifier
        //ECanaMboxes.MBOX25.MSGID.bit.STDMSGID = 25;
    /* Configure Mailbox under test as a Transmit mailbox */
    
        ECanaShadow.CANMD.all = ECanaRegs.CANMD.all;
        ECanaShadow.CANMD.all = 0x0000000;
        ECanaRegs.CANMD.all = ECanaShadow.CANMD.all;
    
    /* Enable Mailbox under test */
    
        ECanaShadow.CANME.all = ECanaRegs.CANME.all;
        ECanaShadow.CANME.all = 1;
        ECanaRegs.CANME.all = ECanaShadow.CANME.all;
    
    /* Write to DLC field in Message Control reg */
    
        ECanaMboxes.MBOX0.MSGCTRL.bit.DLC = 8;
    
    /* Write to the mailbox RAM field */
    
         ECanaMboxes.MBOX0.MDL.all = 0x00000001;
         ECanaMboxes.MBOX0.MDH.all = 0x00000010;
    
    /* 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.TRS0 = 1;     // Set TRS for mailbox under test
         ECanaRegs.CANTRS.all = ECanaShadow.CANTRS.all;
    
         ECanaShadow.CANTA.all = ECanaRegs.CANTA.all;
            do {ECanaShadow.CANTA.all = ECanaRegs.CANTA.all;}   // Wait for TA25 bit to be set..
             while(ECanaShadow.CANTA.bit.TA0 == 0 );
    
         ECanaShadow.CANTA.all = 0;
         ECanaShadow.CANTA.bit.TA0 = 1;         // Clear TA5
         ECanaRegs.CANTA.all = ECanaShadow.CANTA.all;
    
         loopcount ++;
        }
    
    }
    
    
    /* Notes:
    A simple testcase that could be used to transmit data out of a mailbox
    
    
    Last update: 7/22/2017     (Tested)
    */
    
    

    // TI Release: 28xx eCAN programming example
    // Release Date: Fri Aug 4 2017
    // Copyright:
    // Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
    //
    // Redistribution and use in source and binary forms, with or without
    // modification, are permitted provided that the following conditions
    // are met:
    //
    //   Redistributions of source code must retain the above copyright
    //   notice, this list of conditions and the following disclaimer.
    //
    //   Redistributions in binary form must reproduce the above copyright
    //   notice, this list of conditions and the following disclaimer in the
    //   documentation and/or other materials provided with the
    //   distribution.
    //
    //   Neither the name of Texas Instruments Incorporated nor the names of
    //   its contributors may be used to endorse or promote products derived
    //   from this software without specific prior written permission.
    //
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    //
    
    /*********************************************************************
    * Filename: RXLOOP.c                                                 *
    *                                                                    *
    * Description: This is a simple example of how data may be received
    *
    * All mailboxes in CAN-A are configured as receive mailboxes. Each mailbox
    * has a different ID. All mailboxes in node B are allowed to transmit
    * in a sequence to mailboxes in node A. Once the cycle is complete,
    * the cycle is started all over again.
    
    * This program loops forever. The # of times the receive loop is executed
    * is stored in the RXCOUNT value.
    *
    *********************************************************************/
    
    //
    // Included Files
    //
    #include "DSP28x_Project.h"     // Device Headerfile and Examples Include File
    
    long      RXCOUNT = 0;
    long      i;
    Uint32  TestMbox1 = 0;
    Uint32  TestMbox2 = 0;
    Uint32  TestMbox3 = 0;
    
    void MBXwrA(void);                 // This function initializes all 32 MBOXes of CAN-A
    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;
    
    
    // Step 1. Initialize System Control:
    // PLL, WatchDog, enable Peripheral Clocks
    // This example function is found in the DSP280x_SysCtrl.c file.
       InitSysCtrl();
    
    /* Initialize the CAN module */
    
        InitECan();
        InitECanGpio();
        EALLOW;
    
    /* Zero out (or initialize) the entire MBX RAM area */
    
        MBXwrA();
    
    
    /* Write to the MSGID field 0f CAN-A - MBX number is written as its MSGID */
    
        ECanaMboxes.MBOX0.MSGID.all = 0x9555AAA0;
    
    
    
    /* Configure CAN-A Mailboxes as Receive mailboxes */
    
        ECanaShadow.CANMD.all = ECanaRegs.CANMD.all;
        ECanaShadow.CANMD.all = 0xFFFFFFFF;
        ECanaRegs.CANMD.all = ECanaShadow.CANMD.all;
    
    
    
    /* Enable Mailboxes */
    
        ECanaShadow.CANME.all = ECanaRegs.CANME.all;
        ECanaShadow.CANME.all = 0xFFFFFFFF;
        ECanaRegs.CANME.all = ECanaShadow.CANME.all;
    
    
    
    /* Begin receiving */
    
        while(1)
        {
    
         while(ECanaRegs.CANRMP.all != 0x00000001) { }   // Wait for all RMPn to be set..
         ECanaRegs.CANRMP.all = 0x00000001;   // Clear all RMPn bits and start
         RXCOUNT++ ;                                   // all over again...
         if(RXCOUNT==1000){break;}
        }
    
    }
    
    
    /* Zero-out the MBX RAM of CAN-A */
    
    void MBXwrA()
        {
        int j;
        volatile struct MBOX *Mailbox  = (void *) 0x6100;
    
            for(j=0; j<32; j++)
            {
                Mailbox->MSGID.all = 0;
                Mailbox->MSGCTRL.all = 0;
                Mailbox->MDH.all = 0;
                Mailbox->MDL.all = 0;
                Mailbox = Mailbox + 1;
    
            }
        }
    
    
    
    /*
        Note: If writing only to the 11-bit identifier as by
        "ECanaMboxes.MBOX1.MSGID.bit.STDMSGID = 1;", IDE, AME & AAM bit fields also
        need to be initialized. Otherwise, they may assume random values. This could
        be done by just initializing the entire register to zero first and then writing
        the STD MSG ID.
    
    */
    

    Regards,

    Silpa

  • Please provide the waveforms on the TX & RX pins on the receiver side.  The waveform must be like the attached figure, clearly showing the activity on the TX & RX pins. Specifically, I am looking for the ACK signal.

  • I haven't heard from you and presume you have resolved your issue.