User manual
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
253
CANxSetFilter
Prototype
sub procedure CANxSetFilter(dim CAN_FILTER as word, dim val as longint, dim
CAN_CONFIG_FLAGS as word)
Description Function sets message lter. Given value is bit adjusted to appropriate buffer mask registers.
Parameters - CAN_FILTER: CAN module lter number. Valid values: CAN_FILTER constants. See CAN_FILTER
constants.
- val: lter register value. This value is bit-adjusted to appropriate lter registers
- CAN_CONFIG_FLAGS: selects type of message to lter. Valid values: _CAN_CONFIG_STD_MSG and
_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 value and message type
CAN1SetOperationMode(_CAN_MODE_CONFIG,0xFF)‘ set CONFIGURATION mode (CAN1
module must be in cong mode for lter settings)
‘ Set id of lter B1_F1 to 3:
CAN1SetFilter(_CAN_FILTER_B1_F1, 3, _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.