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

nRF52832 is it possible to clear CONFIG_GPIO_AS_PINRESET via software?

I have CONFIG_GPIO_AS_PINRESET defined in my project (both bootloader DFU and main program), so pin 21 is setup as hardware reset.

I would like to disable this function for a test, so would any of the following be possible;

1 - Is it possible to turn it of in software by modifying NRF_UICR->PSELRESET ?

2 - If not would it be possible to remove the define from just the main program and rebuild?

3 - Would the chip need a full erase, and the define removed from the DFU project before re-build / re-programme?

Thanks

  • Hi,

    I would use option 2 and remove the define perform a full rebuild (clean/build). Then I would fully erase the nRF and upload the SoftDevice if required and then your app. 

  • Hi,

    Option 3 (which is like option 2 + full chip erase) is the cleanest and only sensible way in most cases. Option 2 in itself is not possible since you must do a full chip erase to erase the UICR. Simply programming new firmware that is built without CONFIG_GPIO_AS_PINRESET will not reset the PSELRESET registers so that they will keep their original value (enabling pin reset).

    Though likely not relevant for you, option 1 can also be useful on a few special occasions. If you have a device in the field and want to disable pin reset, that would have to be done in a way that does not involve a chip erase. In that case,  you can use the following code snippet to programmatically disable pin reset by writing an invalid configuration to one of the PSELRESET registers. This is a hack, though, and should only be used when that is the only option.

    /** Function to disable pin reset by writing an invalid configuration (all 0) to PSELRESET[1] */
    static void disable_pin_reset(void)
    {
        // Only perform if needed (which is the first time this code runs)
        if (NRF_UICR->PSELRESET[1] != 0)
        {
            NRF_LOG_INFO("Disabling pin reset.");
    
            NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen;
            while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
    
            NRF_UICR->PSELRESET[1] = 0;
    
            NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren;
            while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
    
            // System reset is needed to update UICR registers.
            NVIC_SystemReset();
        }
    }

  • Thanks Einar,

    Sounds good, I will give the hack a try also as it might be useful for some units already in the field.

    Phil

Related