mikroC

mikroC - C Compiler for Microchip PIC microcontrollers

making it simple...

Software I2C Library

mikroC provides routines which implement software I²C. These routines are hardware independent and can be used with any MCU. Software I2C enables you to use MCU as Master in I2C communication. Multi-master mode is not supported.

Note: This library implements time-based activities, so interrupts need to be disabled when using Soft I²C.

Library Routines

Soft_I2C_Config

Soft_I2C_Start

Soft_I2C_Read

Soft_I2C_Write

Soft_I2C_Stop

Soft_I2C_Config

Prototype

void Soft_I2C_Config(char *port, const char SDI, const char SD0,

 

const char SCK);

 

 

Description

Configures software I²C. Parameter port specifies port of MCU on which SDA and SCL

 

pins are located. Parameters SCL and SDA need to be in range 0–7 and cannot point at

 

the same pin.

 

Soft_I2C_Config needs to be called before using other functions from Soft I2C

 

Library.

 

 

Example

Soft_I2C_Config(PORTB, 1, 2);

 

 

page

 

254

MikroElektronika: Development tools - Books - Compilers