mikroC - C Compiler for Microchip PIC microcontrollers
Software SPI Library
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.
Library Routines
Soft_Spi_Config
Soft_Spi_Read
Soft_Spi_Write
Soft_Spi_Config
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
range 0–7 and cannot point at the same pin.
Soft_Spi_Config
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);
page
258
needs to be called before using other functions from Soft SPI
MikroElektronika: Development tools - Books - Compilers
making it simple...
,
, and
need to be in
SDI
SDO
SCK
mikroC
Need help?
Do you have a question about the PIC Microcontrollers PIC12 and is the answer not in the manual?