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.

TDA4VM: How to use MCU_MCAN0 and MCU_MCAN1 in MCU1_0? stuck at transmission

Part Number: TDA4VM


Hi TI Professor,

I have put mcan_test program runs in MCU1_0 as I metioned in https://e2e.ti.com/support/processors/f/791/t/969305.

Now I call canTest() in appRun() in vision_apps\apps\basic_demos\app_tirtos\common\app_run.c.

I disabled the MCU_ MCAN0 and MCU_ MCAN1 in k3-j721e-common-proc- board.dts:

&mcu_mcan0 {
status = "disabled";
pinctrl-names = "default";
pinctrl-0 = <&mcu_mcan0_pins_default &mcu_mcan0_gpio_pins_default>;
stb-gpios = <&wkup_gpio0 54 GPIO_ACTIVE_HIGH>;
en-gpios = <&wkup_gpio0 0 GPIO_ACTIVE_HIGH>;
can-transceiver {
max-bitrate = <5000000>;
};
};

&mcu_mcan1 {
status = "disabled";
pinctrl-names = "default";
pinctrl-0 = <&mcu_mcan1_pins_default &mcu_mcan1_gpio_pins_default>;
stb-gpios = <&wkup_gpio0 2 GPIO_ACTIVE_LOW>;
can-transceiver {
max-bitrate = <5000000>;
};
};

At present, the mcan can be configured normally, and the can transceiver can be enabled normally, but the transmission cannot be completed after adding the transmission request, the MCAN_TXBRP register is  always 0x2 and unable to reset. The program stucks here

/* Waiting for Transmission Complete */
while (((MCAN_getTxBufReqPend(baseAddr) >>
         APP_MCAN_TX_BUF_NUM) &
        0x1) == 0x1)

How to solve this?

  • Hi JJXie,

    The value of MCAN_TXBRP will show which MCAN Tx buffer has a message request pending. 0x2 means that the BUFFER number 1 (as bit position 1 is set) has a pending message to be sent out. 

    Jiajiang.Xie said:
    At present, the mcan can be configured normally, and the can transceiver can be enabled normally, but the transmission cannot be completed after adding the transmission request, the MCAN_TXBRP register is  always 0x2 and unable to reset. The program stucks here

    MCAN_TXBRP is set as soon as you add request for transmission (By writing to MCAN_TXBAR) and the value of the MCAN_TXBRP is reset upon either a successful transmission (and setting MCAN_TXBTO) or if the transmission is cancelled (setting the MCAN_TXBCF). You can not probably reset it manually.

    Can you check the value of the MCAN_PSR register to see if there are any errors?

    Also, are you not using interrupts? As the while() loop as pointed by you is a part of the else case of MCAN_DIAG_INTR_ENABLE.

    Regards,

    Karan

  • Hi Karan,

    Now I'm using another example from pdk_jacinto_07_01_00_45\packages\ti\csl\example\mcan\mcanEvmLoopback\mcan_evm_loopback_app_main_k3.c.

    I did some modify and test MCAN1 transmit CAN frame to MCAN0, it works well.

    But there is something wrong with interrupt registration function App_mcanRegisterIsr().

    I call the mcan configuraion function(includes App_mcanRegisterIsr()) in appMain() in vision_apps\apps\basic_demos\app_tirtos\tirtos_linux\mcu1_0\main.c

    the code goes wrong here:

    static int32_t App_mcanRegisterIsr()
    {
        int32_t configStatus = STW_SOK;
    
        printf("Start registering MCAN interrupt ... \n");
    
        /* MCU MCAN Inst 1 */
        configStatus += App_mcanRegisterInterrupt(APP_MCU_MCAN_1_INT0, &App_mcanTxISR, (void *)(&gMcanMods[MCU_MCAN1_INDEX]));
        configStatus += App_mcanRegisterInterrupt(APP_MCU_MCAN_1_INT1, &App_mcanRxISR, (void *)(&gMcanMods[MCU_MCAN1_INDEX]));
        configStatus += App_mcanRegisterInterrupt(APP_MCU_MCAN_1_TS_INT, &App_mcanTSIntrISR, (void *)(&gMcanMods[MCU_MCAN1_INDEX]));
    
        /* MCU MCAN Inst 0 */
        configStatus += App_mcanRegisterInterrupt(APP_MCU_MCAN_0_INT0, &App_mcanTxISR, (void *)(&gMcanMods[MCU_MCAN0_INDEX]));
        configStatus += App_mcanRegisterInterrupt(APP_MCU_MCAN_0_INT1, &App_mcanRxISR, (void *)(&gMcanMods[MCU_MCAN0_INDEX]));
        configStatus += App_mcanRegisterInterrupt(APP_MCU_MCAN_0_TS_INT, &App_mcanTSIntrISR, (void *)(&gMcanMods[MCU_MCAN0_INDEX]));
    
        if (STW_SOK != configStatus)
        {
            printf("CrossBar/Interrupt Configuration failed.\n");
        }
        else
        {
            printf("CrossBar/Interrupt Configuration done.\n");
        }
    
        return configStatus;
    }
    

    Only highlight line(APP_MCU_MCAN_0_INT0) registration failed, other registration is fine.

    I use CCS to debug and find that when calling Hwi_construct() in pdk_jacinto_07_01_00_45\packages\ti\osal\src\tirtos\HwiP_tirtos.c, eb does not return 0.

    Why is this happen? How to solve this?

    Regards

  • Hi Karan,

    I'm using another example pdk_jacinto_07_01_00_45\packages\ti\csl\example\mcan\mcanEvmLoopback\mcan_evm_loopback_app_main_k3.c and did some modify.

    I test transmit CAN frames form MCAN1 to MCAN0, it works well. But there is some problems about interrupt registration function App_mcanRegisterIsr().

    I call mcan configuration function (include App_mcanRegisterIsr()) in appMain() in vision_apps\apps\basic_demos\app_tirtos\tirtos_linux\mcu1_0\main.c.

    It goes wrong here:

    static int32_t App_mcanRegisterIsr()
    {
        int32_t configStatus = STW_SOK;
    
        printf("Start registering MCAN interrupt ... \n");
    
        /* MCU MCAN Inst 1 */
        configStatus += App_mcanRegisterInterrupt(APP_MCU_MCAN_1_INT0, &App_mcanTxISR, (void *)(&gMcanMods[MCU_MCAN1_INDEX]));
        configStatus += App_mcanRegisterInterrupt(APP_MCU_MCAN_1_INT1, &App_mcanRxISR, (void *)(&gMcanMods[MCU_MCAN1_INDEX]));
        configStatus += App_mcanRegisterInterrupt(APP_MCU_MCAN_1_TS_INT, &App_mcanTSIntrISR, (void *)(&gMcanMods[MCU_MCAN1_INDEX]));
    
        /* MCU MCAN Inst 0 */
        configStatus += App_mcanRegisterInterrupt(APP_MCU_MCAN_0_INT0, &App_mcanTxISR, (void *)(&gMcanMods[MCU_MCAN0_INDEX]));
        configStatus += App_mcanRegisterInterrupt(APP_MCU_MCAN_0_INT1, &App_mcanRxISR, (void *)(&gMcanMods[MCU_MCAN0_INDEX]));
        configStatus += App_mcanRegisterInterrupt(APP_MCU_MCAN_0_TS_INT, &App_mcanTSIntrISR, (void *)(&gMcanMods[MCU_MCAN0_INDEX]));
    
        if (STW_SOK != configStatus)
        {
            printf("CrossBar/Interrupt Configuration failed.\n");
        }
        else
        {
            printf("CrossBar/Interrupt Configuration done.\n");
        }
    
        return configStatus;
    }
    

    Only the highlight line registration (APP_MCU_MCAN_0_INT0) failed, other registration is fine.

    I use CCS to debug and find that when it calling Hwi_construct() in pdk_jacinto_07_01_00_45\packages\ti\osal\src\tirtos\HwiP_tirtos.c, the eb does not return 0.

    Why is this? How to solve this problem?

    Regards

  • Hi,

    Apologies for no response here.

    1. The interrupt registration for MCU MCAN0 shouldn't fail. Can you please check the values of the interrupt number? Are these 0 and 1 for ISR0 and ISR1?

    2. Can you also please provide the patch on top of SDK7.1 which you are using so that I can replicate this on my setup?

    3. Did you follow the developer note - https://software-dl.ti.com/jacinto7/esd/processor-sdk-rtos-jacinto7/latest/exports/docs/psdk_rtos/docs/user_guide/developer_notes_mcu1_0_sysfw.html to create the bootloader images based on you MCU1_0 application?

    Regards,

    Karan