Skip to main content
Graduate II
January 28, 2024
Question

Tick OS to Tick LSE Conversion

  • January 28, 2024
  • 1 reply
  • 902 views

Hi

This is a general question regarding entering sleep, so whatever part you know and can explain will benefit greatly.

The questions are much around the function LpTimerStart, which in general converts OS ticks to LSE clock ticks.

 

The number 1e12 ( or 1,000,000,000,000) is used commonly, why is that specific number chosen?

What is "ps" as referred to in CFG_TS_TICK_VAL_PS, time_ps ?

Can you explain the formula :

 

 

#define CFG_TS_TICK_VAL_PS DIVR( ((uint64_t)CFG_RTCCLK_DIV * 1e12), (uint64_t)LSE_VALUE )

 

 

#define CFG_TS_TICK_VAL_PS DIVR( ((uint64_t)CFG_RTCCLK_DIV * 1e12), (uint64_t)LSE_VALUE )


And this: ( this one is from LpGetElapsedTime)

 

 

 time_ps = (uint64_t)((CFG_TS_TICK_VAL_PS) * (uint64_t)(LpTimerContext.LpTimeLeftOnEntry - LpTimeLeftOnExit));

 

time_ps = (uint64_t)((CFG_TS_TICK_VAL_PS) * (uint64_t)(LpTimerContext.LpTimeLeftOnEntry - LpTimeLeftOnExit));

 

Thanks

    This topic has been closed for replies.

    1 reply

    Super User
    January 29, 2024

    ps is picoseconds. 1e12 picoseconds in a second. Macro gets the number of picoseconds per LSE tick.

    Second definition gets the number of picoseconds left.