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.

TDA2P-ACD: CAN Disconnect

Part Number: TDA2P-ACD

As this is a new topic, moving to a new e2e thread from the following https://e2e.ti.com/support/processors/f/791/t/827092

Per Gokul:  "We are facing some crash issue during one of our test-case scenario. ( CAN disconnect).

 During CAN disconnect , system is freezed.

 We are expecting normal behavior of the system, even when there is no CAN data. (Camera & display should not be freezed)

 I see below error when I connect the CAN again

 [IPU1-0]   3306.653053 s: UTILS: MBX: Utils_mbxSendCmd(): Msg Alloc Failed (0)!!!

[IPU1-0]   3306.662447 s: UTILS: MBX: Utils_mbxSendCmd(): Msg Alloc Failed (0)!!!

 

 I need system support in solving this issue. 

  

 

  • Hi Gokul,

    Looks like exception happens in the ISS Capture Driver Call-back when you connect CAN again. Is there any dependency between Capture and MCAN link?

    Also, can you please step through the 'Utils_mbxSendCmd()' and see where it is returning failure to print error message?

    Thanks & Regards,
    Vivek Dhande.

    Texas Instruments (India) Pvt Ltd

  • Hi Vivek,

    I don't find any dependency between CAN and Capture link. Also  Utils_mbxGetFreeMsgCount returns 0 , in  the  below printf

    Vps_printf(" UTILS: MBX: Utils_mbxSendCmd(): Msg Alloc Failed "
    "(%d)!!!\n", Utils_mbxGetFreeMsgCount());

    Regards,

    Gokul

  • Hi Gokul,

    Does 'Utils_mbxGetFreeMsgCount()' returning '0' mean all the mailboxes for Tx messages are already occupied? If yes, then looks like error handling is needed in the application? Are you doing this? When you disconnect CAN node, TDA device will start throwing errors if any messages are sent after this.

    If message transmission fails, what are the actions taken in the application? 

    Thanks & Regards,
    Vivek Dhande.

    Texas Instruments (India) Pvt Ltd

  • Hi Vivek,

    When we do disconnect, it is blocked in transmitMsgOverMCAN function. There is a while loop in this function,

    /* wait untill transmit complete occurs */
    while (gMcanTxIsrFlag)
    {}
    gMcanTxIsrFlag = 1U;

     When I spoke to Harman CAN team, they said it is expecting for  ACK . Since we do the PCAN- disconnection , the transmitter is not able to able to pull the ACK low.

    Is there way to come out of this loop after some definite times .

    It is part of the PDK -driver code. 

    int32_t transmitMsgOverMCAN(MCAN_TxBufElement *txMsg )
    {
    int32_t status = STW_EFAIL, protocolStatus = STW_SOK;
    MCAN_ProtocolStatus protStatus;

    /* Enable Transmission interrupt */
    status = MCAN_txBufTransIntrEnable(MCAN_MODULE,
    1U,
    (uint32_t)TRUE);

    /* write the message into MessageRAM for transmission */
    MCAN_writeMsgRam(MCAN_MODULE,
    MCAN_MEM_TYPE_BUF,
    1U,
    txMsg);

    /* Add request for transmission */
    status += MCAN_txBufAddReq(MCAN_MODULE, 1U);
    if (STW_SOK != status)
    {
    status = STW_EFAIL;
    //UARTConfigPuts("\nError in Adding Transmission Request...\n");
    }

    /* wait untill transmit complete occurs */
    while (gMcanTxIsrFlag)
    {}
    gMcanTxIsrFlag = 1U;


    /* check for errors */
    MCAN_getProtocolStatus(MCAN_MODULE, &protStatus);
    /* Checking for Errors */
    if (((MCAN_ERR_CODE_NO_ERROR == protStatus.lastErrCode) ||
    (MCAN_ERR_CODE_NO_CHANGE == protStatus.lastErrCode)) &&
    ((MCAN_ERR_CODE_NO_ERROR == protStatus.dlec) ||
    (MCAN_ERR_CODE_NO_CHANGE == protStatus.dlec)) &&
    (0U == protStatus.pxe))
    {
    // no errors;
    }
    else
    {
    protocolStatus = STW_EFAIL;
    }

    if(STW_EFAIL == protocolStatus)
    {
    status = protocolStatus;
    }

    return status;
    }

    Regards,

    Gokul

  • Hi Gokul,

    Can you use semaphores instead of 'while (gMcanTxIsrFlag)' busy loop? This will allow other tasks to run even after the MCAN messages fail to go out.

    Also, in the ISR where 'gMcanTxIsrFlag' gets set, looks like you are handling only successful transmit condition and not the failure.

    Also, one more question does CAN and capture link runs on the same core? If yes, then it explains the hang after CAN disconnection.

    Thanks & Regards,
    Vivek Dhande.

    Texas Instruments (India) Pvt Ltd

  • Hi Gokul,

        Were you able to try the above suggestion? Did it help?

    Thanks & Regards,

    Vivek Dhande.

    Texas Instruments (India) Pvt Ltd

  • Hi Vivek,


    Please give us some time on this. Our CAN  team  member is on Vacation. 

    Regards,

    Gokul

  • Hi Vivek,

    Will Transmission Cancellation Finished bit be set  during  disconnection of the CAN ?

    We need to handle the failure condition. 

    void mcanTxISR(void)
    {
    uint32_t intrStatus;

    intrStatus = MCAN_getIntrStatus(MCAN_MODULE);
    MCAN_clearIntrStatus(MCAN_MODULE, intrStatus);
    if (MCAN_INTR_SRC_TRANS_COMPLETE ==
    (intrStatus & MCAN_INTR_SRC_TRANS_COMPLETE))
    {
    ++can_isr_tx_success_counter;
    resetTxIsrFlag();//gMcanTxIsrFlag = 0U;
    }
    else
    {
    Vps_printf(" UTILS: MCAN Tx Interrupt Status: %x !!!\n", intrStatus);
    }
    }

  • Hi Gokul,

    In the case of message failure, cancellation bit will be set. If auto-retransmission of the failed message is enabled then the MCAN module will re-try the message transmission. You have to handle these error conditions. You need to handle message Tx or Rx failure cases as well as MCAN state changes(like bus off and recovery from it).

    You should not have a busy loop in the multi-threaded application, use semaphore instead. Otherwise, you can run into similar problems later which can be difficult to debug.

    Thanks & Regards,

    Vivek Dhande.

    Texas Instruments (India) Pvt Ltd

  • Hello Gokul, 

    If i understand correctly you are trying to wait synchronously a transmit confirmation (as it is shown in a while loop ) ?

    You can extend your loop condition, by not only waiting for a Transmit confirmation but also waiting for any CAN events (No Ack, BusOff). 

    something like 

    while ( gMcanTxIsrFlag || **McanErrorPassive == 128 || McaBusOffFlagSet   );

    ** When the Transmitting node don't get an ack the Tx error counter is increasing until error passove and stay in the Error passive state ( No B.O. ). 

    ** Also in this situation the Transmitting node re - send the frame ( until an event come INIT mode, BO, etc.. )

    So after the loop, you can check which condition  is raised and make the necessary handling ( Re - Transmit for example )

    Hop this help you. 

    BR,

    Yacine

  • Hi Gokul,

    I haven't heard back from you, I'm assuming you were able to resolve your issue.

    If not, just post a reply below (or create a new thread if the thread has locked due to time-out).

    Thanks & Regards,
    Vivek Dhande.

    Texas Instruments (India) Pvt Ltd