Dialog,
In my project, I let device in deep sleep until a wakeup interrupt is fired or a fixed of time passed.
the following works well, as long as there is a wakeup interrupt fired, it will be waked up and advertise and then goes into sleep.
static void adv_data_update_timer_cb()
{
app_adv_data_update_timer_used = 0xFFFF;
app_easy_gap_advertise_stop();
printf_string("\n\radvertise done\r\n");
/ / app_easy_timer_cancel_all();
//app_easy_timer(30000,ble_timer_cb);
wkupct_disable_irq();
wkupct_register_callback(wake_up_cb);
wkupct_enable_irq(0x40, 0x40, 1, 0);
arch_set_deep_sleep();
arch_ble_ext_wakeup_on();
}
but if I use app_easy_timer and wkupct together as below, it doesn't work. After wakeup interrupt is fired, it won't be waked up.
printf_string("\n\radvertise done\r\n");
app_easy_timer_cancel_all();
app_easy_timer(30000,ble_timer_cb);
wkupct_disable_irq();
wkupct_register_callback(wake_up_cb);
wkupct_enable_irq(0x40, 0x40, 1, 0);
arch_set_deep_sleep();
arch_ble_ext_wakeup_on();
please help, dialog support.
Hi achao1104,
Most probably you dont wake up the BLE properly when waking up. Please try this for waking up once after 6 seconds or by button:
void wake_up_cb(void)
{
if(GetBits16(SYS_STAT_REG, PER_IS_DOWN))
periph_init();
arch_ble_force_wakeup();
arch_ble_ext_wakeup_off();
default_advertise_operation();
}
void app_on_db_init_complete(void)
{
arch_set_deep_sleep();
test_timer = app_easy_timer(600,wake_up_cb);
wkupct_enable_irq(0x200, 0x200, 1, 0);
wkupct_register_callback(wake_up_cb);
arch_ble_ext_wakeup_on();
}
Thanks MT_dialog
what is the reason for placing " arch_set_deep_sleep();" at the first and "arch_ble_ext_wakeup_on();" last?
Hi achao1104,
In the project i used to test this i haven't enabled by default deep_sleep so i had it enabled somewhere. The arch_ble_ext_wakeup_on() should be called last since will put the ble in permanent sleep waiting for an external interrupt. Please check the UM-B-006.pdf file for more info about the sleeping procedures.
Thanks MT_dialog
Hi MT_dialog,
I'm just curious, how the system will wake up after 6 seconds, if the BLE module is permanently disabled in the given example?
Hi PDonchev,
The BLE is permanently disabled but the setting message for the timer is allready sheduled, so when the time comes the BLE will wake up and serve the event. Have you tried the example and didn't work ?
Thanks MT_dialog
Hi,
Thanks for explanation, very helpful. I'm still on my first BLE project (which is low priority at the moment) and I still study the SDK.
In the beginning I was very confused, but now I'm getting the big picture. SDK5 also helped a lot.