Incorrect time elapsed using SysTick
Hi, I'm currently using STM32F401RE Nucleo-64 Board.
My purpose of this project is to configure ISM330DLC Accelerometer, taking reference from STEVAL-BFA001V1B sample code on Vibration Analysis.
As a summary:
- After enabling the accelerometer FIFO FULL FLAG INT, I have initialise a variable StartTick = HAL_GetTick();
- At this point, the accelerometer will trigger an interrupt every 60ms (from my oscilloscope), and it will read everything from the Acclerometer FIFO (limited by the watermark and stop on fth) for roughly 30ms. As I'm using the codes from the sample reference, the BSP STEVAL-IDP005 isn't really efficient in reading from the Accelerometer's FIFO, but that is not of the concern for this post.
- In the main loop, it will keep calling another layer. In that layer, it has initialised a variable ActualTick = HAL_GetTick(); and checks if (ActualTick - StartTick is more than 5000ms). If condition is TRUE, then disable FIFO INT.
Nevertheless, the current problem I'm facing is this:
- The actual time elapsed is around 10 seconds, instead of the expected 5 seconds.
- The debugger shows the value of ActualTick - StartTick is slightly more than 5000, which is expected.
- I assume that SysTick is properly initialised after HAL_Init() is called. I've checked and it seems that HAL_Init() has configured SysTick with a pre-empt priority of 0.
- I made a simple check in the SysTick_Handler by using HAL_GPIO_TogglePin to see if the SysTick is triggering at 1ms through the oscilloscope and it seems correct before interrupts from the accelerometer comes in.
- Once the accelerometer triggers the series of interrupt, my oscilloscope shows erratic behaviour, so i'm assumming its a priority problem. But all the other interrupts have a pre-empt priority of >= 1 after double checking.
Sorry for the long post. I'm only just 2 months into STM32 and I would appreciate any kind advice and tips. Thank you.
