# Are legato's timers affected by system clock changes?

**URL:** <https://forum.legato.io/t/are-legatos-timers-affected-by-system-clock-changes/3204>\
**Category:** Legato Application Framework\
**Created:** [April 11, 2018, 3:20pm UTC](https://forum.legato.io/t/are-legatos-timers-affected-by-system-clock-changes/3204 "2018-04-11T15:20:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elektronenhirn](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/elektronenhirn/32/379_2.png) [@elektronenhirn](https://forum.legato.io/u/elektronenhirn)\
**Post date:** [April 11, 2018, 3:20pm UTC](https://forum.legato.io/t/are-legatos-timers-affected-by-system-clock-changes/3204/1 "2018-04-11T15:20:02Z")

</div>

Hello everyone,

in previous projects I experienced that running timers can be sensitive to system clock changes.

How do the legato timers behave in case of a system clock change while they are running? Will they just fire based on the specified delay? Or are they somehow based on the system clock and I need to adapt my running timers whenever the system clock changes?

Cheers  
Florian

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [April 12, 2018, 2:15am UTC](https://forum.legato.io/t/are-legatos-timers-affected-by-system-clock-changes/3204/2 "2018-04-12T02:15:05Z")

</div>

Hi,

I tried on WP8548 Legato version 17.08.1.  
If I run the following code:

* * *

#include “legato.h”

#define TIMER\_INTERVAL\_SEC 3  
#define TIMER\_INTERVAL\_uSEC 100000  
static void tmrHandler(le\_timer\_Ref\_t timerRef) {  
LE\_INFO(“INSIDE TIMER”);

}  
COMPONENT\_INIT  
{  
LE\_INFO(“Hello, world.”);  
le\_clk\_Time\_t clk = { .sec = TIMER\_INTERVAL\_SEC, .usec = TIMER\_INTERVAL\_uSEC };  
le\_timer\_Ref\_t adxlPollingTimer = le\_timer\_Create(“ADXL\_TIMER”);  
le\_timer\_SetRepeat(adxlPollingTimer, 1000);  
le\_timer\_SetInterval(adxlPollingTimer, clk);  
le\_timer\_SetHandler(adxlPollingTimer, tmrHandler);  
le\_timer\_Start(adxlPollingTimer);  
}

* * *

And keep on running the command "date +%T -s “01:50:00"” in console, I can still see the timer callback message.

Apr 12 01:50:00 | hello1[7119]/hello1Component T=main | hello1Component.c tmrHandler() 6 | INSIDE TIMER  
Apr 12 01:50:00 | hello1[7119]/hello1Component T=main | hello1Component.c tmrHandler() 6 | INSIDE TIMER  
Apr 12 01:50:00 | hello1[7119]/hello1Component T=main | hello1Component.c tmrHandler() 6 | INSIDE TIMER  
Apr 12 01:50:00 | hello1[7119]/hello1Component T=main | hello1Component.c tmrHandler() 6 | INSIDE TIMER  
Apr 12 01:50:00 | hello1[7119]/hello1Component T=main | hello1Component.c tmrHandler() 6 | INSIDE TIMER  
Apr 12 01:50:00 | hello1[7119]/hello1Component T=main | hello1Component.c tmrHandler() 6 | INSIDE TIMER

---

<div class="post-metadata">

**Author:** ![elektronenhirn](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/elektronenhirn/32/379_2.png) [@elektronenhirn](https://forum.legato.io/u/elektronenhirn)\
**Post date:** [April 12, 2018, 1:41pm UTC](https://forum.legato.io/t/are-legatos-timers-affected-by-system-clock-changes/3204/3 "2018-04-12T13:41:46Z")

</div>

Hi jyijyi,

excellent! Thank you very much!

Florian
