nrf_gpiote_drv loss interrupt

timiny gravatar image

asked 2017-07-17 11:07:23 +0200

updated 2017-07-17 11:33:47 +0200


There is an issuse in my project that using nrf_gpiote_drv lost interrupt.

SDK: nRF5_SDK_13.0.0_04a0bfd Chip: nRF52328_xxAA Board: PCA10004

There is two buttons on my board, define as primaryButton & secondaryButton.

Here is my code

#include "nrf.h"
#include "nrf_gpio.h"
#include "nrf_drv_gpiote.h"

#define primary_pin_No      13
#define secondory_pin_No    14

static void button_drv_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    if( nrf_gpio_pin_read(primary_pin_No) == 0 ){
        nrf_gpio_pin_toggle( 17 ); 
static void secondary_button_drv_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    if( nrf_gpio_pin_read( secondory_pin_No) == 0 ){
        nrf_gpio_pin_toggle( 18 ); 

void button_init(void)

    nrf_gpio_cfg_output( 17 );
    nrf_gpio_cfg_output( 18 ); 

    nrf_drv_gpiote_in_config_t int_config = {
        .sense          = NRF_GPIOTE_POLARITY_TOGGLE, 
        .pull           = NRF_GPIO_PIN_PULLUP, 
        .is_watcher     = false, 
        .hi_accuracy    = false, 
    APP_ERROR_CHECK ( nrf_drv_gpiote_in_init(  primary_pin_No, 
                                        & int_config,

    nrf_drv_gpiote_in_config_t sint_config = {
        .sense          = NRF_GPIOTE_POLARITY_HITOLO, 
        .pull           = NRF_GPIO_PIN_PULLUP, 
        .is_watcher     = false, 
        .hi_accuracy    = false, 
    APP_ERROR_CHECK ( nrf_drv_gpiote_in_init(  secondory_pin_No, 
                                        & sint_config,

    nrf_drv_gpiote_in_event_enable( primary_pin_No, true ); 
    nrf_drv_gpiote_in_event_enable( secondory_pin_No, true ); 
  1. It works good when click each button, callbakc function is called.
  2. when i hold the secondary button(this button sense require NRF_GPIOTE_POLARITY_HITOLO or NRF_GPIOTE_POLARITY_LOTOHI) first, then click primary button, it will not enter GPIOTE_IRQHandler, two button pin in LATCH registers,are "Criteria has been met".
  3. release button from hold state, every button can generate interrupt again.

    why holding a button( sense = NRF_GPIOTE_POLARITY_HITOLO or NRF_GPIOTE_POLARITY_LOTOHI), others gpiote interrupt is seem to be masked(disabled? missed?)? it that a bug of nrf_drv_gpiote ? or that is a mechanism that GPIOTE normal work?

edit retag flag offensive close delete report spam

1 answer

Sort by » oldest newest most voted
Petter gravatar image

answered 2017-07-17 15:32:55 +0200

As far as I know, the latch register is not used by the GPIOTE driver.

When you set .hi_accuracy to false the port event is used for that pin. The port event is triggered by the detect signal, which is a common signal for all the pins, see this for more information.

If you want to detect changes on pins changing states at the same time you should set .hi_accuracy to true. Then the in event is used instead.

edit flag offensive delete publish link more


Thanks, Peter! I read the context of link, and GPIO/GPIOTE description in PS. But it still make me confuse why one pin only sense LOW or HIGH under active state can affect other pins generate ports event? I check the register on GPIO & GPIOTE, no obvious modification on them.
And pin sense TOGGLE active state will change this pin sense invert in GPIOTE_IRQHandler, and others pin can also generate ports event. It seems PIN detect has its mechanism, but I dont get it from PS or Debug procedure.

For now, I set all interrupt pins polarity TOGGLE, that I can get all pins interrupt callback, and re-check pin state in callback to decide implement next. That's my final solution for now.

MoRan ( 2017-07-18 05:03:29 +0200 )editconvert to answer

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer. Do not ask a new question or reply to an answer here.

[hide preview]

Question Tools

1 follower


Asked: 2017-07-17 11:07:23 +0200

Seen: 34 times

Last updated: Jul 17