I2C Slave with more than 1 address...?

11 Dec 2011

Hello there,

I'm trying to use mbed as "man-in-the-middle"-device to manipulate data beeing transmitted between an industrial controller and its user-interface. I can interact with the display-unit, which holds a SAA1064 (7-Segment driver) and a PCF8494C (2 x 256 byte EEProm). No problem so far.

Now I want to receive data beeing sent to the display, manipulate and transmit it, in neccessary. Won't be the problem, if there only was one receiver; but the eeprom is in use too, of course, an is beeing accessed both for reading and writing...

As I understand the documentation about mbed library, I can only set one address to listen to in slave mode and address "0", which is a general read-command for all slaves. So at least I need to listen to the addresses 0x70, 0xa8 and 0xaa - could this be done with existing librarys?

Since I'm new to C++ I'd be glad to receive an answer I'm able to understand with little (but slowly growing) knowledge... :-)

Thanks for reading and help in advance!

Michael

11 Dec 2011

Maybe you could use 3 I2CSlaves, giving each one of your addresses?

11 Dec 2011

Hello Rene,

thanks for your answer!

I haven't tried to create 3 instances of the slave interface, because I couldn't imagine this could be possible!

But I'll try this - when it's possible to create many Tickers (for example) it could work with I2CSlave also...

Thanks, Michael

11 Dec 2011

I dont think you can use multiple instances of I2C using the same set of pins and responding to different slave addresses simultaneously. You could use multiple I2C slaves using different pins, where each of them reponds to a different slave address. Note that the lpc1768 has 3 I2C engines, 2 of which are accessible on the mbed pins (p9&p10, p28&p27). You would then have to connect these pins externally (SCL to SCL, SDA to SDA). A better solution would be to use the I2C engines capability to respond to 4 different slave addresses. This feature is documented in the datasheets (chapter 19). However, it is not supported in the current mbed libs and you would have to develop code for that yourself.

11 Dec 2011

Right, that's the wrong way :)

But it could be possible to set mask value SlaveAddrMaskValue (see the http://mbed.org/users/igorsk/programs/DriverLibrary/601ro/docs/structI2C__OWNSLAVEADDR__CFG__Type.html) so, that all messages are received. So need to find out how to set this value and which address the currently received message belongs to.

12 Dec 2011

Hello Rene + Wim,

thanks for thinking about my issue. Looks if my assumption was right that listening to more than one address could not be done without further care... When I understand things right and I would setup 3 instances of I2C_Slave (like Rene wrote before) only the last defined address would be taken in account?

Now I'll dig into it and try to find out how to set the mask value - but it might not really be neccessary to do, as there only will be three addresses which will be sent on the bus (and I'll have to determine which is the actual one if a message arrives).

Thanks!

12 Dec 2011

Hi, if just 3 addresses are sent over the bus, of course you can set the complete mask to 0, not just some bits. Hope it helps you. I never played with it, just read some docs.