Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
CANSPI LIBRARY
The SPI module is available with a number of the AVR compliant MCUs. The mikroPascal PRO
for AVR provides a library (driver) for working with mikroElektronika'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 stan-
dard 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 slow
er 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.
External dependencies of CANSPI Library
187
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6
The following variables must be
defined in all projects using
Sound Library:
Description: 
Example : 
var CanSpi_CS : sbit; sfr;
external;
Chip Select line.
var CanSpi_CS : sbit at
PORTB.B0;
var CanSpi_Rst : sbit; sfr;
external;
Reset line.
var CanSpi_Rst : sbit at
PORTB.B2;
var CanSpi_CS_Bit_Direction :
sbit; sfr; external;
Direction of the Chip
Select pin.
var CanSpi_CS_Bit_Direction
sbit at DDRB.B0;
var CanSpi_Rst_Bit_Direction
sbit; sfr; external;
Direction of the
Reset pin.
var CanSpi_Rst_Bit_Direction
sbit at DDRB.B2;