Hi,
we are using the Motion Fit SDK 5.1 software as a baseline, largely un modified on our board to set up the 9150.
This works great on our platform when talking to a 9150 on a breakout board we bought from sparkfun while waiting on our prototype PCBs.
(It's just a bare board + passives and a single 9150)
When running the same code on a new batch of 9150 chips, Rev E devices recently purchased direct from invensense we read back a 0 as the device ID. We can read Who Am I register correctly and write & read values from other registers so it's not a comms problem.
Suggestions appreciated, Thanks.
Here's our init code - I marked 'HERE' and 'FAILS HERE' below
/**
* @brief Initialize hardware.
* Initial configuration:n
* Gyro FSR: +/- 2000DPSn
* Accel FSR +/- 2Gn
* DLPF: 42Hzn
* FIFO rate: 50Hzn
* Clock source: Gyro PLLn
* FIFO: Disabled.n
* Data ready interrupt: Disabled, active low, unlatched.
* @param[in] int_param Platform-specific parameters to interrupt API.
* @return 0 if successful.
*/
int gyro_init(struct int_param_s *int_param)
{
unsigned char sensors, data[6], rev;
/* Reset device. */
data[0] = BIT_RESET;
if (i2c_write(st.hw->addr, st.reg->pwr_mgmt_1, 1, data))
return -1;
delay_ms(100);
sensors = st.chip_cfg.sensors;
st.chip_cfg.sensors = 0;
#ifdef MPU9150
gyro_set_sensors(INV_XYZ_COMPASS);
#else
gyro_set_sensors(INV_XYZ_GYRO | INV_XYZ_ACCEL);
#endif
/* Check product revision. */
if (i2c_read(st.hw->addr, st.reg->accel_offs, 6, data))
return -2;
rev = ((data[5] & 0x01) << 2) | ((data[3] & 0x01) << 1) |
(data[1] & 0x01);
if (rev) {
/* Congrats, these parts are better. */
if (rev == 1)
st.chip_cfg.accel_half = 1;
else if (rev == 2)
st.chip_cfg.accel_half = 0;
else {
log_e("Unsupported software product rev %d.n", rev);
return -3;
}
} else {
if (i2c_read(st.hw->addr, st.reg->prod_id, 1, data)) <--- HERE
return -4;
rev = data[0] & 0x0F;
if (!rev) {
log_e("Product ID read as 0 indicates device is either " <--- FAILS HERE!
"incompatible or an MPU3050.n");
return -5;
} else if (rev == 4) {
log_i("Half sensitivity part found.n");
st.chip_cfg.accel_half = 1;
} else
st.chip_cfg.accel_half = 0;
}
/* Set to invalid values to ensure no I2C writes are skipped. */
st.chip_cfg.gyro_fsr = 0xFF;
st.chip_cfg.accel_fsr = 0xFF;
st.chip_cfg.lpf = 0xFF;
st.chip_cfg.sample_rate = 0xFFFF;
st.chip_cfg.fifo_enable = 0xFF;
st.chip_cfg.bypass_mode = 0xFF;
st.chip_cfg.lp_accel_mode = 0xFF;
st.chip_cfg.compass_sample_rate = 0xFFFF;
/* gyro_set_sensors always preserves this setting. */
st.chip_cfg.clk_src = INV_CLK_PLL;
/* Handled in next call to gyro_set_bypass. */
st.chip_cfg.active_low_int = 1;
st.chip_cfg.latched_int = 0;
#ifdef USE_DMP
st.chip_cfg.dmp_on = 0;
st.chip_cfg.dmp_loaded = 0;
st.chip_cfg.dmp_sample_rate = 0;
#endif
if (gyro_set_gyro_fsr(2000))
return -6;
if (gyro_set_accel_fsr(2))
return -7;
if (gyro_set_lpf(42))
return -8;
if (gyro_set_sample_rate(50))
return -9;
if (gyro_configure_fifo(0))
return -10;
if (gyro_set_bypass(0))
return -11;
if (gyro_lp_accel_mode(0))
return -12;
if (int_param)
reg_int_cb(int_param);
#ifdef MPU9150
setup_compass();
if (gyro_set_compass_sample_rate(10))
return -13;
#endif
gyro_set_sensors(sensors);
return 0;
}
- Log in to post comments
phpbb Topic ID
15357