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.

TDA4AH-Q1: How to configure MCAN to interrupt transmission and reception mode in MCU 1_0?

Part Number: TDA4AH-Q1

Tool/software:

Hi, experts

My SDK version:

        linux:  ti-processor-sdk-linux-adas-j784s4-evm-09_01_00_06 

        rtos:  ti-processor-sdk-rtos-j784s4-evm-09_01_00_06

How to configure MCAN to interrupt transmission and reception mode in MCU 1_0?

Can you provide an example code for reference.

  • Hello,

    We have PDK Based example in RTOS 

    ti-processor-sdk-rtos-j721e-evm-09_02_00_05/pdk_jacinto_09_02_00_30/packages/ti/csl/example/mcan/mcanEvmLoopback/mcan_evm_loopback_app_main_k3.c

    and in MCUSW ti-processor-sdk-rtos-j721e-evm-09_02_00_05/mcusw/mcal_drv/mcal/examples/Can/CanApp.c

    Linux SDK  you can go through the document https://software-dl.ti.com/processor-sdk-linux/esd/docs/06_03_00_106/linux/Foundational_Components/Kernel/Kernel_Drivers/MCAN.html

    Regards

    Tarun Mukesh

  • Hello,

    I use demo is ti-processor-sdk-rtos-j721e-evm-09_02_00_05/pdk_jacinto_09_02_00_30/packages/ti/csl/example/mcan/mcanEvmLoopback/mcan_evm_loopback_app_main_k3.c.

    At present, MCU_MCAN0 is called in MCU2_1 core. After the interrupt is enabled, the interrupt does not take effect. The code is modified as follows:

    static void App_mcanIntr0ISR(uintptr_t arg)
    {
        uint32_t intrStatus;
        gMcanModAddr = gMcanDiagPortInfo[0].mcanBaseAddr;
        intrStatus = MCAN_getIntrStatus(gMcanModAddr);
        MCAN_clearIntrStatus(gMcanModAddr, intrStatus);
        printf("App_mcanIntr0ISR ===%x.\n",intrStatus);
        tx_counter++;
        if (MCAN_INTR_SRC_TRANS_COMPLETE ==
            (intrStatus & MCAN_INTR_SRC_TRANS_COMPLETE))
        {
            gMcanIsrIntr0Flag = 0U;
            printf("App_mcanIntr0ISR 0000000000.\n");
        }
    
        if (MCAN_INTR_SRC_DEDICATED_RX_BUFF_MSG ==
            (intrStatus & MCAN_INTR_SRC_DEDICATED_RX_BUFF_MSG))
        {
            gMcanIsrIntr1Flag = 0U;
            printf("App_mcanIntr0ISR 111111111111.\n");
        }
    
    }
    
    
    static void App_mcanIntr1ISR(uintptr_t arg)
    {
        uint32_t intrStatus;
        gMcanModAddr = gMcanDiagPortInfo[0].mcanBaseAddr;
        intrStatus = MCAN_getIntrStatus(gMcanModAddr);
        MCAN_clearIntrStatus(gMcanModAddr, intrStatus);
        printf("App_mcanIntr1ISR ===%x.\n",intrStatus);
        rx_conuter++;
        if (MCAN_INTR_SRC_DEDICATED_RX_BUFF_MSG ==
            (intrStatus & MCAN_INTR_SRC_DEDICATED_RX_BUFF_MSG))
        {
            gMcanIsrIntr1Flag = 0U;
            printf("App_mcanIntr1ISR 0.\n");
        }
    
    }
    
    static void App_mcanTSIntrISR(uintptr_t arg)
    {
        printf("Time Stamp overflow happened.\n");
    }
    
    static int32_t App_mcanRegisterIsr(void)
    {
        int32_t configStatus = STW_SOK;
        /* MCU MCAN Inst 0 */
        configStatus =  App_mcanRegisterInterrupt(APP_MCU_MCAN_0_INT0, &App_mcanIntr0ISR);
        configStatus += App_mcanRegisterInterrupt(APP_MCU_MCAN_0_INT1, &App_mcanIntr1ISR);
        configStatus += App_mcanRegisterInterrupt(APP_MCU_MCAN_0_TS_INT, &App_mcanTSIntrISR);
    }
    
    static void BoardDiag_mcanRxIntEnable(uint32_t baseAddr)
    {
        /* Enable Interrupts */
        MCAN_enableIntr(baseAddr, MCAN_INTR_MASK_ALL, (uint32_t)TRUE);
        MCAN_enableIntr(baseAddr,
                        MCAN_INTR_SRC_RES_ADDR_ACCESS, (uint32_t)FALSE);
        /* Select Interrupt Line */
        MCAN_selectIntrLine(baseAddr,
                            MCAN_INTR_MASK_ALL,
                            MCAN_INTR_LINE_NUM_1);
        /* Enable Interrupt Line */
        MCAN_enableIntrLine(baseAddr,
                            MCAN_INTR_LINE_NUM_1,
                            1U);
    }
    
    /**
     * \brief   This API will enables the TX interrupts
     *
     * \param   baseAddr  [IN]  MCAN base address
     *
     */
    static int32_t BoardDiag_mcanTxIntEnable(uint32_t baseAddr)
    {
        int32_t  status = 0;
        MCAN_enableIntr(baseAddr, MCAN_INTR_MASK_ALL, (uint32_t)TRUE);
        MCAN_enableIntr(baseAddr,
                        MCAN_INTR_SRC_RES_ADDR_ACCESS, (uint32_t)FALSE);
        /* Select Interrupt Line */
        MCAN_selectIntrLine(baseAddr,
                            MCAN_INTR_MASK_ALL,
                            MCAN_INTR_LINE_NUM_0);
        /* Enable Interrupt Line */
        MCAN_enableIntrLine(baseAddr,
                            MCAN_INTR_LINE_NUM_0,
                            1U);
        /* Enable Transmission interrupt */
        status = MCAN_txBufTransIntrEnable(baseAddr,
                                           1U,
                                           (uint32_t)TRUE);
        return status;
    }
    
    
    init code :
                    /* Set base address */
                uint32_t baseAddr = gMcanDiagPortInfo[portNum].mcanBaseAddr;
                
                Intc_Init();    
                /* Interrupt handler initialized, here as other functions can use API's to clear pending interrupts if any*/
    
                App_mcanRegisterIsr();
    
                BoardDiag_mcanTxIntEnable(baseAddr);
    
                BoardDiag_mcanRxIntEnable(baseAddr);
                
    
    
    

    After completing the initialization mentioned above, a message was sent to MCU_MCAN0 externally, but the RX interrupt function of MCU_MCAN0 did not enter.

    Question:

    Is it possible to use MCU_SCAN0 interrupts in the MCU2_1 core? I see in the demo code that using MCU_MCAN0 is with BUILD_MCU1_0 enabled.

  • Hello,

    Question:

    Is it possible to use MCU_SCAN0 interrupts in the MCU2_1 core? I see in the demo code that using MCU_MCAN0 is with BUILD_MCU1_0 enabled.

    You can see as below in the starting of example , MCU2_1 core uses MCAN4 in this example.

    * Test support Instances : For mcu1_0
    * 1.Transmitter test : MCU_MCAN0
    * 2.Receiver test : MCU_MCAN1
    * 3.Internal loopback: MCU_MCAN0
    * 4.External loopback: MCU_MCAN0,MCU_MCAN1
    * For mcu2_1
    * 1.Transmitter test : MAIN_MCAN4
    * 2.Receiver test : MAIN_MCAN4
    * 3.Internal loopback: MAIN_MCAN4
    * 4.External loopback: MAIN_MCAN4, MAIN_MCAN5

    You can use MCU_MCAN0 for MCU2_1 but you need to take care of changes required and do interrupt routing as well.

    Regards

    Tarun Mukesh

  • hello,

    use MCU_MCAN0 for MCU2_1,How to use interrupt routing?Please provide guidance.

  • Hello,

    Please allow me some time to elaborate.

    Regards

    Tarun Mukesh