User manual

mikroPascal PRO for PIC32
MikroElektronika
383
Software SPI Library
The mikroPascal PRO for PIC32 provides routines for implementing Software SPI communication. 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 conguration:
- 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.
The library congures SPI to the master mode, clock = 20kHz, data sampled at the middle of interval, clock idle state
low and data transmitted at low to high edge.
Important : The Software SPI library implements time-based activities, so interrupts need to be disabled when using it.
The following variables must be dened
in all projects using Software SPI
Library:
Description: Example:
var SoftSpi_SDI : sbit; sfr;
external;
Data In line.
var SoftSpi_SDI : sbit at RF2_bit;
var SoftSpi_SDO : sbit; sfr;
external;
Data Out line.
var SoftSpi_SDO : sbit at LATF3_
bit;
var SoftSpi_CLK : sbit; sfr;
external;
Clock line.
var SoftSpi_CLK : sbit at LATF6_
bit;
var SoftSpi_SDI_Direction :
sbit; sfr; external;
Direction of the Data In pin.
var SoftSpi_SDI_Direction : sbit at
TRISF2_bit;
var SoftSpi_SDO_Direction :
sbit; sfr; external;
Direction of the Data Out pin
var SoftSpi_SDO_Direction : sbit at
TRISF3_bit;
var SoftSpi_CLK_Direction :
sbit; sfr; external;
Direction of the Clock pin.
var SoftSpi_CLK_Direction : sbit at
TRISF6_bit;
External dependencies of Software SPI Library
Library Routines
- Soft_SPI_Init
- Soft_SPI_Read
- Soft_SPI_Write