[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,
    Michael
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • 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,
    Til
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi Til,
    Hi Michael,

    Thank you for the reply and examples.
    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.
  • 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,

    Martin
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.