User`s manual
mikroBASIC
- Basic Compiler for Microchip PIC microcontrollers
You need to be familiar with constants that are provided for use with CANSPI
library routines. See how to form values (from constants) that will be passed to or
from routines in the example at the end of the chapter. All of the constants are pre-
defined in CAN library.
For the complete list of constants refer to page 119.
This code demonstrates use of CANSPI library routines.
program CANSPI
dim aa as byte
dim aa1 as byte
dim lenn as byte
dim aa2 as byte
dim data as byte[8]
dim id as longint
dim zr as byte
main:
TRISB = 0
SPI_init
' must be performed before any other activity
TRISC.2 = 0
' this pin is connected to Reset pin of MCP2510
portc.2 = 0
' keep MCP2510 in reset state
PORTC.0 = 1
' make sure that MCP2510 is not selected
TRISC.0 = 0
' make RC0 output
PORTD = 0
TRISD = 0
' designate portd as output
aa = 0
aa1 = 0
aa2 = 0
aa = CAN_CONFIG_SAMPLE_THRICE and
CAN_CONFIG_PHSEG2_PRG_ON and
CAN_CONFIG_STD_MSG and
CAN_CONFIG_DBL_BUFFER_ON and
CAN_CONFIG_VALID_XTD_MSG
' prepare flags for
' CANSPIinitialize
PORTC.2 = 1
' activate MCP2510 chip
' continues..
MikroElektronika:
Development
tools
-
Books
-
Compilers
mikroBASIC
making it simple...
131
page
CAN Library Constants
Example