Skip to main content
DMist.992
Visitor II
November 10, 2019
Question

Use systick as a timer and read timer value

  • November 10, 2019
  • 2 replies
  • 937 views

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.

This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
November 10, 2019

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
S.Ma
Principal
November 10, 2019

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.