You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// It is not clear why we need to do this... But it appears to be essential! From the datasheet:
142
+
// "I2C_MST_ODR_CONFIG[3:0]: ODR configuration for external sensor when gyroscope and accelerometer are disabled.
143
+
// ODR is computed as follows: 1.1 kHz/(2^((odr_config[3:0])) )
144
+
// When gyroscope is enabled, all sensors (including I2C_MASTER) use the gyroscope ODR.
145
+
// If gyroscope is disabled, then all sensors (including I2C_MASTER) use the accelerometer ODR."
146
+
// Since both gyro and accel are running, setting this register should have no effect. But it does. Maybe because the Gyro and Accel are placed in Low Power Mode (cycled)?
147
+
// You can see by monitoring the Aux I2C pins that the next three lines reduce the bus traffic (magnetometer reads) from 1125Hz to the chosen rate: 68.75Hz in this case.
148
+
success &= (myICM.setBank(3) == ICM_20948_Stat_Ok); // Select Bank 3
149
+
uint8_t mstODRconfig = 0x04; // Set the ODR configuration to 1100/2^4 = 68.75Hz
150
+
success &= (myICM.write(AGB3_REG_I2C_MST_ODR_CONFIG, &mstODRconfig, 1) == ICM_20948_Stat_Ok); // Write one byte to the I2C_MST_ODR_CONFIG register
151
+
104
152
// Configure clock source through PWR_MGMT_1
105
153
// ICM_20948_Clock_Auto selects the best available clock source – PLL if ready, else use the Internal oscillator
106
154
success &= (myICM.setClockSource(ICM_20948_Clock_Auto) == ICM_20948_Stat_Ok); // This is shorthand: success will be set to false if setClockSource fails
@@ -257,9 +305,9 @@ void setup()
257
305
constunsignedchar accelCalRate[4] = {0x00, 0x00}; // Value taken from InvenSense Nucleo example
// It is not clear why we need to do this... But it appears to be essential! From the datasheet:
142
+
// "I2C_MST_ODR_CONFIG[3:0]: ODR configuration for external sensor when gyroscope and accelerometer are disabled.
143
+
// ODR is computed as follows: 1.1 kHz/(2^((odr_config[3:0])) )
144
+
// When gyroscope is enabled, all sensors (including I2C_MASTER) use the gyroscope ODR.
145
+
// If gyroscope is disabled, then all sensors (including I2C_MASTER) use the accelerometer ODR."
146
+
// Since both gyro and accel are running, setting this register should have no effect. But it does. Maybe because the Gyro and Accel are placed in Low Power Mode (cycled)?
147
+
// You can see by monitoring the Aux I2C pins that the next three lines reduce the bus traffic (magnetometer reads) from 1125Hz to the chosen rate: 68.75Hz in this case.
148
+
success &= (myICM.setBank(3) == ICM_20948_Stat_Ok); // Select Bank 3
149
+
uint8_t mstODRconfig = 0x04; // Set the ODR configuration to 1100/2^4 = 68.75Hz
150
+
success &= (myICM.write(AGB3_REG_I2C_MST_ODR_CONFIG, &mstODRconfig, 1) == ICM_20948_Stat_Ok); // Write one byte to the I2C_MST_ODR_CONFIG register
138
151
139
152
// Configure clock source through PWR_MGMT_1
140
153
// ICM_20948_Clock_Auto selects the best available clock source – PLL if ready, else use the Internal oscillator
@@ -143,7 +156,7 @@ void setup()
143
156
// Enable accel and gyro sensors through PWR_MGMT_2
144
157
// Enable Accelerometer (all axes) and Gyroscope (all axes) by writing zero to PWR_MGMT_2
145
158
success &= (myICM.setBank(0) == ICM_20948_Stat_Ok); // Select Bank 0
146
-
uint8_t pwrMgmt2 = 0x40; // Set the reserved bit 6
159
+
uint8_t pwrMgmt2 = 0x40; // Set the reserved bit 6 (pressure sensor disable?)
147
160
success &= (myICM.write(AGB0_REG_PWR_MGMT_2, &pwrMgmt2, 1) == ICM_20948_Stat_Ok); // Write one byte to the PWR_MGMT_2 register
148
161
149
162
// Configure I2C_Master/Gyro/Accel in Low Power Mode (cycled) with LP_CONFIG
@@ -292,10 +305,9 @@ void setup()
292
305
constunsignedchar accelCalRate[4] = {0x00, 0x00}; // Value taken from InvenSense Nucleo example
0 commit comments