This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nRF51 MPU9255 TWI/I2C READ Failed

Hi all:

I used code from Github to read 9 axis data with TWI. But the example in TWI floder doesn't work.

Does somebody have the same issue?

Chip: nRF51422

Board: PCA10028

Firmware: S130_nRF51_2.0.1

I have checked the TWI pin define, SDA SCL voltage, and the code in mpu_init(). I found a lot of problems in that code. Does somebody have the same issue? Please make a response or even share the ideas with me.

update: I've checked that my module already has 10K pull-up for SDL and SDA. I have found the root cause, I should make SDO (ADO) to low for address 0x68 and SDO (ADO) to high for address 0x69. I still don't know what's the purpose of this design?

  • Hi MakerTim,

    I haven't used that code but I have implemented a library for communicating with MPU9250. If you provide more information someone might be able to help. How it doesn't work exactly? First try to read the WHO AM I register to see if the communication works OK. The value for MPU9250 should be 0x71. Then you can start initializing the sensor.

  • I have gotten those examples working - nRF52 (with the exception of the magnetometer). I just changed the defines in the C/C++ tab and the TWI pins. Make sure to run in SDK 11.0. ADO should be set low for these examples. I used pullups of 10K. They should run w/ no major modification.

  • I wrote codes to read who Am I register, and its error code was 17.(busy, timeout) Maybe I should pull up 10K for TWI pins. By the way, what is ADO and why should I set it low?

  • The AD0 defines the address - low is 0x68 which is in the example code. Mine has to be wired to GND for it to work. Just FYI - I had difficulty getting some of the 3rd party MPU boards to work and had to make my own board. Anyway, I think the answer for you is likely on the hardware side.

  • makerTim, there must be pull-ups on the TWI lines, either internal or external. I always prefer to have external resistors so I can choose the right value for them (for the maximum possible frequency depending on the capacitance of the lines). Decrease the frequency to 100K for the start just in case that the capacitance of the lines are large. You can do it in initializing the TWI module by nrf_drv_twi_init. And as dkwill pointed out, AD0 pin of MPU defines its TWI address which is very important. If this address is not right there won't be any response from the slave device (here MPU), which I guess causes timout. You can either change the configuration of this pin in hardware or simply modify that line of code that defines the slave device.

Related