I am attempting to interface between a custom 8051-based MCU and a new (ebay) GY-521 module (Gyro/Accel chip) using I2C bus. I have written the I2C bit-bang functions myself and they seem to be working fine. I can view bus operations (Read/write) on the scope, and I'm seeing ACKs from the GY-521 when they should be seen.

However, in order to read the gyro/accel data, I must clear the "SLEEP" bit from the PWR_MGMT_1 register.

Procedure: 1. Send START sequence 2. Send 7-bit address + WRITE bit (0) 3. Read ACK from slave 4. Write 8-bit register address (0x6b) 5. Read ACK 6. Write 8-bit data value (0x01 = use X Gyro as clock source) 7. Read ACK 8. Send STOP sequence.

I can watch the MCU write the new value (0x01) to the register, but then when I Read back the register, the value is back to 0x40 (default).

Any reads of the gyro or accel values return zeros due to the module being in sleep mode.

Here is the spec sheet for the MPU-6050 gyro that's used in this board. https://www.cubby.com/pli/Spec+Sheet.pdf/_506bd71d53d3454282f06fa698666f04

Here's the register list: https://www.cubby.com/pli/Register+Map.pdf/_17685da9808c42099c5ebdc1058c63b3

If you wish, I can post the scope output where you can see the value being set, the ACK received, and then reading back the value yielding the default.

Any suggestions appreciated.


  • 1
    \$\begingroup\$ Something that might be worth a try is reading the WHO_AM_I register and see if you get back 0x68 to double-check your I2C code is OK. \$\endgroup\$
    – PeterJ
    Commented Apr 26, 2014 at 6:10
  • \$\begingroup\$ Great suggestion, I tried it: I get the correct address (0x68) for the device. \$\endgroup\$ Commented Apr 26, 2014 at 6:15

1 Answer 1


The PWR_MGMT_1 register should always be set the last after all the register configurations like that:

void MPU9150_Init_awake_SensorRegister(unsigned int MasterI2C_BaseAddress)


WriteByte_to_SlaveRegister(MasterI2C_BaseAddress,RA_GYRO_CONFIG,0x08); WriteByte_to_SlaveRegister(MasterI2C_BaseAddress,RA_ACCEL_CONFIG,0x10); WriteByte_to_SlaveRegister(MasterI2C_BaseAddress,RA_USER_CTRL,0x00); WriteByte_to_SlaveRegister(MasterI2C_BaseAddress,RA_PWR_MGMT_1,0x09);


  • I used 0x09 instead of 0x01 to disable the temperature sensor cuz I don't need it.

  • By the way, I just tried that and it works so far; I still need to experiment with it however.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.