User`s manual
SPI (Serial Peripheral Interface) module is available with a number of PIC MCU
models. Set of library procedures and functions is listed below to provide initial-
ization of slave mode and comfortable work with the master mode.
You can easily communicate with other devices via SPI - A/D converters, D/A
converters, MAX7219, LTC1290 etc. You need PIC MCU with hardware integrat-
ed SPI (for example, PIC16F877). Then, simply use the following functions and
procedures.
Note that these functions support module on PORTC, and won't work with mod-
ules on other ports. Examples for PIC MCUs with module on other ports can be
found in your mikroBasic installation folder, subfolder 'examples'.
You can use procedure
SPI_init without parameters and get the default result:
Master mode, clock Fosc/4, clock idle state low, data transmitted on low to high
edge, input data sampled at the middle of interval;
For advanced settings, configure and initialize SPI using the procedure:
sub procedure SPI_Init_advanced(dim Master as byte,
dim Data_Sample as byte, dim Clock_Idle as byte,
dim Low_To_High as byte)
mikroBASIC
- Basic Compiler for Microchip PIC microcontrollers
156
mikroBASIC
MikroElektronika: Development tools - Books - Compilers
making it simple...
page
SPI Library
Note
sub procedure SPI_init
sub procedure SPI_write(dim Data as byte)
sub function SPI_read(dim Buffer as byte) as byte
sub procedure SPI_Init_advanced(dim Master as byte,
dim Data_Sample as byte, dim Clock_Idle as byte,dim Low_To_High as byte)
Routines
Initialization