AcceptanceFilter11Bit

This parameter restricts the reception of messages from a PCAN Channel by modifying the acceptance filter of its CAN chip, using specific 11-bit code and mask values.

It allows the configuration of complex filter patterns, and it is intended for users with extended CAN knowledge. Note that the calculation of mask and code patterns is not a trivial matter. For most applications the use of the FilterMessages for setting message reception ranges is more adequate.

  Note

  • The acceptance code and mask are coded together in a 64-bit value, each of them using 4 bytes. The acceptance code is stored at the most significant bytes. Bitwise and shifting operations are needed to code and decode the values into and from a 64-bit unsigned integer variable.

  • To set an acceptance code and mask denoting 29-bit CAN IDs, the parameter AcceptanceFilter29Bit must be used instead.

  • The SJA1000 CAN controller has only one acceptance filter for both, standard (11-bit) and extended (64-bit) IDs. When doing settings for 11-bit IDs, the acceptance mask and code are internally shifted to the left as adaptation measure, which also causes possible reception of unwanted messages. For this reason, is also not advisable to mix 11-bits and 29-bits filters.

  • An internal hardware reset is done each time the acceptance filter is modified. If other application is using the same device, its communication could be affected in some scenarios.

For more information on the SJA1000 CAN controller acceptance filter, see Philips Data Sheet SJA1000 Stand-alone CAN-controller.

Availability

It is available since PCAN-Basic version 4.2.0.

Supported By

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

This is a numeric value with a quad-word resolution. Since it contains two double-word values representing the acceptance code and mask, the maximum value range accepted for this parameter is given by the limits of their internal values, which is a range between [0...16838]. This means, the maximum value of this parameter as 64-bit value is 70364449226751 (hexadecimal 00003FFF_00003FFFh).

Default Value

The default state of the receive filter is to receive all messages (Open). This represents a default acceptance code of 0h and an acceptance mask of 7FFh (00000000_000007FFh).

  Note

An automatic filter reset is done before registering the desired code and mask, if the filter state before using this parameter was Open.

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Set: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to modify the acceptance filter of a USB Channel using 11-bit code and mask values:

C#
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    ulong acceptanceFilter = 0x500;
    if (Api.SetValue(channelUsed, PcanParameter.AcceptanceFilter11Bit, acceptanceFilter) == PcanStatus.OK)
        Console.WriteLine($"The acceptance filter for {channelUsed} has been successfully configured to accept the standard IDs 0x100, 0x400, and 0x500.");
    else
        Console.WriteLine($"Error configuring the acceptance filter on channel {channelUsed}.");
    Api.Uninitialize(channelUsed);
}

See Also