User manual

mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
307
ECANxSetMask
Prototype
sub procedure ECANxSetMask(dim ECAN_MASK as word, dim val as longint, dim
ECAN_CONFIG_FLAGS as word)
Description The function congures appropriate mask for advanced message ltering.
Parameters - ECAN_MASK: ECAN module mask number. Valid values: ECAN_MASK constants. See ECAN_MASK
constants.
- val: mask register value. This value is bit-adjusted to appropriate buffer mask registers
- ECAN_CONFIG_FLAGS: selects type of messages to lter. Valid values:
- _ECAN_CONFIG_ALL_VALID_MSG,
- _ECAN_CONFIG_MATCH_MSG_TYPE & _ECAN_CONFIG_STD_MSG,
- _ECAN_CONFIG_MATCH_MSG_TYPE & _ECAN_CONFIG_XTD_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 Cong mode, otherwise the function will be ignored. See
ECANxSetOperationMode.
Example
‘ set appropriate lter mask and message type value
ECAN1SetOperationMode(_ECAN_MODE_CONFIG,0xFF) set CONFIGURATION mode
(ECAN1 module must be in cong mode for mask settings)
‘ Set all mask0 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.
ECAN1SetMask(_ECAN_MASK_0, -1, _ECAN_CONFIG_MATCH_MSG_TYPE and _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.