Mikroelektronika MIKROE-350 Datenbogen

Seite von 526
SOFTWARE SPI LIBRARY
The mikroBasic 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
346
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6
The following variables
must be defined in all
projects using Software
SPI Library:
Description: 
Example : 
dim Chip_Select as
sbit sfr external
Chip select line.
dim Chip_Select as
sbit at 
PORTB.B0
dim SoftSpi_SDI as
sbit sfr external
Data In line.
dim SoftSpi_SDI as
sbit at 
PINB.B6
dim SoftSpi_SDO as
sbit sfr external
Data Out line.
dim SoftSpi_SDO as
sbit at 
PORTB.B5
dim SoftSpi_CLK as
sbit sfr external
Clock line.
dim SoftSpi_CLK as
sbit at 
PORTB.B7
dim
Chip_Select_Direction
as sbit sfr external
Direction of the Chip
Select pin.
dim
Chip_Select_Direction
as sbit at DDRB.B0
dim
SoftSpi_SDI_Direction
as sbit sfr external
Direction of the Data In
pin.
dim
SoftSpi_SDI_Direction
as sbit at DDRB.B6
dim
SoftSpi_SDO_Direction
as sbit sfr external
Direction of the Data Out
pin
dim
SoftSpi_SDO_Direction
as sbit at DDRB.B5
dim
SoftSpi_CLK_Direction
as sbit sfr external
Direction of the Clock pin.
dim
SoftSpi_CLK_Direction
as sbit at DDRB.B7