ICM-20689 accelerometer strange output.

By leventsectroncom , 2 December 2021

Hello!
I use ICM-20689 chip in accelerometer device.
The ICM-20689 chip is connected to the processor via I2C interface.
I get correct "WhoAmI" value of 0x98.
But when I try to get current acceleration for example for X axis the result is 0x0211 with slight changes.
If I tilt the board acceleration value changes and stays around that value even if there is no movement - behaves as tilt sensor.
Attached is my code for testing the accelerometer.
I read current X acceleration value from address 0x3B - high byte and 0x3C - low byte.
Would you please help!

Below is my test code:
void main(void)
{
SYSTEM_Initialize();

while(1)
{
i2c_write1ByteRegister(0x68, 0x6B, 0x81); //Soft reset;
Delay(50);

i2c_write1ByteRegister(0x68, PWR_MGMT_1, 0x01);

whoAmI=i2c_read1ByteRegister(0x68, 0x75);
printf("whoAmI%02X\r\n", whoAmI);

i2c_write1ByteRegister(0x68, PWR_MGMT_2, 0x00);
i2c_write1ByteRegister(0x68, ACCEL_CONFIG, 0x00);
i2c_write1ByteRegister(0x68, ACCEL_CONFIG2, 0x00);
i2c_write1ByteRegister(0x68, GYRO_CONFIG, 0x00);

uint8_t accelX_L;
uint8_t accelX_H;
uint16_t accelX;
uint8_t accelY_L;
uint8_t accelY_H;
uint16_t accelY;
uint8_t accelZ_L;
uint8_t accelZ_H;
uint16_t accelZ;

while(1)
{
//whoAmI=i2c_read1ByteRegister( 0x68 , 0x75 );
accelX=i2c_read2ByteRegister(0x68, 0x3B);

accelY=i2c_read2ByteRegister(0x68, 0x3D);

accelZ=i2c_read2ByteRegister(0x68, 0x3F);

printf("accelX:%04X\r\n", accelX );
//printf("accelY:%04X\r\n", accelY );
//printf("accelZ:%04X\r\n", accelZ );
Delay(1000);
}
}
}

Best regards!

phpbb Topic ID
39236