Mask and filter might be confusing and incomprehensible at the first glance if you are new on CAN. My mission here is to simplify things for your convenience. If you know how to split things into smaller pieces, it is quite easy to get it.
So lets start with lexical meaning of mask; it is explained as "to prevent something from being seen or noticed" in the dictionary unlike its popular meaning nowadays. So masking on CAN does exactly what the dictionary says.
Assuming that we have a message that has ID of 0X2E and we arranged mask as 0x1A and filter is 0xEE. It is always wise to convert numbers to binary to see in wide range.
Legend of table
DC - Don't Care
M - Match
Message ID is compared with MASK. If message ID bit matches with "1" of mask bit, it keeps its original value in masking result, if message id bit matches with "0" of mask bit, masking result is "DC" means not important for the next step.
Now we are on masking result line. We need to filter this line with our filter bits. As some of bits on masking result are "DC", we do not have to worry about them, those are not important for the filtering step. We do only need to check bits with "0" and "1". If those bits are matched with our filter, this message is acceptable for us and we need to listen. If not we can discard message to not waste our chip resources and time.
If filter was 0xE6 as shown below table, we should have discarded message as masking result doesn't match with filter.
Comments
Post a Comment