User manual
455
mikoPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
Software SPI Library
The mikroPascal PRO for dsPIC30/33 and PIC24 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 conguration:
- 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 congures 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 dened 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