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

I need 8 digital inputs on the nRF52840 but I can only find get 4 to work

I have 4 gpio inputs on the nRF52840 working and sending these states over the BLE. I tried to add a few more gpio inputs but I get an error =4 which I think is NRF_ERROR_NO_MEM. I should have several other pins available on the hardware. I cannot see what is going wrong. 

I am using the ble_peripheral/ble_app_blinky/main.c example. It is erroring out in app_button.c at:

err_code = nrf_drv_gpiote_in_init(p_btn->pin_no, &config, gpiote_event_handler);

my buttons_init() function is below. 

#define NORTH_PIR_BUTTON 4 /**< Button that will trigger the notification event with the LED Button Service */
#define NORTHWEST_PIR_BUTTON 5 /**< Button that will trigger the notification event with the LED Button Service */
#define NORTHEAST_PIR_BUTTON 21 /**< Button that will trigger the notification event with the LED Button Service */
#define EAST_PIR_BUTTON 19 /**< Button that will trigger the notification event with the LED Button Service */
#define WEST_PIR_BUTTON 28 /**< Button that will trigger the notification event with the LED Button Service */
#define SOUTH_PIR_BUTTON 29 /**< Button that will trigger the notification event with the LED Button Service */
#define SOUTHWEST_PIR_BUTTON 30 /**< Button that will trigger the notification event with the LED Button Service */
#define SOUTHEAST_PIR_BUTTON 31 /**< Button that will trigger the notification event with the LED Button Service */

static void buttons_init(void)
{
  ret_code_t err_code=0;
  // 4 max works
  //The array must be static because a pointer to it will be saved in the button handler module.
  static app_button_cfg_t buttons[] =
  {
    {NORTHEAST_PIR_BUTTON, APP_BUTTON_ACTIVE_HIGH, NRF_GPIO_PIN_NOPULL, button_event_handler}, // error
    //{NORTHWEST_PIR_BUTTON, APP_BUTTON_ACTIVE_HIGH, NRF_GPIO_PIN_NOPULL, button_event_handler}, //error
    {LEDBUTTON_BUTTON, false, BUTTON_PULL, button_event_handler}, // works
    //{NORTH_PIR_BUTTON, APP_BUTTON_ACTIVE_HIGH, NRF_GPIO_PIN_NOPULL, button_event_handler}, // error
    //{SOUTH_PIR_BUTTON, APP_BUTTON_ACTIVE_HIGH, NRF_GPIO_PIN_NOPULL, button_event_handler}, // error
    //{SOUTHEAST_PIR_BUTTON, APP_BUTTON_ACTIVE_HIGH, NRF_GPIO_PIN_NOPULL, button_event_handler}, // ERROR
    {SOUTHWEST_PIR_BUTTON, APP_BUTTON_ACTIVE_HIGH, NRF_GPIO_PIN_NOPULL, button_event_handler},// works
    {WEST_PIR_BUTTON, APP_BUTTON_ACTIVE_HIGH, NRF_GPIO_PIN_NOPULL, button_event_handler},// works
    {EAST_PIR_BUTTON, APP_BUTTON_ACTIVE_HIGH, NRF_GPIO_PIN_NOPULL, button_event_handler}// works
  };

  err_code = app_button_init(buttons, ARRAY_SIZE(buttons),
  BUTTON_DETECTION_DELAY); // APP_TIMER_TICKS(100)
  APP_ERROR_CHECK(err_code);
  NRF_LOG_INFO("after button_init error=%ld, NUMBER_OF_PINS=%d", err_code, NUMBER_OF_PINS); // 4, 48
}

Parents Reply Children
No Data
Related