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

Problem to using p0.18(RESET Pin) for GPIO

I'm using nrf52833 on custom board.

And I need to using RESET pin to GPIO for battery charging detection.

I found CONFIG_GPIO_AS_PINRESET is configuration RESET pin,

and if I undefined CONFIG_GPIO_AS_PINRESET, p0.18 pin will be working GPIO.

But, many of case was failed.

I think,

If I undefined CONFIG_GPIO_AS_PINRESET,

MCU was nothing to handling NRF_UICR->PSELRESET register.

But NRF_UICR->PSELRESET registor still configuration like RESET pin(like dummy data ).

So, even if CONFIG_GPIO_AS_PINRESET is undefined, MCU still working p0.18 pin is configuration by RESET pin.

That's why I think, it's need to setting NRF_UICR->PSELRESET register to disconnect(connect bit to set '1') when CONFIG_GPIO_AS_PINRESET is undefined.

  • Hi,

    Could you try to do a full chip erase and then flash the firmware.? To use the RESET pin as GPIO, you need to first compile without defining the CONFIG_GPIO_AS_PINRESET, perform a full chip erase and then flash the code again. A full chip erase is necessary to erase the UICR or else, as you have observed, pin reset will remain enabled even after undefining CONFIG_GPIO_AS_PINRESET.

    Regards,

    Swathy

  • Hi ,

    You can check it useing nrfjprog tool.

    First, erase user available code and UICR flash areas:

    nrfjprog --eraseall

    Now you can see the UICR flash of reset pin config as "FFFFFFFF FFFFFFFF":

    nrfjprog --memrd 0x10001200 --w 32 --n 8
    0x10001200: FFFFFFFF FFFFFFFF                     |........|

    Next, to program your nrf52833 custom board, and see the reset pin config again.

    If it is changed, it means that your program contains the definition of the CONFIG_GPIO_AS_PINRESET pin. Please check your APP project configuration and Bootloader project configuration.

    Have a good day

  • HI.

    I'm already solved this problem like t his.

        #if defined (CONFIG_GPIO_AS_PINRESET)
            if (((NRF_UICR->PSELRESET[0] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos)) ||
                ((NRF_UICR->PSELRESET[1] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos))){
                NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NRF_UICR->PSELRESET[0] = 18;
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NRF_UICR->PSELRESET[1] = 18;
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NVIC_SystemReset();
            }
        #else
            if (((NRF_UICR->PSELRESET[0] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Disconnected << UICR_PSELRESET_CONNECT_Pos)) ||
                ((NRF_UICR->PSELRESET[1] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Disconnected << UICR_PSELRESET_CONNECT_Pos))){
                NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NRF_UICR->PSELRESET[0] = 0x80000000;
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NRF_UICR->PSELRESET[1] = 0x80000000;
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NVIC_SystemReset();
            }
        #endif

Related