I'm using the nrf51822 TWI library. I've tried both twi hardware and software master library files and see the same behavior when using both (as a side note an explanation of the difference would be helpful.) I have 3 I2C chips wired to the NRF51822 all with distinct addresses that are wired according to their datasheets. I am reading the SCL/SDA lines with a logic analyzer and I am occasionally seeing an issue that causes bad writes. I've included a screenshot of the analyzer output.
This shows 2 one-byte writes, the first one to address 30 is correct. The device has write address 0x30, I am writing to register 0x33, and the value being written is 0x32. However, the next write should be a write to device address 0x30, register 0x30 with value 0x95, however that is not what is happening. It looks to me like the clock line is very briefly going low at the same time as the data line goes low (where I circled in red). As far as I can see with the resolution of the analyzer, the high-to-low edge on SCL and SDA occur at the same time.
(if you right click on the image and download it, you can see the details more clearly)
This issue does not always occur at one place. Sometimes I don't see it, and when I do it's not always on the same write. I've tried putting in long delays between each write to make sure that the slave has finished the write, but that didn't make any difference. I also have seen it on more than one of the three slave devices. Finally, I will also mention that the SCL and SDA lines both have 10K pullup resistors to the NRF51822's VCC rail.
I'm not very experienced using I2C so I've hit a wall debugging this. It doesn't seem like a code issue on the NRF51822, which leads me to think that it might be a wiring issue, but there isn't much I could change other than maybe the pull-up resistor values.
Any help or suggestions will be greatly appreciated!