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/TM4C123GH6PZ: TIVA CAN_Interface Issue

Part Number: TM4C123GH6PZ
Other Parts Discussed in Thread: EK-TM4C123GXL

Tool/software: Code Composer Studio

Hi,

  1. We are trying to communicate two Tiva controller on CAN BUS.
  2. Sample code used from TIVA library
  3. One controller loaded with sample Tx code.
  4. Another controller loaded with sample Rx code.

 

Issue :

        On start of the communication, program enters into the error state.

 

ERROR:

        Error screenshots are attached for your reference.

 

Kindly advice to proceed further.

Thank you,

Sunil S

AUMA.docx

 

  • The status returned from the function CANStatusGet() indicates a problem with the CAN bus. Have you properly used CAN transceivers with termination resistors to connect the can of the two controllers? The CANTX and CANRX pins of the controllers cannot properly be connected directly to another controller.

    Here is some information about the CAN bus and TI CAN transceivers: www.ti.com/.../sloa101b.pdf
  • Yes, thanks , After the proper Termination.
    I am transmitting the data from TX with CAN ID 0x1001 with 4 bytes.
    1. Now Receiver is getting the data from Transmitter once .
    2. Even after the transmission complete. The receiver getting the packet with CAN ID 0x1001 along with data '0' length. Receiver is in continuously receive mode.
  • The example program simple_tx.c transmits continuous frames as the CANMessageSet() function is in a while(1) loop. Did you modify the simple_tx or the simple_rx routines?
  • Yes,
    1. modified the simple_tx routine. removed from while and now sending the data using CANMessageSet() function every one second.
    2. Kept simple_rx routine as it is.

    image is attached for your reference.

  • please do reply.

    waiting for the good response.
  • Would not that 'good' response - better result - if you, 'Provided the code contained w/in your, "Modified simple_tx.c" routine?'
  • I have verified the CAN programs simple_rx.c and simple_tx.c from TivaWare version 2.1.4.178 using  EK-TM4C123GXL launchpads and external CAN transceivers connecting with PB4 (CAN0RX) and PB4 (CAN0TX). Sequential messages are transmitted and received without error once every second as shown in the snippet below. My only conclusion is there is something wrong in your hardware setup or in your modified software. If you require additional help, you need to provide me more details of your code and your setup.

  • can_code_transmit_modified.txt
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    //*****************************************************************************
    //
    // simple_tx.c - Example demonstrating simple CAN message transmission.
    //
    // Copyright (c) 2010-2016 Texas Instruments Incorporated. All rights reserved.
    // Software License Agreement
    //
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    okay,
    can you send the code for me.

    here i am attaching the code . which is modified 

  • In your file "can_code_transmit_modified" you also modified the CAN baud rate. In your file it is set to 500K baud. In the TI example "simple_RX", the baud rate is 100K baud. I modified your file by changing the baud rate to 100K baud (and deleted the redundant inclusion of some header files). The modified version now works properly with the TI example 'simple_RX".

    /cfs-file/__key/communityserver-discussions-components-files/908/can_5F00_code_5F00_transmit_5F00_modified.c

  • hi,

    can you please share the your code

    for rx and tx.

    thanks.

    mallikarjuna.

  • Yes, I have attached a .zip file which contains two CCS projects, DK-CAN_simple_RX and DK-CAN_simple_TX. The only modification is that they use pins PE4 and PE5 for CAN0, just like the file you provided. Use the CCS function "File" -> "Import", "CCS Projects" and "Select archive file" to add these two projects to your workspace.

    /cfs-file/__key/communityserver-discussions-components-files/908/DK_2D00_CAN_2D00_Simple.zip

  • Dear Bob Crosby ,

    Thank you for sharing the code. I will test and update the status.

  • Dear Bob Crosby,

    1. The code which sent by you is working fine.(DK_Simple zip)

    2. The code which you modified and given is not working.(Which I sent you for the checking, and you modified the baud rate and header).
  • Dear Bob Crosby,

    (2. The code which you modified and given is not working.(Which I sent you for the checking, and you modified the baud rate and header).)
    After looking at your code updated driverlib to Tivaware_C_Series-2.1.4.178 from TivaWare_C_Series-2.1.3.156 and found working.

    Thank you so much for your time and code.
    Finally its worked as expected.