Mikroelektronika MIKROE-350 Fiche De Données

Page de 526
TWI LIBRARY
TWI full master MSSP module is available with a number of AVR MCU models. mikroBasic PRO
for AVR provides library which supports the master TWI mode.
Library Routines
- TWI_Init 
- TWI_Busy 
- TWI_Start 
- TWI_Stop 
- TWI_Read 
- TWI_Write 
- TWI_Status 
- TWI_Close 
TWI_Init
TWI_Busy
465
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
mikroBasic PRO for AVR
Introduction
CHAPTER 1
Prototype
sub procedure TWI_Init(dim clock as longword)
Returns
Nothing.
Description
Initializes TWI with desired 
clock
(refer to device data sheet for correct values
in respect with Fosc). Needs to be called before using other functions of TWI
Library.
You don’t need to configure ports manually for using the module; library will take
care of the initialization.
Requires
Library requires MSSP module on PORTB or PORTC.
Example
TWI_Init(100000)
Prototype
sub function TWI_Busy() as byte
Returns
Returns 0 if TWI start sequnce is finished, 1 if TWI start sequnce is not finished.
Description
Signalizes the status of TWI bus.
Requires
TWI must be configured before using this function. See TWI_Init.
Example
if (TWI_Busy = 1) 
...
end if