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 returnfalse. Therefore, if there are many interrupts in a short interval (app_button_press_cb()is called many times in a row), the block of code wrapped inside the secondifstatement 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_buttonwhich does not affect the sleep likearch_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.
Regards,
Oren Zomer

Arrgh - there is no html tag that maintains the indentation... sorry for the ugly code.
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.
No, there is no additional example that demonstrates the wake up interrupt using a button or handling multiple wake up interrupts. The arch_ble_ext_wakeup_on(), is used in order to suppress the periodic wake up of the device every 10 seconds, if you have the arch_ble_ext_wakeup_on() you will be able to wake up from an internal timer, even if you dont invoke the arch_ble_ext_wakeup_on() you will be able to listen to an external wake up interrupt, you dont have to invoke the arch_ble_ext_wakeup_on() in order to enable the external interrupt (you will be able to verify that by removing the arch_ble_ext_wakeup_on() and offcourse the if() condition in the callback, but if you do that be aware that the device will automatically wake up in a period of 10 seconds for a brief period of time). Offcourse if the interrupt occurs at the same time that the wake up ISR is executing then the interrupt will be registered as pending and will occur as soon as the currently running ISR exits, thats why you need to keep the ISR as short as possible.
Thanks MT_dialog
Hi,
I now noticed an old post of mine:https://support.dialog-semiconductor.com/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()? Any significantly longer wakeup-times? Any significant change in power consumption during Deep/Extended sleep? Why is it not the default for all peripherals to use arch_ble_ext_wakeup_on and suppress this timer? What does the 10-seconds wakeup good for? What may happen if I change it to 60 seconds, or 1 hour?
Thanks,
Oren
Hi oren,
I allready mentioned what the arch_ble_ext_wakeup_on() does, so if you increase the CFG_MAX_SLEEP_DURATION_EXTERNAL_WAKEUP_MS and you are satisfied with the periodic wake up value then its ok not to use arch_ble_ext_wakeup_on(). The function is not used by all the peripheral examples since only the ble_app_sleepmode goes to permanent sleep without any BLE activity, so if this is not used you would see that small waking up periodically. As mentioned your previous post () that timeout is leftover from the GTL interface, since you apply the patch for the bug mentioned in the previous post then it should be ok to increase the value.
Thanks MT_dialog