Hi,
I am working on a project that utilizes the nRF52832.
How to properly enable Access Port protection in the code, if I want to have a single firmware for all three revisions of the IC.
Currently, I have something like that:
#define NRF_IC_REVISION_1 (0x00000042)
#define NRF_IC_REVISION_2 (0x00000045)
static void enable_read_out_protection(void)
{
uint32_t ic_variant = NRF_FICR->INFO.VARIANT;
uint32_t build_code = ((ic_variant >> 8) & 0x000000FF);
if ((NRF_IC_REVISION_1 != build_code) && (NRF_IC_REVISION_2 != build_code))
{
return;
}
// check if APPROTECT is already enabled.
if (0xFFFFFF00 != NRF_UICR->APPROTECT)
{
// APPROTECT not set yet
// program new value to APPROTECT
nrf_nvmc_write_word((uint32_t)&(NRF_UICR->APPROTECT), 0xFFFFFF00);
// trigger reset to apply new settings
NVIC_SystemReset();
}
}
Is the approach used to detect the revision of the IC ok?