Read fifo-buffer from DMP of MPU9250

By yukichiiroha , 13 June 2017

Hi.
I use MPU9250 & nRF52.

I want to read fifo-buffer for get data of quaternion that made by DMP.

But I couldn't read fifo-buffer well.
I read fifo_count register(0x & x), first time, it's 242,after this,512 all the time.
I think fifo_count is 0, next 22, next 44... increase by 22.
And data in fifo-buffer is almost 0 or 255.

Is it wrong how to read fifo-buffer?

Thanks,

//address = 0x68,reg = 0x74(fifo_r_w), length = 22(MAX)
static uint_t mpu_read_fifo_register(uint_t address, uint_t reg, uint_t length, uint_t * p_data)
{
uint_t err_code;

for(unsigned char iii = 0; iii < length; iii++){

err_code = nrf_drv_twi_tx(&m_twi_instance, address, &reg, 1, false);//read
if(err_code != NRF_SUCCESS) {
printf("err_code = %d @read_register_#\n\r",err_code);
return err_code;
}
if(!waitInt(MPU9250_TWI_TIMEOUT)){ //return true,read is finished
printf("Timeout read_reg #\r\n");
return NRF_ERROR_TIMEOUT;
}
twi_done = false;



uint_t * p_tmp;
err_code = nrf_drv_twi_rx(&m_twi_instance, address, p_tmp, 1);
if(err_code != NRF_SUCCESS) {
printf("err_code = %d @read_register_#2\n\r",err_code);
return err_code;
}

if(!waitInt(MPU9250_TWI_TIMEOUT)){ //return true,read is finished
printf("Timeout read_reg #2\r\n");
return NRF_ERROR_TIMEOUT;
}
p_data[iii] = p_tmp[0];
twi_done = false;
}
return err_code;
}

phpbb Topic ID
36363