title: I have two i2c devices. Both alone work well, but when I read from one, and then write to the other, the second one is not an ancknowledging
body: <p>I have two devices MPU6050 and EEPROM 24C256. I can write and read from both alone. But when I try to read from MPU6050 and than write data to EEPROM in the same session, the EEPROM does not respond. I am using mbed OS libraries. And my question is.. Is it library, code or hardware problem?</p>
  
  <p>MPU6050 read sequence: 
  <a href="https://i.stack.imgur.com/gRo9U.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>EEPROM write page sequance:
  <a href="https://i.stack.imgur.com/DTYYP.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>//CODE</p>
  
  <pre><code>const char imuAddress = 0x68&lt;&lt;1;
  const char imuDataAddress = 0x3B;
  const char eepAddress = 0xA0;
  const char data[3] = {1.1, 2.2, 3.3};
  char acc[3];
  
  //reading acceleration data from IMU
      while(true){
          i2c.start();
          if(i2c.write(imuAddress) != 1){
              i2c.stop();
              continue;
          }
          if(i2c.write(imuDataAddress) != 1){
              i2c.stop();
              continue;
          }
          i2c.start();
          if(i2c.write(imuAddress | 0x01) != 1){
              i2c.stop();
              continue;
          }
          for (int i = 0; i &lt; 2; i++){
              i2c.read(1);   //read and respond ACK to continue
          }
          i2c.read(0);   //read and respond NACK to stop reading
          i2c.stop();
          break;
      }
  //write data to EEPROM
      while(true){
              i2c.start();
              if(i2c.write(eepAddress) != 1){   //here is the problem (EEPROM does not respond)
                  i2c.stop();
                  continue;
              }
              if(i2c.write(0x00) != 1){
                  i2c.stop();
                  continue;
              }
              if(i2c.write(0x00) != 1){
                  i2c.stop();
                  continue;
              }
              bool ack = true;
              for(int i = 0; i &lt; 3; i++){
                  if(i2c.write(data[i]) != 1){
                      i2c.stop();
                      ack = false;
                      break;
                  }
              }
              if (ack == true){
                  i2c.stop();
                  break;    
              }
          }
  </code></pre>