Hello,
I've programmed the state machine to the following algorithm for I2C communication:
state 0: Generate start condition & send address to slave. Go to state 1.
state 1: Receive address Ack/ Nack bit. Go to state 2.
state 2: Process address Ack/ Nack & handle data TX, i.e.
if Nack received, send stop(go to state 5), else
if Ack received, TX data to slave(go to state 3)
state 3: Receive data Ack/ Nack bit (go to state 4)
state 4: Process data Ack/ Nack & send stop, i.e.
if Nack received, do nothing, else
if Ack received send stop (go to state 5)
state 5: Generate Stop condition
I wrote:
I2C_state = 0;
USICTL1 |= USIIFG;
do
_BIS_SR(GIE|LPM0_bits);
while (I2C_state >= 0);
But the state machine is stuck on state 1.
I wonder why!
Krishna.