Datasheet

SOFTWARE SPI LIBRARY
The mikroC PRO for AVR provides routines for implementing Software SPI commu-
nication. 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
410
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6
The following variables
must be defined in all
projects using Software
SPI Library:
Description: Example :
extern sfr sbit
Chip_Select;
Chip select line.
sbit Chip_Select at
PORTB.B0;
extern sfr sbit
SoftSpi_SDI;
Data In line.
sbit SoftSpi_SDI at
PINB.B6;
extern sfr sbit
SoftSpi_SDO;
Data Out line.
sbit SoftSpi_SDO at
PORTB.B5;
extern sfr sbit
SoftSpi_CLK;
Clock line.
sbit SoftSpi_CLK at
PORTB.B7;
extern sfr sbit
Chip_Select;
Direction of the Chip
select pin.
sbit Chip_Select at
PINB.B6;
extern sfr sbit
Chip_Select_Direction;
Direction of the Data In
pin.
sbit
Chip_Select_Direction
at DDRB.B0;
extern sfr sbit
SoftSpi_SDO_Direction;
Direction of the Data Out
pin
sbit
SoftSpi_SDO_Direction
at DDRB.B5;
extern sfr sbit
SoftSpi_CLK_Direction;
Direction of the Clock pin.
sbit
SoftSpi_CLK_Direction
at DDRB.B7;