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

nRF52832 can nRESET be programmed to any GPIO using PSELRESET[0] & PSELRESET[1] registers ?

On the previous nRF51822 project the SWDIO pin could be used for nRESET.

The nRF52832 Product Specification and example code program nRESET to P0.21.

The Product Spec hints another GPIO may be used by programming the AAAAA bits. But then states the Value as 21 - and then in the description says P0.n onto which Reset is exposed. So it is ambiguous as to if it can be programmed to P0.0-through-n or if 21 is the only value it may be programmed to.

Can PSELRESET[0]/[1] be programmed to any P0.n pin or exclusively to P0.21 ?

Parents Reply Children
  • Hi Santosh

    All you have to do to set these registers is to define CONFIG_GPIO_AS_PINRESET in your project settings. 

    Then the system_nrf52xxx.c file will automatically check if the PSELRESET registers are updated, and set them correctly if they are 0xFFFFFFFF. 

    Below I added the code from the system_nrf52840.c file for reference:

        /* Configure GPIO pads as pPin Reset pin if Pin Reset capabilities desired. If CONFIG_GPIO_AS_PINRESET is not
          defined, pin reset will not be available. One GPIO (see Product Specification to see which one) will then be
          reserved for PinReset and not available as normal GPIO. */
        #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();
            }
        #endif

    Best regards
    Torbjørn

Related