Hi,
I'm trying to get extended sleep working on my custom board with the DA14581 MOD board. The setup is as follows:
The system is initially configured with extended_sleep without OTP Copy. The wakeup is configured on a button interrupt, which does wake the system up on first press. Upon wakeup, the sleep is disabled (using arch_disable_sleep) so I can sample a sensor every 100ms using the timer0. The extended_sleep is then meant to be re-enabled after 7 seconds.
After a defined period of time(~3-4 seconds), the system seems to just decide it should go back into extended_sleep, eventhough it was never re-enabled, and according to arch_get_sleep_mode the sleep mode is off (0). Of course then the timer0 is no longer running, so the sensor is no longer being sampled.
If I configure the system to not use extended_sleep then everything works as expected. As well, this system with extended_sleep works fine when running off RAM (using KEIL debug), but not when using the flash.
Do you have any idea what is causing this?
Thanks
I had set the default_operation_adv = NULL, rather than user_app_adv_start as all the other examples did. Once its put back to user_app_adv_start then it works fine in the flash while the advertising is running. If I wait until the advertising is complete to press the button then it again does the freezing. Based on the current consumption when it freezes, it looks like its not actually in extended_sleep mode, and actually still in active mode, just stuck somewhere.
Do you have any ideas on why this is? From my perspective all this changed is it advertising at the beginning versus not, but it seems to affect more than just that.
Hi AdamShier,
Thanks for your question online and for your interest in our TINY module solution, Let me change the device selection for your initial post, as the DA14581 is selected instead of the DA14531 TINY Module.
Please correct if my understanding in wrong : the module is configured in EXT Sleep mode with OTP copy upon system initialization - user_app_init() callback – and the wake-up controller is also enabled in order to wake-up the system via a GPIO trigger. When the chips wake-up, can you please indicate if it also starts advertising ? Do you call the user_app_adv_start() callback?
>>>After a defined period of time(~3-4 seconds), the system seems to just decide it should go back into extended_sleep, eventhough it was never re-enabled
So, if you are booting from System-RAM, can you wake it up after a GPIO trigger after the device decides to sleep?
Can you please check if a timer causes the “automatic” sleep? Which SDK project are you using as a reference to develop your own application?
>>>Based on the current consumption when it freezes, it looks like its not actually in extended_sleep mode, and actually still in active mode, just stuck somewhere.
可以在调试模式和c运行它heck if it the code breaks into an assertion, NMI etc.?
If the default_operation_adv = user_app_adv_start, then the DA4531 will start advertising automatically after the system initialization.
Thanks, PM_Dialog
The module is configured in ext_sleep_modewithoutOTP copy, user_app_init is used as the .app_on_init, and the wakeup controller is configured to use a GPIO as the wakeup from the button. When the chip wakes up it does not start advertising, because I have purposedly removed that aspect. The user_app_adv_start() callback is only called when someone holds the button for 10 seconds.
I can wake it up the first time from the sleep with the GPIO trigger. Once it wakes up it will freeze after the 3-4 seconds, unless advertising is enabled, in which case everything will work fine.
The problem with running in debug mode is that everything works fine in debug mode, but not when running from the flash.
I understand the aspect of default_operation_adv = user_app_adv_start automatically starting the advertising at the beginning. Im just not sure why that seems to change the behavior of the code in terms of getting frozen after the defined period, versus working as expected.
In terms of a base project that it is similar to, it would be a combination of the user_peripheral one and the proxy one for the sleep modes.
The code also works fine if I use the app_easy_timer() instead of setting up the timer0 as the counter. I know the timer0 is disabled in extended sleep mode but im using arch_disable_sleep() upon wakeup from the button so I dont see why that would be a problem.
Upon wakeup from the button the timer is fully reinitialized/configured so it seems to be starting properly, but after some time the code just stops.
Edit: This time from button wakeup until freeze is 2.7 seconds, very consistently. And its definately not sleeping, the run current goes up from 200uA to 300uA when the freeze occurs.
Hi AdamShier,
You are right – the timer0 is off when the device is sleeping, as all the peripheral blocks. You can use the app_easy_timer() to wake up periodically because it’s using the BLE timer. Can you please check if the device is sleeping between the advertising intervals? I
>>>The problem with running in debug mode is that everything works fine in debug mode, but not when running from the flash.
When the debugger is attached, this prevents the system to go into any of sleep modes.
Could you please clarify what you mean that the device getting frozen after the defined period?
Since you are booting from flash, you could use the arch_printf() in order to print some debugging information in a serial terminal.
Thanks, PM_Dialog
When using the flash to boot, the device definately goes to sleep when I'm not pressing the button or inbetween advertising, sleep current drops to ~10uA.
I am using printf in order to determine that it is frozen. When the button is pressed, sleep is disabled, and the timer0 is started and generates an interrupt every 100ms. All the interrupt handler does is print an incrementing index. The incrementing index works for 2.7 seconds, until it just stops, that's how I know it freezes consistently after 2.7 seconds.
这是或多或少地得到解决。I don't exactly know why it was freezing after the 2.7 seconds, or why it was working when advertising is enabled, but it works properly now when I've removed the
if (arch_ble_ext_wakeup_get()) in the button press callback. I think it's in the example projects because the button starts the advertising, and it only evaluates true when the advertising is complete. So for my project it makes sense for it to not be there.
Hi AdamShier,
The WDOG time out is around 2.6sec by default, so I assume that the WDOD timer expires.
Did you run is with the debugger attached? You should also have the development debug enabled - CFG_DEVELOPMENT_DEBUG.
Thanks, PM_Dialog
The wdog is not defined in the config file, but those times seem too close to be a coincidence. The CFG_DEVELOPMENT_DEBUG is defined. The problem occurs when running from flash, and occurs whether or not the debugger is attached.
Hi AdamShier,
Could you please define the WDOG and run it in debug mode? If you run it from System-RAM in normal mode (without the debugger attached), can you replicate this behavior? When the debugger is attached, this blocks the system to sleep.
Thanks, PM_Dialog
So I tried enabling the watchdog and that seems to solve it also, rather than removing the check on the arch_ble_ext_wakeup_get in the wakeup callback. I'll summarize the combinations here for people:
If you have
if (arch_ble_ext_wakeup_get())
{
arch_ble_force_wakeup();
arch_ble_ext_wakeup_off();
app_easy_wakeup();
}
And you want to disable sleep for some period, then re-enable sleep at some later point, then the watchdog must be enabled. Otherwise after waking the code will freeze after the watchdog timeout, still not sure why exactly. There's also the case when advertising is enabled then it will work while the device is advertising, then will freeze again when finished, therefore with infinite advertising you dont see this problem.
Hi AdamShier,
Thanks for your indication and glad that you got it working.
Thanks, PM_Dialog