This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

sd_app_evt_wait() waking up before the expected time

I am using the nrf52840  with freertos and bluetooth (based on the HRM example). Application is designed to sleep for a set period of time before the RTC timer wakes the MCU. I am using sd_app_evt_wait()  to put the MCU in the systemON sleep. But i see that the MCU is waking up before the expected time. how can i find out whats causing the wake up? Could the RTC1 used in the Freertos be causing the wake up? 

Thanks

Sharu O

Parents
  • Hi,

    Could the RTC1 used in the Freertos be causing the wake up? 

    Have you set configUSE_TICKLESS_IDLE to 1 in FreeRTOSConfig.h? If so, the device will sleep until there is any other interrupt or until a task is due to wake up.

    how can i find out whats causing the wake up?

    There is no super simple and elegant way of detecting which of any interrupts has occurred. There are a few options, though. You can put breakpoints in the ISR's you suspect and see if any is hit. Or you can disable all interrupts, and run for some time before you check which interrupts are pending.

  • Thank you for the quick reply. 

    configUSE_TICKLESS_IDLE is set to 1. After disabling the interrupts ( __disable_irq(); ) before sleep , the pending interrupts ( NVIC_USPR[0] ) shows Power_clock and RTC1 to be true.  Should the Power_clock be running during system on sleep?

  • The LFCLK should run during system on sleep, as well as RTC1 when using FreeRTOS (or most other practical application as well). RTC0 will also be running if you are using the SoftDevice. Then the system will wake up on an interrupt, typically a compare event from the RTC. This is expected, but it should not wake up until it is time to do so. If there are no Bluetooth connection or advertising etc. active, then the system should only wake up for regular tasks you have running in your application. Since RTC1 has an active interrupt, this seems to be the case.

Reply
  • The LFCLK should run during system on sleep, as well as RTC1 when using FreeRTOS (or most other practical application as well). RTC0 will also be running if you are using the SoftDevice. Then the system will wake up on an interrupt, typically a compare event from the RTC. This is expected, but it should not wake up until it is time to do so. If there are no Bluetooth connection or advertising etc. active, then the system should only wake up for regular tasks you have running in your application. Since RTC1 has an active interrupt, this seems to be the case.

Children
Related