wkupct and app_easy_timer doesn't work together in sdk5

8 posts / 0 new
Last post
achao1104
Offline
Last seen:5 years 3 months ago
Master
加入:2015-12-24 10:56
wkupct and app_easy_timer doesn't work together in sdk5

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();

Device:
achao1104
Offline
Last seen:5 years 3 months ago
Master
加入:2015-12-24 10:56
please help, dialog support.

please help, dialog support.

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

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

achao1104
Offline
Last seen:5 years 3 months ago
Master
加入:2015-12-24 10:56
what is the reason for

what is the reason for placing " arch_set_deep_sleep();" at the first and "arch_ble_ext_wakeup_on();" last?

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

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

PDonchev
Offline
Last seen:2 years 8 months ago
加入:2015-06-21 14:37
Hi 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?

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

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

PDonchev
Offline
Last seen:2 years 8 months ago
加入:2015-06-21 14:37
Hi,

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.