nRF5 SDK is not maintained anymore
More Info: Consider nRF Connect SDK for new designs
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

BUTTON PULLDOWN QUESTION

hello. I want to use the button as a pull-down.
I am using nrf52832, and the button and circuit part are composed of pull-down and the code is written as follows.

#define LED_RED 17
#define LED_GREEN  18

int main(void)
{
    nrf_gpio_cfg_output(LED_RED); 
    nrf_gpio_cfg_output(LED_GREEN);
    nrf_gpio_cfg_input(14, NRF_GPIO_PIN_PULLDOWN);
    
    for(;;)
    {
        if(nrf_gpio_pin_read(14) == 1)
        {
            nrf_gpio_pin_clear(LED_RED);
            nrf_gpio_pin_set(LED_GREEN);
        }
        else
        {
            nrf_gpio_pin_clear(LED_GREEN);
            nrf_gpio_pin_set(LED_RED);
        }
    }
}

However, even if the button is pressed, it always behaves as 0.
I want to know why...

Ask for help.

Parents
  • I have solved this problem! It happened because I misunderstood the circuit. 

    The chip I used is nrf52832 and is written from sdk15.2. Not DK. Thanks for the reply! And for other developers who may have the same problem, in NRF52dk, GPIOs 13~17 are internally pulled-up, so if you use it as a button, you must do a pull-up set.

    Also, if you use GPIO 13~17 as a pull-down in a non-dk version, you should not use the bsp handler.

    Actually I think the best way is to use 20 or more GPIOs with nothing defined...

    I am writing the answer through a translator, there may be mistranslations.

    Thank you!!

Reply
  • I have solved this problem! It happened because I misunderstood the circuit. 

    The chip I used is nrf52832 and is written from sdk15.2. Not DK. Thanks for the reply! And for other developers who may have the same problem, in NRF52dk, GPIOs 13~17 are internally pulled-up, so if you use it as a button, you must do a pull-up set.

    Also, if you use GPIO 13~17 as a pull-down in a non-dk version, you should not use the bsp handler.

    Actually I think the best way is to use 20 or more GPIOs with nothing defined...

    I am writing the answer through a translator, there may be mistranslations.

    Thank you!!

Children
No Data
Related