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

app_button module works only for up to 4 buttons (otherwise NRF_ERROR_NO_MEM)

I am using nRF51, SD 130 1.0 and SDK 10.0.0. I have 11 buttons connected to nRF. Currently it only works for up to 4 buttons (APP_TIMER_OP_QUEUE_SIZE is 4, but I'm not sure this is dependent on number of buttons. I think I saw this somewhere.).

If I try to increase APP_TIMER_OP_QUEUE_SIZE to 11 and then create app_button_cfg_t no button works at all (i.e. handler is not fired). Here's the code:

static app_button_cfg_t p_button[] = {{BUTTON0_PIN, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler},
									{BUTTON1_PIN, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler},
									{BUTTON2_PIN, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler},
									{BUTTON3_PIN, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler},
									{BUTTON4_PIN, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler},
									{BUTTON5_PIN, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler},
									{BUTTONUP_PIN, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler},
									{BUTTONDOWN_PIN, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler},
									{BUTTONLEFT_PIN, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler},
									{BUTTONRIGHT_PIN, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler},
									{BUTTONSC_PIN, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler}};
									
app_button_init(p_button, sizeof(p_button) / sizeof(p_button[0]), APP_TIMER_TICKS(30, APP_TIMER_PRESCALER)); // 30ms debounce
app_button_enable();

Obviously, since getting NRF_ERROR_NO_MEM, I'm getting out of memory. I think there is a define where I can reserve the space for max num. of buttons but I can't remember where.

These are the section sizes:

Program Size: Code=24332 RO-data=416 RW-data=268 ZI-data=3460

I am using nrf51 QFACA1.

I get NRF_ERROR_NO_MEM from app_button_init() -> nrf_drv_gpiote_in_init() -> channel_port_alloc(). Returned channel is 0xFF (no space to alloc).

Parents Reply Children
No Data
Related