User manual

266
mikoBasic PRO for dsPIC30/33 and PIC24
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
dim CanSpi_CS as sbit at LATF0_bit
CanSpi_CS_Direction as sbit at TRISF0_bit
CanSpi_Rst as sbit at LATF12_bit
CanSpi_Rst_Direction as sbit at TRISF1_bit
‘ End CANSPI module connections
dim CANSPI_Init_Flags as word
...
CANSPI_Init_Flags = _CANSPI_CONFIG_SAMPLE_THRICE and
_CANSPI_CONFIG_PHSEG2_PRG_ON and
_CANSPI_CONFIG_STD_MSG and
_CANSPI_CONFIG_DBL_BUFFER_ON and
_CANSPI_CONFIG_VALID_XTD_MSG and
_CANSPI_CONFIG_LINE_FILTER_OFF
...
SPI1_Init() ‘ initialize SPI1 module
CANSPI(1,3,3,3,1,CANSPI_Init_Flags) ‘ initialize CANSPI
Notes - CANSPI mode NORMAL will be set on exit.