Is there any example program that responds to button click without going to external-wakeup-only mode?

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
5 posts / 0 new
Last post
oren.
Offline
Last seen:1 year 7 months ago
Expert
Joined:2014-06-28 22:03
Is there any example program that responds to button click without going to external-wakeup-only mode?

Hi,
So far I found only peripheral examples that callarch_ble_ext_wakeup_on()before configuring the button and going to sleep.
i.e. the program is not intended to work (advertise or respond to timers) while it waits for a button click.

Furthermore, when the wkupct callback is called it does something like:

> static void app_button_press_cb(void)
> {
> if (GetBits16(SYS_STAT_REG, PER_IS_DOWN))
> {
> periph_init();
> }
>
>如果(arch_ble_ext_wakeup_get ())
> {
> arch_set_sleep_mode(app_default_sleep_mode);
> arch_ble_force_wakeup();
> arch_ble_ext_wakeup_off();
> app_easy_wakeup();
> }
> }

Notice how the call toarch_ble_ext_wakeup_off()turns off a boolean flag (namedsleep_ext_force.), so future calls toarch_ble_ext_wakeup_get()will return错误的. Therefore, if there are many interrupts in a short interval (app_button_press_cb()连续多次调用),代码块包裹在第二个内部ifstatement will be executed only once.

We have a project in which there are many interrupts in a short interval, to which we want to respond only once. However, we want the program to keep "working" while waiting for the "button-clicks" (advertise and run timers) - for example, count the number of button-clicks and update the advertising payload with this number.
We are experiencing a very strange behavior - program resets, program stop working and waste battery, etc. We are not sure where the bug is.
Is there an example program that do something similar?
Should I follow a similar pattern, i.e. do something like:

> bool waiting_for_button __attribute__((section("retention_mem_area0"), zero_init));
> static void app_button_press_cb(void)
> {
> if (GetBits16(SYS_STAT_REG, PER_IS_DOWN))
> {
> periph_init();
> }
>
> if (waiting_for_button)
> {
> arch_set_sleep_mode(app_default_sleep_mode);
> arch_ble_force_wakeup();
> waiting_for_button = false;
> app_easy_wakeup();
> }
> }

i.e. Should I use a different boolean flagwaiting_for_button这不会影响睡眠arch_ble_ext_wakeup_on()?
Is there a risk in listening for a button click without going to external-wakeup-on mode ? Like interrupting the program if the button is clicked in exactly the same moment it is executing?

I know that thewkupct_enable_irqaccepts two parameters number-of-events and debouncing-time. We will use higher number-of-events to avoid too many wakeups. I want to be sure that even with a low number-of-events the program does not reset or goes crazy.

问候,
Oren Zomer

Device:
oren.
Offline
Last seen:1 year 7 months ago
Expert
Joined:2014-06-28 22:03
Arrgh - there is no html tag

Arrgh - there is no html tag that maintains the indentation... sorry for the ugly code.

MT_dialog
Offline
Last seen:2 months 2 weeks ago
Staff
Joined:2015-06-08 11:34
Hi oren,

Hi oren,

I am not sure if i get the bottom line of the question, please have a look at the comments below, hopefully will provide some help.

否,没有其他示例,使用按钮演示唤醒中断或处理多个唤醒中断。使用ARCH_BLE_EXT_WAKEUP_ON()以便每10秒抑制设备的定期唤醒,如果您有ARCH_BLE_EXT_WAKEUP_ON(),您将能够从内部计时器唤醒,即使您不调用ARCH_BLE_EXT_WAKESUP_ON()您将能够侦听外部唤醒中断,您不必调用ARCH_BLE_EXT_WAKEUP_ON()以启用外部中断(您可以通过删除ARCH_BLE_EXT_WAKEUP_ON()和违反IF()条件来验证。在回调中,但如果您这样做意识到设备将在短时间内自动唤醒10秒钟)。如果中断发生在唤醒ISR的同时发生的情况下,则中断将被注册为挂起,并且一旦当前运行的ISR退出,就会出现为什么需要保持ISR尽可能短。

Thanks MT_dialog

oren.
Offline
Last seen:1 year 7 months ago
Expert
Joined:2014-06-28 22:03
Hi,

Hi,
I now noticed an old post of mine:https://support.dialog-semicondiondiondum/forums/post/dialog-smartbond-bl ....
We increased CFG_MAX_SLEEP_DURATION_EXTERNAL_WAKEUP_MS from 10 seconds to 60 seconds - and fixed the bug in rwip_slot_2_lpcycles_rcx (i.e. working with uint64_t instead of uint32_t). We will increase it even more to 1 hour, so we could ignore its power consumption in our calculations.
You already said there that calling arch_ble_ext_wakeup_on() will not suppress the timers. I was confused because the code-comment above arch_ble_ext_wakeup_on says: "Puts the BLE core to permanent sleep. Only an external event can wake it up. BLE sleeps forever waiting a forced wakeup.". Please change the comment.

We will also change the program so that it will looks as similar as possible to your code examples (except that the timers and advertising will still run when waiting for button clicks).

使用ARCH_BLE_EXT_WAKEUP_ON()是否有负副作用?任何明显更长的唤醒时间?深/延长睡眠期间功耗的任何重大变化?为什么所有外围设备都没有默认使用ARCH_BLE_EXT_WAKEUP_ON并抑制此计时器?10秒唤醒是什么好处?如果我将其更改为60秒或1小时,可能会发生什么?

谢谢,
Oren

MT_dialog
Offline
Last seen:2 months 2 weeks ago
Staff
Joined:2015-06-08 11:34
Hi oren,

Hi oren,

我已经提到了Arch_ble_ext_Wakeup_on()所做的内容,因此如果增加CFG_MAX_SLEEP_DOURATION_EXTERNAL_WAKEUP_MS,并且您对定期唤醒值满意,则其确定不使用ARCH_BLE_EXT_WAKEUP_ON()。所有外围示例都不使用该函数,因为只有BLE_APP_SLEEPMODE进入永久睡眠而没有任何BLE活动,所以如果不使用这一点,您会看到周期性醒来。如上所述您之前的POST()那个超时从GTL接口中剩余,因为您将修补程序应用于上一篇文章中提到的错误,那么它应该可以增加值。

Thanks MT_dialog