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

Configuration of Buttons with different settings

 Hello,

 

I am using nRF52832, SDK_15.3.0, S132 SoftDevice and Segger for flash the image.

I started development on top of ‘ble_app_blinky’ code.

 

I have few queries on GPIO configuration.

 

1) For LEDs I am seeing bsp_board_init(BSP_INIT_LEDS) to configure LEDs. But for buttons I am not seeing any such function (bsp_board_init(BSP_INIT_BUTTONS). How buttons are configured (Input, pull-up/pull-down, priority etc…).

2) In this example, both button press & release is detected. I want to detect only press. How to change this.

3) How Raising & Edge trigger interrupts are configured for buttons.

4) In example code, all buttons are configured to same delay/debounce. Whether can I configure different buttons to different debounce (Button 1 with 5 sec, Button 2 with 1 sec etc...).

5) What is the max debounce time can I configure ?

 

Thanks & Regards

Vishnu Beema

Parents
  • Hi, 

     

    1) For LEDs I am seeing bsp_board_init(BSP_INIT_LEDS) to configure LEDs. But for buttons I am not seeing any such function (bsp_board_init(BSP_INIT_BUTTONS). How buttons are configured (Input, pull-up/pull-down, priority etc…).

     The buttoms are configured by app_button_init().

     

    2) In this example, both button press & release is detected. I want to detect only press. How to change this.

    3) How Raising & Edge trigger interrupts are configured for buttons.

    Please see this post.

    4) In example code, all buttons are configured to same delay/debounce. Whether can I configure different buttons to different debounce (Button 1 with 5 sec, Button 2 with 1 sec etc...).

    The Button Handler  uses the GPIOTE Handler to detect that a button has been pushed. To handle debouncing, it will start a timer in the GPIOTE event handler. The button will only be reported as pushed if the corresponding pin is still active when the timer expires. If there is a new GPIOTE event while the timer is running, the timer is restarted.

     

    5) What is the max debounce time can I configure ?

    app_button_init() uses the app_timer, so the max here will be the same for app_button detection_delay. According this post, it's 256 seconds if APP_TIMER_CONFIG_RTC_FREQUENCY is configured to 0.

     

    Best regards,

    Amanda

     

  • Hello Amanda,

    Thank you for your inputs. I am trying to understand more about query 4.

    1. Whether can I configure the debouncing delay dynamically. Assume for first time I want a debouncing delay of 5 sec, later I want debouncing delay on same pin for 2 sec. For this whether can I call app_button_init() whenever I want to change the delay settings.
    2. For GPIOTE if I configure button for delay of 5 seconds, then within 5 seconds whether chip will go to low power mode.

    Even in the below link all buttons are configured to same delay.

    https://devzone.nordicsemi.com/f/nordic-q-a/10721/button-interrupt-problem-when-booting

    Thanks & Regards

    Vishnu Beema

  • Hi,

     

    beemavishnu said:
    Whether can I configure the debouncing delay dynamically.

     I think it should be fine as long as you first call app_button_disable()

    app_button_init() calls app_timer_create(), which will return an error if p_timer_id->is_running.

     

    beemavishnu said:
    For GPIOTE if I configure button for delay of 5 seconds, then within 5 seconds whether chip will go to low power mode.

    I am not sure if I understand correctly. Do you ask if the chip will go to sleep while holding the button?

    When the button is pushed, GPIOTE handler will be called where the detection timer is started. When the timer times out, timer event handler will be called. If you puts device in sleep mode in main application, it should also sleep during detection delay (unless there is other tasks that needs to be done).

    -Amanda

Reply Children
No Data
Related