mikroElektronika PIC Microcontrollers PIC12 User Manual page 275

Mikroc user's manual
Table of Contents

Advertisement

mikroC
making it simple...
Spi_Init_Advanced
Prototype
void Spi_Init_Advanced(char master, char data_sample, char
clock_idle, char transmit_edge);
Description
Configures and initializes SPI.
before using other functions of SPI Library.
Parameter
The
Parameter
Parameter
Requires
You need PIC MCU with hardware integrated SPI.
Example
This will set SPI to master mode, clock = Fosc/4, data sampled at the middle of interval,
clock idle state low and data transmitted at low to high edge:
Spi_Init_Advanced(MASTER_OSC_DIV4, DATA_SAMPLE_MIDDLE,
CLK_IDLE_LOW, LOW_2_HIGH)
MikroElektronika: Development tools - Books - Compilers
determines the work mode for SPI; can have the values:
mast_slav
// Master clock=Fosc/4
MASTER_OSC_DIV4
// Master clock=Fosc/16
MASTER_OSC_DIV16
MASTER_OSC_DIV64
// Master clock=Fosc/64
MASTER_TMR2
// Master clock source TMR2
SLAVE_SS_ENABLE
// Master Slave select enabled
SLAVE_SS_DIS
// Master Slave select disabled
determines when data is sampled; can have the values:
data_sample
DATA_SAMPLE_MIDDLE // Input data sampled in middle of interval
DATA_SAMPLE_END
// Input data sampled at the end of interva
determines idle state for clock; can have the following values:
clock_idle
CLK_IDLE_HIGH
// Clock idle HIGH
CLK_IDLE_LOW
// Clock idle LOW
transmit_edge
LOW_2_HIGH
// Data transmit on low to high edge
HIGH_2_LOW
// Data transmit on high to low edge
mikroC - C Compiler for Microchip PIC microcontrollers
Spi_Init_Advanced
can have the following values:
or
needs to be called
SPI_Init
l
page
267

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the PIC Microcontrollers PIC12 and is the answer not in the manual?

This manual is also suitable for:

Pic microcontrollers pic16Pic microcontrollers pic18

Table of Contents