FlexCAN filter of type "Range" in iMX8 CM7

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FlexCAN filter of type "Range" in iMX8 CM7

424 Views
Lornix
Contributor I

Hello,

I am working on the CM7 part of a iMX8 processor and i am trying to create a FDCAN library

In my old project, made on a STM32H7, there were two type of can filters: MASK and RANGE

I am using FLEXCAN drivers from the folder SDK_2_13_0_MIMX8ML8xxxLZ\devices\MIMX8ML8\drivers of the SDK generated by the NXP SDK builder

So my question: How to create a CAN filter of type RANGE, a filter that accepts CAN id arbiters from a value to another, excluding all others from reception?

Thank you

 

0 Kudos
3 Replies

398 Views
Lornix
Contributor I

Hi Dhruvit, so the simple answer is:

No, there isn't a way to do a CAN filter of type RANGE using only CAN peripheral, i have to make a filter of type MASK and then correct any unwanted messages filtering them by Firmware

Thanks & Regards,

Lorenzo

0 Kudos

376 Views
Dhruvit
NXP TechSupport
NXP TechSupport

Hi @Lornix,

If one wants to create a CAN filter type of RANGE then one should use the global mask to create a CAN filter type of RANGE FLEXCAN_SetRxMbGlobalMask, which is used to receive a range of Tx_ids. FLEXCAN_SetRxIndividualMask will filter the rx_MBs.

for more details please refer to the link I have shared.

https://mcuxpresso.nxp.com/api_doc/dev/1523/a00024.html#ga40ec3ab55bd92277d4fa0a5f994313c6
https://mcuxpresso.nxp.com/api_doc/dev/1523/a00024.html


Thanks & Regards,
Dhruvit Vasavada

0 Kudos

402 Views
Dhruvit
NXP TechSupport
NXP TechSupport

Hi @Lornix,

I hope you are doing well.

The CAN frames are filtered using an Identifier or a range of identifiers. So one can set an individual mask or else a global mask to filter out the message that one wants to have at the receiver end.for that one has to follow the below sequence for filtering purposes.

Receive node end

*        flexcan_handle_t g_sFlexcanHandle;
*        flexcan_config_t sFlexcanConfig;
*        flexcan_fd_config_t sFDConfig;
*        FLEXCAN_GetDefaultConfig(&sFlexcanConfig, EXAMPLE_CAN_CLK_FREQ);
*        FLEXCAN_GetFDDefaultConfig(&sFDConfig);
*        FLEXCAN_FDCalculateImprovedTimingValues(&sFlexcanConfig.sTimingConfig,
*            &sFlexcanConfig.psFDConfig->sTimingConfig, sFlexcanConfig.u32BaudRateBps,
*            sFlexcanConfig.psFDConfig->u32BaudRateBps, sFlexcanConfig.u32ClkFreqHz);
*        sFlexcanConfig.psFDConfig = &sFDConfig;
*        // Module initialization
*        FLEXCAN_Init(CAN, &sFlexcanConfig);
*        // Set up send transfer configuration
*        flexcan_mb_transfer_t g_sTxXfer;
*        flexcan_frame_t g_sFrame;
*        // Create FlexCAN handle structure and set call back function.
*        FLEXCAN_TransferCreateHandle(CAN, &g_sFlexcanHandle, flexcan_callback, NULL);
*        // Set Rx Masking mechanism.
*        FLEXCAN_SetRxMbGlobalMask(CAN, FLEXCAN_RX_MB_STD_MASK(g_u32RxIdentifier, 0, 0));
*        // Setup Rx Message Buffer.
*        sRxMbConfig.eFormat = kFLEXCAN_FrameFormatStandard;
*        sRxMbConfig.eType   = kFLEXCAN_FrameTypeData;
*        sRxMbConfig.u32Id   = FLEXCAN_ID_STD(g_u32RxIdentifier);
*        // Clean Rx Message Buffer.
*        FLEXCAN_SetFDRxMbConfig(CAN, RX_MESSAGE_BUFFER_NUM, &sRxMbConfig, true);
*        g_sTxXfer.u8MsgBufIdx = (uint8_t)RX_MESSAGE_BUFFER_NUM;
*        g_sTxXfer.psFrameFD = &g_sFrame;
*        // Receive node interrupt transfer
*        FLEXCAN_TransferFDSendNonBlocking(&g_sFlexcanHandle, &g_sTxXfer);

for more details please refer to the link I have shared.

https://mcuxpresso.nxp.com/api_doc/dev/1523/a00024.html#ga40ec3ab55bd92277d4fa0a5f994313c6
https://mcuxpresso.nxp.com/api_doc/dev/1523/a00024.html

Thanks & Regards,
Dhruvit Vasavada

0 Kudos