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: 2 microcontrollers connection with DCAN does not work, receiver cannot receive message

Part Number: TMS570LS1224

Hi, all. I have 2 microcontrollers and want to make a DCAN communication between both of them. I use the CAN transceiver MCP2551, all of hardware is proper wired. I think it should be the software problem.

I follow the tutorial from official TI Training, however, it does not work.

The main part of transmit code is

    canInit();
    canTransmit(canREG1, canMESSAGE_BOX1, tx_data);
    while(1);

The main part of receiver code is

    canInit();
    while( !canIsRxMessageArrived(canREG1, canMESSAGE_BOX1) );
    while(1);     //Set Breakpoint here, it does not execute

As I said in comments, I set a breakpoint at while(1);, it does not execute when I transmit.

I use the oscilloscope to troubleshoot it, firstly, I check the Transmit MicroController's Tx pin, there is data send out. I check the Receive MicroController's Rx pin, there is data receive. However, it does not execute the breakpoint line.

I check the technique documents, I think it should be some problems of initialization or CAN protocol problem? Or, could you give me some idea how to trouble shoot it? I doubt the driver code has problem, the canTransimit( ... ) function is implemented wrong? How could I send message and receive message by direct accessing the CAN RAM? Could you give some sample code?

Please please help, thanks.

  • Hello Joe,

    The DCAN is designed in such a way that it isn't necessary to access the CAN RAM directly. This helps to avoid collisions between the DCAN logic and the CPU. To perform transmit and receive functions we have included the IFx registers to allow the CPU to access these during CAN active communication.

    For debug of this issue, it would really be necessary to try several things going back to the basics. First, I would recommend you configure the can in loopback mode to take the external HW and second device out of the picture. This will allow you to focus only on the SW you have and not any outside influences.

    If you would like, you can post your code to this thread and I can have a look to see if I can see anything.
  • Pretty thanks for your answer.

    From your suggestion, I tried the DCAN1 communicate with DCAN2, and it is SUCCESS ! I have no idea why I cannot communicate between 2 same launchpad with DCAN1? Is that the problem of bit rate or something? I keep them in default, which is 500.

    The main part of my code is here,

    Trans

     canInit();

    canTransmit(canREG1, canMESSAGE_BOX1, tx_data);

    while(1);

    Receiver:

    canInit();

    while( !canIsRxMessageArrived(canREG1, canMESSAGE_BOX1) );  //For DCAN 1 to DCAN2, the code replace canREG1 to canREG2

    while(1);      //Breakpoint here, it does not execute if communicate between 2 launchpad, but it execute if on 1 launchpad between DCAN1 and DCAN2 !

    Thanks very much.

  • Joe,

    It is most likely a hardware issue. Do you have transceivers for both Launchpads and also the proper terminators for both? The cabling should also be twisted pair.

  • Hi, Chuck. It is really interesting. I cannot receive the CAN message when I use the TI's original USB cable, which connect between PC and Launchpad. When I use my friend's mobile charger cable, connect between PC and Launchpad, I receive the message !!! When I change back to TI's original cable, I cannot receive again !

    I have no idea why. May it cause by different supporting voltage from PC, if I use two different USB cable?

  • Joe,

    I am very confused by this post. You are using a USB cable for CAN communications? This is fairly unorthodox unless you are referencing the cable between the other nodes (PC) CAN adapter HW. At any rate, it could very well be that there is a defect within the cable, that it isn't shielded adequately, or that it has a built in filter that is interfering. Glad to hear that you have isolated the cause of the inability to communicate though.