k_uptime_get/k_uptime_delta on 32-bit devices
Hi,
I want to use k_uptime_get and k_uptime_delta.
These are defined as having return type int64_t, and k_uptime_delta expects an argument of type *int64_t.
However, it seems that there is garbage in the upper 32 bits of the values returned by these functions.
Or at least, when I print the value using LOG_INF (with format %lld), I get values with some garbage data in the upper 32 bits (and it sometimes seems to corrupt other values being printed in the same LOG_INF line).
I know that it's garbage (vs. part of the actual time value) b/c (1) my system hasn't been up nearly long enough to have an uptime value of >32 bits, and (2) the value in the upper 32 bits depends on context - i.e., in one function it would be one value, in another function it's another value - which makes me strongly suspect that it's arbitrary data from other variables in the stack space.
If I cast it to uint32_t before printing with LOG_INF, it prints fine.
What's the solution? Do I cast to uint32_t every time I want to use values from these functions for any purpose other than as parameters to k_uptime_delta?
Thanks!
I want to use k_uptime_get and k_uptime_delta.
These are defined as having return type int64_t, and k_uptime_delta expects an argument of type *int64_t.
However, it seems that there is garbage in the upper 32 bits of the values returned by these functions.
Or at least, when I print the value using LOG_INF (with format %lld), I get values with some garbage data in the upper 32 bits (and it sometimes seems to corrupt other values being printed in the same LOG_INF line).
I know that it's garbage (vs. part of the actual time value) b/c (1) my system hasn't been up nearly long enough to have an uptime value of >32 bits, and (2) the value in the upper 32 bits depends on context - i.e., in one function it would be one value, in another function it's another value - which makes me strongly suspect that it's arbitrary data from other variables in the stack space.
If I cast it to uint32_t before printing with LOG_INF, it prints fine.
What's the solution? Do I cast to uint32_t every time I want to use values from these functions for any purpose other than as parameters to k_uptime_delta?
Thanks!