DA14531 deep sleep - multiple wake up events possible?

Hi RR,

we discussed before, that hibernation AND deep sleep modes cannot be mixed - either way works, but not able to select one or the other during runtime.

The current situation: before sending the device to deep sleep mode, I can set wake up parameters for the RTC and it wakes up as ordered - all 3 RAM areas are retained and the system starts as expected.

The question: can I define RTC event AND GPIO event for wake up and decide which one to set for wake up right before sending the device to deep sleep?

Question #2: can both be activated and whichever comes first makes the device wake?

Question #3: I have some variables, which are retained in memory. I am using flash (for dev; later OTP will be used for final product) and not sure about which memory area to retain not to lose these variables. Further more, I would like to test, which is the better option for me: a.) load the firmware from OTP for each wake up OR b.) retain all memory for the whole time and let it run from there? I read in the docs, that both ways are right, but there is a trade off between retain memory (keep memory refreshed all the time - minimal, but constant drain) vs loading from OTP (more loading time and current, but only during wake ups).

Thanks in advance!

Best regards,

Balázs

  • Hi Balázs,

    Thank you for posting your question online.
    Question 1:
    Yes, you could define the RTC event and the GPIO event for wake-up and decide which one to set for wake-up right before sending the device to deep sleep. 
    As you can see on the proxr.h file on the prox_reporter example:

    #if defined (CFG_DEEP_SLEEP_WAKEUP_POR) && defined (CFG_DEEP_SLEEP_WAKEUP_GPIO)
        #error "Config error: Can not define both CFG_DEEP_SLEEP_WAKEUP_POR and CFG_DEEP_SLEEP_WAKEUP_GPIO."
    #endif
    
    #if !defined (CFG_DEEP_SLEEP_WAKEUP_POR) && !defined (CFG_DEEP_SLEEP_WAKEUP_GPIO) && \
        !defined (CFG_DEEP_SLEEP_WAKEUP_RTC) && !defined (CFG_DEEP_SLEEP_WAKEUP_TIMER1)
        #error "Config error: At least one wake-up source has to be selected."
    #endif
    
    
    #if defined (CFG_EXT_SLEEP_WAKEUP_RTC) && defined (CFG_EXT_SLEEP_WAKEUP_TIMER1)
        #error "Config error: Can not define both CFG_EXT_SLEEP_WAKEUP_RTC and CFG_EXT_SLEEP_WAKEUP_TIMER1."
    #endif

    You would not be able to set a POR(Power on Reset) and GPIO event for the wake-up controller at the same time. And you could not use both RTC and Timer1 to configure the wake-up controller. 

    Question 2:
    Yes, you could have both activated and logically the one that comes first should wake-up your device.
    Question 3:
    If you have burned your FW into your OTP you should refer to AN-B-072, chapter 10. Boot from OTP, page:22

    If you have retained all 3 RAM blocks and you have entered Deep Sleep mode then you should refer on the Sleep Modes Tutorial, chapter 6. Deep Sleep Configuration:

    As you can see the measurement is for 16kB RAM retained, you should follow the tutorial measurement steps in order to see what is your current consumption if you have retained all the RAM blocks.

    Kind Regards,
    OV_Renesas

  • Verified and acknowledged - both can work and wake the system up, thanks! One last question: how to determine, which wake-up interrupt was triggered? (deep sleep, so firmware reloaded, if I am correct)

  • Hi There,

    Thank you for the reply.
    Glad you were able to make both wake-up interrupts work. 
    Regarding your question it depends on your application specific. 
    If you print messages in any console you can just print a message and state which method woke-up your device. You could also implement different LEDs to turn on depending on the wake-up method. 
    You could even update your advertising data to show the wake-up method with a specific byte. 
    You can retain a bool variable, and set it to true if woken-up by GPIO and set it to false if woken-up by RTC and then read the value of this bool variable. It depends on how you have configured your project and what is your functionalities. 

    If you found any answer helpful, you can verify it so you can help others in the community as well.

    Kind Regards,
    OV_Renesas

  • I mean how to know, which source was triggered? Does RTC and GPIO wake-up call the callback function during deep sleep? Should I place a variable setting operation there? Or is there a register, which identifies the source?

  • Hi There,

    Thank you for the reply.
    Please refer on the DA14531 Datasheet, on 32.20 Wake-Up Registers, on page:347

    From what I can see, there is not a register that clarifies if the interrupt was triggered by RTC or GPIO, so I would personally set a variable to check which method woke-up the device.

    Kind Regards,
    OV_Renesas

  • Ok - thanks, but original question is: how to determine the cause = how to set the variable? Should I register the callback functions and set it there? I am asking, because after deep sleep operation, a complete reboot/fw copy will take place, so no callbacks will be executed. Is this correct?

  • Hi There,

    Thank you for the reply.
    You have set the wake-up controller in order to wake up via GPIO or RTC interrupt.
    In order to do that you should use the following functions:

    app_easy_wakeup_set(set_cb_function);
    wkupct_register_callback(button_press_cb);
    wkupct_enable_irq(...);

    On the callback function you had set for app_easy_wakeup_set function you can check the PIN you have configured for your Button to see if it was triggered.
    /**
     ****************************************************************************************
     * @brief Application wakeup callback function. Registered in API message utility.
     ****************************************************************************************
    */
    static void set_cb_function(void)
    {
    
    		
    	  if (GPIO_GetPinStatus(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN))
        {   
    		arch_printf("I woke up via Button-press \r\n");	
        }
    
    }

    Or you could set there a variable to see if it woke-up via Button Press, if this variable did not change and you wake-up then it means that RTC woke-up the device.

    Kind Regards,
    OV_Renesas