cancel
Showing results for 
Search instead for 
Did you mean: 

lsm6dso accelerometer not working

hello , i am using lsmds0 sensor with nxp board below is the section of my code 

int main(void)
{
 
 
    /* Write your code here */
Clock_Ip_StatusType clockStatus;
clockStatus = Clock_Ip_Init(&Clock_Ip_aClockConfig[0]);
Siul2_Port_Ip_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);
Siul2_Dio_Ip_WritePin(MEMS_CS_DRIVE_ENABLE_PORT ,MEMS_CS_DRIVE_ENABLE_PIN,1);
i2c_int();
//i2c_scan_bus();
i2c_bustest();
// I2C_ManualBusRecovery();
dev_ctx.write_reg = accelero_write;//assigning read and write pointers to ST driver context
dev_ctx.read_reg = accelero_read;
dev_ctx.handle = NULL;
uint8_t who_am_i = 0;
uint8_t ctrl1;
 
int16_t raw_accel_data[3];// variable to store raw 16 bit accelerometer value
volatile float acceleration_mg[3];// converted acceleration in milli-g
lsm6dso_status_reg_t reg_status; // structure store the register flags
 
lsm6dso_device_id_get(&dev_ctx, &who_am_i);
lsm6dso_reset_set(&dev_ctx, PROPERTY_ENABLE);// starting resetting process
uint8_t rst;
uint8_t odr_check = 0;
//lsm6dso_reset_get(&dev_ctx, &rst);
do
{
lsm6dso_reset_get(&dev_ctx, &rst);
}while(rst);//waits for completion of resetting
lsm6dso_xl_data_rate_set(&dev_ctx, LSM6DSO_XL_ODR_104Hz);// sampling frequency = 104Hz
 
lsm6dso_xl_full_scale_set(&dev_ctx, LSM6DSO_2g);// measurement range +- 2g
lsm6dso_xl_full_scale_get(&dev_ctx, &odr_check);
lsm6dso_read_reg(&dev_ctx, 0x10, &ctrl1, 1);
 
lsm6dso_block_data_update_set(&dev_ctx, PROPERTY_ENABLE);// Data consistency
memset(raw_accel_data, 0 , sizeof(raw_accel_data));
while (1)
{
 
 
// read the status register to check if new data is available
lsm6dso_status_reg_get(&dev_ctx,&reg_status);
if(reg_status.xlda) // it indicates that new data is available
{
 
lsm6dso_acceleration_raw_get(&dev_ctx, raw_accel_data);
 
acceleration_mg[0] = lsm6dso_from_fs2_to_mg(raw_accel_data[0]);
acceleration_mg[1] = lsm6dso_from_fs2_to_mg(raw_accel_data[1]);
acceleration_mg[2] = lsm6dso_from_fs2_to_mg(raw_accel_data[2]);
 
}
 
}
    return exit_code;
}


everything works fine till first reading, i am getting first reading and for next reading i am getting raw values as 136, 8256,-36 and repeats same, values are not getting updated.  i request you please help me solve this issue

0 REPLIES 0