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

Erasing UICR doesn't work on S130

SDK 7.2 S130 Alpha 0.9

I'm using the UICR customer register address 0x10001080 to stare a single 32 bit number. The code below is a bit of "brute force" to demonstrate what I'm trying to do:

static void write_uicr_customer_register(uint32_t * data, uint32_t offset)

{

uint32_t* cust_data = (uint32_t*)(NRF_UICR_BASE + 0x80 + offset);

if(*cust_data != 0xFFFFFFFF)
{
	NRF_NVMC->CONFIG = 2; //erase enable
	
	while(NRF_NVMC->READY == NVMC_READY_READY_Busy);//busy
	
	NRF_NVMC->ERASEUICR = 1; //perform erase of UICR only

	while(NRF_NVMC->READY == NVMC_READY_READY_Busy || NRF_NVMC->ERASEUICR == 1);//busy
	
	while(*cust_data != 0xFFFFFFFF);
}

NRF_NVMC->CONFIG = 1; //write enabled
	
while(NRF_NVMC->READY == NVMC_READY_READY_Busy);//busy

*cust_data = *data;
	
while(NRF_NVMC->READY == NVMC_READY_READY_Busy);//busy
	
NRF_NVMC->CONFIG = 0; //read only
	
while(NRF_NVMC->READY == NVMC_READY_READY_Busy);//busy

NVIC_SystemReset();

}

The first run, everything writes correctly. It just doesn't erase so I can re-write to it. Is there some trick to erase the UICR registers?

Related