Category:I2C Library

From Pinguino-Wiki
Jump to: navigation, search

Contents

Purpose

I2C is a multi-purpose, multi-master bus for communications between integrated circuits. It is a 2-wire serial interface commonly used in embedded systems.

The Pinguino I2C library allows for your programs to communicate over this bus/protocol.

Functions

See under Pages in category "I2C Library" below.

Compatible Boards/Compatibility

How to Use/Include

I2C Addresses

7-bit I2C Addresses

The majority of I2C devices use 7-bit addresses, although there is a variety of ways in which the addresses are quoted in the various device data sheets.

Where 7-bit I2C addresses are used the Pinguino I2C library assumes that the 7-bit address occupies the 7 most significant bits of an 8 bit byte and that the least significant bit, which is used for Read/Write (R/W) indication, is 0 (zero) i.e. the address used is the write address of the device, X X X X X X X 0, where the Xs represent the 7 bits of the I2C address. You will need to consult the particular device datasheet to make sure that you have the I2C address in the correct format.

For example the PCF8563 Real-time clock calendar product data sheet quotes a write address of A2h and a read address of A3h. Since the write and read addresses differ by 1 (one) and they are both > 0x7F the required address is 0xA2.
Similary, the Bosch BMP085 Digital pressure sensor data sheet quotes a write address of 0xEE and a read address of 0xEF so the required address is 0xEE.
However, the Bosch BMA180 accelerometer data sheet quotes two address 40h and 41h, but on further examination of the datasheet it is clear that these two addresses correspond to different settings of one of the device pins and do not include the R/W bit so the required address will be either 0x80 or 0x82 depending on the setting of the device pin.

10-bit I2C Addresses

For a 10-bit address, the address is used "as is" without including a R/W bit. This may seem inconsistent with how the 7-bit address is dealt with, but is due to how 10-bit addresses are specified in the I2C specification.

Examples

Known Bugs/Limitations

The current implementation of the 8bits / I2C library (April 2014) allows

- single master operations with peripheral slave devices as PCF8574, PCF8593, DS1307, etc...(not MCU)

- single master operations with a slave MCU

See Also

  • Further details on I2C communications can be found in Philips Semiconductors "The I2C-BUS Specification", Version 2.1, January 2000, document order number: 9398 393 40011.
  • Details of support for I2C communication on the Microchip PIC18F2455/2550/4455/4550 can be found in the PIC18F2455/2550/4455/4550 Data Sheet, Section 19.4, I2C Mode, document DS39632E, Revision E, August 2008.
  • Details of support for I2C communication on the Microchip PIC18F26J50 can be found in the PIC18F46J50 Family Data Sheet, Section 19.5, I2C Mode, document DS39931D, Revision D, March 2011.
  • Details of support for I2C communication on the Microchip PIC18F47J53 can be found in the PIC18F47J53 Family Data Sheet, Section 20.5, I2C Mode, document DS39964B, Revision B, June 2010.
  • Details of support for I2C communication on the Microchip PIC32 series can be found in the PIC32 Family Reference Manual, Section 24. Inter-Integrated Circuit (I2C), document DS61116E, Revision E, October 2011.

Other Comments/Suggestions

Corrections, suggestions, and new documentation can be made directly on this Wiki

Library Functions

Personal tools