ABL electronic PIC12 Personal Computer User Manual


 
// ..continued
#define CAN_CONFIG_DBL_BUFFER_BIT 0x10
#define CAN_CONFIG_DBL_BUFFER_ON 0xFF
// XXX1XXXX
#define CAN_CONFIG_DBL_BUFFER_OFF 0xEF
// XXX0XXXX
#define CAN_CONFIG_MSG_BITS 0x60
#define CAN_CONFIG_ALL_MSG 0xFF
// X11XXXXX
#define CAN_CONFIG_VALID_XTD_MSG 0xDF
// X10XXXXX
#define CAN_CONFIG_VALID_STD_MSG 0xBF
// X01XXXXX
#define CAN_CONFIG_ALL_VALID_MSG 0x9F
// X00XXXXX
You may use bitwise AND (&) to form config byte out of these values. For exam-
ple:
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
CAN_TX_MSG_FLAGS
CAN_TX_MSG_FLAGS are flags related to transmission of a CAN message:
#define CAN_TX_PRIORITY_BITS 0x03
#define CAN_TX_PRIORITY_0 0xFC
// XXXXXX00
#define CAN_TX_PRIORITY_1 0xFD
// XXXXXX01
#define CAN_TX_PRIORITY_2 0xFE
// XXXXXX10
#define CAN_TX_PRIORITY_3 0xFF
// XXXXXX11
#define CAN_TX_FRAME_BIT 0x08
#define CAN_TX_STD_FRAME 0xFF
// XXXXX1XX
#define CAN_TX_XTD_FRAME 0xF7
// XXXXX0XX
#define CAN_TX_RTR_BIT 0x40
#define CAN_TX_NO_RTR_FRAME 0xFF
// X1XXXXXX
#define CAN_TX_RTR_FRAME 0xBF
// X0XXXXXX
You may use bitwise AND (&) to adjust the appropriate flags. For example:
/* form value to be used with CANSendMessage: */
send_config = CAN_TX_PRIORITY_0 && CAN_TX_XTD_FRAME &
CAN_TX_NO_RTR_FRAME;
//...
CANSendMessage(id, data, 1, send_config);
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
14 8
MikroElektronika:
Development
tools
-
Books
-
Compilers
page