How dose the function "wire.requestFrom()" really work?

Hi , I have been reading I2C for several days by

Im not sure how dose the function “wire.requestFrom()” really works.

/ MPU-6050 Short Example Sketch
// By Arduino User JohnChi
// August 17, 2014
// Public Domain
const int MPU_addr=0x68;  // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
void setup(){
  Wire.write(0x6B);  // PWR_MGMT_1 register
  Wire.write(0);     // set to zero (wakes up the MPU-6050)
void loop(){
  Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
  Wire.requestFrom(MPU_addr,14,true);  // request a total of 14 registers<<8|;  // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)<<8|;  // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)<<8|;  // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)<<8|;  // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)<<8|;  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)<<8|;  // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)<<8|;  // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
  Serial.print("AcX = "); Serial.print(AcX);
  Serial.print(" | AcY = "); Serial.print(AcY);
  Serial.print(" | AcZ = "); Serial.print(AcZ);
  Serial.print(" | Tmp = "); Serial.print(Tmp/340.00+36.53);  //equation for temperature in degrees C from datasheet
  Serial.print(" | GyX = "); Serial.print(GyX);
  Serial.print(" | GyY = "); Serial.print(GyY);
  Serial.print(" | GyZ = "); Serial.println(GyZ);

According to the reference which is “used by the master to request bytes from a slave device .The bytes may then be retrieved with available() and read() functions.” What I thought is this func. receives data x times from a slave with the register like 0x3B(in the code). But actually it receives data x times from x
registers!? Is that right?
I understand it is right to receive data from different register at a time ,it would be useless if receive data
x times from one register with one loop run but i cant know it by the reference.

The Wire.requestFrom() requests data from a I2C device, also called a I2C Slave. That Slave has a certain I2C address. Let's read 10 bytes from I2C address 0x68:

Wire.requestFrom( 0x68, 10);

That's all, 10 bytes are requested. The Master tells the Slave: "Give me a bytes, and another one, and another one...." until 10 bytes are read.

The Slave determines what those 10 bytes are. If the Slave decides to return 10 same bytes or 10 random bytes, or 10 bytes from sequential registers, so be it.

Most I2C devices have registers, and most I2C devices automatically increment the register address. Therefor the most common way is that the Master writes the starting register address, and after that request bytes. The Slave returns bytes from the starting register address and after that the next registers because the register address is automatically incremented in the Slave.

The means if the register address is set to 5, and 10 bytes are read, then a new Wire.requestFrom() will read data starting at 15. Because that register address in the Slave is auto-incremented and keeps it value until it will be written again by the Master.

Thank you! But where can I find this information about "auto-incremented"? I mean dose every i2c device's

datasheet would tell you that information whether it has "auto-incremented"?

and what if overflow occurs? it would continuous to the first register?

Good question. It should be in the datasheet, but you better avoid overflow ;)

The MPU-6050 is outdated and had/has 5 datasheets.

For example the HMC5883L tells in the datasheet: "To minimize the communication between the master and this device, the address pointer updated automatically without master intervention. The register pointer will be incremented by 1 automatically after the current register has been read successfully".

Since it is so common, perhaps not every datasheet has explicitly written that in the datasheet.

Ok, thank you very much!