User manual

Table Of Contents
436
mikoC PRO for PIC32
MikroElektronika
Parameters
Returns Nothing.
Requires MCU must have the SPI module.
Example
// Set SPI1 to the Master Mode, data length is 16-bit, clock = Fcy (no clock
scaling), data sampled in the middle of interval, clock IDLE state high and
data transmitted at low to high clock edge:
SPI1_Init_Advanced(_SPI_MASTER, _SPI_16_BIT, 1, _SPI_SS_DISABLE, _SPI_DATA_
SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_ACTIVE_2_IDLE);
Notes SPI library routines require you to specify the module you want to use. To select the desired SPI
module, simply change the letter x in the routine prototype for a number from 1 to 3.
Number of SPI modules per MCU differs from chip to chip. Please, read the appropriate datasheet
before utilizing this library.
Clock Polarity
Description Predened library const
IDLE state is Lo, ACTIVE state is Hi _SPI_CLK_IDLE_LOW
IDLE state is Hi, ACTIVE state is Lo _SPI_CLK_IDLE_HIGH
Clock Edge
Description Predened library const
Data is valid on ACTIVE-to-IDLE transition _SPI_ACTIVE_2_IDLE
Data is valid on IDLE-to-ACTIVE transition _SPI_IDLE_2_ACTIVE
The parameter clock_idle determines the behaviour of the SPI clock (CLK) line in IDLE phase.
The parameter edge determines on which clock edge data is considered to be valid.