Mikroelektronika MIKROE-738 Datenbogen

Seite von 682
mikroC PRO for PIC32
MikroElektronika
421
Software SPI Library
The  mikroC  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 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. 
The library configures 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 defined 
in  all  projects  using  Software  SPI 
Library:
Description:
Example:
extern sfr sbit SoftSpi_SDI;
Data In line.
sbit SoftSpi_SDI at RF4_bit;
extern sfr sbit SoftSpi_SDO;
Data Out line.
sbit SoftSpi_SDO at LATF3_bit;
extern sfr sbit SoftSpi_CLK;
Clock line.
sbit SoftSpi_CLK at LATF6_bit;
extern  sfr  sbit  SoftSpi_SDI_
Direction;
Direction of the Data In pin.
sbit SoftSpi_SDI_Direction at TRISF4_
bit;
extern  sfr  sbit  SoftSpi_SDO_
Direction;
Direction of the Data Out pin
sbit SoftSpi_SDO_Direction at TRISF3_
bit;
extern  sfr  sbit  SoftSpi_CLK_
Direction;
Direction of the Clock pin.
sbit SoftSpi_CLK_Direction at TRISF6_
bit;
External dependencies of Software SPI Library
Library Routines
 
- Soft_SPI_Init 
 
- Soft_SPI_Read 
 
- Soft_SPI_Write