Mikroelektronika MIKROE-350 Datenbogen

Seite von 526
CANSPI LIBRARY
The SPI module is available with a number of the AVR compliant MCUs. The
mikroBasic PRO for AVR provides a library (driver) for working with mikroElektroni-
ka's CANSPI Add-on boards (with MCP2515 or MCP2510) via SPI interface.
The CAN is a very robust protocol that has error detection and signalization,
self–checking and fault confinement. Faulty CAN data and remote frames are re-
transmitted automatically, similar to the Ethernet.
Data transfer rates depend on distance. For example, 1 Mbit/s can be achieved at
network lengths below 40m while 250 Kbit/s can be achieved at network lengths
below 250m. The greater distance the lower maximum bitrate that can be achieved.
The lowest bitrate defined by the standard is 200Kbit/s. Cables used are shielded
twisted pairs.
CAN supports two message formats:
- Standard format, with 11 identifier bits and 
- Extended format, with 29 identifier bits 
Note: 
- Consult the CAN standard about CAN bus termination resistance. 
- An effective CANSPI communication speed depends on SPI and certainly is 
slower than “real” CAN. 
- CANSPI module refers to mikroElektronika's CANSPI Add-on board connected to  
SPI module of MCU. 
- Prior to calling any of this library routines, Spi_Rd_Ptr needs to be initialized with 
the appropriate SPI_Read routine. 
172
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6