Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Acceptance Filters

You can use the CAN controller acceptance filters to select received messages by identifier for writing into the receive FIFO. Therefore, fewer read attempts are required to get the messages of importance to the real-time 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). A mask parameter and a code parameter define each acceptance filter.

  • For each bit of the identifier, the mask parameter defines whether the filtering process cares about this bit or not. A 0 means "do not care" and a 1 means "do care."

  • For each bit that the filtering process cares about, the code parameter defines the bit value (0 or 1).

For standard identifiers, the mask parameter and code parameter must both be in the range 0–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 a bit is 1, the message is voided.

According to this description, acceptance filters work using binary evaluation, while most systems 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. Because the filtering expression evaluates to 0, all incoming messages reach the receive FIFO (no filtering takes place). The parameter values are defined using decimal numbers. You can use the MATLAB® function hex2dec to define hexadecimal numbers in the dialog box entry.

For example, assume a CAN network model where messages with the following identifiers (standard) are crossing the CAN network:

2-30, 48-122 (decimal)

The real-time application processes only incoming messages 4–29.

Ideally, all messages not having identifiers 4–29 would be filtered, but the mask and code parameters do not allow this scheme. You can, however, filter the messages with identifiers above 31 by using 2047 – 31 = 2016 for the mask parameter and 0 for the code parameter. The FIFO read driver block cannot filter messages with identifiers 0, 1, 2, and 3. The block returns them, even if the real-time application does not process them.

Was this topic helpful?