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.

EK-TM4C123GXL: CAN communication not working.

Part Number: EK-TM4C123GXL

Hi,

I am trying to send and receive data over CAN BUS using EK-TM4C123GXL with help of simple_rx and simple_tx example codes provided in TIVAware. I am connecting CAN Tx and Rx from EK-TM4C123GXL to Tx and Rx of  TJA1050 CAN transceiver. I am not able to send and receive any data. CANStatusGet(CAN0_BASE, CAN_STS_CONTROL) in CANInthandler() returns 0x101 while running simple_rx program and it returns 0xE5 while simple_tx is running.

I am clueless about where I am going wrong. So, any sort of help to resolve this would be really appreciated.

Hoping for a quick response.

Regards,

Pradeep Choudhary

  • The status code of 0x101 does not make sense for simple_rx. The control status register is only 8 bits wide. The code of 0xE5 for simple_tx does make sense and points to an issue in the physical CAN bus. Look at the CANH and CANL lines with a scope? They should normally be at the same voltage (around 2V). This is the recessive state. When a transmission starts, CANH goes high and CANL goes low. If this is not happening, check you termination resistors (120 Ohm or two 60 Ohm in series) at each end of the bus. Check that no other device on the bus is holding the bus in a dominate state. And check that you have properly connected and powered your CAN transceiver. For the examples to work there must be another node on the bus properly configured to the same baud rate that will acknowledge the frame from simple_tx.

    See this application report for a detailed description on a CAN bus: https://www.ti.com/lit/an/sloa101b/sloa101b.pdf

  • Hi Bob,

    It's 101 in decimal which is equal to 0x65. And regarding termination resistors, I have connected termination resistors at both ends. The device on the other end is PCAN-USB.  I have tested the exact same hardware with MCU from another hardware and it works fine. So,I am bit confused about what can go wrong with the hardware.

    If you can point me to specific direction it would be really great.

    Regards,

    Pradeep Choudhary

  • OK, that makes more sense. In both cases the last error code (LEC) is 0x5, which means that the Launchpad was trying to send a zero (dominate) but read back a one (passive). Check the CAN bus with an oscilloscope. If the bus is properly switching between passive and active, check the routing of the RX signal from the transducer to the Launchpad. If you can still see an active low signal going to the CAN RX pin of the Launchpad, double check the software to make sure it is configuring the same pin for CANRX as you connected to. The example is generic and the appropriate pins must be configured. There are three possible pin choices for CAN0RX, PB4, PE4 or PF0. Which pins are you using? (Or are you using CAN1?) If you used PF0, there is additional code needed to unlock the configuration registers as that pin can be used as the NMI.

  • Hi Bob,

    Thanks for your suggestion. I am using PB4 and PB5 pins. Also, I didn't get exactly what does LEC 0x5 suggests. And, what do you mean by the active low signal on Rx Pin of Launchpad, and if that happens what it would suggest?

    Best Regards,

    Pradeep Choudhary

  • The LEC (last error code) is the last three bits of the CAN status register. The error codes are shown on page 1074 of the data sheet:

    A bit 0 error means the CANTX pin was trying to drive a low, but it saw a high on the CANRX pin. In proper operation when a CAN module has control of the bus, it should see the same state on CANRX as it is driving on CANTX. From page 8 of the application report here is what a proper 0 bit looks like. 

    Using a scope, trigger off of the following edge of CANTX (trace 1). Check to see that CANH (trace 2) is high and CANL (trace 3) is low on the bus. If it is, check that CANRX (trace 4) is low. What error code 5 is telling you is that when CANTX was low, CANRX was still high.