Hi there,
I’m facing an issue in enabling the FIFO interrupt functionality in LIS2DH12. Here’s the details.
First, I forked the Ruuvitag firmware repository (here) and I’ve added a new function in app_sensor.c to enable the FIFO interrupt (similarly to this one)
At this point, I defined a handler function for FIFO interrupts:
At the moment, the fifo_task
function prints a log with a timestamp (ms) followed by a string (“FIFO called”)
Then, I edited app_main.c in order to call the app_sensor_acc_fifo_set
function from above.
I’ve also set APP_SENSOR_LIS2DH12_SAMPLERATE to 50Hz, increased the advertising frequency (i.e APP_BLE_INTERVAL_MS) to 3 seconds and set APP_NUM_REPEATS to 1. In this way, the Ruuvitag should send a BLE advertisement packet every 3 seconds (since APP_NUM_REPEATS is set to 1).
Additionally, I’ve enabled logging (RI_LOG_ENABLED) and set the log level (APP_LOG_LEVEL) to “INFO” (RI_LOG_LEVEL_INFO).
Finally, I erased the chip and flashed the firmware using SEGGER Embedded Studio (project “ruuvitag_b”) and the Ruuvitag development kit. The application mode was set to “Release”.
Here’s a screenshot:
In general, it seems that FIFO interrupts are triggered approximately every 3 seconds. For instance, the third “FIFO called” log (6491: FIFO called) is printed after (6491 - 3482)/1000=3.009 seconds from the second one (“3482: FIFO called”).
From my understading, FIFO interrupts should be fired roughly every 32/APP_SENSOR_LIS2DH12_SAMPLERATE since the LIS2DH12 FIFO buffer can hold up to 32 samples. Given that APP_SENSOR_LIS2DH12_SAMPLERATE is 50, we should expect the “FIFO interrupt” log to be printed every 32/50=0.64 seconds. However, it seems that interrupts are triggered every APP_HEARTBEAT_INTERVAL_MS*1000 seconds.
Indeed, by printing additional logs, I found out that FIFO interrupts are triggered almost every time the app_sensor_get
function in app_sensor.c is called, that is, every APP_HEARTBEAT_INTERVAL_MS milliseconds:
Perhaps, FIFO interrupts are triggered when the ri_lis2dh12_data_get
function in ruuvi_interface_lis2dh12.c gets called from app_sensor_get.
I’ve also tried setting APP_SENSOR_LIS2DH12_SAMPLERATE to a different value (100Hz), but FIFO interrupts are still fired every 3 seconds.
Given that I’m a beginner, it is very likely that I didn’t properly enabled the FIFO functionality at all.
Any hints on what I should do to enable FIFO interrupts would be greatly appreciated.
Thanks