Wakeup from sleep with gpio intrrupt

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at https://www.dialog-semiconductor.com/support . We’ll be fixing bugs / optimising the searching and tagging over the coming days.
4 posts / 0 new
Last post
jagath52
Offline
Last seen: 1 year 6 months ago
Joined: 2020-07-06 10:40
Wakeup from sleep with gpio intrrupt

Hello 

I am using da14695 controller with extended and hibernation sleep mode.
I want to wake up the device with 2 gpios for both extended and hibernation

hw_gpio_set_pin_function(ACCEL_INT_PORT,ACCEL_INT_PIN,HW_GPIO_MODE_INPUT_PULLDOWN,HW_GPIO_FUNC_GPIO);
 void wkup_init(void)
{
        hw_wkup_init(NULL);

        /*
         * Set debounce time expressed in ms. Maximum allowable value is 63 ms.
         * A value set to 0 disables the debounce functionality.
         */
        hw_wkup_set_debounce_time(10);

        /*
         * Enable interrupts produced by the KEY block of the wakeup controller (debounce
         * circuitry) and register a callback function to hit following a KEY event.
         */
        hw_wkup_register_key_interrupt(acceleroIntrrupt_cb, 1);

        /*
         * Set the polarity (rising/falling edge) that triggers the WKUP controller.
         *
         * \note The polarity is applied both to KEY and GPIO blocks of the controller
         *
         */

        hw_wkup_configure_pin(ACCEL_INT_PORT, ACCEL_INT_PIN, 1, HW_WKUP_PIN_STATE_HIGH); // 0-> rising edge : 1 falling edge 1 -> board ;; 0 -> EVM

        /*
         * Add a PDC LUT entry so that to wake up the M33 core following an event on PORT0
         * This is important since M33 is turned off when the device enters sleep.
         */

        hw_wkup_enable_irq();
}

This key wakeup is working as expected and device is waking up from both extended and hibernation.

But 

hw_gpio_set_pin_function(ACCEL_INT_PORT,ACCEL_INT_PIN,HW_GPIO_MODE_INPUT_PULLDOWN,HW_GPIO_FUNC_GPIO);
 void wkup_init(void)
{
        hw_wkup_init(NULL);
        /*
         * Add a PDC LUT entry so that to wake up the M33 core following an event on PORT0
         * This is important since M33 is turned off when the device enters sleep.
         */
        hw_wkup_gpio_configure_pin(ACCEL_INT_PORT,ACCEL_INT_PIN,1,HW_WKUP_PIN_STATE_HIGH);
        pdc_wkup_gpio_id = hw_pdc_add_entry(HW_PDC_LUT_ENTRY_VAL(ACCEL_INT_PORT, ACCEL_INT_PIN,HW_PDC_MASTER_CM33, 0));
        OS_ASSERT(pdc_wkup_gpio_id != HW_PDC_INVALID_LUT_INDEX);

        /*
         * Trigger the PDC LUT entry by SW. This action guarantees that the PD_SYS
         * power domain stays ON in case the application invalidates all the other
         * activated PDC entries which are keeping the M33 alive.
         */
        hw_pdc_set_pending(pdc_wkup_gpio_id);

        /*
         * Acknowledging the newly created (and activated) PDC entry is recommended
         * although not strictly needed, since M33 will automatically acknowledge
         * all the M33 pending PDC entries before its next attempt to enter sleep.
         */
        hw_pdc_acknowledge(pdc_wkup_gpio_id);
        hw_wkup_register_gpio_p1_interrupt(acceleroIntrrupt_cb,2);

        hw_wkup_enable_irq();
}

 

void acceleroIntrrupt_cb(void)
{
        status = hw_wkup_get_status(HW_GPIO_PORT_1);
        hw_wkup_clear_status(HW_GPIO_PORT_1,status);

        wakeUpExtendedSleep = true;
        hw_wkup_reset_interrupt();
        pm_sleep_mode_set(pm_mode_active);

        hw_gpio_set_pin_function(REDLEDPORT, REDLEDPIN, HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_GPIO);
        hw_gpio_pad_latch_enable(REDLEDPORT, REDLEDPIN);
        hw_gpio_pad_latch_disable(REDLEDPORT, REDLEDPIN);

        hw_gpio_set_inactive(REDLEDPORT,REDLEDPIN);
            delay_ms(1000);
            delay_ms(1000);
         hw_gpio_set_active(REDLEDPORT, REDLEDPIN);

}

But the gpio wake up is not waking up the device from both hibernation and extended sleep mode.
Further i placed led toggle in gpio intrrupt callback, The call back is executing and led is turned on but device is waking up from sleep
After getting intrrupt the device is hanging 
I want to use two gpio for wakeup from sleep, How to configure and use two gpio wakeup using hw_wkup_gpio_configure_pin

Thank you

Jagath

Device: 
PM_Dialog
Offline
Last seen: 7 months 1 week ago
Staff
Joined: 2018-02-08 11:03
Hi jagath52,

Hi jagath52,

Thanks for your question. In you initial post, you have put 2 wkup_init() function. So in my understanding, the first one is working as expected and the other now. Is my assumption correct?

For waking up, the ACCEL_INT_PORT / _PIN is used, so you need to configure the wake up controller with a second GPIO to wake-up. Is the correct?

Thanks, PM_Dialog

jagath52
Offline
Last seen: 1 year 6 months ago
Joined: 2020-07-06 10:40
Hello PM_Dialog

Hello PM_Dialog

Yes i want to wakeup the device with second gpio using gpio wakeup controller. Key wakeup controller is working as expected.

Thank you
Jagath
 

 

PM_Dialog
Offline
Last seen: 7 months 1 week ago
Staff
Joined: 2018-02-08 11:03
Hi jagath52m

Hi jagath52m

Could you please check the DA1469x Wake up controller SW Example from the DA1469x portal? To enable the GPIO P0 sub block, the WKUP_GPIO_P0_BLOCK_ENABLE macro should be set to 1.

Please give a try an let me know.

Thanks, PM_Dialog