Mikroelektronika MIKROE-724 データシート

ページ / 726
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
253
CANxSetFilter
Prototype
sub procedure CANxSetFilter(dim CAN_FILTER as worddim val as longintdim 
CAN_CONFIG_FLAGS as word)
Description Function sets message filter. Given 
value
 is bit adjusted to appropriate buffer mask registers.
Parameters 
CAN_FILTER
: CAN module filter number. Valid values: 
CAN_FILTER
 constants. See CAN_FILTER 
constants. 
val
: filter register value. This value is bit-adjusted to appropriate filter registers 
CAN_CONFIG_FLAGS:
 selects type of message to filter. 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 Config mode, otherwise the function will be ignored. See CANxSetOperationMode.
Example
‘ set appropriate filter value and message type
CAN1SetOperationMode(_CAN_MODE_CONFIG,0xFF)‘  set  CONFIGURATION  mode  (CAN1 
module must be in config mode for filter settings)
‘ Set id of filter 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.