ICM-20948 Wake=on=Motion

By dingari , 11 July 2017

Hi, I'm having trouble configuring the WOM logic for ICM-20948. The MPU9250 Product Specification has a flowchart explaining the necessary steps for configuring WOM, but the ICM-20948 is lacking in that regard. I've tried to translate the steps for MPU9250 to the ICM-20948, and this is the routine I'm using to set up:


    // Power down magnetometer
bypassOn();
m_i2c.writeByte(ICM20948_MAG_ADDRESS, ICM20948_RA_MAG_CNTL2, (uint8_t) MagMode::MAG_MODE_POWER_DOWN);
bypassOff();

selectBank(0);

// Disable all interrupts
writeByte(ICM20948_RA_INT_ENABLE, 0x00);
writeByte(ICM20948_RA_INT_ENABLE_1, 0x00);
writeByte(ICM20948_RA_INT_ENABLE_2, 0x00);

// Set all CYCLE bits to 0
writeByte(ICM20948_RA_LP_CONFIG, 0x00);

// Set SLEEP to 0
writeByte(ICM20948_RA_PWR_MGMT_1, 0x00);

// Enable accel and disable gyro
writeByte(ICM20948_RA_PWR_MGMT_2, 0x07);

selectBank(2);

// Configure accel LPF
uint8_t accel_config = 0;
accel_config |= ((uint8_t) AccelLpf::ADLPF_246_0Hz << 3); // Set DLPF to 246.0 Hz
// accel_config |= ((uint8_t) AccelRes::AFS_2G << 1); // Set FSR to 2 g
accel_config |= (1 << 0); // Enable DLPF
writeByte(ICM20948_RA_ACCEL_CONFIG, accel_config);

// Enable motion interrupts only
selectBank(0);
writeByte(ICM20948_RA_INT_ENABLE, (1 << 3));

selectBank(2);

// Configure WOM logic
writeByte(ICM20948_RA_ACCEL_INTEL_CTRL, 0x03);

// Set the WOM threshold
// LSB is 4mg. Available range is 0 - 1020mg (0-255 register value)
threshold = (threshold > 1020) ? 1020 / 4 : threshold / 4;
writeByte(ICM20948_RA_ACCEL_WOM_THR, threshold);

// Set frequency of wake-up
// uint8_t accel_smplrt_div = 1022;
uint8_t accel_smplrt_div = 127;
writeByte(ICM20948_RA_ACCEL_SMPLRT_DIV_1, ((accel_smplrt_div >> 8) & 0x0f));
writeByte(ICM20948_RA_ACCEL_SMPLRT_DIV_2, (accel_smplrt_div & 0xff));

selectBank(0);

// Set LP_EN bit
writeByte(ICM20948_RA_PWR_MGMT_1, (1 << 5));

// Set ACCEL_CYCLE to 1 (Accel Low Power Mode)
writeByte(ICM20948_RA_LP_CONFIG, (1 << 5));

The logic seems to work somewhat, but if I set the threshold below ~600 mg, the interrupt is triggered immediately after the configuration routine. If I set it above ~600 mg, the interrupt doesn't trigger, and if I tap the device hard on the table, the interrupt is triggered.

Are there any guidelines for configuring the WOM logic for ICM-20948?

phpbb Topic ID
36401