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.

TMS570LS1224: Hardware setup for the CAN communication example

Part Number: TMS570LS1224
Other Parts Discussed in Thread: HALCOGEN

I have two TMS570LS1224 Hercules development kit boards and two CAN transceivers (SN65HVD230DR). I followed the example video and have flashed the Tx and Rx codes separately on my MCUs. But can you help me with the hardware setup. I think I also will have to take care of the termination as well. I need help with the hardware setup. Thanks.

  • Hello,
    Assuming you got TMS570LS1224 LaunchPads and CAN transceivers that needs to be connected to LaunchPads.
    Connections between CAN transceiver and MCU must be as follows:
    Pin D from CAN transceiver must be connected to CAN1RX, CAN2RX or CAN3RX (according to which CAN module you will use);
    Pin R from CAN transceiver must be connected to CAN1TX, CAN2TX or CAN3TX.

    CANH of 1st CAN transceiver must be connected to CANH of 2nd and CANL of 1st transceiver must be connected to CANL of 2nd;

    At both sides you must connect 120 Ohm termination resistors between CANH and CANL.

    I hope this helps.

    Best regards,
    Miro
  • Hello,
    Do you need any additional information or support on this thread?
    I'll close the thread since there is no activity on it. You can reopen it with writing in it again or you ca open new thread.

    Best regards,
    Miro
  • I made the connections as suggested by you. Also I am following the video https://training.ti.com/hercules-how-tutorial-can-communication .Please take a look at the attached picture. I have connected a 120 Ohms terminating resistor between the CAN H and CAN L on both the sides.

       

    After successfully flashing the code on the Transmitting board I tried flashing the code for receiving the message on the Receiving board. I am getting the following errors.

    Also I am attaching the code that I am using for the Transmitting and the Receiving boards. 

    Code for Transmitting:

    #include "can.h"
    /* USER CODE END */

    /* Include Files */
    #include "system.h"
    #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 tx_data[D_SIZE] = {'R','O','M','E','O','P','O','W','\0'};

    uint32_t checkPackets(uint8_t *src_packet,uint8_t *dst_packet,uint32_t psize);
    /* USER CODE END */

    void main(void)
    {
    /* USER CODE BEGIN (3) */
    canInit();
    canTransmit(canREG1, canMESSAGE_BOX1, tx_data);
    while(1);

    /* USER CODE END */
    }
    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++; /* data error */
    }
    }
    return (err);
    }
    /* USER CODE BEGIN (4) */
    void canMessageNotification(canBASE_t *node, uint32_t messageBox)
    {
    return;
    }

    void canErrorNotification(canBASE_t *node, uint32_t messageBox)
    {
    return;
    }

    void esmGroup1Notification(unsigned channel)
    {
    return;
    }

    void esmGroup2Notification(unsigned channel)
    {
    return;
    }
    /* USER CODE END */

    ***********************************************************************************************************************************

    Code for Receiving:

    #include "system.h"
    #include "sys_common.h"
    #include "can.h"
    #include "sci.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;

    uint32_t checkPackets(uint8_t *src_packet,uint8_t *dst_packet,uint32_t psize);
    /* USER CODE END */

    void main(void)
    {
    /* USER CODE BEGIN (3) */
    canInit();
    sciInit();

    while(!canIsRxMessageArrived(canREG1, CANMESSAGE_BOX1));
    canGetData(canREG1, CANMESSAGE_BOX1, rx_data); /* receive on can2 */
    sciSend(scilinREG, D_SIZE, rx_data);

    error = checkPackets(&tx_data[0],&rx_data[0], D_SIZE);

    while(1);
    /* USER CODE END */


    }


    /* 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);
    }
    /* USER CODE END */
    void canMessageNotification(canBASE_t *node, uint32_t messageBox)
    {
    return;
    }

    void sciNotification(sciBASE_t *sci, unsigned flags)
    {
    return;
    }

    void canErrorNotification(canBASE_t *node, uint32_t notification)
    {
    return;
    }

    void esmGroup1Notification(unsigned channel)
    {
    return;
    }

    void esmGroup2Notification(unsigned channel)
    {
    return;
    }

    FYI, I have generated code in Halcogen following the video I mentioned above. Can you please help?

  • Hello,
    Connections from picture looks fine (I can't see how you are powering the transceiver boards but I assume they are powered). Also I am not sure whether transceiver boards include 120 Ohm resistor on board. If they include it on board, you should disconnect the external one.
    Please check whether your include folder of Receive project is added in ARM compiler Include options (Project Properties --> CCS Build --> ARM Compiler --> Include options )

    Best regards,
    Miro
  • Hi Miro,

    Thanks for getting back. I confirmed from the tranceiver schematic. It already has a internal 120 Ohms resistor. So I removed my external resistor. I am powering it from the Hercules boards' J10 connector pin 3 (3.3V). Attaching the image below. I confirmed the include options. I already added Receive project in ARM compiler Include options. Still same error. 

  • Hello,
    You are using all caps in receive code. Try like this: canMESSAGE_BOX1.
    I don't see where you have defined tx_data in receive code but you are using tx_data in: error = checkPackets(&tx_data[0],&rx_data[0], D_SIZE);

    Best regards,
    Miro
  • Thanks for all the help. I was able to receive the data.