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

GPIO IN_EVENT to GPIO PORT Event

Hello, I'm new to Nordic SDK and I would like to ask you for help with change of GPIO IN_EVENT to GPIO PORT event implementation. The reason is we are using revision < 3 and I need to decrease power consumption.

Current implementation is like following:

void init_gpio_button()
{
    nrf_gpio_cfg_input(GPIO_BUTTON, NRF_GPIO_PIN_PULLUP);

	uint32_t err_code = nrf_drv_gpiote_init();
	APP_ERROR_CHECK(err_code);
  
    nrf_drv_gpiote_in_config_t btn = GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
	btn.pull = NRF_GPIO_PIN_PULLUP;

	nrf_drv_gpiote_in_uninit(GPIO_BUTTON);
	err_code = nrf_drv_gpiote_in_init(GPIO_BUTTON, &btn, btn_handler_isr);
	APP_ERROR_CHECK(err_code);

	nrf_drv_gpiote_in_event_enable(GPIO_BUTTON, true);
}

Is it enough to just set GPIOTE_CONFIG_IN_SENSE_HITOLO.hi_accuracy = false?

Thank you very much for your help.

Parents Reply Children
  • PS: If you need to decrease power consumption, take a look at this post.

  • Thank you I will have a look on the post.

    I have one more question. In case I have more than one input GPIOs, how the interrupt handling must be changed? In our implementation we have 4 input GPIOs and if change .hi_accuracy to false for all four GPIOs after I receive first interrupt, I don't receive any else. Do I need to clear any interrupt flag?

    Thank you very much.

  • You should not need to clear any interrupt flag yourself, the GPIOTE driver should take care of that for you.

    Could you post your init_gpio_button() function where you use 4 inputs GPIOs ?

  • First function is the one mentioned in the initial question. It's also called first. Next three init functions are following:

    void init_gpio_acc()
    {
      ret_code_t err_code;
      nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(false);
      in_config.pull = NRF_GPIO_PIN_NOPULL;
      
      err_code = nrf_drv_gpiote_in_init(GPIO_AINT1, &in_config, pin_handler);
      APP_ERROR_CHECK(err_code);
      nrf_drv_gpiote_in_event_enable(GPIO_AINT1, false);  
    }
    
    void int_gpio_gyro()
    {
      ret_code_t err_code;
      nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(false);
      in_config.pull = NRF_GPIO_PIN_NOPULL;
      
      err_code = nrf_drv_gpiote_in_init(GPIO_GINT1, &in_config, pin_handler);
      APP_ERROR_CHECK(err_code);
      nrf_drv_gpiote_in_event_enable(GPIO_GINT1, false);
    }
    
    void int_gpio_comm()
    {
      ret_code_t err_code;
      nrf_drv_gpiote_in_config_t dio0 = GPIOTE_CONFIG_IN_SENSE_LOTOHI(false);
      dio0.pull = NRF_GPIO_PIN_NOPULL;
      
      nrf_drv_gpiote_in_uninit(GPIO_DIO0);
      err_code = nrf_drv_gpiote_in_init(GPIO_DIO0, &dio0, dio_handler_isr);
      APP_ERROR_CHECK(err_code);
      nrf_drv_gpiote_in_event_enable(GPIO_DIO0, true);
    }
    

    If I use .hi_accuracy set to true the functionality is fine. When I change it to false I receive just one interrupt and that's all.

    Thank you for comment.

  • I believe that if a port event is triggered on a low to high transition on a pin, a new port event can’t be triggered before that pin has gone low again or the pin is configured to sense low (which will trigger a new event on high to low transition). See the answers to this and this post.

    You could try to use the GPIOTE_CONFIG_IN_SENSE_TOGGLE() instead.

Related