ABL electronic PIC12 Personal Computer User Manual


 
mikroC provides library which implement software SPI. These routines are hard-
ware independent and can be used with any MCU. You can easily communicate
with other devices via SPI: A/D converters, D/A converters, MAX7219, LTC1290,
etc.
Note: These functions implement time-based activities, so interrupts need to be
disabled when using the library.
Soft_Spi_Config
Soft_Spi_Read
Soft_Spi_Write
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
25 8
MikroElektronika:
Development
tools
-
Books
-
Compilers
page
Software SPI Library
Library Routines
Prototype
void Soft_Spi_Config(char *port, const char SDI, const char SD0,
const char SCK);
Description Configures and initializes software SPI. Parameter port specifies port of MCU on which
SDI, SDO, and SCK pins will be located. Parameters SDI, SDO, and SCK need to be in
range 0–7 and cannot point at the same pin.
Soft_Spi_Config needs to be called before using other functions from Soft SPI
Library.
Example This will set SPI to master mode, clock = 50kHz, data sampled at the middle of interval,
clock idle state low and data transmitted at low to high edge. SDI pin is RB1, SDO pin
is RB2 and SCK pin is RB3:
Soft_Spi_Config(PORTB, 1, 2, 3);
Soft_Spi_Config