This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Timer not correct?

Now,I use a 1s timer to calculate the clock. At first,I use the telephone to adjust the time to fit the telephone time. but finally(after a night ) the result runs fastly compared with the telephone. For example,the telephone time is 8:40,but the devices are 8:42 or 8:46. The code is:

#define APP_TIMER_PRESCALER    0
#define CLOCK_MEAS_INTERVAL    APP_TIMER_TICKS(1000,APP_TIMER_PRESCALER)

static void ble_stack_init(void)
{
  SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM,NULL);
}
create the timer:
app_timer_create(&m_clock_timer_id,APP_TIMER_MODE_REPEATED,clock_meas_timeout_handler);
start the timer:
app_timer_start(m_clock_timer_id,CLOCK_MEAS_INTERVALL,NULL);


static void clock_meas_timeout_handler(void *p_context)
{
 UNUSED_PARAMETER(p_context);
 clock_process();//calculate the time
}

The function of clock_process() is dealling with the clock time,but the result as describe above.

Related