User manual
308
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
ECANxSetFilter
Prototype
sub procedure ECANxSetFilter(dim ECAN_FILTER as word, dim val as longint,
dim ECAN_FILTER_MASK as word, dim ECAN_FILTER_RXBUFF as word, dim ECAN_
CONFIG_FLAGS as word)
Description The function congures and enables appropriate message lter.
Parameters - ECAN_FILTER: ECAN module lter number. Valid values: ECAN_FILTER constants. See ECAN_
FILTER constants.
- val: lter register value. This value is bit-adjusted to appropriate lter registers
- ECAN_FILTER_MASK: mask register corresponding to lter. Valid values: ECAN_MASK constants.
See ECAN_MASK constants.
- ECAN_FILTER_RXBUFF: receive buffer corresponding to lter. Valid values: ECAN_RX_BUFFER
constants. See ECAN_RX_BUFFER constants.
- ECAN_CONFIG_FLAGS: selects type of messages to lter. Valid values: _ECAN_CONFIG_XTD_MSG
and _ECAN_CONFIG_STD_MSG. See ECAN_CONFIG_FLAGS constants.
Returns Nothing.
Requires The ECAN routines are supported only by MCUs with the ECAN module.
Microcontroller must be connected to ECAN transceiver which is connected to the ECAN bus.
The ECAN module must be in Cong mode, otherwise the function will be ignored. See
ECANxSetOperationMode.
Example
‘ set appropriate lter value and message type
ECAN1SetOperationMode(_ECAN_MODE_CONFIG,0xFF) ‘ set CONFIGURATION mode
(ECAN1 module must be in cong mode for lter settings)
‘ Set id of lter 10 to 3, mask2, receive buffer 7, extended messages:
ECAN1SetFilter(_ECAN_FILTER_10, 3, _ECAN_MASK_2, _ECAN_RX_BUFFER_7, _ECAN_
CONFIG_XTD_MSG)
Notes - ECAN library routine require you to specify the module you want to use. To select the desired ECAN
module, simply change the letter x in the routine prototype for a number from 1 to 2.
- Number of ECAN modules per MCU differs from chip to chip. Please, read the appropriate datasheet
before utilizing this library.