Report
4 years, 4 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: /media/uploads/youyou/qq--20140429160549.jpg

This wave is very good and follow my code.

But read wave:

/media/uploads/youyou/20140429.jpg

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:

The nRF51822-mKIT is a low cost ARM mbed enabled development board for Bluetooth® Smart designs with the nRF51822 SoC. The kit gives access to all GPIO pins via pin headers ...
Comment on this question

1 Answer

4 years, 4 months ago.

Thank you for spotting and sharing this.

It's now fixed and should be in the most recent repo.

Is this also an issue on other mbed products?

...kevin

posted by Kevin Braun 30 Apr 2014

No, this was a bug in the NRF hardware abstraction layer.

posted by Tuze Kuyucu 02 May 2014

Thank you,Tuze Kuyucu. I creat a new program and use the same code, but the same bug is still exist.

posted by youyou yu 04 May 2014

Hi 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 Tuze Kuyucu 05 May 2014

Oh,I see. Thank you very much.

posted by youyou yu 06 May 2014

Now I try the new official library, it works fine! Thank you very much!

posted by youyou yu 21 May 2014

To post an answer, please log in.