LIS2DTW12 SENSOR IC
Dear Sir/Madam,
I am trying to configure x axis, y axis and z axis in LIS2DTW12 SENSOR IC interfacing with NUCLEO-L476RG microcontroller when board is towards sky direction. These are the values in z axis1.26 in (+-2g configuration), 2.046 in (+-4g configuration) ,4.125 in (+-8g configuration) and8.254 in (+-16g configuration). Can you conform if the above values are correct?
Find the code below for your reference.
lis2dtw12_device_id_get(&dev_ctx, &whoamI);
if (whoamI != LIS2DTW12_ID)
while (1) {
/* manage here device not found */
}
/* Configure power mode */
lis2dtw12_power_mode_set(&dev_ctx, LIS2DTW12_HIGH_PERFORMANCE);
/* Set Output Data Rate */
lis2dtw12_data_rate_set(&dev_ctx, LIS2DTW12_XL_ODR_1k6Hz);
/* Set full scale */
lis2dtw12_full_scale_set(&dev_ctx, LIS2DTW12_4g);
/* Configure FIFO continous mode */
lis2dtw12_fifo_mode_set(&dev_ctx, LIS2DTW12_BYPASS_MODE);
/* Configure FIFO continous mode */
lis2dtw12_fifo_watermark_set(&dev_ctx, 10);
lis2dtw12_fifo_mode_set(&dev_ctx, LIS2DTW12_STREAM_MODE);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
uint8_t val,i,val_1;
lis2dtw12_fifo_wtm_flag_get(&dev_ctx, &val);
if(val)
{
lis2dtw12_fifo_data_level_get(&dev_ctx, &val);
gl_Sample_Count = val+gl_Sample_index;
for (i = gl_Sample_index; i < gl_Sample_Count; i++) {
/* Read acceleration data */
memset(data_raw_acceleration, 0x00, 3 * sizeof(int16_t));
lis2dtw12_acceleration_raw_get(&dev_ctx, data_raw_acceleration);
acceleration_mg_x[gl_Sample_index] = lis2dtw12_from_fs4_to_mg(data_raw_acceleration[0]);
acceleration_mg_y[gl_Sample_index] = lis2dtw12_from_fs4_to_mg(data_raw_acceleration[1]);
acceleration_mg_z[gl_Sample_index] = lis2dtw12_from_fs4_to_mg(data_raw_acceleration[2]);
gl_Sample_index++;
if(gl_Sample_index >= 1023)
{
gl_Sample_index = 0;
//lis2dtw12_fifo_data_level_get(&dev_ctx, &val);
}
//lis2dtw12_fifo_data_level_get(&dev_ctx, &val);
}
}
lis2dtw12_fifo_ovr_flag_get(&dev_ctx, &val_1);
if(val_1)
{
lis2dtw12_fifo_mode_set(&dev_ctx, LIS2DTW12_BYPASS_MODE);
lis2dtw12_fifo_mode_set(&dev_ctx, LIS2DTW12_STREAM_MODE);
}
