User manual

264
mikoPascal 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
var CanSpi_CS : sbit at LATF0_bit;
CanSpi_CS_Direction : sbit at TRISF0_bit;
CanSpi_Rst : sbit at LATF1_bit;
CanSpi_Rst_Direction : sbit at TRISF1_bit;
// End CANSPI module connections
var CANSPI_Init_Flags: 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
CANSPIInit(1,3,3,3,1,CANSPI_Init_Flags); // initialize CANSPI
Notes - CANSPI mode NORMAL will be set on exit.