Content originally posted in LPCWare by madid87 on Thu Oct 06 04:48:07 MST 2011
Quote: manishd
Can anyone point me to documentation on the correct use of the mode_id field and particularly the mask field in the CAN_MSG_OBJ structure?
Perhaps their use is self evident to many of you, but, unfortunately not so clear to me.
typedef struct _CAN_MSG_OBJ {
uint32_t mode_id;
uint32_t mask;
uint8_t data[8];
uint8_t dlc;
uint8_t msgobj;
}CAN_MSG_OBJ
Thanks
Hi.
Fields "mode_id" and "mask" are used for acceptance filtering, i.e. CAN controller will receive only IDs that you specify.
Example:
mode_id = 0x020
mask = 0x7FF
This mask has all bits (in case of 11 bit ID) as ones. This means that the filter will compare all bits with the mode_id. So only ID=0x020 will be accepted.
If mask is for example 0x7F0 the filter will compare only upper bits, so IDs ranging from 0x020 to 0x02F (filter doesn't care for lower nibble) will be accepted.
In other words the filter will logical AND input message ID with the mask and the result will be compared to mode_id. If equal, the message is accepted.
Cheers.