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.

TMS570LS0432: CAN Communication between TMS570LS0432 and TMS320F28069M

Part Number: TMS570LS0432


I tried CAN communication between two F28069 boards as well as between two Hercules boards and it is working fine, but i am able not communicate between F28069 and Hercules board. I checked the baud rate, msgid and DLC, all these are set same and the hardware connections are CANL and CANH of F28069 are connected to transceiver for hercules board and to TX, RX.

/* Code for TMS320F28069 */
#include "DSP28x_Project.h"     // Device Headerfile and Examples Include File

#define TXCOUNT  100            // Transmission will take place (TXCOUNT) times

long      i;
long      loopcount = 0;

void mailbox_read(int16 i);

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

void main(void)
{
    struct ECAN_REGS ECanaShadow;

    InitSysCtrl();
    InitECanGpio();

    DINT;
    InitPieCtrl();
    IER = 0x0000;
    IFR = 0x0000;
    InitPieVectTable();

    InitECan();            // Initialize eCAN-A module

    // Write to the MSGID field
    ECanaMboxes.MBOX0.MSGID.all = 0x80000001;          // Extended Identifier
    ECanaMboxes.MBOX16.MSGID.all = 0x80000001;

    // Configure Mailbox under test as a Transmit and Receive mailbox
    ECanaShadow.CANMD.all = ECanaRegs.CANMD.all;
    ECanaShadow.CANMD.bit.MD0 = 0;
    ECanaRegs.CANMD.all = ECanaShadow.CANMD.all;

    ECanaShadow.CANMD.all = ECanaRegs.CANMD.all;
    ECanaShadow.CANMD.bit.MD16 = 1;
    ECanaRegs.CANMD.all = ECanaShadow.CANMD.all;

    // Enable Mailbox under test
    ECanaShadow.CANME.all = ECanaRegs.CANME.all;
    ECanaShadow.CANME.bit.ME0 = 1;
    ECanaRegs.CANME.all = ECanaShadow.CANME.all;

    ECanaShadow.CANME.all = ECanaRegs.CANME.all;
    ECanaShadow.CANME.bit.ME16 = 1;
    ECanaRegs.CANME.all = ECanaShadow.CANME.all;

    // Write to DLC field in Master Control reg
    ECanaMboxes.MBOX0.MSGCTRL.bit.DLC = 8;
    ECanaMboxes.MBOX16.MSGCTRL.bit.DLC = 8;

    // Write to the mailbox RAM field
    ECanaMboxes.MBOX0.MDL.all = 0x80000001;
    ECanaMboxes.MBOX0.MDH.all = 0x89ABCDEF;

    //
    // Begin transmitting
    //
    for(i=0; i < TXCOUNT; i++)
    {
        ECanaShadow.CANTRS.all = 0;
        ECanaShadow.CANTRS.bit.TRS0 = 1;     // Set TRS for mailbox under test
        ECanaRegs.CANTRS.all = ECanaShadow.CANTRS.all;

        do
        {
            ECanaShadow.CANTA.all = ECanaRegs.CANTA.all;
        } while(ECanaShadow.CANTA.bit.TA0 == 0 );// Wait for TA25 bit to be set

        ECanaShadow.CANTA.all = 0;
        ECanaShadow.CANTA.bit.TA0 = 1;                  // Clear TA25
        ECanaRegs.CANTA.all = ECanaShadow.CANTA.all;

        loopcount ++;

            // This func reads the indicated mailbox data
            mailbox_read(16);
    }
}

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

/* code for TMS570LS0432 */
/* USER CODE BEGIN (0) */
#include "sys_common.h"
#include "system.h"
#include "can.h"
#include "sci.h"
/* USER CODE END */
/* Include Files */
#include "sys_common.h"
/* USER CODE BEGIN (1) */
/* USER CODE END */
/** @fn void main(void)
*   @brief Application main function
*   @note This function is empty by default.
*
*   This function is called after startup.
*   The user can use this function to implement the application.
*/
/* USER CODE BEGIN (2) */
#define D_SIZE 9
uint8_t rx_data[D_SIZE]= {0};
uint32_t error=0;
uint8 value=0x80;
uint32_t checkPackets(uint8_t *src_packet,uint8_t *dst_packet,uint32_t psize);
/* USER CODE END */
int main(void)
{
/* USER CODE BEGIN (3) */
    canInit();//initialize can module
    sciInit();//initialize sci module
    sciSend(scilinREG, 21, (unsigned char *)"Hey\r\n");
    sciSend(scilinREG, D_SIZE, value);
    /*wait until message received on can1*/
    while(!canIsRxMessageArrived(canREG1, canMESSAGE_BOX1));
    canGetData(canREG1, canMESSAGE_BOX1, rx_data);/*receive on CAN1*/
    sciSend(scilinREG, D_SIZE, rx_data);//sends received data on canbus
    /*check received data pattern*/
    //error= checkPackets(&tx_data[0], &rx_data[0], D_SIZE);
    while(1);//infinite loop
/* USER CODE END */
    //return 0;
}
/* USER CODE BEGIN (4) */
uint32_t checkPackets(uint8_t *src_packet,uint8_t *dst_packet,uint32_t psize)
{
    uint32_t err=0;
    uint32_t cnt=psize;
    while(cnt--)
    {
        if((*src_packet++) != (*dst_packet++))
        {
            err++;
        }
    }
    return (err);
}
/*can interrupt notification (not used but must be provided)*/
void canMessageNotification(canBASE_t *node, uint32_t messageBox)
{
    return;
}
/*can interrupt notification (not used but must be provided)*/
void canErrorNotification(canBASE_t *node, uint32_t notification)
{
    return;
}
/*can interrupt notification (not used but must be provided)*/
void esmGroup1Notification(unsigned channel)
{
    return;
}
/*can interrupt notification (not used but must be provided)*/
void esmGroup2Notification(unsigned channel)
{
    return;
}
/* part of library file */
for (i = 0U; i < 8U; i++)
        {
#if ((__little_endian__ == 1) || (__LITTLE_ENDIAN__ == 1))
            /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
            node->IF1DATx[i] = *data;
            /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
            /*SAFETYMCUSW 567 S MR:17.1,17.4 <APPROVED> "Pointer increment needed" */
            data++;
#else
            /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
            node->IF1DATx[s_canByteOrder[i]] = *data;
            /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
            /*SAFETYMCUSW 567 S MR:17.1,17.4 <APPROVED> "Pointer increment needed" */
            data++;
#endif
        }
        /** - Copy TX data into message box */
        /*SAFETYMCUSW 93 S MR: 6.1,6.2,10.1,10.2,10.3,10.4 <APPROVED> "LDRA Tool issue" */
        node->IF1NO = (uint8) messageBox;
        success = 1U; 
    }

In this 'part of library' file, the 32 bit data is copied to 8 bit message box, will that be a issue for the communication.