cancel
Showing results for 
Search instead for 
Did you mean: 

Why uwTick in HAL is uint32_t type?

EAlek.11
Associate II

This simple question was interested by me for this reason: for uint32_t type uwTick can only count up to 4294967295 ms. It is only 49 days. In practivce it realy achievable value of or working time without reboot. In any applications it may be not enought. The HAL library may be more useful if user will can change uwTick type on CubeMX project level to uint64_t. Please can you add this feature in next releases?

P.S. I know that all STM32 have embedded RTC and it can obtain timebase for longer periods. But if the application is very simple, using of RTC will be overkill for it.

3 REPLIES 3
TDK
Guru

uint32_t is the natural and fastest integer type on the STM32. If you need more than 49 days, there are other options. I can't see it changing just to suit your own needs.

If you feel a post has answered your question, please click "Accept as Solution".
Pavel A.
Evangelist III

By the way, this funny fact hints to the real meaning of the Pentecost. It is approx. 32-bit worth of milliseconds.

This is a hidden message from ancient aliens, or whoever invented it, to check for timer overflows.

Most people aren't using delay loops or timeouts lasting 49 days.

Simple unsigned math works across the wrap, and doesn't need 64-bit math.

The 64-bit math would add a lot of clutter to delays that typically need to be sub-second, and rarely into minutes.

You're in the distinct minority wanting to increase the code burden in this way.

If you need a 64-bit count, create one, it's hardly difficult, or have a second count. Call it u64LongTermTick.

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