cancel
Showing results for 
Search instead for 
Did you mean: 

SPC5 Studio osalThreadGetMicroseconds overflow

sonerb
Associate II

Hi,

In the osal.c line 389 "osalThreadGetMicroseconds" function uses "osalSysTime_ST2US" macro to convert ticks to microseconds.

The macro uses osalsystime_t variable type that is 32-bit length.

 return ((uint32_t)((((osalsystime_t)ticks) * 1000000UL) / osal_ticks_per_sec));

After 4294 microseconds, the value of the calculation overflows 32-bit and gives a wrong time. (4295 x 1000000 = 0x100007FC0 )

I change to type to uint64_t and it's working now.

 return ((uint32_t)((((uint64_t)ticks) * 1000000UL) / osal_ticks_per_sec));

1 REPLY 1
ODOUV.1
ST Employee

Hello,

thank you for your remark.

We will fix in next release.

Best regards.