MPC5674F FlexCAN Filter Code

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

MPC5674F FlexCAN Filter Code

1,503 Views
CNarendra
Contributor III

Hi,

Can i get example code for FlexCAN Filtering for MPC5674F mcu.

 

Thanks

Narendra

@lukaszadrapa, MPC5674F 

0 Kudos
Reply
3 Replies

1,436 Views
PetrS
NXP TechSupport
NXP TechSupport

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

0 Kudos
Reply

1,409 Views
CNarendra
Contributor III

Hi @PetrS,

How many Message ID's can be filtered for one CAN port ? As per reference manual it is mentioned only 8 Extended Message ID's can be filtered .

CNarendra_2-1731480890666.png

As you mentioned below we can filter Message ID's range between 0x500 - 0x57f that means we can receive 127 Msg ID's for 1 message buffer . Since we have 63 Message buffers for all ports around 8000 Msg ID's ?

CNarendra_0-1731480669807.png

Thanks

Narendra

MPC5674F 

0 Kudos
Reply

1,383 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

yes, on RXFIFO FIlter table you can have 8 filter elements. Using FORMAT A it can be 8 std or ext IDs. This can be masked similarly as regular MB. See chapter 23.4.7 Rx FIFO

This was just an example for mask acceptance setting of single MB. If e.g. mask is cleared then all std or ext. IDs will be received into single MB.

BR, Petr

0 Kudos
Reply