ABL electronic PIC12 Personal Computer User Manual


 
MikroElektronika:
Development
tools
-
Books
-
Compilers
14 3
page
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
Prototype
void CANInitialize(char SJW, char BRP, char PHSEG1, char PHSEG2,
char PROPSEG, char CAN_CONFIG_FLAGS);
Description Initializes CAN. All pending transmissions are aborted. Sets all mask registers to 0 to
allow all messages.
Filter registers are set according to flag value:
if (CAN_CONFIG_FLAGS & CAN_CONFIG_VALID_XTD_MSG != 0)
// Set all filters to XTD_MSG
else if (config & CONFIG_VALID_STD_MSG != 0)
// Set all filters to STD_MSG
else
// Set half the filters to STD, and the rest to XTD_MSG
Parameters:
SJW as defined in 18XXX8 datasheet (1–4)
BRP as defined in 18XXX8 datasheet (1–64)
PHSEG1 as defined in 18XXX8 datasheet (1–8)
PHSEG2 as defined in 18XXX8 datasheet (1–8)
PROPSEG as defined in 18XXX8 datasheet (1–8)
CAN_CONFIG_FLAGS is formed from predefined constants (see CAN constants).
Requires CAN must be in Config mode; otherwise the function will be ignored.
Example
init = CAN_CONFIG_SAMPLE_THRICE &
CAN_CONFIG_PHSEG2_PRG_ON &
CAN_CONFIG_STD_MSG &
CAN_CONFIG_DBL_BUFFER_ON &
CAN_CONFIG_VALID_XTD_MSG &
CAN_CONFIG_LINE_FILTER_OFF;
...
CANInitialize(1, 1, 3, 3, 1, init);
// initialize CAN
CANInitialize