11 years, 3 months ago.

I2C Library

Hi,

I would like to know how much I2C Library implements. I'm looking to achieve multi-master / detect lost in arbitration on a I2C bus with 2 mbed and other peripheral on the line. The available library provides limited functionality. How can i get I2C state-machine state with an interrupt or something else ?

Mbed is great for some stuff but for the I2C documentation, I'm having trouble finding information on what the error code mean or what the functions return. The I2C library page gives me a " Page Not Found " Error BTW !

Thanks, Stan

I am not sure, but you can probably quite easily check it; I assume the error codes returned are equal to final status of the I2C state machine, which can be found in the user manual.

posted by Erik - 19 Jan 2013

1 Answer

11 years, 3 months ago.

Is there a way to set up a callback to be called once a master mbed is addressing the slave mbed, avoiding polling for I2CSlave::receive(). I'd like to be doing something else meanwhile.

I set up a 2 mbed bus and i got a I2C dead lock, on one mbed last return code is 0 (don't know if the function succeed or is the error code 0), on the other last return code is 248 "No relevant state information available".

Are the I2C and I2CSlave library suited for such operations ( being used at the same time on one mbed ) ?

Stan

The standard I2Cslave library has no interrupts, you can probably add them by directly addressing the I2C hardware. If it returns 0 it is probably a success.

But you want to use them as slave and master at the same time? When you use the master I2C it will probably at least disable the I2C slave. It depends on your exact requirements, but I dont think the standard library will do it for you.

posted by Erik - 20 Jan 2013

I caught the stall issue :

> Address 01 Start Status : 08

> Write return : 1 Status : 40

> Read return : 1 Status : F8

The read returns status F8 which doesn't match anything in the documentation. The reason is perhaps that the I2C Library/Driver do something meanwhile. The stall come form outputting a Stop condition on the bus. On the other end, the other mbed is at state 0xA8 " Own SLA+R has been received; ACK has been returned." Which is wired because i only enable master mode and General Call bits are 0. Does I2C master answer General call as a default behavior ?

Stan

posted by Ruaridh Clark 20 Jan 2013

It is hard to follow what is going on from this explanation. Please post code to provide more details.

The F8 status code is the reset value (see table 383 and 402 in the UM10360 LPC1768 user manual).

The master may have been enabled to respond to its own address also. Check the AA bit in the I2CxCONSET (table 381).

You should be able to use master and slave I2C on the same mbed when they are using different I2C engines. The LPC1768 has 3 I2C engines in total. Only two of them are accessible on external mbed pins.

posted by Wim Huiskamp 20 Jan 2013