hello,
I want to recevie messages using CAN0, and the stadard ID of these message include 16 fixed ID (like 0x302, 0x040, 0x375...)and other all ID between 0x400 to 0x47F.
Configue the key regesters as following:
1.CTRL2[RFFN] = 0x08;
2. set RX individual mask, CAN0->RXIMR[i] = 0xFFFFFFFFu,(which i = 0,1,2...15); CAN0->RXIMR[16] = (((uint32_t)0x780) << CAN_ID_STD_SHIFT) & CAN_ID_STD_MASK;
3.and then set the id_filter_table = {0x302, 0x040, 0x375,...0x400};
4.call the library function FLEXCAN_SetRxFifoFilter(CAN0, FLEXCAN_RX_FIFO_ID_FORMAT_A, &id_filter_table);
The result were strange :
MCU could receive ID:0x400, 0x401, but could not receive 0x402, 0x403.... the configution is fault?
How could configue the MCU regesters to receive the message ID between 0x400 to 0x47F?
Hello,
In order to achieve your requirements you could use classical message buffers (MBs) or the Rx FIFO.
For the classical MBs, you can set a fixed ID using FLEXCAN_DRV_ConfigRxMb function, which means that the respective MB will only receive frames that match the configured ID. There is also an option to mask the configured ID, which allows frames with IDs that respect a pattern to be received in the same MB. This mask can be global (it applies to all configured MBs) or individual (it only applies to a single MB).
- FLEXCAN_DRV_SetRxMaskType - chooses between individual and global masks
- FLEXCAN_DRV_SetRxMbGlobalMask - sets the global mask (except for MB14 and MB15)
- FLEXCAN_DRV_SetRxIndividualMask - sets the individual mask
- FLEXCAN_DRV_SetRxMb14Mask / FLEXCAN_DRV_SetRxMb15Mask - sets the mask for MB14 / MB15
The RxFIFO uses ID filter tables as acceptance criteria for the incoming frames. These filters have 4 formats:
- format A: one full ID (standard or extended) per ID Filter Table element
- format B: two full standard IDs or two partial 14-bit (standard or extended) IDs per ID Filter Table element
- format C: four partial 8-bit Standard IDs per ID Filter Table element
- format D: all frames rejected
Individual masks can be set for a number of N elements from the ID filter table using FLEXCAN_DRV_SetRxIndividualMask. For all the others, only a global mask can be set using FLEXCAN_DRV_SetRxFifoGlobalMask. N = the total number of MBs available for the respective CAN instance.
There is a known bug for the format B and C which results in a wrong matching between the configured ID and the incoming ID. It will be fixed in the next SDK release.
Please let me know if you need more information.
Best regards,
Ana
Dear Ana,
do you have a demo code for s32k144 flexcan using id filter? Thanks.
Ana:
Thank you for you advice!
Now, I want to use RX FiFo to meet the requirement that only received the incoming frame thoses ID are the fixed ID (0x302,0x040,0x375...) and the all ID which rang from 0x400 to 0x47F.
Setting individual masks only could achieve my requirements?
Here is my idea. (change some codes in function FLEXCAN_DRV_Init ( ) as follows)
1.set individual masks CAN0->RXIMR[i] = 0xFFFFFFFFu (which i = 0,1,2..15), checking all bits to receive 16 fixed ID frame.
2.set individual masks FLEXCAN_DRV_SetRxIndividualMask(CAN0, FLEXCAN_MSG_ID_STD,16, 0x780), checking some bits to receive all ID between 0x400 to 0x47F frame
3.set the CAN0->RAMn[ ], call the library function FLEXCAN_SetRxFifoFilter(INST_CAN0COM, FLEXCAN_RX_FIFO_ID_FORMAT_A, &id_filter_table); and the id_filter_table pointing to {0x302, 0x040, 0x375,...0x400};
Unfortunately, MCU could only receive some frames thoses ID are 16 fixed ID and ID:0x400, other ID (such as 0x401, 0x402...) frame could not be receive! The requirement is not achieved.
I don't know what's wrong, please point out the details.
Best regards,
shingo