Skip to main content
Bicer
Associate II
Jun 8, 2021 9:48 PM UTC
Solved

Arduino milis() function stm32f103xx

I am trying to port some Arduino library to stm32. In Arduino, 

millis()

 returns the number of milliseconds since boot. Is there an equivalent function in stm32? I am using stm32f103 MCU.

This topic has been closed for replies.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
Jun 8, 2021 10:53 PM UTC

HAL_GetTicks () should suffice, typically a 1ms tick via SysTick ​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..

6 replies

TDK
Jun 8, 2021 10:41 PM UTC

No, there's not. You can roll your own using a timer or the DWT counter, but be aware both of these can roll over.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Bicer
BicerAuthor
Associate II
Jun 9, 2021 7:39 AM UTC

Thanks for your feedback. How can I use the DWT counter? I just want to see the running time of the mcu.

TDK
Jun 9, 2021 1:42 PM UTC
Google "stm32 enable dwt counter" or use Tesla's suggestion.
"If you feel a post has answered your question, please click ""Accept as Solution""."
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
Jun 8, 2021 10:53 PM UTC

HAL_GetTicks () should suffice, typically a 1ms tick via SysTick ​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..