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

"app_button" functions doesn't work on XL1 gpio "P0.00"

Hello,

On my custom board, on nrf52832, I can can use app_buttons for all usual pins, but not the XL1 (P0.00). I didn't try XL2 (not routed)

Using this pin as input or output works fine with standard functions.  I use sdk15.2, with softdevice s132, and didnt't try without it (I'm not sure it would help, and anyway I need the softdevice)

As I'm not using the 32kHz crystal, I set my sdk_config with:

#define NRFX_CLOCK_CONFIG_LF_SRC 0
#define CLOCK_CONFIG_LF_SRC 0
#define NRF_SDH_CLOCK_LF_SRC 0
Do you have some idea?
I guess is might need some interuption configuration.
Parents Reply Children
  • I'm using 5 buttons(P0.28 P0.30,P0.00,P0.02,P0.03). Code is working for the 4 other buttons. Defining the button "P0.00" to pin P0.31 (a sixth button no defined at all yet anywhere in the code), works very fine.


    This is my code:

    nrf_gpio_cfg_input (0,NRF_GPIO_PIN_PULLUP);
    //! if you want more buttons, change value GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS in sdk_config.h
    static app_button_cfg_t p_button[] = {  {BUTTON_1, APP_BUTTON_PUSH, BUTTON_PULL, button_pressed_handler},
                                                {BUTTON_2, APP_BUTTON_PUSH, BUTTON_PULL, button_pressed_handler},
                                                {BUTTON_3, APP_BUTTON_PUSH, BUTTON_PULL, button_pressed_handler},
                                                {BUTTON_4, APP_BUTTON_RELEASE, BUTTON_PULL, button_pressed_handler},
                                                {BUTTON_5, APP_BUTTON_PUSH, BUTTON_PULL, button_pressed_handler}};
    
        app_button_init(p_button,sizeof(p_button) / sizeof(p_button[0]),100);
        app_button_enable();
    

    By making this new test, one more info: I'm using internal pull-up. This pull up is not active.and in it I specify the pin 0 as input pull up, so the app_button_init seems to erase this setting.
    If I change to P0.31, the pull-up works great on P0.00
    At last, even if the pull up is not active, connecting the pin to the ground or VCC does not call an handler.

  • Is BUTTON_PULL defined as "pull up" in your board header? In that case I don't see why app_button_init would clear this setting. Could you upload your project here so I can try to replicate it? Also if you could verify that NRF_GPIO->PIN_CNF[0].SENSE is not '0' after app_button_enable(). 

  • Hi Vidar,

    Thanks for your help.

    of course:

    #define BUTTON_PULL    NRF_GPIO_PIN_PULLUP

    Also, NRF_GPIO->PIN_CNF[0].SENSE doesn't exist. NRF_GPIO->PIN_CNF[PIN] is an integer. this is what I get (button 0 is 0):

        NRF_LOG_INFO("NRF_GPIO->PIN_CNF[0] %d",NRF_GPIO->PIN_CNF[0]);
        NRF_LOG_INFO("NRF_GPIO->PIN_CNF[BUTTON_1] %d",NRF_GPIO->PIN_CNF[BUTTON_1]);
         	nrf_gpio_cfg_input (0,NRF_GPIO_PIN_PULLUP);
    //! if you want more buttons, change value GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS in sdk_config.h
        static app_button_cfg_t p_button[] = {  {BUTTON_0, APP_BUTTON_PUSH, BUTTON_PULL, button_pressed_handler},
                                                {BUTTON_1, APP_BUTTON_PUSH, BUTTON_PULL, button_pressed_handler},
                                                {BUTTON_2, APP_BUTTON_PUSH, BUTTON_PULL, button_pressed_handler},
                                                {BUTTON_3, APP_BUTTON_RELEASE, BUTTON_PULL, button_pressed_handler},
                                                {BUTTON_4, APP_BUTTON_PUSH, BUTTON_PULL, button_pressed_handler}};
    
        NRF_LOG_INFO("NRF_GPIO->PIN_CNF[0] %d",NRF_GPIO->PIN_CNF[0]);
        NRF_LOG_INFO("NRF_GPIO->PIN_CNF[BUTTON_1] %d",NRF_GPIO->PIN_CNF[BUTTON_1]);
        app_button_init(p_button,sizeof(p_button) / sizeof(p_button[0]),100);
        NRF_LOG_INFO("NRF_GPIO->PIN_CNF[0] %d",NRF_GPIO->PIN_CNF[0]);
        NRF_LOG_INFO("NRF_GPIO->PIN_CNF[BUTTON_1] %d",NRF_GPIO->PIN_CNF[BUTTON_1]);
        app_button_enable();
        NRF_LOG_INFO("NRF_GPIO->PIN_CNF[0] %d",NRF_GPIO->PIN_CNF[0]);
        NRF_LOG_INFO("NRF_GPIO->PIN_CNF[BUTTON_1] %d",NRF_GPIO->PIN_CNF[BUTTON_1]);
    
    and its log:

    <info> app: NRF_GPIO->PIN_CNF[0] 2
    <info> app: NRF_GPIO->PIN_CNF[BUTTON_1] 2
    <info> app: NRF_GPIO->PIN_CNF[0] 12
    <info> app: NRF_GPIO->PIN_CNF[BUTTON_1] 2
    <info> app: NRF_GPIO->PIN_CNF[0] 12
    <info> app: NRF_GPIO->PIN_CNF[BUTTON_1] 12
    <info> app: NRF_GPIO->PIN_CNF[0] 196620
    <info> app: NRF_GPIO->PIN_CNF[BUTTON_1] 196620

    I'm sorry, I cannot give you my code. I tryed with no success to make a standalone app_button example. (it seems complicated with timers, clock, etc...). But you have all the interesting part.
    Kind regards,

  • Hi, 

    PIN0.0 is configured as input  with pull-up and sense for low level according to log output. PIN_CNF[x] has a bit-field for SENSE configuration. The way I wrote it was a bit misleading. You can see the register description here.

    Anyway, can you log the P0.0 register from your main loop to see if the value remains the same?  

  • Please try attached example and see if it works on your board. It works on the DK if you cut SB1.  

    ble_app_uart_w_app_button.zip

Related