IIC Not Sending 'Stop' Bit

cancel
Showing results for 
Search instead for 
Did you mean: 

IIC Not Sending 'Stop' Bit

1,113 Views
sskuce
Contributor I
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?

do{
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 );
Labels (1)
0 Kudos
1 Reply

67 Views
sskuce
Contributor I
I figured it out. It's because I'm sending the read command to the EEPROM in the loop, instead of the write command. That doesn't explain why it works the first time through the loop, but it definitely makes this not a Freescale problem. Sorry about that.
0 Kudos