Mikroelektronika MIKROE-724 データシート

ページ / 726
256
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
CAN Constants
There is a number of constants predefined 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 define CAN operation mode. Function CANxSetOperationMode expects one of these as its 
argument:
Copy Code To Clipboard 
const    _CAN_MODE_BITS    as word = $E0   ‘ Use this to access opmode  bits
         _CAN_MODE_NORMAL     as word = 0x00
         _CAN_MODE_DISABLE    as word = 0x01
         _CAN_MODE_LOOP       as word = 0x02
         _CAN_MODE_LISTEN     as word = 0x03
         _CAN_MODE_CONFIG     as word = 0x04
         _CAN_MODE_LISTEN_ALL as word = 0x07
CAN_CONFIG_FLAGS Constants
CAN_CONFIG_FLAGS
  constants  define  flags  related  to  CAN  module  configuration.  Functions  CANxInitialize  and 
CANxSetBaudRate expect one of these (or a bitwise combination) as their argument:
Copy Code To Clipboard 
const
    _CAN_CONFIG_DEFAULT         as word = 0xFF   ‘ 11111111
    _CAN_CONFIG_PHSEG2_PRG_BIT  as word = 0x01
    _CAN_CONFIG_PHSEG2_PRG_ON   as word = 0xFF   ‘ XXXXXXX1
    _CAN_CONFIG_PHSEG2_PRG_OFF  as word = 0xFE   ‘ XXXXXXX0
    _CAN_CONFIG_LINE_FILTER_BIT as word = 0x02
    _CAN_CONFIG_LINE_FILTER_ON  as word = 0xFF   ‘ XXXXXX1X
    _CAN_CONFIG_LINE_FILTER_OFF as word = 0xFD   ‘ XXXXXX0X
    _CAN_CONFIG_SAMPLE_BIT      as word = 0x04
    _CAN_CONFIG_SAMPLE_ONCE     as word = 0xFF   ‘ XXXXX1XX
    _CAN_CONFIG_SAMPLE_THRICE   as word = 0xFB   ‘ XXXXX0XX
    _CAN_CONFIG_MSG_TYPE_BIT    as word = 0x08
    _CAN_CONFIG_STD_MSG         as word = 0xFF   ‘ XXXX1XXX
    _CAN_CONFIG_XTD_MSG         as word = 0xF7   ‘ XXXX0XXX
    _CAN_CONFIG_DBL_BUFFER_BIT  as word = 0x10
    _CAN_CONFIG_DBL_BUFFER_ON   as word = 0xFF   ‘ XXX1XXXX
    _CAN_CONFIG_DBL_BUFFER_OFF  as word = 0xEF   ‘ XXX0XXXX