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.

TMS570LS1114: TMS570LS 1114 DCAN, why bus-off generated during sleep and wakeup process.

Part Number: TMS570LS1114

Hi,

When we test the DCAN driver sleep and wakeup funciton, we found that bus-off will generate during the process, sleep and wakeup seems woke normally , but when we execute the sleep-wakeup 20 times continuously , then bus-off will generate at least one time during the process.

So why bus-off generated? Hope your suggestions.

BR, Thanks

Ming

  • Hi Ming,

    If a CAN controller fails or if there are extreme accumulations of errors (TEC, or REC in ERRC register), a state transition is made to the Bus Off state. The CAN controller disconnects from the CAN bus.

    The CAN protocol defines 5 mechanisms to detect the corrupted messages: bit monitoring, form check, stuff check, ACK check, and CRC check. The bit monitoring and ACK check are performed by the sender. The receiver performs the form check, stuff check, and CRC check. Whenever the tx error counter exceeds the value of 255, it will switch to the bus-off state.

    This maybe caused by your setup, the sleep-wakeup sequence. Is the bus-off only for the sleep-wakeup node, or other node?

  • Hi QJ Wang,
    Yes ,only for the sleep-wakeup node, actully we only test one node with the CAN test tool.
    Our code for sleep and wakeup as followed:

    sleep:
    u8 m_ubLoopCnt;
    volatile u32 ulShadowReg;
    /*set WUBA and PDR bits request power-down mode*/
    CAN_SETREG_BIT(CAN_CONTROL_REG_ADDR, (CAN_CONTROL_WUBA_BIT | CAN_CONTROL_PDR_BIT),u32);

    /* Wait for pending Transmission or reception to end and sleep mode acknowledgement */
    m_ubLoopCnt = 0U;
    /*wait PDA bit */
    do
    {
    m_ubLoopCnt++;
    ulShadowReg = CAN_GETREG_VALUE(CAN_STATUS_REG_ADDR);
    }
    while ( ((ulShadowReg & CAN_STATUS_PDA_BIT)==0) && (m_ubLoopCnt < CAN_LOOP_MAX) );
    /* Once CAN controller is sleeping, activate wake up interrupt */
    CAN_WakeUpInterruptEnable(IDXCTRL_VOID);

    wakeup interrupt routne:
    if (NCS_TST_BIT_SET(ulDataValue,CAN_STATUS_WAKEUPPND_BIT,tCanBusSize))
    {
    /* Switch the protocol handler to INITIALISATION mode to prevent */
    /* from CAN frame transmission and/or reception */
    CAN_Desactivate (); // set init mode
    CAN_WAKE_UP_IND;
    }

    after wakeup the routne will transmit data.

    Is there some problems in the process?
  • Hi Ming,

    I don't see the problem. Please add code to monitor the error count and error status. The bus-off state is entered only when the error count reaches 255.
  • Hi,

    The TEC=0xF8, and REC=0, every time when the process inter bus-off status and BOFF= 1.  and the value of error status REG is 000002E7.

    1, why TEC is not 255 in bus-off status?

    2, why WakeUpPnd not reset after read the error status REG?

    3, where can I find some DCAN demo code for bus-off and sleep-wakeup, in TI websit , polling mode will be better.

    BR, and Thanks

    Ming

  • Hi Ming,

    Very good questions.

    1. I think the TEC is not updated for the last error (TEC+=8) at this moment the bus-off occurs
    2. Reading the ES register will clear the WakeUpPnd flag, the DCAN may re-assert the WakeUpPnd flag, and a second interrupt may occur
    3. No, we don't have sample code to generate DCAN local power-down and wakeup.

    Entering local power down:
    1. set PDR bit in DCAN CTL register

    Wakeup from local power down:
    1. clar the PDR bit and Init bit manually
    or
    2. CAN bus message wakeups the ode: the WUBA should be enabled in DCAN CTL register
  • Hi Ming,

    Please post your code, so I can do a test on my board. I don't understand the ISR in your code:

    wakeup interrupt routne:
    if (NCS_TST_BIT_SET(ulDataValue,CAN_STATUS_WAKEUPPND_BIT,tCanBusSize))
    {
    /* Switch the protocol handler to INITIALISATION mode to prevent */
    /* from CAN frame transmission and/or reception */
    CAN_Desactivate (); // set init mode
    CAN_WAKE_UP_IND;
    }

    If WUBA bit is set, the dominant CAN bus level will automatically start the wake up sequence.
  • Hi, 

    Yes we use the CAN bus message wakeups, set the WUBA .

    What about the Bus-Off and Recovery process, especially the Recovery process, the operation steps when enable ABO  and operation steps not enable ABO.

    Thanks and Best Regards.

    Ming

  • Hi,
    Interrupt routine:
    void CAN_LLD_AllInterrupts (CTRLIDX_VOID)
    {
    u16 ISRnb;
    ISRnb = (u16) (CAN_GETREG_VALUE(CAN_INTERRUPT_REG_ADDR) & 0x80FFU);

    /* Status interrupt */
    if((ISRnb & CAN_STATUS_INTERRUPT) == CAN_STATUS_INTERRUPT)
    {
    CAN_ControllerStatusManage(IDXCTRL_VOID);
    }

    /* Mailbox interrupt */
    else
    {
    /* Rx Confirmation */
    if (CAN_MAILBOX_DIRECTION_TEST(ISRnb-1U) == CAN_MAILBOX_MODE_RX)
    {
    CAN_RxFrameMailbox(IDXCTRL (u16)(ISRnb-1U));
    }

    /* Tx Confirmation */
    #if (CAN_TX_MODE == CAN_INTERRUPT_MODE)
    else
    {
    CAN_TxFrameMailbox(IDXCTRL (u16)(ISRnb-1U));
    }
    #endif
    }

    /*clear INTERRUPT_REG*/
    ISRnb = CAN_GETREG_VALUE(CAN_INTERRUPT_REG_ADDR);

    }

    NCS_PRI_FCT void CAN_ControllerStatusManage (CTRLIDX_VOID)
    {
    tCanBusSize ulDataValue;

    /* Reading the register clears the IT flag */
    ulDataValue = CAN_GETREG_VALUE(CAN_STATUS_REG_ADDR);

    /* Bus Off state */
    if (NCS_TST_BIT_SET(ulDataValue,CAN_STATUS_BOFF_BIT, tCanBusSize))
    {
    /* Block the protocol handler in the BUS-OFF state, */
    /* by putting the protocol handler to INITIALISATION mode, */
    /* to prevent from CAN frame transmission and/or reception */
    CAN_LLD_Deactivate(IDXCTRL_VOID);

    /* Notify upper layer only once per BusOff state */
    /* CHECK: NOPARSE */
    /* NOCOV-DEFENSIVE*/
    if ( CAN_FALSE == m_ubBusOffNotified)
    {
    /* Set BusOff notification flag */
    m_ubBusOffNotified = CAN_TRUE;

    /* BUS-OFF indication */
    CAN_BUS_OFF_IND;
    }
    else
    {
    }
    /* CHECK: PARSE */
    }

    if (NCS_TST_BIT_SET(ulDataValue,CAN_STATUS_WAKEUPPND_BIT,tCanBusSize))
    {
    /* Switch the protocol handler to INITIALISATION mode to prevent */
    /* from CAN frame transmission and/or reception */
    CAN_Desactivate ();
    CAN_WAKE_UP_IND;
    }
    }

    Please Kindly check. Thank you.

    Ming
  • Hi Ming,

    If ABO is enabled, the BUS-OFF recovery sequence will be started automatically. If ABO is not enable, the module will stay in bus-off state, and you need to manually set and reset the Init bit in CTL register.

    When the Init bit is cleared by the application again, the module will then wait for 129 occurrences of Bus Idle (129 × 11 consecutive recessive bits) before resuming normal operation. At the end of the Bus-Off recovery sequence, the error counters will be reset.

    If the issue which causes the BUS-OFF is not solved, the bus-off sequence will repeat.