AnsweredAssumed Answered

i2c fails to send start condition and address

Question asked by Vincent Gagliardo on May 28, 2013
Latest reply on May 30, 2013 by Vincent Gagliardo

device: mcf52258

RTOS: MQX 3.8.1

 

Use the following code to send a start condition and address.

// set transmit mode: bit 4 = 1;

      MCF_I2C0_I2CR |= MCF_I2C_I2CR_MTX;

      // send ACK after receive

      MCF_I2C0_I2CR &= ~MCF_I2C_I2CR_TXAK;

      // set MSTA to 1 to generate START condition

      MCF_I2C0_I2CR |= MCF_I2C_I2CR_MSTA;

      // set slave address

      MCF_I2C0_I2DR = address;

 

//* wait for bus busy *//

loop_count2 = 0;

      while(!(MCF_I2C0_I2SR & MCF_I2C_I2SR_IBB)) //if bus is idle, wait until busy

      {

     loop_count2++;

     if(loop_count2 > LOOP_TIMEOUT)

     {

          break;

     }

      }

 

      // wait until transfer finish

      //---------------------------

     _lwsem_wait( &i2c_ready_semaphore );

 

 

     _time_delay(5);

 

     MCF_I2C0_I2DR = *(unsigned char *)(data + i); //load data onto i2c bus.

 

This code works fine, but if I remove the _time_delay(5), the start condition and address do not get sent but the data does.  For our application, we read a lot of bytes of data.  It would be a big time saver if we could remove the time delay.  Any idea what is going on here?

 

Outcomes