Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
SOFTWARE SPI LIBRARY
The mikroPacal PRO for AVR provides routines for implementing Software SPI com-
munication. These routines are hardware independent and can be used with any
MCU. The Software SPI Library provides easy communication with other devices via
SPI: A/D converters, D/A converters, MAX7219, LTC1290, etc.
Library configuration: 
- SPI to Master mode 
- Clock value = 20 kHz. 
- Data sampled at the middle of interval. 
- Clock idle state low. 
- Data sampled at the middle of interval. 
- Data transmitted at low to high edge. 
Note: The Software SPI library implements time-based activities, so interrupts need
to be disabled when using it.
External dependencies of Software SPI Library
359
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 Software
SPI Library:
Description: 
Example : 
var Chip_Select :
sbit; sfr; external;
Chip select line.
var Chip_Select :
sbit at PORTB.B0;
var SoftSpi_SDI :
sbit; sfr; external;
Data In line.
var SoftSpi_SDI :
sbit at PINB.B6;
var SoftSpi_SDO :
sbit; sfr; external;
Data Out line.
var SoftSpi_SDO :
sbit at PORTB.B5;
var SoftSpi_CLK :
sbit; sfr; external;
Clock line.
var SoftSpi_CLK :
sbit at PORTB.B7;
var
Chip_Select_Direction
sbit; sfr; external;
Direction of the Chip
Select pin.
var
Chip_Select_Direction
sbit at DDRB.B0;
var
SoftSpi_SDI_Direction
sbit; sfr; external;
Direction of the Data In pin.
var
SoftSpi_SDI_Direction
sbit at DDRB.B6;
var
SoftSpi_SDO_Direction
sbit; sfr; external;
Direction of the Data Out pin
var
SoftSpi_SDO_Direction
sbit at DDRB.B5;
var
SoftSpi_CLK_Direction
sbit; sfr; external;
Direction of the Clock pin.
var
SoftSpi_CLK_Direction
sbit at DDRB.B7;