Skip to main content
Bicer
Associate II
June 8, 2021
Solved

Arduino milis() function stm32f103xx

  • June 8, 2021
  • 2 replies
  • 6242 views

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.
Best answer by Tesla DeLorean

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

2 replies

TDK
Super User
June 8, 2021

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
June 9, 2021

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

TDK
Super User
June 9, 2021
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
June 8, 2021

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

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..