Mikroelektronika MIKROE-350 Datenbogen
![Mikroelektronika](https://files.manualsbrain.com/attachments/e0529b3b58069a916ad7bb89f7e9f5f0eda73421/common/fit/150/50/1b07b99aa3112e022a916b06db07f1f4f211e91d41878452d87c7638b1bf/brand_logo.gif)
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.
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.
- 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.
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
sbit sfr external
Chip select line.
dim Chip_Select as
sbit at PORTB.B0
sbit at PORTB.B0
dim SoftSpi_SDI as
sbit sfr external
sbit sfr external
Data In line.
dim SoftSpi_SDI as
sbit at PINB.B6
sbit at PINB.B6
dim SoftSpi_SDO as
sbit sfr external
sbit sfr external
Data Out line.
dim SoftSpi_SDO as
sbit at PORTB.B5
sbit at PORTB.B5
dim SoftSpi_CLK as
sbit sfr external
sbit sfr external
Clock line.
dim SoftSpi_CLK as
sbit at PORTB.B7
sbit at PORTB.B7
dim
Chip_Select_Direction
as sbit sfr external
Chip_Select_Direction
as sbit sfr external
Direction of the Chip
Select pin.
Select pin.
dim
Chip_Select_Direction
as sbit at DDRB.B0
Chip_Select_Direction
as sbit at DDRB.B0
dim
SoftSpi_SDI_Direction
as sbit sfr external
SoftSpi_SDI_Direction
as sbit sfr external
Direction of the Data In
pin.
pin.
dim
SoftSpi_SDI_Direction
as sbit at DDRB.B6
SoftSpi_SDI_Direction
as sbit at DDRB.B6
dim
SoftSpi_SDO_Direction
as sbit sfr external
SoftSpi_SDO_Direction
as sbit sfr external
Direction of the Data Out
pin
pin
dim
SoftSpi_SDO_Direction
as sbit at DDRB.B5
SoftSpi_SDO_Direction
as sbit at DDRB.B5
dim
SoftSpi_CLK_Direction
as sbit sfr external
SoftSpi_CLK_Direction
as sbit sfr external
Direction of the Clock pin.
dim
SoftSpi_CLK_Direction
as sbit at DDRB.B7
SoftSpi_CLK_Direction
as sbit at DDRB.B7