Mikroelektronika MIKROE-350 Fiche De Données

Page de 526
SPI LIBRARY
mikroBasic PRO for AVR provides a library for comfortable with SPI work in Master mode. The
AVR MCU can easily communicate with other devices via SPI: A/D converters, D/A converters,
MAX7219, LTC1290, etc. 
Note: Some AVR MCU's have alternative SPI ports, which SPI signals can be redirected to by
setting or clearing SPIPS (SPI Pin Select) bit of the MCUCR register. Please consult the appro-
priate datasheet.
Library Routines
- SPI1_Init 
- SPI1_Init_Advanced 
- SPI1_Read 
- SPI1_Write 
- SPI1_Init
SPI1_Init
362
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6
Prototype
sub procedure SPI1_Init()
Returns
Nothing.
Description
This routine configures and enables SPI module with the following settings:
- master mode 
- 8 bit data transfer 
- most significant bit sent first 
- serial clock low when idle 
- data sampled on leading edge 
- serial clock = fosc/4 
Requires
MCU must have SPI module.
Example
' Initialize the SPI module with default settings
SPI1_Init()