MPU9250 i2C read / write registers

By ddss , 4 November 2014

Hi,

I'm having trouble writing to registers. I don't understand.
First start to read the WhoAmI register works; I readback 0x71
So I think the readback code is ok.


i2c_start(bus); //normal start
i2c_write(bus, 0xD0); //write adress MPU (AD=0)
i2c_write(bus, 0x75); //invoke WhoAmI register
i2c_start(bus); //normal start
i2c_write(bus, 0xD1); //read adress MPU (AD=0)
i80= i2c_read(bus,0); //read the byte in the invoked register, 0=NACK
i2c_stop(bus);
fprintf(debug,"MPU92 ID readback: %xn",i80);


Then I write the SMPLRT_DIV register 0x19 using below and and an adapted readback as above



i2c_start(bus); //normal start
i2c_write(bus, 0xD0); //write adress MPU (AD=0)
i2c_write(bus, 0x19); //invoke register 0x19
i2c_write(bus, 0xA5); //write data 0xA5 to 0x19
i2c_stop(bus);

i2c_start(bus); //normal start
i2c_write(bus, 0xD0); //adress MPU for write (AD=0)
i2c_write(bus, 0x19); //invoke register 0x19
i2c_start(bus); //normal start
i2c_write(bus, 0xD1); //adress MPU for read (AD=0)
i80= i2c_read(bus,0); //read the byte in the invoked register, 0=NACK
i2c_stop(bus);
fprintf(debug," | Mpu : %xn",i80);



The readback is 0x00. I presume the write is not done. Is there a write protection bit I have to disable or so?
Any other things?

Any help appreciated.
phpbb Topic ID
16716