Multiple timers not working

4 posts / 0 new
Last post
wisilica
Offline
Last seen:10月3周前
加入:2015-03-17 08:16
Multiple timers not working

Hi Dialog Team,

I am using 3 timers in my ble_app_peripheral project. Initially, I start a systick timer of duration 2ms, then in the callback of systick timer, I start a kernel timer by using the api app_easy_timer(), of 100ms. I continue calling this function, and upto this point the project works fine. Now, when I call another kernel timer of 5 seconds as follows, device execution stops abruptly. This is the code I am using :

systick_register_callback(handle_2ms_timer);

void abc (void)
{
.....
systick_start(2000,1);

}
void handle_2ms_timer(void)
{

systick_stop();

listen_interval = 50;
timer_listen_interval = app_easy_timer((listen_interval*10),handle_listen_interval_timer);
user_adv();

}

void user_adv()
{
struct gapm_start_advertise_cmd* cmd;
cmd = app_easy_gap_non_connectable_advertise_get_active();

set_parser_data();

set_beacon_data(cmd);

app_easy_gap_non_connectable_advertise_start();
timer_adv_interval = app_easy_timer((adv_interval*10),handle_adv_interval_timer);

}

The execution doesnt reach the callback handler of either kernel timers.
When just 2 timers, systick and adv_interval_timer are called, device functioning is fine. Problem starts when I am introducing a second kernel timer concurrently.

Thanks in advance,

wisilica

Device:
MT_dialog
Offline
Last seen:2 months 3 weeks ago
工作人员
加入:2015-06-08 11:34
Hi wisilica,

Hi wisilica,

There is no issue in setting two kernel timers at the same time, few things that you should keep in mind is:

  • Systick timer isn't able of waking up the device, if you start the systick timer and the device decides to go to sleep the device wont wake up via the timer but only when it is time to serve the next BLE event, if you set a systick timer and you fall asleep simply the callback will never occur.
  • The only timers that can wake up the device are the kernel timers.
  • You will have to set the kernel timers when the device is awake, i can see that you are setting the timer when you start advertise, that timer will occur.

When you say that your code execution stops, where is it stopping ?

Thanks MT_dialog

wisilica
Offline
Last seen:10月3周前
加入:2015-03-17 08:16
Hi Dialog,

Hi Dialog,

I have found that the time duration I am setting for both the timers are the same. Is this the reason why the device execution stops? If I am setting different time duration for both the timers, the execution doesnt stop.

Thanks,
Wisilica

MT_dialog
Offline
Last seen:2 months 3 weeks ago
工作人员
加入:2015-06-08 11:34
Hi wisilica,

Hi wisilica,

No, this should not happen, you will have to check exactly where the code stalls, in which function, in order to see why this is happening.

Thanks MT_dialog