Sam Skuce

IIC Not Sending 'Stop' Bit

Discussion created by Sam Skuce on Feb 8, 2007
Latest reply on Feb 8, 2007 by Sam Skuce
I'm using CW 5.7.0 with an MC9S08GB60, in the Softech-HCS08 starter kit. I've got the following loop in my code, waiting for an EEPROM to burn. The loop continually Starts the IIC bus, sends a command to EEPROM, stops the bus, and loops again if no ACK bit was received. What I am seeing when I step through the code is the second time I go through this loop, when the IIC1C_MST = 0 line is executed, is the clock line (SCL) is raised, but the data line (SDA) stays low, i.e. there is no stop bit sent (the first time the master bit is lowered, the stop bit is sent just fine). This causes the IIC1S_BUSY bit to lock at a 1, and I have to power-cycle (not just reset, power-cycle) the board to make it low again. I'm sure there are other ways I can do this loop, but this behavior seems ... out of specification. Is there some subtlety to the IIC I'm not respecting?

IIC1C_MST = 1; /* Send start signal to start polling process. */
IIC1D = COMMAND_BYTE | 0x01; /* Send read command. */
while ( !IIC1S_IICIF );
IIC1S_IICIF = 1; /* Clear interrupt. */
IIC1C_MST = 0; /* Send stop signal and relinquish master mode. This is what fails. */
while ( IIC1S_BUSY ); /* Wait for stop to send. */
} while ( IIC1S_RXAK );