[SOLVED] OS_GetTime32() Return Parameter range ?

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] OS_GetTime32() Return Parameter range ?

    Hi, I have the following question:
    According to the manual the return value is a 32 int. This int ist a signed int. Does this mean that after (2^31) the value gets negative or 0? What happens after the overflow?

    The post was edited 1 time, last by PTepe ().

  • Hello PTepe,

    Yes, OS_GetTime32()'s return type is a signed 32 bit integer. However, the signed/unsigned is just how the binary value is interpreted, and doesn't change it's binary representation. Therefore, if the overflow from ((2^31) - 1) to (2^31) occurs, the binary value continues counting upwards from (2^31) up to ((2^32) - 1).

    Best regards,
  • Hello PTepe,

    just two additional notes:

    1. Overflow is no problem for all our timeout functions like OS_TASK_Delay(). It simply works!
    You can also use it for yourself as long as you are working with signed subtractions between two OS_GetTime32() values.

    2. If you just need the absolute system time after reset you can also use OS_TIME_Getus64() which returns the current system time in microseconds as a 64 bit value.
    With this 64 bit value OS_TIME_Getus64() can return up to 18446744073709 seconds or ~584942 years before an overflow occurs (should be sufficient for most applications :D ).

    Best regards,
  • Hi PTepe,

    Thanks for your feedback, we'll consider this case solved then.

    PTepe wrote:

    In my EmbOS version I don't have OS_TIME_Getus64() but I do the substraction and now I'm also sure what the return range of OS_GetTime32() is.
    This function was called OS_GetTime_us64() with previous versions of embOS. Since V5.00, it's called OS_TIME_Getus64().

    Best regards,