Welcome to the CAN-bus Wiki project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

can_faq:can_message_filtering [2018/08/21 23:08] (current)
Line 1: Line 1:
 +====== What is CAN Message Filtering ======
 +
 +The two most common terms used are //accceptance mask// and //acceptance code//. Let's see how Allen Pothoof <apothoof@hotmail.com> explains this:
 +
 +In an ideal world, you would have a filter for each message you wanted to receive.  That would allow you to  reject any messages you aren't interested in.  But we don't live in a perfect world.  If you don't have enough filters, you have to "open" the filters, risking receiving messages you don't care about.  Any message you receive but don't want, you have to throw away in your applications software.  This costs code space and CPU cycles.  Having the hardware do it for you is "better".
 +
 +As for the difference between acceptance registers and mask registers, it has to do with how the micro controller builds the filter.
 +
 +For some micro controllers, such as Infineon, you only have 1 "filter."  What you are telling the CAN controller is, in effect, "these bits, which I have set, are the only bits I am interested in and the corresponding bits in the identifier must also be set".
 +
 +In mathematical terms, you AND the filter with the identifier and, if the result is the same as the filter, the identifier/message is accepted.
 +
 +On other micro controllers, such as the PIC and Motorola parts, you have two parts to the filter.  The mask says "these bits, which I have set, are the 
 +only bits I am interested in" The acceptance register says "for those bits which correspond to the mask, the identifier must match the bits in the 
 +acceptance register".
 +
 +Again, in mathematical terms, you AND the mask with the identifier; if the result is the acceptance filter, the identifier/message is accepted.
 +
 +Note that some micro controllers use inverted bitmasks; i.e., the bits in the mask are flipped before the AND operation. Is one way better than the other?  It would seem that the two-part filter would do a better job but in the real world, I am not sure it does.  However, my observations are biased by the fact that the Infineon chips have 16 mailboxes/filters while the Microchip parts I have used only have two receive buffers/filters.  As a practical matter, that has made the filtering on the Microchip parts worthless for me.
 +
  

QR Code
QR Code can_faq:can_message_filtering (generated for current page)