How work the "Message Buffer" and the "Message ID Mask?

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

How work the "Message Buffer" and the "Message ID Mask?

1,431 Views
fra_rio
Contributor I

Hi,

I work with the S32K144 EVB and the MBD toolbox version 4.0.0.

There is the FCAN Receive block and the options "Message Buffer" and "Message ID Mask.

Does somebody know, how the Message Buffer and the Message ID Mask work?

What is the purpose of the Message Buffer and how I have to use it?

Thanks in advance.

Frank

2 Replies

1,287 Views
constantinrazva
NXP Employee
NXP Employee

Hello fra_rio‌,

The message buffers are exactly what the name says: a buffer in which you can store messages. You have a certain number of such buffers (the ones available on the list). You can choose one in which to store that message.

As for the message ID mask, this is used for filtering a class of messages. So you can have one message buffer receive only 1 class of messages from your network. Let's get into a few details about how the matching is done:

When a CAN frame is received, all message buffers will be scanned (looking for Rx MB that have the ID equal to the received one, or equal to the received one after applying the mask). Lets look at an example:

If we only want to accept frames with ID = 0x01, we can set the ID = 0x01 and the mask to 0x1FFFFFF.

Note: the ID has length is either 11 bits (with standard message, introduce from older CAN standards - I think CAN1.2), either 29 bits (extended ID, introduced from CAN2.0).

In the example above we're using extended ID (29bits), having the mask all 1s (29 bits), thus the value 0x1FFFFFF.

So when a frame arrives, its ID must match every bit from 0x01 -- so with these settings, we're only accepting messages from 0x01.

Lets take a look at another example. Let's say we want to accept IDs from 0x10 through 0x1F. We can set the ID to 0x10, and set the mask to 0x1FFFFF0. With this mask we're basically saying that the last 4 bits can be anything, but the first 25 must match the ID. 

Note: for matching, the following must be true:

recv_frame_id & mask == ID (set in block)

Hope this helps,

Razvan.

0 Kudos
Reply

1,287 Views
constantinrazva
NXP Employee
NXP Employee

Some things that are worth mentioning is that in the matching process, the scan begins from the first MB (lowest number) -- so if you are using multiple MBs, you might want to keep this in mind.

You might also want to take a look at the RX FIFO - you can read the help we provide in Simulink to get further information about how to enable it and how to filtering table works.

Kind regards,

Razvan.