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.

LAUNCHXL-F28379D: Mixed eCAN-DCAN three nodes CANbus communication

Part Number: LAUNCHXL-F28379D
Other Parts Discussed in Thread: LAUNCHXL-F28069M

Hi TI forum users,

I wonder how I can get 1 DCAN device in transmission mode, right after receiving 2 eCAN messages as pictured below using LaunchXL-F28379D.

Thank you!
Nur

changed thread title
original : LAUNCHXL-F28379D:1 DCAN transmitting upon receiving 2 eCAN message
6 Oct '21 : LAUNCHXL-F28379D: continuous transmissions of 3 data frames using 2 eCAN and 1 DCAN
2 Nov '21 : LAUNCHXL-F28379D: Mixed eCAN-DCAN three nodes CANbus communication

  • 6th Sep is a holiday in US and hence please expect a delay in response.

  • Nur,

              Your question is not very clear. If you want the DCAN to respond to a transmission from eCAN, you can have the eCAN send a remote frame and have the DCAN respond with a dataframe. There are working examples in my App.report www.ti.com/lit/sprace5 that shows how to respond to a remote frame. www.ti.com/lit/spra876 has an example that shows you how to generate a remote frame.

  • Thank you for your response.

    What our system needed is a continuously repeated data frame transmission appear on the CAN bus with this sequence:
    1 - 2 - 3 - 1 - 2 -3 - 1 - 2 - 3 - (and so forth)
    1: eCAN device
    2: eCAN device
    3: DCAN device

    Our code looks like this


    while(1)
    {
        // Poll RxOk bit in CAN_ES register to check completion of Reception
        if(((HWREGH(CANB_BASE + CAN_O_ES) & CAN_ES_RXOK)) == CAN_ES_RXOK)
        {
            // Get the received message
            CAN_readMessage(CANB_BASE, RX_MSG_OBJ_ID1, rxMsgData1);
            CAN_readMessage(CANB_BASE, RX_MSG_OBJ_ID2, rxMsgData2);
            // CAN_readMessage(CANB_BASE, RX_MSG_OBJ_ID3, rxMsgData3);
            // RxReady=1;
            rxMsgCount++;
            //transmit upon receiving
            CAN_sendMessage(CANB_BASE, TX_MSG_OBJ_ID, MSG_DATA_LENGTH_TX, txMsgData);
        }
    }


    The code works well with 1 eCAN - 1 DCAN with sequence:

    1 - 3 - 1 -3 - 1 - 3 - (and so forth)

    Any thoughts or comment would be helpful. Thank you!

  • You are only polling RXOK once for both frames. It could be that the second frame of data has not been received yet when your code is attempting to read it. Ensure the data has actually been received before attempting to read it. You can use the NDAT bits for specific message objects.

  • Thank you for your response!

    I tried using a code as follows


    if (CanbRegs.CAN_NDAT_X.bit.NewDatReg2>0)
        {
            rxMsgCount++;
        }


    But it appears that the code didn't work.

    Any comment or suggestion? Thank you.

  • Please take a look at the attachment if you want to directly access the registers.

    W_R to registers.pdf

  • In the figure above, I have succeeded in creating a continuous data frame transmission one after another, using 1 eCAN (launchxl-f28035) & 1 DCAN (launchxl-f28379d).

    However, when the third device's (launchxl-f28069m: power off) CAN pin terminal is connected physically to the CAN bus, the DCAN device stop transmitting and register errors appear as follows:

    F28379D: Boff 1, EWarn 1, EPass 1

    F28069M: SE 1, CRCE 1

    F28035: SE 1

    Could any TI CAN expert suggest kindly why such errors could happen?

    Thank you!

  • Is the behavior any different if the LAUNCHXL-F28069 is powered on?  Also be aware that the bus can only be terminated on either ends. You now have three 120-ohm resistors on the bus. That could be the problem. See debug tips in SPRA876.

  • Thank you for your valuable comment!

    I came back here, after I followed your valuable suggestion on using remote frame based on example can_ex_9_remote_frame fromSPRA876.
    However, I found issue when using 1xLaunchXLf28069m and 2xLaunchXLf28379D. From three 120-ohm resistors on the bus, one is removed (desoldered), hence two 120-ohm resistors terminate the ends. The f28069m acts as master which is able to transmit two different remote frame on the bus (but only one at a time, using selector scheme) which is then received by two DCAN devices each has unique Message Object ID. The remote frame has been transmitted successfully, the reply message has also been received in the master (eCAN) mailbox. The issue is that once the remote frame is transmitted by master, only the Message Object ID with the lower value (hence higher priority) is able to respond. How to get the lower priority Message Object also be able to respond to the remote frame? Which DCAN register require attention to solve this issue? Please kindly advise. Thank you!

  • Sorry, your question is not clear. Please provide the MSGID of all the mailboxes involved in each one of the 3 nodes. Then, clearly indicate the sequence of transmission.

  • Thank you for your reply! The MSGIDs and their selected setups are provided below.

    //Node 1 launchxlf28069
    ECanaMboxes.MBOX3.MSGCTRL.bit.RTR = 1; //remote-transmission-request bit
    ECanaMboxes.MBOX4.MSGCTRL.bit.RTR = 1; //remote-transmission-request bit
    ECanaMboxes.MBOX3.MSGCTRL.bit.DLC = 8; 
    ECanaMboxes.MBOX4.MSGCTRL.bit.DLC = 8; 
    ECanaShadow.CANMD.bit.MD3 = 1; //configured as receive mailbox //corresponding remote reply data frame is received
    ECanaShadow.CANMD.bit.MD4 = 1; //in the same mailbox
    ECanaRegs.CANMD.all = ECanaShadow.CANMD.all;
    eCANaMboxes.MBOX3.MSGID.bit.STDMSGID = 50;
    eCANaMboxes.MBOX4.MSGID.bit.STDMSGID = 60;
    
    //Node 2 launchxlf28379d
    #define MSG_DATA_LENGTH 8
    #define TX_MSG_OBJ_ID 1
    CAN_setupMessageObject(CANB_BASE, TX_MSG_OBJ_ID, 50,
    CAN_MSG_FRAME_STD, CAN_MSG_OBJ_TYPE_RXTX_REMOTE, 0,
    CAN_MSG_OBJ_NO_FLAGS, 8);
    
    //Node 3 launchxlf28379d
    #define MSG_DATA_LENGTH 8
    #define TX_MSG_OBJ_ID 1
    CAN_setupMessageObject(CANB_BASE, TX_MSG_OBJ_ID, 60,
    CAN_MSG_FRAME_STD, CAN_MSG_OBJ_TYPE_RXTX_REMOTE, 0,
    CAN_MSG_OBJ_NO_FLAGS, 8);


    The sequence of transmission is indicated by the code below.

    //The selector scheme:
    if(remote_frame_select == 1)
    {
    EALLOW;
    
    ECanaShadow.CANME.all = ECanaRegs.CANME.all;
    ECanaShadow.CANME.bit.ME3=0; //Disable
    ECanaShadow.CANME.bit.ME4=0; //Disable
    ECanaRegs.CANME.all = ECanaShadow.CANME.all;
    
    ECanaMboxes.MBOX3.MSGCTRL.bit.RTR = 1;
    ECanaMboxes.MBOX4.MSGCTRL.bit.RTR = 0;
    
    ECanaShadow.CANME.all = ECanaRegs.CANME.all;
    ECanaShadow.CANME.bit.ME3=1;
    ECanaRegs.CANME.all = ECanaShadow.CANME.all;
    
    ECanaShadow.CANTRS.all=0;
    ECanaShadow.CANTRS.bit.TRS3=1;
    ECanaRegs.CANTRS.all = ECanaShadow.CANTRS.all;
    
    }
    
    if(remote_frame_select == 2)
    {
    EALLOW;
    
    ECanaShadow.CANME.all = ECanaRegs.CANME.all;
    ECanaShadow.CANME.bit.ME3=0; //Disable
    ECanaShadow.CANME.bit.ME4=0; //Disable
    ECanaRegs.CANME.all = ECanaShadow.CANME.all;
    
    ECanaMboxes.MBOX3.MSGCTRL.bit.RTR = 0;
    ECanaMboxes.MBOX4.MSGCTRL.bit.RTR = 1;
    
    ECanaShadow.CANME.all = ECanaRegs.CANME.all;
    ECanaShadow.CANME.bit.ME4=1;
    ECanaRegs.CANME.all = ECanaShadow.CANME.all;
    
    ECanaShadow.CANTRS.all=0;
    ECanaShadow.CANTRS.bit.TRS4=1;
    ECanaRegs.CANTRS.all = ECanaShadow.CANTRS.all;
    
    }

    which is run at Node 1 (LaunchXL-F28069M).


    After some assessments, I found this following particular line of code (provided from the example)

    while(((HWREGH(CANB_BASE + CAN_O_ES) & CAN_ES_TXOK)) != CAN_ES_TXOK){}

    freezes the DSP with the lower priority MSGID (in this case MSGID=60, the 3rd node).

    This led to another question, what are the possible conditions that freeze the DSP? Thank you!

  • Hi Nur,

    Thanks for your follow-up. Hareesh is currently OOO with limited access, so I will assist with this thread in the meantime.

    First, I will address the question regarding freezing:

    The DSP is freezing at this line because it is waiting or the data to come in (TxOk==0 when no message received since last time this bit was read). This essentially makes this a "blocking" read of the device, hence the device is not really "freezing" but instead "waiting". The issue is that there is no additional data being received to this device, hence it is perpetually waiting. This leads us to the main question.

    Why is node 3 freezing at all?

    Let's try debugging like this (action items highlighted in bold for easier reading):

    1. Please swap the message IDs of Node 2 and Node 3. Let me know if the issue now moves to Node 2 (since before it was on Node 3). If the issue moves with message ID, then we will need to handle the two message IDs differently in the transmit.

    2. Please take a scope capture of the RX pin of the bad node during the full sequence of transmissions from the master. I want to sanity check that all the data is being sent.

    I look forward to seeing the results of this test!

    Regards,

    Vince

  • Hi Vince,

    Thanks for your support. I found that using a CANTalker device, when sending the remote frame for Node 3, the remote frame for Node 2 is somehow also transmitted. This eventually causes Node 2 to respond since it is assigned with a higher priority MSGID.


    1. Please swap the message IDs of Node 2 and Node 3. Let me know if the issue now moves to Node 2 (since before it was on Node 3).

    I swapped the message IDS of Node 2 and Node 3, and, yes, the issue now moves to Node 2!


    2. Please take a scope capture of the RX pin of the bad node during the full sequence of transmissions from the master.

    Rather than a scope capture, I provided a data window captured by a Can analyzer, which shows that during request of the lower priority MSGID, the request of higher priority MSGID is somehow also carried and transmitted.

    This led to another question, is this more a register programming issue, or does the CAN protocol behave this way?

  • Hi,

    Thanks for the follow-up. To answer your final question, the CAN protocol will always allow the highest priority frame through only, all other nodes will stop communicating when they realize they are not the highest priority. Therefore, if we have a situation like this, where the highest priority node is essentially "taking up" all the communication time, the other nodes will not get a chance to communicate/talk.

    So to see if this is from the sending protocol side, could you put a very long delay (maybe 1 second) between each transmission and see if this resolves the issue? I would guess this is the root cause, that basically the transmitting device is conflicting its own transmissions (by sending additional transmissions before the first one has finished sending).

    Regards,

    Vince

  • Hi Hareesh & Vince,

    Thank you very much for your helpful suggestions.

    1) Removing the unnecessary resistors on the CanBus solved the physical layer issue.

    2) Understanding the differences of eCAN (Bitfields) and DCAN (Driverlib), TI examples, and also how to modifiy DCAN registers helped in writing the code.

    3) Inserting a very long delay really helps understanding the mechanism and debugging the issues.

    The three nodes communication are working fine using data frames broadcast. It's not perfect, but it is working.

    Thank you for your support!

    Nur