Use Reset pin as a normal GPIO - nRF52832

Hi, I am using a custom nrf52832 device. In that device , button is connected with reset pin P0.21. due to reset functionality I am not able get interrupt from button.

how can I use P0.21 as normal gpio??
Can I implement long-press functionality on P0.21 pin??

below is schematic of button and reset pin.

I have tried below possibilities
- used longpress node.

- disabled uicr node from dts.

- Remove GPIO as nRESET properties.


according to the documentation of nRESET.


while in nrf5 sdk it is working as gpio. why not in nrf connect sdk??

  • Thanks , how can I implement that solution in my application?
    currently my setting.json looks like as below.

    {
        "nrf-connect.taskBindings": {
            "pristineBuild": [
                {
                    "taskName": "Build: long_press_v2/build (active)",
                    "buildConfigs": [
                        "${workspaceFolder}/build"
                    ]
                }
            ]
        }
    }

  • Hi

    What version of the nRF Connect SDK are you using? In the latest versions (at least from NCS 2.7.0 and newer) the correct way to set the reset pin as a GPIO is through the devicetree. By default, the board's devicetree sets the GPIO as a reset with the following. Removing this line from the .dts file should make the reset pin function as a GPIO. This is documented in the Zephyr 3.5 migration guide: https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/releases/migration-guide-3.5.html 

    &uicr {
        gpio-as-nreset;
    };
    Best regards,
    Simon
  • Hi  

    I am using a nRF Connect SDK v2.6.0. I have tried that solution did not worked.

    currently I have deleted gpio-as-nreset; property like as below.

    &uicr {
        /delete-property/gpio-as-nreset;
    };

    is it validate according to the format?

    also I added a line in setting.json file.

    In vscode file/preferences/setting/"nrf-connect.flash.softreset": true (enabled from setting)

    after that I able to use reset pin as gpio. but it is correct solution to use reset pin as gpio?? after that I am not able to connect a device via ble, not updating display etc..

    because I want to implement single press and long press functionality on that pin.
    below is my code for long press and single press

    case if(pins & BIT(button_0.pin)){
            printk("button 0 pressed");
            LOG_INF("reset pressed\n\r");
            read_time(rtc_dev,(time_t *)&unix_time);
            uint32_t reset_pressed_epoch_time = unix_time;
            while (!gpio_pin_get_dt(&button_0) && (unix_time - reset_pressed_epoch_time) <= 10)
            {
                k_msleep(100);
                read_time(rtc_dev,(time_t *)&unix_time);
            }
            if (unix_time - reset_pressed_epoch_time > 10)
            {
                Reset_Flag=1;
                eeprom_write(i2c_dev,EEPROM_RESET_FLAG_ADDRESS, &Reset_Flag, 1);
                eeprom_write(i2c_dev,EEPROM_RESET_TIME_FLAG, &current_epoch_time, 4);
                guide_flag=1;
                eeprom_write(i2c_dev,EEPROM_DEVICE_GUIDE_ADDRESS,&guide_flag,1);
                reset_hardware_locally();
                //reset_hardware();
                k_msleep(1000);
                NVIC_SystemReset();
            }
            else
            {
                k_msleep(1000);
                NVIC_SystemReset();
            }
            break;

  • Hi

    Yes, it should be fine setting it up like this. You need to use the /delete-property/ if the gpio-as-nreset is set by default I believe. But why are you enabling the Softreset when flashing after doing so? The pin shouldn't be needed to do a full reset when flashing? Have you tried power cycling the board and see if it works afterwards when you've flashed it like this? A full power cycle might be needed after flashing the device when using softreset. 

    What exactly are you using the reset pin GPIO for in your project?

    Best regards,

    Simon

Related