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.

MSPM0G3107: CANFD: Received messages does not trigger callback function

Part Number: MSPM0G3107
Other Parts Discussed in Thread: SYSCONFIG

Tool/software:

Hello

I'm porting an application to the MSPM03107 MCU and have ported the CAN driver to it.
I have verified the drivers transmit, but it doesn't trigger when I receive a message.

I verified by building the mcan_message_rx demo code from the SDK and the callback function works properly.

I can see that MCAN_IR_RF0N and MCAN_IR_RF0F changes to 1 when I transmit a message on the bus so it receives the message to the FIFO0.
But the Callback function is never called. I tried to register a callback with DL_Interrupt_registerInterrupt without success.

What are some good steps to take from here?


  • Hi, 

    Could you enable the RX FIFO new message interrupt and check if you can enter this interrupt routine correctly. And for call back, you mean send a message back when it receives a certain message right?

    Best regards,

    Cash Hao

  • Hello!

    I can confirm that I have RX FIFO new message interrupt enabled, but it doesn't enter the interrupt routine and by that I mean then callback function that's specified in ti_msp_dl_config.h called MCAN0_INST_IRQHandler 

    So no the callback is the function that handles the incoming message in this case

    Here's the init function for CANFD

    SYSCONFIG_WEAK void SYSCFG_DL_MCAN0_init(void) {
        DL_MCAN_RevisionId revid_MCAN0;
    
        DL_MCAN_enableModuleClock(MCAN0_INST);
    
        DL_MCAN_setClockConfig(MCAN0_INST, (DL_MCAN_ClockConfig *) &gMCAN0ClockConf);
    
        /* Get MCANSS Revision ID. */
        DL_MCAN_getRevisionId(MCAN0_INST, &revid_MCAN0);
    
        /* Wait for Memory initialization to be completed. */
        while(false == DL_MCAN_isMemInitDone(MCAN0_INST));
    
        /* Put MCAN in SW initialization mode. */
    
        DL_MCAN_setOpMode(MCAN0_INST, DL_MCAN_OPERATION_MODE_SW_INIT);
    
        /* Wait till MCAN is not initialized. */
        while (DL_MCAN_OPERATION_MODE_SW_INIT != DL_MCAN_getOpMode(MCAN0_INST));
    
        /* Initialize MCAN module. */
        DL_MCAN_init(MCAN0_INST, (DL_MCAN_InitParams *) &gMCAN0InitParams);
    
        /* Configure MCAN module. */
        DL_MCAN_config(MCAN0_INST, (DL_MCAN_ConfigParams*) &gMCAN0ConfigParams);
    
        /* Configure Bit timings. */
        DL_MCAN_setBitTime(MCAN0_INST, (DL_MCAN_BitTimingParams*) &gMCAN0BitTimes);
    
        /* Configure Message RAM Sections */
        DL_MCAN_msgRAMConfig(MCAN0_INST, (DL_MCAN_MsgRAMConfigParams*) &gMCAN0MsgRAMConfigParams);
    
    
    
        /* Set Extended ID Mask. */
        DL_MCAN_setExtIDAndMask(MCAN0_INST, MCAN0_INST_MCAN_EXT_ID_AND_MASK );
    
        /* Loopback mode */
    
        /* Take MCAN out of the SW initialization mode */
        DL_MCAN_setOpMode(MCAN0_INST, DL_MCAN_OPERATION_MODE_NORMAL);
    
        while (DL_MCAN_OPERATION_MODE_NORMAL != DL_MCAN_getOpMode(MCAN0_INST));
    
        /* Enable MCAN mopdule Interrupts */
        DL_MCAN_enableIntr(MCAN0_INST, MCAN0_INST_MCAN_INTERRUPTS, 1U);
    
        DL_MCAN_selectIntrLine(MCAN0_INST, DL_MCAN_INTERRUPT_BO|DL_MCAN_INTERRUPT_RF0N|DL_MCAN_INTERRUPT_RF1N|DL_MCAN_INTERRUPT_TFE, DL_MCAN_INTR_LINE_NUM_0);
        DL_MCAN_enableIntrLine(MCAN0_INST, DL_MCAN_INTR_LINE_NUM_0, 1U);
        DL_MCAN_selectIntrLine(MCAN0_INST, DL_MCAN_INTERRUPT_RF0N|DL_MCAN_INTERRUPT_RF1N, DL_MCAN_INTR_LINE_NUM_1);
        DL_MCAN_enableIntrLine(MCAN0_INST, DL_MCAN_INTR_LINE_NUM_1, 1U);
    
        /* Enable MSPM0 MCAN interrupt */
        DL_MCAN_clearInterruptStatus(MCAN0_INST,(DL_MCAN_MSP_INTERRUPT_LINE0
    		 | DL_MCAN_MSP_INTERRUPT_LINE1));
        DL_MCAN_enableInterrupt(MCAN0_INST,(DL_MCAN_MSP_INTERRUPT_LINE0
    		 | DL_MCAN_MSP_INTERRUPT_LINE1));
    
    }

  • Hi,

    I am checking your init function code. Why you are mapping the DL_MCAN_INTERRUPT_RF0N and DL_MCAN_INTERRUPT_RF1N both on interrupt line 0 and 1 at the same time? It should only be mapped to one interrupt line here. 

    The other part of the code looks good to me. Since the demo code can work on your board without issue, what changes have you made for your applications?

    Best regards,

    Cash Hao

  • Hi

    That's weird, this is the auto generated code from Sysconfig

    I found the issue though
    I forgot to call NVIC_EnableIRQ after this and before calling DL_Interrupt_registerInterrupt, 
    it works great now!

  • Good to know you solved the issue!