Skip to main content
Basavanagouda1
Associate II
December 6, 2019
Solved

How to record time stamps in SPC5 code

  • December 6, 2019
  • 1 reply
  • 819 views

Hi All,

I need to record time stamps in the code, how i can do it? is there any example code is available?

Thanks,

Basava.

    This topic has been closed for replies.
    Best answer by Angelo Castello

    Hello,

    First of all, sorry for the delay.

    In case you are using the latest SPC5Studio tool version you can record the timestamp using the OSAL API's like these piece of code.

    result_t wait_for(uint16_t mdelay) {

    uint32_t btime = osalThreadGetMilliseconds();

    // 0xffff is a infinite wait.

    while (is_active() == 0x0) {

    if (mdelay < (osalThreadGetMilliseconds() - btime)) {

    if (mdelay != 0xffff)

    return TIMEOUT;

    }

    }

    return NO_ERROR;

    }

    Hoping this is useful for you.

    Regards,

    Angelo

    1 reply

    Angelo Castello
    Angelo CastelloBest answer
    ST Employee
    January 18, 2021

    Hello,

    First of all, sorry for the delay.

    In case you are using the latest SPC5Studio tool version you can record the timestamp using the OSAL API's like these piece of code.

    result_t wait_for(uint16_t mdelay) {

    uint32_t btime = osalThreadGetMilliseconds();

    // 0xffff is a infinite wait.

    while (is_active() == 0x0) {

    if (mdelay < (osalThreadGetMilliseconds() - btime)) {

    if (mdelay != 0xffff)

    return TIMEOUT;

    }

    }

    return NO_ERROR;

    }

    Hoping this is useful for you.

    Regards,

    Angelo