cancel
Showing results for 
Search instead for 
Did you mean: 

Use systick as a timer and read timer value

DMist.992
Associate

i am new in stm32 . i am using stm32lo31 series nucleo board . i want to read push button press timing so i am using polling method to detect read button press event. then i want time between press event to release. how can i configure systick to read time between that .i tried so many online questions and answers but i can't find proper answer in detail in HAL library.

2 REPLIES 2

Would SysTick be managed by CMSIS functions? You could read the count directly also. 24-bit down-count so will need to factor that into your delta computation.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
S.Ma
Principal

Buttons... deboucing, glitches, etc..

I would set a ram flag in systick interrupt every 50 msec.

In the main loop, once the flag is set, I check the pin level and if pressed, increment a KeyPressedTime_50msec or clear it.

Debounce? Counter must reach 3 to key pressed. Key repetition press events, Hot key event after pressing for more than 5 seconds, etc... can be done through this polling counter. For waking up the MCU from low power mode, select a EXTI or WAKEUP pin as button press signal.

Set the flag in interrupt, wait for it in the main loop and clear it once its purpose is done.