AnsweredAssumed Answered

I2C on  twr-k70f120n

Question asked by Ankur Chauhan on Aug 25, 2015
Latest reply on Sep 1, 2015 by Ankur Chauhan

Hii,

 

I'm using twr-k70f120(master) development kit and trying to read the data from sensor(slave).

I configured the I2C0 in receive mode and write the I2C0_D register with the slave address in read mode as shown below:

 

I2C0_C1 = I2C_C1_IICEN_MASK;

I2C0_C1 &= (~I2C_C1_TX_MASK);

  I2C0_C1 |= I2C_C1_MST_MASK;

   I2C0_D = 0x93;

  

  while ( !(I2C0_S & (1<<1)) );

  I2C0_S = I2C0_S | (1 << 1);

  

  readData = I2C0_D;

  

  while ( !(I2C0_S & (1<<1)) );

  I2C0_S = I2C0_S | (1 << 1);

  

   I2C0_C1 = I2C0_C1 | (1 << 2);

  

   I2C0_D = 0x93;

   while ( !(I2C0_S & (1<<1)) );

   I2C0_S = I2C0_S | (1 << 1);

  

   I2C0_C1 |= I2C_C1_TXAK_MASK;

  

   readData_1 = I2C0_D;

  

  while ( !(I2C0_S & (1<<1)) );

  I2C0_S = I2C0_S | (1 << 1);

 

  readData_2 = I2C0_D;

  I2C0_C1 &= ~I2C_C1_MST_MASK;

 

m doing repetitive reading bcoz single reading giving output zero and most of the time its getting stuck in while condition..

Outcomes