How to use I2C0

16 Apr 2012

How do I utilize I2C0? In an existing custom design, pins 9,10 (I2C1) and 27,28 (I2C2) are already used. To add an I2C device to the design I need to use I2C0. The mbed libraries only allow the use of I2C1 & 2. Does anyone have any code that uses I2C0? or is there any way to modify the mbed library functions to use I2C0? I'm hoping I don't have to re-invent the wheel and write to the bare registers. It seems like a non-trivial state machine.

16 Apr 2012

The problem with I2C0 is not so much the library. The problem is that the pins for I2C0 (p0.28, P0.27) are not available on any of the external mbed pins. See table on http://mbed.org/users/Lerche/notebook/lpc1768-pin-functions/

So you would have to fix the software and add some wiring. Don't recommend that. See if you can modify your code to use I2C1 or I2C2 instead, or look into adding an external I2C multiplexer (nxp has several devices) or add some other device like a UART-to-I2C converter.

17 Apr 2012

I recently had to write a software i2c library for the same reason, not sure about performance, but it works (at least in my test case of 1 device),

Import librarySoftwareI2C

First release of a Software I2C implementation, Tested and confirmed to work with the BMP085 Barometric Pressure Sensor

Wouldnt recommend using a software hack for anything serious though

18 Apr 2012

I have compiled with

I2C MyI2C (P0_27,P0_28);

but not tested functionality, yet.

Will tell you if it works on my custom board.

Ceri.

11 Oct 2016

Hi Ceri, Did that work on your custom board?

David.

ceri clatworthy wrote:

I have compiled with

I2C MyI2C (P0_27,P0_28);

but not tested functionality, yet.

Will tell you if it works on my custom board.

Ceri.