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

Suggestion for update to SDK (UICR Read back protection enabled by preprocessor flag)

Hi,

I added this in SystemInit() (just below the CONFIG_NFCT_PINS_AS_GPIOS section) within system_nrf.c so that I could easily turn on or off the APPROTECT read back protection when switching between my debug and release builds.


#if defined(ENABLE_READBACK_PROTECTION)
  if ((NRF_UICR->APPROTECT & UICR_APPROTECT_PALL_Msk) == (UICR_APPROTECT_PALL_Disabled << UICR_APPROTECT_PALL_Pos)) {
    NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos);
    while (NRF_NVMC->READY == NVMC_READY_READY_Busy) {
    }
    NRF_UICR->APPROTECT = 0xFFFFFF00;
    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

Hope this helps anyone else who may have been struggling with enabling read back protection.

Related