User manual

332
mikoC PRO for dsPIC
MikroElektronika
ECANxSetFilter
Prototype
void ECANxSetFilter(unsigned int ECAN_FILTER, long val, unsigned int ECAN_
FILTER_MASK, unsigned int ECAN_FILTER_RXBUFF, unsigned int ECAN_CONFIG_
FLAGS);
Description The function congures 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 Cong 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 cong 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.