Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

button interruption in nRF52805

excuse me,I'm developing nRF52805 and I set the button pin number like this:
#define BUTTON_START 1
#define BUTTON_1 1
#define BUTTON_2 5
#define BUTTON_3 12
#define BUTTON_4 16
#define BUTTON_STOP 16
what's more, I define like this in advertising_buttons_configure
err_code = bsp_event_to_button_action_assign(0,
BSP_BUTTON_ACTION_PUSH
BSP_EVENT_KEY_0);
RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
err_code = bsp_event_to_button_action_assign(1,
BSP_BUTTON_ACTION_PUSH
BSP_EVENT_KEY_1);
RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
err_code = bsp_event_to_button_action_assign(2,
BSP_BUTTON_ACTION_PUSH
BSP_EVENT_KEY_2);
RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
however, only BSP_EVENT_KEY_0 in bsp_event_handler can produce interruption when I give the pin number 1 a high level.
The other pins(5 and 12) produce BSP_EVENT_KEY_1 and BSP_EVENT_KEY_2 interruption periodically, but I don't give them high level.
Hope you can help me.

Parents
  • Hello,

    Are the button pins connected to anything, or are the pins floating? 

    Do you have a define called BUTTON_PULL in the same file as your BUTTON_START definition? What is it set to?

    The BSP library is handling the logic around button presses, but the buttons are actually set up using app_button_init(), which is called in bsp_init() in bsp.c. It uses the array called app_buttons in the example that you refer to. What does that look like in your case?

    Best regards,

    Edvin

  • Thanks for your help
    Three button pins connect to three different touch pad, when the finger touches one of the three touch pads, it will give a high level to the button pin.
    These orders can normally read the high level in button pins, when I touch the touch pad, the value these orders read will turn to 1 from 0.
    nrf_gpio_pin_read(12);
    nrf_gpio_pin_read(5);
    nrf_gpio_pin_read(1);
    BUTTON_PULL is defined like this in the pca10040.h
    #define BUTTON_PULL NRF_GPIO_PIN_PULLUP
    The array app_buttons is defined like this in my code
    static const app_button_cfg_t app_buttons[BUTTONS_NUMBER] =
    {
    #ifdef BSP_BUTTON_0
    {BSP_BUTTON_0, false, BUTTON_PULL, bsp_button_event_handler},
    #endif // BUTTON_0
    #ifdef BSP_BUTTON_1
    {BSP_BUTTON_1, false, BUTTON_PULL, bsp_button_event_handler},
    #endif // BUTTON_1
    #ifdef BSP_BUTTON_2
    {BSP_BUTTON_2, false, BUTTON_PULL, bsp_button_event_handler},
    #endif // BUTTON_2
    I have uploaded my code to the github, the example I use is in _nRF52805/nRF5_SDK_17.0.2_d674dde/examples/ble_peripheral/ble_app_hids_mouse/pca10040e_nrf52805 v1.05/s112/arm5_no_packs/
    The address of my code in github is https://github.com/1436294280/_nRF52805

    Best regards

Reply
  • Thanks for your help
    Three button pins connect to three different touch pad, when the finger touches one of the three touch pads, it will give a high level to the button pin.
    These orders can normally read the high level in button pins, when I touch the touch pad, the value these orders read will turn to 1 from 0.
    nrf_gpio_pin_read(12);
    nrf_gpio_pin_read(5);
    nrf_gpio_pin_read(1);
    BUTTON_PULL is defined like this in the pca10040.h
    #define BUTTON_PULL NRF_GPIO_PIN_PULLUP
    The array app_buttons is defined like this in my code
    static const app_button_cfg_t app_buttons[BUTTONS_NUMBER] =
    {
    #ifdef BSP_BUTTON_0
    {BSP_BUTTON_0, false, BUTTON_PULL, bsp_button_event_handler},
    #endif // BUTTON_0
    #ifdef BSP_BUTTON_1
    {BSP_BUTTON_1, false, BUTTON_PULL, bsp_button_event_handler},
    #endif // BUTTON_1
    #ifdef BSP_BUTTON_2
    {BSP_BUTTON_2, false, BUTTON_PULL, bsp_button_event_handler},
    #endif // BUTTON_2
    I have uploaded my code to the github, the example I use is in _nRF52805/nRF5_SDK_17.0.2_d674dde/examples/ble_peripheral/ble_app_hids_mouse/pca10040e_nrf52805 v1.05/s112/arm5_no_packs/
    The address of my code in github is https://github.com/1436294280/_nRF52805

    Best regards

Children
  • Hello,

    So the app_buttons[] have 4 elements for each button. 

    {pin_no, active_state, pull_cfg, button_handler}

    In your case, the active_state is false -> low. So the button is pushed when the pin is changed from high to low. In addition, you have a pullup set in your BUTTON_PULL. This means that if the pad is not trying to set it to either high or low, it will be pulled high. 

    This works well when a button push shorts the pin to ground when you push a button, and the pin is floating when the button is not pushed (because the pullup will pull it high when the button is not pushed). 

    Perhaps your touch pads are pulling the pins low, and have an active high? Try to measure with a voltmeter what the state of the output is when the pad is not pushed. What is the voltage difference between GND and touchpad when the pad is pushed and pad is not pushed, and what is the difference between VDD and the touchpad when the pad is pushed and not?

    That is:

    - Pad pushed Pad not pushed
    GND->Output A B
    VDD->Output C D

    What is A, B, C, and D?

    Best regards,

    Edvin

Related