User manual
mikroC PRO for dsPIC
MikroElektronika
279
CANxSetMask
Prototype
void CANxSetMask(unsigned int CAN_MASK, long val, unsigned int CAN_CONFIG_
FLAGS);
Description Function sets mask for advanced ltering of messages. Given value is bit adjusted to appropriate
buffer mask registers.
Parameters - CAN_MASK: CAN module mask number. Valid values: CAN_MASK constants. See CAN_MASK
constants.
- val: mask register value. This value is bit-adjusted to appropriate buffer mask registers
- CAN_CONFIG_FLAGS: selects type of message to lter. Valid values:
- _CAN_CONFIG_ALL_VALID_MSG,
- _CAN_CONFIG_MATCH_MSG_TYPE & _CAN_CONFIG_STD_MSG,
- _CAN_CONFIG_MATCH_MSG_TYPE & _CAN_CONFIG_XTD_MSG.
See CAN_CONFIG_FLAGS constants.
Returns Nothing.
Requires MCU with the CAN module.
MCU must be connected to the CAN transceiver (MCP2551 or similar) which is connected to the CAN
bus.
CAN must be in Cong mode, otherwise the function will be ignored. See CANxSetOperationMode.
Example
// set appropriate lter mask and message type value
CAN1SetOperationMode(_CAN_MODE_CONFIG,0xFF); // set CONFIGURATION
mode (CAN1 module must be in cong mode for mask settings)
// Set all B1 mask bits to 1 (all ltered bits are relevant):
// Note that -1 is just a cheaper way to write 0xFFFFFFFF.
// Complement will do the trick and ll it up with ones.
CAN1SetMask(_CAN_MASK_B1, -1, _CAN_CONFIG_MATCH_MSG_TYPE & _CAN_CONFIG_XTD_
MSG);
Notes - CAN library routine require you to specify the module you want to use. To use the desired CAN
module, simply change the letter x in the routine prototype for a number from 1 to 2.
- Number of CAN modules per MCU differs from chip to chip. Please, read the appropriate datasheet
before utilizing this library.