Mikroelektronika MIKROE-738 Data Sheet
mikroC PRO for PIC32
MikroElektronika
271
CANSPI Library
The SPI module is available with a number of the PIC32 MCUs. The mikroC PRO for PIC32 provides a library (driver)
for working with mikroElektronika’s CANSPI Add-on boards (with MCP2515 or MCP2510) via SPI interface.
Important:
- Consult the CAN standard about CAN bus termination resistance.
- An effective CANSPI communication speed depends on SPI and certainly is slower than “real” CAN.
- The library uses the SPI module for communication. User must initialize appropriate SPI module before using
the CANSPI Library.
- For MCUs with multiple SPI modules it is possible to initialize both of them and then switch by using the
SPI_Set_Active
routine.
- Number of SPI modules per MCU differs from chip to chip. Please, read the appropriate datasheet before
utilizing this library.
Library Dependency Tree
External dependencies of CANSPI Library
The following variables must be
defined in all projects using CANSPI
Library:
Description:
Example:
extern sfr sbit CanSpi_CS;
Chip Select line.
sbit CanSpi_CS at
RF0_bit;
extern sfr sbit
CanSpi_Rst;
Reset line.
sbit CanSpi_Rst at
RF1_bit;
extern sfr sbit
CanSpi_CS_Direction;
Direction of the Chip Select pin.
sbit
CanSpi_CS_Direction
at TRISF0_bit;
extern sfr sbit
CanSpi_Rst_Direction;
Direction of the Reset pin.
sbit
CanSpi_Rst_Direction
at TRISF1_bit;