User manual

254
mikoPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
CAN Constants
There is a number of constants predened in CAN library. To be able to use the library effectively, you need to be
familiar with these. You might want to check the example at the end of the chapter.
CAN_OP_MODE Constants
CAN_OP_MODE constants dene CAN operation mode. Function CANxSetOperationMode expects one of these as its
argument:
Copy Code To Clipboard
const
_CAN_MODE_BITS : word = $E0; // Use this to access opmode bits
_CAN_MODE_NORMAL : word = 0x01;
_CAN_MODE_SLEEP : word = 0x02;
_CAN_MODE_LOOP : word = 0x03;
_CAN_MODE_LISTEN : word = 0x04;
_CAN_MODE_CONFIG : word = 0x07;
CAN_CONFIG_FLAGS Constants
CAN_CONFIG_FLAGS constants dene ags related to CAN module conguration. Functions CANxInitialize and
CANxSetBaudRate expect one of these (or a bitwise combination) as their argument:
Copy Code To Clipboard
const
_CAN_CONFIG_DEFAULT : word = 0xFF; // 11111111
_CAN_CONFIG_PHSEG2_PRG_BIT : word = 0x01;
_CAN_CONFIG_PHSEG2_PRG_ON : word = 0xFF; // XXXXXXX1
_CAN_CONFIG_PHSEG2_PRG_OFF : word = 0xFE; // XXXXXXX0
_CAN_CONFIG_LINE_FILTER_BIT : word = 0x02;
_CAN_CONFIG_LINE_FILTER_ON : word = 0xFF; // XXXXXX1X
_CAN_CONFIG_LINE_FILTER_OFF : word = 0xFD; // XXXXXX0X
_CAN_CONFIG_SAMPLE_BIT : word = 0x04;
_CAN_CONFIG_SAMPLE_ONCE : word = 0xFF; // XXXXX1XX
_CAN_CONFIG_SAMPLE_THRICE : word = 0xFB; // XXXXX0XX
_CAN_CONFIG_MSG_TYPE_BIT : word = 0x08;
_CAN_CONFIG_STD_MSG : word = 0xFF; // XXXX1XXX
_CAN_CONFIG_XTD_MSG : word = 0xF7; // XXXX0XXX
_CAN_CONFIG_DBL_BUFFER_BIT : word = 0x10;
_CAN_CONFIG_DBL_BUFFER_ON : word = 0xFF; // XXX1XXXX
_CAN_CONFIG_DBL_BUFFER_OFF : word = 0xEF; // XXX0XXXX