2026-04-13
7:34 PM
- last edited on
2026-04-14
8:07 AM
by
Lina_DABASINSKA
While using the iis3dw sensor, I discovered that when I employed an interrupt-based polling method to read data—where, ideally, the sensor captures data, triggers an interrupt, and then the data is read—the data acquisition frequency should be around 26 kHz (based on SPI transmission and code execution time). However, I found that reading the data was taking up some of that time; when I disabled this process, the issue disappeared. My SPI rate is 18 Mbps. Subsequent testing with FIFO reading also exhibited this behavior. Specifically, when I disabled the function `iis3dwb_acceleration_raw_get(&IIS3DWB_ctx, accel)` during the read process, reading 10,240 data points took approximately 391 ms (about 26k). Without disabling it, reading the same 10,240 data points took 523 ms (about 19k). Below is my read code without using FIFO. The attachment contains the official ST driver. `uint8_t iis3dwb_init_drdy_mode(void)` is the initialization function without using FIFO,
int16_t iis3dwb_read(void)
{
int16_t accel[3];
iis3dwb_acceleration_raw_get(&IIS3DWB_ctx, accel);
// if(IisINITNum % 10 == 0)
{
AllData[IisDataNum].Iis[0] = accel[0];//iis3dwb_from_fs16g_to_mg(accel[0]) * 9.8 / 1000;
AllData[IisDataNum].Iis[1] = accel[1];//iis3dwb_from_fs16g_to_mg(accel[1]) * 9.8 / 1000;
AllData[IisDataNum].Iis[2] = accel[2];//iis3dwb_from_fs16g_to_mg(accel[2]) * 9.8 / 1000;
IisDataNum++;
if(IisDataNum >= DATA_MAX_NUM)
{
IisDataNum = 0;
iis3dwb_xl_data_rate_set(&IIS3DWB_ctx, IIS3DWB_XL_ODR_OFF);
g_events |= MAIN_EVENT_SEND_IIS;
return 0;
}
}
IisINITNum++;
return 0;
}
The ST Community moderator has translated the post to comply with the language of the Community which is English. For more information, see: ST Community Terms and Conditions - STMicroelectronics Community
Translated with DeepL.com (free version)
Solved! Go to Solution.
2026-04-16 12:30 AM
Hi @Leo_leo ,
Your observation is correct: the overhead introduced by the iis3dwb_acceleration_raw_get() function—including SPI transactions, data conversion, and context handling—reduces the maximum achievable data rate, even with an 18 Mbps SPI clock. This is why you see a lower acquisition frequency when this function is used.
To maximize throughput:
The official ST driver prioritizes portability over raw speed. For high-speed applications, a streamlined, application-specific readout routine is recommended.
2026-04-13 7:35 PM
2026-04-16 12:30 AM
Hi @Leo_leo ,
Your observation is correct: the overhead introduced by the iis3dwb_acceleration_raw_get() function—including SPI transactions, data conversion, and context handling—reduces the maximum achievable data rate, even with an 18 Mbps SPI clock. This is why you see a lower acquisition frequency when this function is used.
To maximize throughput:
The official ST driver prioritizes portability over raw speed. For high-speed applications, a streamlined, application-specific readout routine is recommended.