A:
On CanSetChannelAcceptance
function,
In addition to store only one CAN ID message to the receive buffer, you
can store the multiple CAN ID messages to the receive buffer by combining
CanIdMask and CanIdCode.
The internal process inside the driver software as below.
It performs a bitwise AND operation between the received CAN ID and specified
CanIdMask.
Separately, it performs a bitwise AND operation between specified CanIdMask
and CanIdCode.
When these two AND bit results are same value, the target CAN ID message
is stored to the receive buffer.
Acceptance settings using AND bit operations are a general-technique
that requires short PC processing time to make a decision.
However, it takes some experience to determine the CanIdMask and CanIdCode
that match your desired acceptance settings.
The following tables are some examples of standard format (11bit).
Please decide the properly CanIdMask and CanIdCode for your system with
there examples.
In the case of extended format, the same processing is performed with 29 bits.
Numbers with the prefix "0x" are hexadecimal numbers.
The numbers in parentheses are binary numbers. Numbers not specified are
decimal numbers.
Example1)
If you want store all CAN ID messages in the receive buffer, please specify
CanIdMask = 0x0.
When CanIDMask = 0x0, the operation is the same regardless of the number
of CanIdCodes, but in the table below, CanIdCode = 0x0 (default value).
Definition |
Example 1 |
Pattern 2 |
Pattern 3 |
Pattern 4 |
Pattern 5 |
CAN ID |
0x000 ( 000 0000 0000) |
0x001 ( 000 0000 0001) |
0x123 ( 001 0010 0011) |
0x1FF ( 001 1111 1111) |
0x7FF ( 111 1111 1111) |
Specified Mask (CanIdMask) |
0x000 ( 000 0000 0000) |
0x000 ( 000 0000 0000) |
0x000 ( 000 0000 0000) |
0x000 ( 000 0000 0000) |
0x000 ( 000 0000 0000) |
The result of (CAN ID) AND (CanIdMask) |
0x000 ( 000 0000 0000) |
0x000 ( 000 0000 0000) |
0x000 ( 000 0000 0000) |
0x000 ( 000 0000 0000) |
0x000 ( 000 0000 0000) |
Specified Code (CanIdCode) |
0x000 ( 000 0000 0000) |
0x000 ( 000 0000 0000) |
0x000 ( 000 0000 0000) |
0x000 ( 000 0000 0000) |
0x000 ( 000 0000 0000) |
The result of (CanIdCode) AND (CanIdMask) |
0x000 ( 000 0000 0000) |
0x000 ( 000 0000 0000) |
0x000 ( 000 0000 0000) |
0x000 ( 000 0000 0000) |
0x000 ( 000 0000 0000) |
Comparison of two AND operation results |
Equal |
Equal |
Equal |
Equal |
Equal |
To store in receive buffer |
To store |
To store |
To store |
To store |
To store |
Example 2)
If you want store the message of CAN ID "0x123" in the receive
buffer, please specify CanIdMask = 0x7FF, CanIdCode = 0x123 on standard
format (11bit).
Definition |
Pattern 1 |
Pattern 2 |
Pattern 3 |
Pattern 4 |
Pattern 5 |
CAN ID |
0x000 ( 000 0000 0000) |
0x001 ( 000 0000 0001) |
0x123 ( 001 0010 0011) |
0x1FF ( 001 1111 1111) |
0x7FF ( 111 1111 1111) |
Specified Mask (CanIdMask) |
0x7FF ( 111 1111 1111) |
0x7FF ( 111 1111 1111) |
0x7FF ( 111 1111 1111) |
0x7FF ( 111 1111 1111) |
0x7FF ( 111 1111 1111) |
The result of (CAN ID) AND (CanIdMask) |
0x000 ( 000 0000 0000) |
0x001 ( 000 0000 0001) |
0x123 ( 001 0010 0011) |
0x1FF ( 001 1111 1111) |
0x7FF ( 111 1111 1111) |
Specified Code (CanIdCode) |
0x123 ( 001 0010 0011) |
0x123 ( 001 0010 0011) |
0x123 ( 001 0010 0011) |
0x123 ( 001 0010 0011) |
0x123 ( 001 0010 0011) |
The result of (CanIdCode) AND (CanIdMask) |
0x123 ( 001 0010 0011) |
0x123 ( 001 0010 0011) |
0x123 ( 001 0010 0011) |
0x123 ( 001 0010 0011) |
0x123 ( 001 0010 0011) |
Comparison of two AND operation results |
Not Equal |
Not Equal |
Equal |
Not Equal |
Not Equal |
To store in receive buffer |
Not to store |
Not to store |
To store |
Not to store |
Not to store |
Example 3)
If you want store the message of CAN ID from "0x200" to "0x2FF"
in the receive buffer, please specify CanIdMask = 0x700, CanIdCode = 0x200
on standard format (11bit).
Definition |
Pattern 1 |
Pattern 2 |
Pattern 3 |
Pattern 4 |
Pattern 5 |
CAN ID |
0x000 ( 000 0000 0000) |
0x001 ( 000 0000 0001) |
0x200 ( 010 0000 0000) |
0x2FF ( 010 1111 1111) |
0x7FF ( 111 1111 1111) |
Specified Mask (CanIdMask) |
0x700 ( 111 0000 0000) |
0x700 ( 111 0000 0000) |
0x700 ( 111 0000 0000) |
0x700 ( 111 0000 0000) |
0x700 ( 111 0000 0000) |
The result of (CAN ID) AND (CanIdMask) |
0x000 ( 000 0000 0000) |
0x000 ( 000 0000 0000) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
0x700 ( 111 0000 0000) |
Specified Code (CanIdCode) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
The result of (CanIdCode) AND (CanIdMask) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
Comparison of two AND operation results |
Not Equal |
Not Equal |
Equal |
Equal |
Not Equal |
To store in receive buffer |
Not to store |
Not to store |
To store |
To store |
Not to store |
Example 4)
If you want store the message of CAN ID from "0x200" to "0x23F"
in the receive buffer, please specify CanIdMask = 0x7C0, CanIdCode = 0x200
on standard format (11bit).
Definition |
Pattern 1 |
Pattern 2 |
Pattern 3 |
Pattern 4 |
Pattern 5 |
CAN ID |
0x000 ( 000 0000 0000) |
0x200 ( 010 0000 0000) |
0x23F ( 010 0011 1111) |
0x240 ( 010 0100 0000) |
0x7FF ( 111 1111 1111) |
Specified Mask (CanIdMask) |
0x7C0 ( 111 1100 0000) |
0x7C0 ( 111 1100 0000) |
0x7C0 ( 111 1100 0000) |
0x7C0 ( 111 1100 0000) |
0x7C0 ( 111 1100 0000) |
The result of (CAN ID) AND (CanIdMask) |
0x000 ( 000 0000 0000) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
0x240 ( 010 0100 0000) |
0x7C0 ( 111 1100 0000) |
Specified Code (CanIdCode) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
The result of (CanIdCode) AND (CanIdMask) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
Comparison of two AND operation results |
Not Equal |
Equal |
Equal |
Not Equal |
Not Equal |
To store in receive buffer |
Not to store |
To store |
To store |
Not to store |
Not to store |
Example 5)
If you want store the message of CAN ID from "0x280" to "0x2FF"
in the receive buffer, please specify CanIdMask = 0x780, CanIdCode = 0x280
on standard format (11bit).
Definition |
Pattern 1 |
Pattern 2 |
Pattern 3 |
Pattern 4 |
Pattern 5 |
CAN ID |
0x27F ( 010 0111 1111) |
0x280 ( 010 1000 0000) |
0x2FF ( 010 1111 1111) |
0x300 ( 011 0000 0000) |
0x7FF ( 111 1111 1111) |
Specified Mask (CanIdMask) |
0x780 ( 111 1000 0000) |
0x780 ( 111 1000 0000) |
0x780 ( 111 1000 0000) |
0x780 ( 111 1000 0000) |
0x780 ( 111 1000 0000) |
The result of (CAN ID) AND (CanIdMask) |
0x200 ( 010 0000 0000) |
0x280 ( 010 1000 0000) |
0x280 ( 010 1000 0000) |
0x300 ( 011 0000 0000) |
0x780 ( 111 1000 0000) |
Specified Code (CanIdCode) |
0x280 ( 010 1000 0000) |
0x280 ( 010 1000 0000) |
0x280 ( 010 1000 0000) |
0x280 ( 010 1000 0000) |
0x280 ( 010 1000 0000) |
The result of (CanIdCode) AND (CanIdMask) |
0x280 ( 010 1000 0000) |
0x280 ( 010 1000 0000) |
0x280 ( 010 1000 0000) |
0x280 ( 010 1000 0000) |
0x280 ( 010 1000 0000) |
Comparison of two AND operation results |
Not Equal |
Equal |
Equal |
Not Equal |
Not Equal |
To store in receive buffer |
Not to store |
To store |
To store |
Not to store |
Not to store |
Example 6)
If you want store the message of CAN ID from "0x200" to "0x3FF"
in the receive buffer, please specify CanIdMask = 0x600, CanIdCode = 0x200
on standard format (11bit).
Definition |
Pattern 1 |
Pattern 2 |
Pattern 3 |
Pattern 4 |
Pattern 5 |
CAN ID |
0x1FF ( 001 1111 1111) |
0x200 ( 010 0000 0000) |
0x3FF ( 011 1111 1111) |
0x600 ( 110 0000 0000) |
0x7FF ( 111 1111 1111) |
Specified Mask (CanIdMask) |
0x600 ( 110 0000 0000) |
0x600 ( 110 0000 0000) |
0x600 ( 110 0000 0000) |
0x600 ( 110 0000 0000) |
0x600 ( 110 0000 0000) |
The result of (CAN ID) AND (CanIdMask) |
0x000 ( 000 0000 0000) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
0x600 ( 110 0000 0000) |
0x600 ( 110 0000 0000) |
Specified Code (CanIdCode) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
The result of (CanIdCode) AND (CanIdMask) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
0x200 ( 010 0000 0000) |
Comparison of two AND operation results |
Not Equal |
Equal |
Equal |
Not Equal |
Not Equal |
To store in receive buffer |
Not to store |
To store |
To store |
Not to store |
Not to store |