Device doesn't wake up from low power mode on Zephyr timer events

Our board is based on nRF52833, using SDK 2.1.2, Zephyr 3.1.99

Project is configured to enter low power mode for both CPU and peripherals

CONFIG_PM=y
CONFIG_PM_DEVICE=y

Our Zephyr application contains a timer that fires up every 5 min and performs certain activity (including advertising BLE)
I'd expect that timer event (interrupt) would wake device up from low power mode 
Unfortunately sometimes it doesn't.
Occasionally we discover devices that are "frozen" and stay in low power mode until GPIO interrupt, which ALWAYS causes device to wake up.
The problem is that I can't rely on this GPIO interrupt to happen periodically enough, timer is my last line of defense.
When I set breakpoint int he debugger, after waking up, I'm always at next instruction after WFI (low power mode Wait for interrupt)

I'm wondering if timer interrupt is not configured properly in the device tree somewhere...




Parents
  • Hi,

    Can you explain/show in detail how you have configured the timer interrupt?

  • Hi Einar,
    I didn't explicitly configure timer interrupt, you can see that in my attached device tree files, so it is whatever configuration is the default chosen by SDK (again, I'm at 2.1.2)
    I also attached device tree files created by build for reference

    Thank you,
    Alex

  • Hi,

    That is not expected. In practice, virtually all applitactions work like this waking up from time to time to perform certain tasks. Zephyr use the RTC for this, which runs of the 32.768 kHz clock (not a timer, which runs of the HF clock and is too power consuming). I do not recall seeing an issue like this before and given that this approch is virtuall universal, I wonder if you have tested multiple devices? Do you see this on all, or just one?

    If this issue is only reproducabel on one of many devices, we can look into if there could be an hardware failure. If not, it would be good to know more about your application. Could there ber another reason it does not behave as it should? For instance, could it be an issue related to qork queue or similar? Perhaps it is full due to some issue/bug causing problems processing work? Or somethign else? Have you done more debugging to see the state of the device when it does not wake up on time?

  • Hi Einar, 
    You are absolutely correct, it is RTC and not a timer, my board has RTC running of 32 KHz crystal,
    and I have CONFIG_NRF_RTC_TIMER=y
    The problem has so far been reproduced on 20 or so different boards (out of thousands), so its not a one off. It is not reproducible at will unfortunately.
    On one occasion I was able to attach debugger to board in this state, and found myself at break point on next instruction after WFE (I suspect connecting JTAG generated an interrupt). Unfortunately I didn't do any further debugging at that time, wasn't sure what to look at. Once the PC was past WFE - everything went back to normal and Zephyr started running
    It is of course possible that the problem is caused by a bug in app, full work-queue and such...

  • Hi,

    I see. Do you have the hardware watchdog enabled? If not, it would be intreresting to see if using the watchdog would help, so that the device would reset in case it is in this bad state. One reason is that it could be a potential fail-safe/workaround if the issue is not fixed, but also as the watchdog is based on the LFCLK, and if the watchdog functions, that means that the LFCLK is also running. Given that this issue is difficult to reproduce I am not sure how easy it is to test, though?

    Focusing on the firmware side of things, could there be a bug in your fimrware that could create a situation were there are no threads that have any work to do at any time in the future withotu a GPIO interrupt? So that other than the idle task which enters WFE there is no work to be done before a GPIO interrupt happens?

  • Hi Einar,
    Thank you, HW watchdog is a great idea, I was thinking I need to implement it regardless of this problem.
    There is a bit of concern that If max WD timer is not long enough - and therefore needs to be pet frequently - it could have impact on my battery life, but I suspect it would be tolerable.
    Could you please point me to concise example of WDT implementation ?
    The only example I found in SDK 2.1.2 is MemFault demo, and its very memfault-specific
    Thank you,
    Alex

  • Hi Alex,

    I suggest you refer to the watchdog driver sample under zephyr/samples/drivers/watchdog/ (this link is for SDK v2.9, but the sample exist in 2.1.2).

Reply Children
No Data
Related