Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 7 months ago.
Question about I2C library
Hello,
I use these codes on nRF51822:(section)
I2C mpu(P0_22,P0_20);
int main()
{
char cdd[2]={PWR_MGMT_1,0x03};
mpu.frequency(100000);
while(1)
{
mpu.start();
mpu.write((0x68<<1));
mpu.write(PWR_MGMT_1); register address: 0x6B
mpu.write(0x01);
mpu.stop();
wait(0.5);
mpu.start();
mpu.write((0x68<<1));
mpu.write(ACCEL_XOUT_H); register address: 0x3B
mpu.start();
mpu.write((0x68<<1)|1);
mpu.read(0); no ack
mpu.stop();
wait(0.5);
}
}
But something wrong with these codes. I use the logical analyzer to capture the wave. See as follows:
Write wave:
This wave is very good and follow my code.
But read wave:
My code just want to read a byte and answer a no-ack. But actually, it gives me two bytes and appear a ack.
Some bugs with the I2C library base on nRF51822? I used the MPU6050 library based on the I2C library, but I have no correct readings. Same phenomenon, more bytes more than my code gives.
Please help me.Thank you!
Question relating to:
1 Answer
10 years, 7 months ago.
Thank you for spotting and sharing this.
It's now fixed and should be in the most recent repo.
Thank you,Tuze Kuyucu. I creat a new program and use the same code, but the same bug is still exist.
posted by 04 May 2014Hi youyou, I assume you are using the mbed official library (the one also used by the online compiler). The updates have not been committed to this library yet. The last update was 6 days ago (https://mbed.org/users/mbed_official/code/mbed/shortlog). You can get the latest code from https://github.com/mbedmicro/mbed.
posted by 05 May 2014