I’m seeing some very weird behavior that we can’t explain. The way the code is working now, we have an external computer sending commands to the Hercules through its serial port. The Hercules is running a debug command manager that translates the requests into I2C commands. So at its simplest, we are doing repeated I2C writes and reads to and from an EEPROM. The commands look like this:
Loop (
i2c write 50 0
i2c read 50 2 )
So all we’re doing is writing an EEPROM address of 0 to the EEPROM (I2C ID 0x50) and then reading back two bytes starting at address 0. This works fine most of the time, but occasionally instead of the write command working as expected, we see it send the I2C address and data (0x00) with no I2C Stop followed immediately by a Restart and the I2C address but no data. There IS a Stop after this address. This is much easier to explain looking at the scope trace in “badI2C.pdf” attached. I’ve also attached the “goodI2C.pdf” that shows what it’s supposed to look like. We can’t find anything in the software (built using Mentor Graphics Nucleus drivers) that explains the occurrence of the restart and the subsequent I2C address without any data. The write in the first part of this sequence is not successful, and the read of the EEPROM gets the wrong data back (reads from an address shifted one bit to the left). Can you please take a look and see if you can think of what could cause the Restart to occur? Does the hardware have the capability to create the Restart without being commanded to by the software? One other note is that putting some delay between the read and the write seems to help prevent the problem. Even without the delay, there seems to be plenty of time for the read to finish, so it doesn’t appear that the I2C calls are overlapping at all.
Thanks!
Dave Mack