Two GPIOTE not working at the same time

Hi,

I'm trying to use to gpio pins in order to wake up a system from sleep mode.(PIN1= P0.24   PIN2 =P1.1 )

If I use the GPIOTEs separately in my project, it works and sytem wakes up, but if I use both GPIOTEs at the same time, it doesnt work.

below is my code:

void bma400_int_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    
    NRF_LOG_INFO("Activity detected");
}
void check_pod_handle(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
 
    NRF_LOG_INFO("check pod detected");

}

void gpiote_init(void)
{
    ret_code_t err_code;

    if (!nrf_drv_gpiote_is_init())
    {
        err_code = nrf_drv_gpiote_init();
        APP_ERROR_CHECK(err_code);
    }

    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);
    in_config.pull = NRF_GPIO_PIN_NOPULL;

    err_code = nrf_drv_gpiote_in_init(BMA400_INT, &in_config, bma400_int_handler);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_gpiote_in_init(CHECK_POD_PIN, &in_config, check_pod_handle);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_event_enable(BMA400_INT, true);  
    nrf_drv_gpiote_in_event_enable(CHECK_POD_PIN, true);

    nrf_gpio_cfg_sense_input(BMA400_INT, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
    nrf_gpio_cfg_sense_input(CHECK_POD_PIN, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);


}

i am using nrf52840, sdk 17.02, custom board,segger embedded studio

Can you help with setting up those pins for wake-up?

Thanks

Emrah

Parents
  • Hi,

    By doesn't work, you mean that it does not wakeup from sleep?

    Can you double check that none of the pins are already held high when you test this? If one of the pins are already high when you try to test this, it will effectively block the other interrupts pins from firing,

    regards

    Jared 

  • Hi,

    Yes, it does not wake up from sleep mode.

    The pin P1.1 is pulled through the pull-down circuit.
    The pin P0.24 is pulled over the pull-up circuit.

  • Hi,

    In the last lines of your code you setup the IN event on LOW by using nrf_gpio_cfg_sense_input(). This means that if either P0.24 or P1.1 is pulled low, then the IN event will be generated. Thus you need to make sure that both pins are pulled low before you go system off sleep.

    I made a simple sample setting up the IN event on Button 1 and Button 2 for HIGH on the devkit and it worked:

    #include <stdbool.h>
    #include <stdint.h>
    #include "nrf_delay.h"
    #include "boards.h"
    #include "nrf_gpio.h"
    #include "nrf_log.h"
    #include "nrf_log_ctrl.h"
    #include "nrf_log_default_backends.h"
    
    #define LED_PIN 13
    #define BUTTON_1 11
    #define BUTTON_2 12
    
    int  main(void)
    {
    
    nrf_gpio_cfg_output(LED_PIN);
    nrf_gpio_pin_clear(LED_PIN);
    
     nrf_delay_ms(2000);
     nrf_gpio_pin_set(LED_PIN);
     nrf_gpio_cfg_sense_input(BUTTON_1, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
     nrf_gpio_cfg_sense_input(BUTTON_2, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
    
    
      while (1)
      {
        NRF_POWER->SYSTEMOFF = 1;
        nrf_delay_ms(2000);
      }
    
    
    return 0;
    }
    
    

    regards

    Jared 

Reply
  • Hi,

    In the last lines of your code you setup the IN event on LOW by using nrf_gpio_cfg_sense_input(). This means that if either P0.24 or P1.1 is pulled low, then the IN event will be generated. Thus you need to make sure that both pins are pulled low before you go system off sleep.

    I made a simple sample setting up the IN event on Button 1 and Button 2 for HIGH on the devkit and it worked:

    #include <stdbool.h>
    #include <stdint.h>
    #include "nrf_delay.h"
    #include "boards.h"
    #include "nrf_gpio.h"
    #include "nrf_log.h"
    #include "nrf_log_ctrl.h"
    #include "nrf_log_default_backends.h"
    
    #define LED_PIN 13
    #define BUTTON_1 11
    #define BUTTON_2 12
    
    int  main(void)
    {
    
    nrf_gpio_cfg_output(LED_PIN);
    nrf_gpio_pin_clear(LED_PIN);
    
     nrf_delay_ms(2000);
     nrf_gpio_pin_set(LED_PIN);
     nrf_gpio_cfg_sense_input(BUTTON_1, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
     nrf_gpio_cfg_sense_input(BUTTON_2, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
    
    
      while (1)
      {
        NRF_POWER->SYSTEMOFF = 1;
        nrf_delay_ms(2000);
      }
    
    
    return 0;
    }
    
    

    regards

    Jared 

Children
No Data
Related