cancel
Showing results for 
Search instead for 
Did you mean: 

Arduino milis() function stm32f103xx

Bicer
Associate II

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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

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

View solution in original post

6 REPLIES 6
TDK
Guru

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".

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

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

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

Google "stm32 enable dwt counter" or use Tesla's suggestion.
If you feel a post has answered your question, please click "Accept as Solution".

The uint64_t variable is so big that it really never overflows.

HAL_GetTicks () 

is useful.

I just tested in stm32L475.

Its working.

I am getting 1001 count for delay of 1000 milliseconds.