app_buttons don't work

Hi,

    I have a strange question about app_buttons, I have two buttons, only one of the buttons is initialized, which works well, but once both buttons are initialized at the same time, they will not work. Here is my  initialization program with work well: 

static void button_int(void)
{
uint32_t err_code;

err_code = bsp_event_to_button_action_assign(0, APP_BUTTON_PUSH, BSP_EVENT_DEFAULT);

static const app_button_cfg_t app_buttons[1] =
{
  {FINGER_INT_PIN, APP_BUTTON_ACTIVE_HIGH, NRF_GPIO_PIN_NOPULL, button_callback}
};

err_code = app_button_init((app_button_cfg_t *)app_buttons, 1, 50);
APP_ERROR_CHECK(err_code);

err_code = app_button_enable();
APP_ERROR_CHECK(err_code);
}

  Here is my  initialization program that it do not  work: 

static void button_int(void)
{
uint32_t err_code=NRF_SUCCESS;

err_code = bsp_event_to_button_action_assign(0, BSP_BUTTON_ACTION_RELEASE, BSP_EVENT_DEFAULT);

err_code = bsp_event_to_button_action_assign(1, APP_BUTTON_PUSH, BSP_EVENT_DEFAULT);

static const app_button_cfg_t app_buttons[2] =
{
{BUTTON_SET_PIN, APP_BUTTON_ACTIVE_HIGH, NRF_GPIO_PIN_NOPULL, button_callback},
{FINGER_INT_PIN, APP_BUTTON_ACTIVE_HIGH, NRF_GPIO_PIN_NOPULL, button_callback}
};

err_code = app_button_init((app_button_cfg_t *)app_buttons, 2, 50);
APP_ERROR_CHECK(err_code);

err_code = app_button_enable();
APP_ERROR_CHECK(err_code);
}

I want to konw what is wrong,thanks!

THANKS!

Parents
  • Hello,

    I notice that you are not checking the returned error code of your button assignment functions, please make sure to add checks for those.
    Could you also confirm that you have DEBUG defined in your preprocessor defines, like shown in the include image?

    This will make the logger output a detailed error message whenever a non-NRF_SUCCESS error code is passed to an APP_ERROR_CHECK. Please let me know what this error message says, if there is any.

    Could you also detail what you observe when you try to initialize the two buttons at once? Please elaborate on the behavior you are seeing, and describe how it differs from what you would have expected.

    Best regards,
    Karl

Reply
  • Hello,

    I notice that you are not checking the returned error code of your button assignment functions, please make sure to add checks for those.
    Could you also confirm that you have DEBUG defined in your preprocessor defines, like shown in the include image?

    This will make the logger output a detailed error message whenever a non-NRF_SUCCESS error code is passed to an APP_ERROR_CHECK. Please let me know what this error message says, if there is any.

    Could you also detail what you observe when you try to initialize the two buttons at once? Please elaborate on the behavior you are seeing, and describe how it differs from what you would have expected.

    Best regards,
    Karl

Children
No Data
Related