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.

AM2634: Bus off ISR does not work as expected.

Part Number: AM2634
Other Parts Discussed in Thread: SYSCONFIG

Tool/software:

Hello, I am trying to make the ECU enter bus off to do some stuff in CanIf_ControllerBusOff, but neither the bus off handler(Can_mcanProcessBusOff) nor CanIf_ControllerBusOff is being called.


The transmission counter increases but the bus off flag in never raised.

Could you guide how to make the bus off flag raised?

I put a breakpoint at Canwrite to make the ECU stop before sending and after that shorting the CANHigh and CANLow and go.

Yours,
Abdelrhman Afifi 

  • Hello Abdelrhman,

    Can you outline how you are configuring the CAN bus to try and detect the interrupt for bus off state?

    I'm not familiar with this particular flag so asking some other experts with more knowledge on this, but understanding what you are doing to enable this would help too.

    Best Regards,

    Ralph Jacobi

  • Hello,
    I am configuring it to work ion interrupt, which works with tx and rx.

    const struct Can_ControllerStruct_PC
        CanConfigSet_PC_CanController_CAN1 =
    {
        CanConf_CanController_CanController_CAN1,      /* Id as provided by GUI */
        (boolean)TRUE,   /* Contoller is used=1 or not_used=0*/
        0x52600000U, /* Can Controller Base Address */
    	(boolean)FALSE,    /* Automatic wakeup via bus activity */
        CAN_TX_RX_PROCESSING_INTERRUPT,  /* Can Rx Processing Type */
        CAN_TX_RX_PROCESSING_INTERRUPT,  /* Can Tx Processing Type */
        (boolean)TRUE,/* BusOff  TRUE = Interrupt FALSE = Polling */
    	(boolean)TRUE,    /* TRUE = Interrupt FALSE = Polling */
    	(boolean)TRUE,    /* Auto retransmission on Tx error Enable/Disable */
    	NULL_PTR,
    	CAN_CONTROLLER_INSTANCE_MCAN0,  /* Controller Instance */
    };

  • Hello Abdelrhman,

    Multiple experts are unavailable due to US holiday - I will circle back to you next week.

    Is the code snippet you posted generated from SysConfig? Or unique to your application?

    There is a Bus Monitoring Mode on CAN which maybe needs to be enabled for this but I haven't been able to confirm if these two are related.

    Best Regards,

    Ralph Jacobi

  • Hello,
    It is generated from tresos, TI AUTOSAR MCAL.

  • Hello Abdelrhman,

    I have looped in an MCAL expert who can better assist with configuration for Tresos.

    Best Regards,

    Ralph Jacobi

  • Hello Ralph,

    I don't have any issue with Tresos, the problem is with the MCAL as I mentioned.
    Bus off ISR is never executed.

    Yours,
    Abdelrhman Afifi

  • Hello Abdelrhman,

    I am able to enable mcan1_psr_bus_off bit using attached code.

        uint32             testPassed = E_OK;
        Std_ReturnType     status;
        Can_ConfigType    *ConfigPtr;
        const Can_PduType *PduInfo;
    
        PduInfo         = &Pdu;
        canTestInitPdu(testPrms->testCaseId);
    
        ConfigPtr = &testObj->canConfig;
    
        gCanTestResult = E_OK;
        /* Do Can Init */
        Can_Init(ConfigPtr);
    
        if (gCanTestResult == E_OK)
        {
            canTestInterruptEnable();
            /* Initialize Tx and Rx Confirmation Count to 0 */
            CanIf_TxConfirmationCount = 0U;
            CanIf_RxConfirmationCount = 0U;
    
    
            if (Can_SetBaudrate(gCanControllerId, 1U))
            {
                GT_0trace(testObj->traceMask, GT_INFO1,
                          " Error in changing BaudRate\n\r");
                testPassed = E_NOT_OK;
            }
    
            /* Set Controller Mode for controller 0U*/
            status = Can_SetControllerMode(gCanControllerId, CAN_CS_STARTED);
            
            if (status != E_OK)
                testPassed |= E_NOT_OK;
            
            if (testPassed == E_OK)
            {
                testPassed = E_NOT_OK;
                do {
                    /* Polls for CAN state */
                    status = Can_Write(testPrms->mailbox, PduInfo);
                //    Can_MainFunction_Write();
                    // AppUtils_delay(100U);
    //                Can_MainFunction_BusOff();
                    // AppUtils_delay(100U);
                } while ((MainFunc_Execution !=
                          3U) && ControllerMode1[0] == CAN_CS_STARTED);
                testPassed = E_OK;
            }
            
        }

    Please check if it works for you. 

    Thanks and Best Regards,
    Gunjan

  • Hello ,

    I am using MCAL version 9.1.0, I don't know what is that code snippet kindy guide.

    CAN is configured in interrupt mode as was shared from configuration

    Hello,
    I am configuring it to work ion interrupt, which works with tx and rx.

    Waiting for your feedback.
    Thanks

  • Hello ,

    This code is just enabling interrupts and then performing can_write.

    Can you please share your steps (of code) for enabling interrupts and checking bus_off?

    Thanks and Best Regards,
    Gunjan

  • Hello,

    I am using the TI AUTOSAR MCAL, I don't know what code you need me to share.

    I shared my generated configuration from Tresos in one of the above comments and buss off is configured in interrupt mode: BusOff  TRUE = Interrupt FALSE = Polling */

    The CAN handler works fine while reception and transmission but bus off does not occur.

    Yours,
    Abdelrhman Afifi