Hi,
For the simple FlexCAN demo you can refer to the AN2865 (chapter 25, https://www.nxp.com/docs/en/application-note/AN2865.pdf) and associated SW package.
Regarding the RX process and filtering…
There are following rules for message filtering for different FlexCAN module configuration:
a) When MCR[FEN]=0, no RX FIFO
MCR[MBFEN]=0: MB0-MB63 use RXGMASK except MB14 uses RX14MASK and MB15 used RX15MASK
MCR[MBFEN]=1: MB0-MB63 use RXIMR0-RXIMR63
b) When MCR[FEN]=1, RX FIFO used
MCR[MBFEN]=0: ID0-ID5 use RXGMASK, ID6 uses RX14MASK, ID7 uses RX15MASK
MB8-MB63 use RXGMASK except MB14 uses RX14MASK and MB15 used RX15MASK
MCR[MBFEN]=1: ID0-ID7 uses RXIMR0-RXIMR7, MB8-MB63 use RXIMR8-RXIMR63
There is bit2bit correspondence between received ID, mask and programmed MB ID. The mask says if corresponding incoming ID bit is compared with programmed ID bit.
If mask bit is cleared the incoming ID bit is not compared, it is don’t care. If mask bit is set, then there must be exact match between incoming ID bit and programmed ID bit. To receive a message into a MB all bits with mask bit set must be equal to programmed one.
Note the standard ID is left shifted in the MB ID field and just those 11 ID bits are compared. The mask must be also shifted in the Mask register.
So assume MCR[MBFEN]=1, you want to receive range of standard IDs of 500-57F into MB61, then set
MB[61].ID.R = 0x500 << 18;
MB[61].CS.B.IDE = 0
RXIMR[61].R = 0x780<<18; // lower 7 bits of standard ID is don’t care
If for the same the extended ID range 0x500-0x57F should only be received, then set
MB[61].ID.R = 0x500;
MB[61].CS.B.IDE = 1
RXIMR[61].R = 0x1FFFFF80 // lower 7 bits are don’t care
BR, Petr