Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
SPI1_Init_Advanced 
375
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6
Prototype
procedure SPI1_Init_Advanced(mode : byte; fcy_div : byte;
and_edge : byte)
Returns
Nothing.
Description
Configures and initializes SPI. SPI1_Init_Advanced or SPI1_Init needs to be
called before using other functions of SPI Library.
Parameters 
mode, fcy_div
and 
clock_and_edge
determine the work mode for
SPI, and can have the following values:
Note: Some SPI clock speeds are not supported by all AVR MCUs and these
are: Fosc/2, Fosc/8, Fosc/32. Please consult appropriate datasheet. 
Mask
Description
Predefined library const
SPI mode constants:
0x10
Master mode
_SPI_MASTER
0x00
Slave mode
_SPI_SLAVE
Clock rate select constants:
0x00
Sck = Fosc/4, Master mode
_SPI_FCY_DIV4
0x01
Sck = Fosc/16, Master mode _SPI_FCY_DIV16
0x02
Sck = Fosc/64, Master mode _SPI_FCY_DIV64
0x03
Sck = Fosc/128, Master mode _SPI_FCY_DIV128
0x04
Sck = Fosc/2, Master mode
_SPI_FCY_DIV2
0x05
Sck = Fosc/8, Master mode
_SPI_FCY_DIV8
0x06
Sck = Fosc/32, Master mode _SPI_FCY_DIV32
SPI clock polarity and phase constants:
0x00
Clock idle level is low,
sample on rising edge
_SPI_CLK_LO_LEADING
0x04
Clock idle level is low,
sample on falling edge
_SPI_CLK_LO_TRAILING
0x08
Clock idle level is high,
sample on rising edge
_SPI_CLK_HI_LEADING
0x0C
Clock idle level is high,
sample on falling edge
_SPI_CLK_HI_TRAILING