S32 SDK FLEXCAN Rx FIFO multiple individual custom masks

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

S32 SDK FLEXCAN Rx FIFO multiple individual custom masks

Jump to solution
2,808 Views
adria
Contributor I

Hello,

I am using FLEXCAN driver from S32 SDK and I have enabled the Rx FIFO feature with 8 Rx FIFO filters using FLEXCAN_RX_FIFO_ID_FORMAT_A as id format.

I want to set multiple (less than 8, of course) custom individual masks. Is that possible?

What I am doing for now is, after initializing the driver (FLEXCAN_DRV_Init()), i call FLEXCAN_DRV_ConfigRxFifo(), but through this function I have no option to specify a custom mask per id. What I need after this is to specify a mask per each one of the ids I added in the table I specified when I called FLEXCAN_DRV_ConfigRxFifo().

Is there a way I can do that?

I have seen the API FLEXCAN_DRV_SetRxIndividualMask(), but it needs for MB to be specified and I don't know in which MB have the ids (from the id table I specified in FLEXCAN_DRV_ConfigRxFifo()) been configured.

To summarize, what I want is to use the Rx FIFO and at the same time be able to have different filters like:

- Filter 1:

         - ID: 0x100

         - Mask: 0x740

- Filter 2:

         - ID: 0x560

         - Mask: 0x7E0

- ...

Thanks in advance!

Best regards,

Adria

Labels (1)
0 Kudos
1 Solution
2,374 Views
alexandrunan
NXP Employee
NXP Employee

You can call  FLEXCAN_DRV_SetRxIndividualMask()  as many time you want to reconfigure the ID Mask same with FLEXCAN_DRV_SetRxFifoGlobalMask(). Only be aware as any time you reconfigure the mask and filters the CAN interface is no participating to bus transactions until finish the reconfiguration.

BR,

Alexandru Nan

View solution in original post

0 Kudos
8 Replies
2,374 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

the RXFIFO table usage is described in driver's documentation

{S32SDK_PATH}/doc/html_S32K144/group__flexcan__driver.html

You can also refer to example posted on https://community.nxp.com/docs/DOC-343091 

BR, Petr

0 Kudos
2,374 Views
adria
Contributor I

Hi Petr,

I have been reading again the manual reference and also the html file you mentioned.

Regarding the html file, exactly in the part where it talks about what I am asking, it is very unclear for me. Text says as follows:

"The FLEXCAN_DRV_SetRxIndividualMask() can self determine if CAN is in normal mode and will only set acceptance ID Mask. If CAN is in Rx FIFO mode, will determine the ID format type and will set the acceptance ID Mask as corresponding Id Filter Format corresponding to individual mask number the user must ensure that the ID Element is not affected by RxFIFO Global Mask in this case the ID Filter will be set as normal configuration to allow functionality of receiving as normal MB of the remaining MBs outside of RxFIFO use."

Could you please explain in a better way the quoted paragraph?

Another confusing thing I found is in the API FLEXCAN_DRV_SetRxIndividualMask() input parameters name and definition. Specifically in parameter number 3 (uint8_t mb_idx) defined as "Index of the message buffer". This definition makes me think that I have to specify the MB where the id filter is, but there are 4 id filters per MB and each one should have its own mask, so it makes no sense. Then in the example code you attached there is a comment right before calling the API within a loop which says: "/* first 10 filter items are masked with RXIMR0-RXIMR9 */". Then this makes me think that parameter 3 from the API means id filter index instead of MB index. Maybe this confusion is because when you call the API with FIFO not enabled, then parameter 3 is actually MB index, but the fact of reusing the same API for both FIFO and normal MB reception instead of creating another API for configuring individual masking for FIFO Rx requires more information in the API documentation, otherwise it can easily lead to confusion.

Best regards,

Adria

0 Kudos
2,374 Views
alexandrunan
NXP Employee
NXP Employee

Hello Adria,

To be short regards your issue first you need to be sure you are using Rx Individual Masking to do that is to enable the driver to use individual masking by calling after driver init FLEXCAN_DRV_SetRxMaskType with type parameter FLEXCAN_RX_MASK_INDIVIDUAL.

To explain you how the FLEXCAN_DRV_SetRxIndividualMask() api is working is that based on configuration of the driver as ID filter type and number of filters used in this case some RxFIFO filters can be affected by individual mask register as RXIMR[0]-RXIMR[7] in your case configuration described above with 8 Filters ID and other by RxFIFO global mask.

This function also set the individual filters for MBs, so the driver can use a mix of Filters and individual MBs. in this case the first mb_idx corresponds to filters IDs to one to one correspondence in your config case and the rest for individual MBs.

For better understanding how this works please read the description of CTRL2 register from RM. More exactly is a Table 53-6. Rx FIFO filter: possible structures.

0 Kudos
2,374 Views
adria
Contributor I

Hello Alexandru,

OK thanks.

3 more questions:

1. Can I call FLEXCAN_DRV_ConfigRxFifo() multiple times? To modify the id filter table.

2. In my case, using the 8 filters config. If I only want to add individual mask to the first 2 ids, then (after calling FLEXCAN_DRV_SetRxMaskType(instance, FLEXCAN_RX_MASK_INDIVIDUAL)) I call FLEXCAN_DRV_SetRxIndividualMask() for id 0 and then same thing for id 1, and then I can call FLEXCAN_DRV_SetRxFifoGlobalMask() and this last one will be applied to the rest of ids (from 2 to 7), is that right?

3. After doing what I mentioned in question 2, is it possible to call FLEXCAN_DRV_SetRxIndividualMask() for id (for example) 2, or after having called FLEXCAN_DRV_SetRxFifoGlobalMask() you can't call again FLEXCAN_DRV_SetRxIndividualMask()?

Best regards,

Adria

0 Kudos
2,374 Views
alexandrunan
NXP Employee
NXP Employee

Hello Adria,

1. You can call as many times you want FLEXCAN_DRV_ConfigRxFifo but you need to provide all the filters table(reconfigured), because the function will reapply all the filters.

2. Is not possible in your configuration to have some filters affected by Individual Mask register or some other by global mask, what I suggest to do is to apply for the first 2 ids the mask you want and for rest (2-7) you need to apply the individual mask as 0xFFFFFFFF; in this case will be matched exactly the filter applied.

3. Is not possible. 

BR,

Alexandru Nan

0 Kudos
2,374 Views
adria
Contributor I

Hello Alexandru,

OK, thanks. Questions 1 and 2 perfectly understood. Regarding question 3:

Then, once I have called FLEXCAN_DRV_SetRxIndividualMask() for a specific id filter I cannot call again FLEXCAN_DRV_SetRxIndividualMask() to reconfigure the mask of the specific id filter?

Then I cannot change an individual mask which has already been configured?

Best regards,

 

Adria

 

0 Kudos
2,375 Views
alexandrunan
NXP Employee
NXP Employee

You can call  FLEXCAN_DRV_SetRxIndividualMask()  as many time you want to reconfigure the ID Mask same with FLEXCAN_DRV_SetRxFifoGlobalMask(). Only be aware as any time you reconfigure the mask and filters the CAN interface is no participating to bus transactions until finish the reconfiguration.

BR,

Alexandru Nan

0 Kudos
2,374 Views
adria
Contributor I

Thanks!

0 Kudos