User manual

Table Of Contents
mikroC PRO for PIC32
MikroElektronika
435
SPIx_Init_Advanced
Prototype
void SPIx_Init_Advanced(unsigned master_mode, unsigned data_mode, unsigned
clock_divider, unsigned slave_select, unsigned data_sample, unsigned clock_
idle, unsigned edge);
Description Congures and initializes the SPI module with user dened settings.
Parameters Parameters master_mode, data_mode, clock_divider, slave_select, data_sample,
clock_idle and determine the working mode for SPI.
The master_mode parameter determines the working mode for SPI module.
Master/Slave mode
Description Predened library const
Master mode _SPI_MASTER
Slave mode _SPI_SLAVE
Data Length Mode
Description Predened library const
32-bit mode _SPI_32_BIT
16-bit mode _SPI_16_BIT
8-bit mode _SPI_8_BIT
Clock Divider Value
Valid values from 2 to 1024
The parameter data_mode the data length mode, which can be 8-bits (per transmitions cycle), 16-bits
or 32-bits.
The parameter clock_divider determines the value of the SPI clock speed. Used only in the Master
Mode.
The parameter slave_select determines whether the Slave Select (SS) pin is used in communication.
Valid in the Slave Mode only.
Slave Select Enable/Disable
Description Predened library const
SS used for the Slave mode _SPI_SS_ENABLE
SS not used for the Slave mode _SPI_SS_DISABLE
The parameter data_sample determines the sample moment (phase) of input data.
Data Sampling Moment
Description Predened library const
Data sampled in the middle of data output
time
_SPI_DATA_SAMPLE_MIDDLE
Data sampled at end of data output time _SPI_DATA_SAMPLE_END