Monday 25 June 2007

Bodge it and move on

The I²C nightmare continues. I thought slowing the clock of the MSP430 had fixed the problem. However, it still locks up after a few packets. The symptoms are that the MC9S12NE64 decides that the MSP430 has not ACKed the address byte. At this point both clock and data are low. The MC9S12NE64 sends a stop and both lines go high. It then thinks the bus is permanently busy. If I reset the MC9S12NE64 then it works for a while again so the MSP430 is not locked up.

So my first bodge was to detect the MC9S12NE64 thinking the bus is busy when it should not be and reset its I²C module. This caused it to lock up thinking the bus was not busy when it should have been. In desperation I added a 100us delay after the reset and now it works.

It looks like my digital scope will not arrive for at least a couple of weeks so I can't really get to the bottom of this until then but at least it is working with retries. I haven't done a lot of I²C stuff in my career but it looks like a really clever protocol. Less wires than SPI but has defined start and stop codes, multi-master arbitration and auto clocking down to the slowest device. As both ends implement it in hardware I just expected it to work. I should have known better as most hardware has bugs these days like all software.

No comments:

Post a Comment