Author Topic: I2C Repeated Start / PCA9555  (Read 4003 times)

holynoise

  • Newbie
  • *
  • Posts: 2
    • View Profile
I2C Repeated Start / PCA9555
« on: May 08, 2013, 02:15:46 PM »
Hello everybody!
I'm new here and I'm currently using the SBC65EC intensively for a home automation project with a java application server (will provide the code as open source when I'm done). A lot of things work excellent but I have troubles getting I2C to work.

For additional GPIO I have a PCA9555 I2C->GPIO chip here and I can control the output ports. That's is using the UDP->I2C Bridge. So writing (i.e. controlling the pins on a given port) works. What doesn't work is reading from a port (or a register). I understand that I have to write the config register to turn to port into an input but I2C spec of the chip says to do the dummy write and then read the registers using a repeated start condition. This, I cannot get it working. According to the spec the most straight-forward way is to do the following:

START, SLAVE_ADR(R), COMMAND_BYTE,S*,SLAVE_ADR(W), Reading some bytes and when done, STOP

My Write Address is 0x4E (that I can use to write and control ports) and my Read Address is 0x4F

How does this translate to UDP notation?

S4E00S4FR02P doesn't work. no reply. when I hook up my bus analyzer communication stops as soon as I introduce the repeated start condition (second S). Documentation on the I2C bus by Modtronix isn't very clear but my UDP String should work. I tried all combinations that I could think of but none of it worked.

PS: Yes I do S4E06FFFFP to set the ports to input before reading from it. But again, this is writing - not reading.

Here is the sheet of how to speak to the PCA9555. See Fig 12 / Page 11
http://www.nxp.com/documents/data_sheet/PCA9555.pdf


Thank you very much!

gr

  • Hero Member
  • *****
  • Posts: 171
    • View Profile
Re: I2C Repeated Start / PCA9555
« Reply #1 on: May 08, 2013, 07:38:18 PM »
I think you are going to have to modify the source code.  I haven't used this feature (I2C) but I'm wondering if maybe you can't write to 4E and then read from 4F?  Does that make sense?

I've built the SBC65EC firmware.  It isn't too hard.  I explained all the steps somewhere in this forum.

Also I hope you have an oscilloscope because I2C issues tend to be difficult to debug without one.  I have debugged I2C issues on other platforms but not this one.

holynoise

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: I2C Repeated Start / PCA9555
« Reply #2 on: May 08, 2013, 07:56:21 PM »
Thanks for the reply.

Does this mean that repeated start condition isn't officially implemented (or at least not correctly?). I can write and read on I2C (even using the UDP bridge) but repeated start condition seems to fail (shouldn't the master toggle the clock while reading so that the slave can transmit it? - Clock stands still after the second start cond as you can see on the screenshot of my logic analyzer).

A simple read from the read address doesn't work (well I get some data, but it doesn't reflect what it should).

I don't think I can improve the I2c library as this is a little bit too complex for me.

I have a scope and a logic analyzer with decoding features - it doesn't help me at the moment! All I see is that communication get's interrupted as soon as the second S is being sent (well, it never arrives on the i2c but it get's parsed by the udp handler).

There is another "bug" in the firmware. The i2c loop sends continuously on address 0x50 the first standard address of the LCD. Even when switching the address on the LCD the loop still sends on 0x50 effectively nulling any use of standard i2c components that use the default address (or 0x28 in 7bit) (as my Hygrochip HYT-221 sensor). Somebody on this forum changed the firmware without the loop issue but I really don't want to get into compilation of embedded firmware. I would use an already existing image to flash it to the board, thou...

The UDP/I2C bridge is very powerful and useful. I just managed to drive a HD44780 based LCD with a MCP23008 GPIO by sending each port value (actually pin toggles) through I2C (and Java being the app-server and sending out every pin change as UDP). It works and is quite fast. Too bad the repeated S condition seems to by buggy.

Can I assume that my UDP notation string is correct?

Thanks!




gr

  • Hero Member
  • *****
  • Posts: 171
    • View Profile
Re: I2C Repeated Start / PCA9555
« Reply #3 on: May 09, 2013, 07:38:26 AM »
>I don't think I can improve the I2c library as this is a little bit too complex for me.
Well you could at least try to see how it works so you know for sure if it even has the capability you want.

>The i2c loop sends continuously on address 0x50 the first standard address of the LCD
On the web page settings did you tell it that there is no LCD?  If you are lucky that will turn it off.

> I really don't want to get into compilation of embedded firmware.
There's a very good chance that will be your only option.  It's really not too hard.  And you can't break anything.  The bootloader firmware is in a safe, secure location that you can't write over.  It's almost impossible to brick this device through the ethernet (I think it *is* impossible) and believe me people have done everything possibly wrong.

There are lots of components in the firmware that can be added in or removed in the .h files with #define statements.  I think the LCD is probably one of them so simply changing that one line of code may fix your loop below or you could try the solution someone else offered.  Again, if you look through only my posts I have some that describe the steps to build your own firmware.
« Last Edit: July 28, 2013, 04:15:24 PM by modtro2 »