ke_timer timing varies with connection interval

3 posts / 0 new
Last post
mohit3112
Offline
Last seen:7 months 1 week ago
Expert
加入:2014-08-04 13:45
ke_timer timing varies with connection interval

I have to measure time in sleep mode so i am using app_timer_set function as it works in sleep mode

code for timer handler

int timer_handler()
{
app_disable_sleep();
app_timer_set(FLIP_MAIN_TIMER,TASK_APP,2);
time_n = lld_evt_time_get();
if(ke_state_get(TASK_APP) == APP_CONNECTED)
{
debug_data_t debug_data;
debug_data.data_float =(time_n-time_o)*0.625;
attmdb_att_update_value((BAS_IDX_DEBUG_LOG_VAL + bass_env.shdl[0]),4,0,(uint8_t *)debug_data.data_bytes);
prf_server_send_event((prf_env_struct *)&bass_env, false,(BAS_IDX_DEBUG_LOG_VAL + bass_env.shdl[0]));
}
time_o =time_n;
app_set_extended_sleep();
return (KE_MSG_CONSUMED);
}

I am trying to verify the timing using lld_evt_time_get() function.
Here i noticed following thing:

if connection_interval > timer_delay -------- then timer_handler executes at different time intervals (not i the one defined by the function call) i.e. (time_n-time_o)*0.625 not constant
if connection_interval < timer_delay -------- then timer_handler executes at interval equal to connection interval i.e. (time_n-time_o)*0.625 = connection_interval

Timer is not executing at the proper intervals this is a big problem as we need a timer to work in sleep mode ( it is used to find RR-intervals from the heart rate sensor )

请尽快回应

Thanks
Mohit Maheshwari

Device:
MT_dialog
Offline
Last seen:6 days 3 hours ago
工作人员
加入:2015-06-08 11:34
Hi mohit3112,

Hi mohit3112,

The kernel timers have an error of -20ms to 0. You wont be able to achieve this time resolution of 20ms you want.

Thanks MT_dialog

mohit3112
Offline
Last seen:7 months 1 week ago
Expert
加入:2014-08-04 13:45
seriously error of -20ms to 0

seriously error of -20ms to 0 , why you call it kernel_timer then you can call it kernel_jitter