Mikroelektronika MIKROE-350 Fiche De Données

Page de 526
SOFTWARE I²C LIBRARY
The mikroBasic PRO for AVR provides routines for implementing Software I˛C com-
munication. These routines are hardware independent and can be used with any
MCU. The Software I˛C library enables you to use MCU as Master in I˛C communi-
cation. Multi-master mode is not supported.
Note: This library implements time-based activities, so interrupts need to be dis-
abled when using Software I˛C.
Note: All Software I˛C Library functions are blocking-call functions (they are waiting
for I˛C clock line to become logical one).
Note: The pins used for Software I˛C communication should be connected to the
pull-up resistors. Turning off the LEDs connected to these pins may also be
required.
External dependencies of Soft_I2C Library
338
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6
The following variables
must be defined in all
projects using Soft_I2C
Library:
Description: 
Example : 
dim
Soft_I2C_Scl_Output
as sbit sfr external
Soft I2C Clock output line.
dim
Soft_I2C_Scl_Output
as sbit at PORTC.B0
dim
Soft_I2C_Sda_Output
as sbit sfr external
Soft I2C Data output line.
dim
Soft_I2C_Sda_Output
as sbit at PORTC.B1
dim
Soft_I2C_Scl_Input 
as
sbit sfr external
Soft I2C Clock input line.
dim
Soft_I2C_Scl_Input 
as
sbit at PINC.B0
dim
Soft_I2C_Sda_Input 
as
sbit sfr external
Soft I2C Data input line.
dim
Soft_I2C_Sda_Input 
as
sbit at PINC.B1
dim
Soft_I2C_Scl_Pin_Dire
ction 
as sbit sfr
external
Direction of the Soft I2C
Clock pin.
dim
Soft_I2C_Scl_Pin_Dire
ction 
as sbit at
DDRC.B0
dim
Soft_I2C_Sda_Pin_Dire
ction 
as sbit sfr
external
Direction of the Soft I2C
Data pin.
dim
Soft_I2C_Sda_Pin_Dire
ction 
as sbit at
DDRC.B1