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

Writing to UICR from application code

Hello,

I am truing to store data in the UICR register "customer area" from application code. The procedure is invoked only once when the registers are still empty. The code is as follows:

void write_to_uicr()
{
        uint32_t data_to_write;

        uint32_t err_code = sd_softdevice_disable();
        APP_ERROR_CHECK(err_code);

        interrupts_disable();
        //...

        data_to_write = get_data();

        NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;	
        while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
        *(uint32_t *)0x10001080 = data_to_write ;
        NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;	
        while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}

}

Unfortunately the only data written to the registers is 0x00000000 even though I can verify with the debugger that the value of the "data_to_write" variable is different than zero and it is as expected. Optimizations are switched off. I would be more than glad to get any input on this problem. Thank you in advance!

Related