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.

AWR6843: MCAN AWR6843 Recieve is not happening If I send from PCAN View software :

Part Number: AWR6843

Hi Team of TI,

MCAN Interrupt recieve mode is not working even If I manually send a 64 byte frame from PCAN View software...

Even sometimes interrupt is not triggering and That is somehow resolved with Hardcode method... can you please give comments on the same to resolve the MCAN Receive mode issue.

  • Hey Ramesh,

    Thanks for reaching out regarding this issue. First of all, what code are you working with? Is this an application based on TI's CAN demo or an application made from scratch? In either case, I would recommend following the application note linked below on how to properly implement CAN to an SDK 3 project. There are a few lines of code and additional steps that you should follow which I've listed below:

    • Change CANFD_Init to include an instance
      • Either 0 or 1 may be used
    • Change pinmux macros in Can_Initialize to match the device being integrated into
      • Should be SOC_XWR68XX_ macros
    • If using an EVM, flip board switches to select CAN bus
      • This can be found in the schematic for each board; for AWR6843AOP, S2.1 should be set to ON

    If you would like to understand how interrupts should be enabled for the CAN module, I would recommend stepping through the Can_Initializeand CANFD_Init functions. The interrupts are configured by the errInterruptEnable, dataInterruptEnable, appErrCallBack, and appDataCallBack fields of the mcanCfgParams struct in the Can_Initialize function which gets interpreted by the CANFD_Init function to create the interrupt handler and enables the interrupt line for CAN.

    Another feature you should be careful of is message filtering? Message filtering can be complex and relies upon many different registers. For the application note below, the global filter configuration (GFC) register - set as the filterConfig field in the mcanCfgParams struct - is set to reject all standard and extended remote frames and accept all standard and extended non-matching frames to Rx FIFO 1 - i.e., ignore/don't filter received messages.

    Hopefully, this has given you some ideas as for how to solve or debug this issue. If you haven't seen it already, I have also shared a link to the Bosch MCAN User Guide which helps understand how CAN works in general. Let me know if you are confused by any of the information shared above and have any additional questions.

    Regards,

    Kristien

    CAN integration application note: https://www.ti.com/lit/an/spracf7/spracf7.pdf

    Bosch MCAN User Guide: https://www.bosch-semiconductors.com/media/ip_modules/pdf_2/m_can/mcan_users_manual_v331.pdf

  • Hi Kristien, I am developing Driver level support to MCU CANFD, and I am seeing that CAN Recieve mode is not happening with interrpt mode.. Thanks

  • Hey Ramesh,

    Could you elaborate more on what you've implemented so far? Have you looked over the material I sent over and compared it to your own CAN implementation? You may also post snippets of your code such as your initialization function for CAN or your ISR for CAN. This will help me better understand what you are initializing so that I can provide more direct feedback regarding your application.

    Regards,

    Kristien

  • Thanks for the Reply, 

    Yes, I am analyzing the docs sent by you and meanwhile this so far I have added CAN Initialization, transmission with interrupt method is working and Reception with polling method is working, and am seeing that Reception with interrupt method is not working... I am always seeing that  if (bitPos == (newDataStatus.statusLow & bitPos)) condition is not satisfying and it is not reading from RAM... I am sending a 64 Byte Extended BRS enabled frame from the PCAN View software.

    Thanks and Regards,

    Ramesh Janagi
    
    
    /* Standard Id configured in TX application.
     * This macro defined to compare with the received message id in this application */
    #define APP_MCAN_STD_ID                          (0xC0U)
    #define APP_MCAN_STD_ID_MASK                     (0x7FFU)
    #define APP_MCAN_STD_ID_SHIFT                    (18U)
    #define APP_MCAN_EXT_ID_MASK                     (0x1FFFFFFFU)
    
    
    /* Static Function Declarations */
    static void    App_mcanIntrISR(void *arg);
    
    
    void can_test(void *args)
    {    
        int32_t                 status = SystemP_SUCCESS;
        HwiP_Params             hwiPrms;
        MCAN_RxBufElement       rxMsg;
        MCAN_ErrCntStatus       errCounter;
    
        uint32_t                i, bufNum, fifoNum, bitPos = 0U;
        MCAN_RxNewDataStatus    newDataStatus;
    
        DebugP_log("[MCAN] RX Application, Interrupt mode started ...\r\n");
    
        /* Enable Interrupts */
        App_mcanEnableIntr();
    
        /* Transmit And Receive Message */
        for (i = 0U; i < APP_MCAN_MSG_LOOP_COUNT; i++)
        {
            /* Wait for Rx completion */
            SemaphoreP_pend(&gMcanRxDoneSem, SystemP_WAIT_FOREVER);
    
            /* ClockP_sleep(1); */
    
            /* Checking for Rx Errors */
            MCAN_getErrCounters(gMcanRxBaseAddr, &errCounter);
            DebugP_assert((0U == errCounter.recErrCnt) &&
                          (0U == errCounter.canErrLogCnt));
    
            /* Get the new data staus, indicates buffer num which received message */
            MCAN_getNewDataStatus(gMcanRxBaseAddr, &newDataStatus);
            MCAN_clearNewDataStatus(gMcanRxBaseAddr, &newDataStatus);
    
            /* Select buffer and fifo number, Buffer is used in this app */
            bufNum = 0U;
            fifoNum = MCAN_RX_FIFO_NUM_0;
            
            bitPos = (1U << bufNum);
    
            if (bitPos == (newDataStatus.statusLow & bitPos))
            {
                MCAN_readMsgRam(gMcanRxBaseAddr, MCAN_MEM_TYPE_BUF, bufNum, fifoNum, &rxMsg);
                /* MCAN_readMsgRam(gMcanRxBaseAddr, MCAN_MEM_TYPE_FIFO, bufNum, (uint32_t)fifoNum, &rxMsg); */
            }
            else
            {
                DebugP_assert(FALSE);
            }
    
            /* Compare Tx/Rx data */
            App_mcanCompareMsg(&rxMsg);
        }
    }
    
    static void App_mcanInitStdFilterElemParams(MCAN_StdMsgIDFilterElement *stdFiltElem,
                                                uint32_t bufNum)
    {
        /* sfid1 defines the ID of the standard message to be stored. */
        stdFiltElem->sfid1 = APP_MCAN_STD_ID;
        /* As buffer mode is selected, sfid2 should be bufNum[0 - 63] */
        stdFiltElem->sfid2 = bufNum;
        /* Store message in buffer */
        stdFiltElem->sfec  = MCAN_STD_FILT_ELEM_BUFFER;
        /* Below configuration is ignored if message is stored in buffer */
        stdFiltElem->sft   = MCAN_STD_FILT_TYPE_RANGE;
    
        return;
    }
    
    static void App_mcanEnableIntr(void)
    {
        MCAN_enableIntr(gMcanRxBaseAddr, MCAN_INTR_MASK_ALL, (uint32_t)TRUE);
        MCAN_enableIntr(gMcanRxBaseAddr,
                        MCAN_INTR_SRC_RES_ADDR_ACCESS, (uint32_t)FALSE);
        /* Select Interrupt Line 0 */
        MCAN_selectIntrLine(gMcanRxBaseAddr, MCAN_INTR_MASK_ALL, MCAN_INTR_LINE_NUM_0);
        /* Enable Interrupt Line */
        MCAN_enableIntrLine(gMcanRxBaseAddr, MCAN_INTR_LINE_NUM_0, (uint32_t)TRUE);
    
        /* Take MCAN out of the SW initialization mode */
        MCAN_setOpMode(gMcanRxBaseAddr, MCAN_OPERATION_MODE_NORMAL);
        while (MCAN_OPERATION_MODE_NORMAL != MCAN_getOpMode(gMcanRxBaseAddr))
        {}
    
        /* Manually Enabling MCAN_CFG Rx related registers */
        SET_MCAN_CFG_RxReg();
    
        return;
    }
    
    static void App_mcanInitMsgRamConfigParams(MCAN_MsgRAMConfigParams
                                               *msgRAMConfigParams)
    {
        int32_t status;
    
        MCAN_initMsgRamConfigParams(msgRAMConfigParams);
    
        /* Configure the user required msg ram params */
        msgRAMConfigParams->lss = 127U;
        msgRAMConfigParams->lse = 64U;
        msgRAMConfigParams->txBufCnt = 32U;
        msgRAMConfigParams->txFIFOCnt = 0U;
        /* Buffer/FIFO mode is selected */
        msgRAMConfigParams->txBufMode = 0;
        msgRAMConfigParams->txEventFIFOCnt = 0U;
        msgRAMConfigParams->rxFIFO0Cnt = 64U;
        msgRAMConfigParams->rxFIFO1Cnt = 64U;
        /* FIFO blocking mode is selected */
        msgRAMConfigParams->rxFIFO0OpMode = 0U;
        msgRAMConfigParams->rxFIFO1OpMode = 0U;
        msgRAMConfigParams->rxFIFO0WaterMark = 0U;
        msgRAMConfigParams->rxFIFO1WaterMark = 0U;
    
        status = MCAN_calcMsgRamParamsStartAddr(msgRAMConfigParams);
        DebugP_assert(status == CSL_PASS);
    
        return;
    }
    
    
    static void App_mcanIntrISR(void *arg)
    {
        uint32_t intrStatus;
    
        intrStatus = MCAN_getIntrStatus(gMcanRxBaseAddr);
        MCAN_clearIntrStatus(gMcanRxBaseAddr, intrStatus);
    
        /* If FIFO0/FIFO1 is used, then MCAN_INTR_SRC_DEDICATED_RX_BUFF_MSG macro
         * needs to be replaced by MCAN_INTR_SRC_RX_FIFO0_NEW_MSG/
         * MCAN_INTR_SRC_RX_FIFO1_NEW_MSG respectively */
    
        if (MCAN_INTR_SRC_DEDICATED_RX_BUFF_MSG ==
            (intrStatus & MCAN_INTR_SRC_DEDICATED_RX_BUFF_MSG))
        {
            SemaphoreP_post(&gMcanRxDoneSem);
        }
    
        if (MCAN_INTR_SRC_TRANS_COMPLETE ==
            (intrStatus & MCAN_INTR_SRC_TRANS_COMPLETE))
        {
            SemaphoreP_post(&gMcanTxDoneSem);
        }
    
        if (MCAN_INTR_SRC_RX_FIFO0_NEW_MSG ==
                (intrStatus & MCAN_INTR_SRC_RX_FIFO0_NEW_MSG))
        {
            SemaphoreP_post(&gMcanRxDoneSem);
        }
    
        if (MCAN_INTR_SRC_RX_FIFO1_NEW_MSG ==
                (intrStatus & MCAN_INTR_SRC_RX_FIFO1_NEW_MSG))
        {
            SemaphoreP_post(&gMcanRxDoneSem);
        }
    
        return;
    }
    
    
  • Hey Ramesh,

    I haven't had the best chance to look over your code today, but I'll take a deeper look as soon as I can. Just to clarify, the ISR is being called and posting the semaphore successfully, correct? Have you verified that frames are being received by the FIFO or the buffers? The CANFD_MCANInt0Isr in the canfd.c file for the CAN driver shows how to process receive buffer interrupts and receive FIFO interrupts. I'll try to get back to you as soon as I can once I have the chance to review your code.

    Regards,

    Kristien