can I enable and disable nrf52832 reset pin when code is running

I find NRF_UICR->PSELRESET[0],[1] can't be written to 0xffff when their values is 0x0015, but the values can be written to 0x0015 when pre values is 0xffff.

so, I can't enable and disable nrf52832 reset pin when code is running, right ?

here is my code

void reset_system(void)
{

	NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
    while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
    NRF_UICR->PSELRESET[0] = 0xffff;
    while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
    NRF_UICR->PSELRESET[1] = 0xffff;
    while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
	NRF_UICR->NFCPINS = 0xfffe;
    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){}

	nrf_gpio_cfg(
            SYSTEM_RESET,
            NRF_GPIO_PIN_DIR_OUTPUT,
            NRF_GPIO_PIN_INPUT_DISCONNECT,
            NRF_GPIO_PIN_PULLDOWN,
            NRF_GPIO_PIN_H0H1,
            NRF_GPIO_PIN_NOSENSE);
	nrf_gpio_pin_clear(SYSTEM_RESET);
	
}

void set_system_reset_pin(void)
{
	NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
    while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
    NRF_UICR->PSELRESET[0] = 21;
    while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
    NRF_UICR->PSELRESET[1] = 21;
    while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
	NRF_UICR->NFCPINS = 0xfffe;
    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){}
}

what I want is that if nrf52832 find other chips go wrong, it configures P0.21 as normal output pin to reset other chips, otherwise, it configures P0.21 as reset pin.

  • You need to perform a System Reset after writing to the UICR registers in order for the changes to take affect, i.e.

        NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
        while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
        NRF_UICR->PSELRESET[0] = 21;
        while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
        NRF_UICR->PSELRESET[1] = 21;
        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();