Cannot configure Port 1 Pin 8

Hello,

I need to use Port 1 pin 8 as an interrupt pin:

#define INT_PIN  NRF_GPIO_PIN_MAP(1, 8)

nrf_drv_gpiote_in_config_t int_pin_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);
int_pin_config.pull = NRF_GPIO_PIN_PULLUP;
ret_code_t err_code = nrf_drv_gpiote_in_init(INT_PIN, &int_pin_config, int_pin_handler);
APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_in_event_enable(INT_PIN, true);

This results in the error NRF_ERROR_INVALID_STATE, when nrf_drv_gpiote_in_init() is called. Everything works fine, if I use a port 0 pin. What can be the problem with using port 1?

I'm using the nRF52832, SDK 17.1.0, SoftDevice S132 7.2.0, and a custom board.

Parents
  • Hi,

    nrf_drv_gpiote_in_init() will return NRFX_ERROR_INVALID_STATE if the pin is already used (Only one GPIOTE channel can be assigned to one physical pin), so I suspect that is what you are seeing.

    Which SDK version are you using? (To double check I took the pin changed interrupt example form SDK 17.1.0 and changed the input pin to P1.08, and that worked as expected, so there does not seem to be a bug with port 1 specifically in that version, at least.)

  • Hi,

    Thanks for your reply! I'm using SDK 17.1.0. I've tried it with an other pin at port 1 and it works. This is my board definitions:

    #ifndef CUSTOM_BOARD_H
    #define CUSTOM_BOARD_H
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    #include "nrf_gpio.h"
    
    #define BUTTONS_NUMBER 2
    
    #define BUTTON_1       NRF_GPIO_PIN_MAP(0, 3)
    #define BUTTON_2       NRF_GPIO_PIN_MAP(0, 28)
    #define BUTTON_PULL    NRF_GPIO_PIN_PULLUP
    
    #define BUTTONS_ACTIVE_STATE 0
    
    #define BUTTONS_LIST { BUTTON_1, BUTTON_2 }
    
    #define SCL_PIN             	NRF_GPIO_PIN_MAP(0, 24)
    #define SDA_PIN             	NRF_GPIO_PIN_MAP(0, 25)
    #define INT_PIN				    NRF_GPIO_PIN_MAP(1, 8)
    
    #ifdef __cplusplus
    }
    #endif
    
    #endif // CUSTOM_BOARD_H

    Port 1 pin 8 isn't defined anywhere else, so I don't know how it could be already in use. Is there anything else in the SDK, which has to do with pin definitions?

Reply
  • Hi,

    Thanks for your reply! I'm using SDK 17.1.0. I've tried it with an other pin at port 1 and it works. This is my board definitions:

    #ifndef CUSTOM_BOARD_H
    #define CUSTOM_BOARD_H
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    #include "nrf_gpio.h"
    
    #define BUTTONS_NUMBER 2
    
    #define BUTTON_1       NRF_GPIO_PIN_MAP(0, 3)
    #define BUTTON_2       NRF_GPIO_PIN_MAP(0, 28)
    #define BUTTON_PULL    NRF_GPIO_PIN_PULLUP
    
    #define BUTTONS_ACTIVE_STATE 0
    
    #define BUTTONS_LIST { BUTTON_1, BUTTON_2 }
    
    #define SCL_PIN             	NRF_GPIO_PIN_MAP(0, 24)
    #define SDA_PIN             	NRF_GPIO_PIN_MAP(0, 25)
    #define INT_PIN				    NRF_GPIO_PIN_MAP(1, 8)
    
    #ifdef __cplusplus
    }
    #endif
    
    #endif // CUSTOM_BOARD_H

    Port 1 pin 8 isn't defined anywhere else, so I don't know how it could be already in use. Is there anything else in the SDK, which has to do with pin definitions?

Children
Related