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

PORT Event vs nrf_drv_gpiote_in_init()

nrf_drv_gpiote_in_config_t in_config_lotohi = GPIOTE_CONFIG_IN_SENSE_LOTOHI(false);
if(!nrf_drv_gpiote_is_init())
{
    err_code = nrf_drv_gpiote_init();
    APP_ERROR_CHECK(err_code);
}
err_code = nrf_drv_gpiote_in_init(GPIO_AC_INTP1_PIN, &in_config_lotohi, key_event_handler);
  1. my code is just like above
  2. I know the difference between IN EVENT and PORT event
  3. If I use nrf_drv_gpiote_init() with GPIOTE_CONFIG_IN_SENSE_LOTOHI(false), that means I use Port Event? or same current consumption as Port Event? or it use IN EVENT?
Parents Reply Children
  • Can I have more questions?

    1. So I can use nrf_drv_gpiote_in_init() for every 31 GPIO pins? or there is limitations for pin numbers. (ex, 8 pin)
    2. if I don't use IN_EVENT, still I need to init GPIOTE with nrf_drv_gpiote_init()?
    3. Can I register (with nrf_drv_gpiote_in_init()) and use all different event handler functions for each GPIO pin? ex) pin 1 Port Event -> key1_event_handler function pin 2 Port Event -> key2_event_handler function
  • 1:

    For high accuracy mode(IN_EVENT) there is a limit of 8 pins on the nRF52. On nRF51 the limit is 4. This limit is set by the number of GPIOTE channels available. For low accuracy mode (PORT event) there is no such limit. You must specify GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS, which is the number of pins used for low power EVENTS_PORT. This define can be found in sdk_config.h

    2:

    Yes, you need to call nrf_drv_gpiote_init() if you want to use PORT or IN_EVENT. This function is needed for initializing the GPIOTE module.

    3:

    Yes, you can do that. Also, for buttons you might want to look into the app_button library if you have problem with debounce on the buttons(so a single button press doesn't appear like multiple presses).

  • What is the difference between IN EVENT and PORT event?

Related