Mikroelektronika MIKROE-442 데이터 시트
450
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
Software I²C Library
The mikroBasic PRO for dsPIC30/33 and PIC24 provides routines for implementing Software I²C communication.
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 communication. Multi-master mode is not supported.
Important:
- This library implements time-based activities, so interrupts need to be disabled when using Software I²C.
- All Software I²C Library functions are blocking-call functions (they are waiting for I²C clock line to become logical
one).
- The pins used for the Software I²C communication should be connected to the pull-up resistors. Turning off the
LEDs connected to these pins may also be required.
- Every Software I²C library routine has its own counterpart in Hardware I²C library, except
I2C_Repeated_Start.
Soft_I2C_Start
is used instead of
I2C_Repeated_Start
.
- Working clock frequency of the Software I²C is 20kHz.
The following variable must be defined in all
projects using RS-485 Library:
Description:
Example:
dim Soft_I2C_Scl as sbit sfr external
Soft I²C Clock line.
dim Soft_I2C_Scl as sbit at RF3_bit
dim Soft_I2C_Sda as sbit sfr external
Soft I²C Data line.
dim Soft_I2C_Sda as sbit at RF2_bit
dim Soft_I2C_Scl_Direction as sbit
sfr external
Direction of the Soft I²C
Clock pin.
dim Soft_I2C_Scl_Direction as sbit
at TRISF3_bit
dim Soft_I2C_Sda_Direction as sbit
sfr external
Direction of the Soft I²C
Data pin.
dim Soft_I2C_Sda_Direction as sbit
at TRISF2_bit
External dependencies of Software I²C Library
Library Routines
- Soft_I2C_Init
- Soft_I2C_Start
- Soft_I2C_Read
- Soft_I2C_Write
- Soft_I2C_Stop
- Soft_I2C_Break