Skip to main content
Basavanagouda1
Associate II
Dec 6, 2019 9:44 PM UTC
Solved

How to record time stamps in SPC5 code

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.
    Angelo Castello
    Angelo CastelloBest answer
    ST Employee
    Jan 18, 2021 6:11 PM UTC

    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
    Jan 18, 2021 6:11 PM UTC

    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