User manual

Table Of Contents
274
mikoC PRO for PIC32
MikroElektronika
Requires Global variables:
- CanSpi_CS: Chip Select line
- CanSpi_Rst: Reset line
- CanSpi_CS_Direction: Direction of the Chip Select pin
- CanSpi_Rst_Direction: Direction of the Reset pin
must be dened before using this function.
The CANSPI routines are supported only by MCUs with the SPI module.
The SPI module needs to be initialized. See the SPIx_Init and SPIx_Init_Advanced routines.
MCU has to be properly connected to mikroElektronika’s CANSPI Extra Board or similar hardware.
See connection example at the bottom of this page.
Example
// CANSPI module connections
sbit CanSpi_CS at RF0_bit;
sbit CanSpi_CS_Direction at TRISF0_bit;
sbit CanSpi_Rst at RF1_bit;
sbit CanSpi_Rst_Direction at TRISF1_bit;
// End CANSPI module connections
// initialize the CANSPI module with the appropriate baud rate and message
acceptance ags along with the sampling rules
char CANSPI_Init_Flags;
...
CANSPI_Init_Flags = _CANSPI_CONFIG_SAMPLE_THRICE & // form value to be
used
_CANSPI_CONFIG_PHSEG2_PRG_ON & // with
CANSPIInitialize
_CANSPI_CONFIG_XTD_MSG &
_CANSPI_CONFIG_DBL_BUFFER_ON &
_CANSPI_CONFIG_VALID_XTD_MSG;
...
SPI1_Init(); // initialize SPI1 module
CANSPIInitialize(1,3,3,3,1,CANSPI_Init_Flags); // initialize external
CANSPI module
Notes - CANSPI mode NORMAL will be set on exit.