| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → xPC Target |
| Contents | Index |
| Learn more about xPC Target |
| On this page… |
|---|
As mentioned earlier, you can use the CAN controller's acceptance filters to ensure that certain received messages referenced by their identifiers are written into the receive FIFO. Therefore, fewer read attempts are necessary to get at the messages that are of importance for the target application.
The behavior of the acceptance filter is described for standard and extended identifier ranges individually (one for standard identifiers and one for extended identifiers). Each acceptance filter is defined by a mask parameter and a code parameter.
The mask parameter defines, for each bit of the identifier, whether the filtering process cares about this bit or not. A 0 means "don't care" and a 1 means "do care."
The code parameter then defines, for each bit of the identifier, that the filtering process cares about (defined by the mask parameter), what the bit value has to be (0 or 1).
For standard identifiers the mask parameter and code parameter must both be in the range 0 to 2047. For extended identifiers the mask parameter and code parameter must both be in the range 0 to 229-1.
The filtering process evaluates the following binary expression:
and( xor( mask, identifier ), code )
If all bits of the resulting value are 0, the message with this identifier is accepted. If any bit is 1, the message is voided.
According to this description, acceptance filters work using binary evaluation, while most applications differentiate messages (identifiers) in a decimal or hexadecimal manner. As a consequence, it is possible to filter messages, whose identifiers are above a certain decimal number. The opposite (identifiers below a certain decimal number) cannot be achieved in a general way.
The default values for the mask parameter and the code parameter in the FIFO setup driver block are both 0. These parameter values ensure (the above expression always evaluates to 0) that all incoming messages will reach the receive FIFO (no filtering takes place). All parameter values are defined using decimal numbers. You can use the MATLAB function hex2dec to define hexadecimal numbers in the dialog box entry.
Assume a CAN application where messages with the following identifiers (standard) are crossing the CAN network:
2-30, 48-122 (decimal)
Additionally, only incoming messages 4-29 must be processed by the target application. Ideally, all messages not having identifiers 4-29 would be filtered out, but the mask and code parameters do not allow this exact scheme. The closest you can achieve is filtering out all messages with identifiers above 31 by using value 2047-31=2016 for the mask parameter and value 0 for the code parameter. The messages with identifier 0, 1, 2, and 3 cannot be filtered out and are returned by the FIFO read driver block, even if they do not need to be processed by the target application.
![]() | FIFO CAN Demonstrations | Accessing CANdb DBC Format Databases from the xPC Target Environment | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2010- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |