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.

IWRL6432BOOST: MCAN Filtering to accept all the CAN ID's

Part Number: IWRL6432BOOST

Hello,

        As discussed in the previous thread regarding the filtering of CAN ID - "">e2e.ti.com/.../iwrl6432boost-sbl-via-can. i have updated the filterconfig parameters anfe and anfs = 0 as mentioned below. However i'm still unable to receive data from other CAN ID's except 192. Can you please help me resolve this issue. Thanks 

/* Initialize MCAN module Global Filter Params */
MCAN_initGlobalFilterConfigParams(&configParams);
configParams.filterConfig.anfe = 0;
configParams.filterConfig.anfs = 0;

for (i = 0U; i < APP_MCAN_STD_ID_FILTER_CNT; i++)
{

App_mcanInitStdFilterElemParams(&stdFiltElem[i], i);
}
/* wait for memory initialization to happen */
while (FALSE == MCAN_isMemInitDone(gMcanBaseAddr))
{}

/* Put MCAN in SW initialization mode */
MCAN_setOpMode(gMcanBaseAddr, MCAN_OPERATION_MODE_SW_INIT);
while (MCAN_OPERATION_MODE_SW_INIT != MCAN_getOpMode(gMcanBaseAddr))
{}

/* Initialize MCAN module */
MCAN_init(gMcanBaseAddr, &initParams);
/* Configure MCAN module Gloabal Filter */
MCAN_config(gMcanBaseAddr, &configParams);
/* Configure Bit timings */
MCAN_setBitTime(gMcanBaseAddr, &bitTimes);
/* Configure Message RAM Sections */
MCAN_msgRAMConfig(gMcanBaseAddr, &msgRAMConfigParams);
/* Set Extended ID Mask */
MCAN_setExtIDAndMask(gMcanBaseAddr, APP_MCAN_EXT_ID_MASK);

/* Configure Standard ID filter element */
for (i = 0U; i < APP_MCAN_STD_ID_FILTER_CNT; i++)
{
MCAN_addStdMsgIDFilter(gMcanBaseAddr, i, &stdFiltElem[i]);
}
if (TRUE == enableInternalLpbk)
{
MCAN_lpbkModeEnable(gMcanBaseAddr, MCAN_LPBK_MODE_INTERNAL, TRUE);
}

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;
//SBL_printf("McanInitstdFilter");
return;
}

APP_MCAN_STD_ID = 192. so i'm able to receive canid with 192. But unable to receive all the CAN iD's. I tried to disbale filter with sfec == 0U. changed anfe and anfs == 0. however it did not resolve my issue, Can you please give me more insight about how to resolve this. Thanks 

  • Hey Madhusudhan,

    As shown in the filter diagram in the E2E post linked, when accepting non-matching frames, they will always go to a FIFO. Since you have set ANFS to zero, this means the frames are going to FIFO 0. You will have to make adjustments to the MCAN ISR so that it posts the gMcanRxDoneSem when a new message is received in FIFO0 (MCAN_INTR_SRC_RX_FIFO0_NEW_MSG). After the gMcanRxDoneSem pend, you should read FIFO0 in the message RAM using MCAN_readMsgRam(gMcanBaseAddr, MCAN_MEM_TYPE_FIFO, bufNum, fifoNum, &rxMsg) where fifoNum = 0.

    Regards,

    Kristien

  • Hello Kristien, 

       Thanks for the information. Now i have changed the code to 


    if (MCAN_INTR_SRC_RX_FIFO0_NEW_MSG == (intrStatus & MCAN_INTR_SRC_RX_FIFO0_NEW_MSG))

    {

    MCAN_readMsgRam(gMcanBaseAddr, MCAN_MEM_TYPE_FIFO, bufNum, fifoNum, &rxMsg);

    }

    when i try to print the rxMsg.data[i] i'm only able to print the first packet which i had sent of 64bytes. All the examples are based on Rx buffer and not Rx FiFO and tried to read and understand from Technical reference mannual. However as it was bit confusing reached out to you again. Is there any possiblity to receive range of CAN ID's using rx Buffer instead of rx fifo. Or can you provide me more information about how to use Rx FiFo. as i send the latest packet i should be able to read it, There is some information about getidx and putidx. However i was unable to understand. Can you please provide more information about it. Thanks 

  • Hey Madhusudhan,

    As mentioned in the Bosch MCAN User Guide, when the Rx buffer is used to receive data, the Standard Filter Type (SFT) register is ignored and only a single ID can be received by a single buffer. You would have to setup multiple buffers for multiple different IDs which isn't too bad if you loop through a set of IDs you want to filter with.

    Instead, I'll describe how to use the Rx FIFO with acceptance of non-matching frames. Besides the changes previously mentioned, ensure that the FIFO0 count is non-zero. For the sake of simplicity, you could use a count of one and use the MCAN_getRxFIFOStatus to check if FIFO0 is full (1) and if so, read the message RAM for Rx FIFO0. The MCAN_readMsgRam function automatically fetches the Get Index, but you will need to call MCAN_writeRxFIFOAck afterwards with the buffer index of the last element read - should always be zero for a size 1 FIFO. This will update the Get Index and the Fill Level of the FIFO0. 

    If you want to receive both buffer data and FIFO data, add a conditional that will read the buffer when it receives new data, and if not, check the FIFO0 fill level and read its contents if it is full. Keep in mind there are other ways to approach this, so try to experiment a bit to find what works for your setup.

    Regards,

    Kristien

  • Hello Kristien, 

          Thanks for the information. However currently i have setup multiple buffers to receive different CAN ID's. I have incremented the forloop to number of CAN ID's i wanted included bufferes. For ex: 192 CANID corresponds to Buff - 1, 193 ID to Buff 2, respectively. It works for my setup and if in case if there's a demand for using FIFO in future, Will try and get back to you in case i have any questions. Thanks 

  • Hey Madhusudhan,

    Thank you for the update! As always, feel free to post a new thread should you have any more questions.

    Regards,

    Kristien