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

System Reset after UICR Erase and write leads to System Off.

Hello,

I am using a custom board NRF52382, Softdevice 132_v2.0, SDK 11. Two power supply options are given, battery and USB.

I tried to rewrite UICR register with two implementation
 
    1st.

    uint32_t err_code = sd_softdevice_disable();
	APP_ERROR_CHECK(err_code);
	NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
	nrf_delay_ms(100);
	while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
	nrf_delay_ms(100);
	*(uint32_t *)0x100010E4 = var_register[0] ;
	*(uint32_t *)0x100010E8 = var_register[1] ;
	*(uint32_t *)0x100010EC = var_register[2] ;
	*(uint32_t *)0x100010F0 = var_register[3] ;
	nrf_delay_ms(100);
	NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
	while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
	NVIC_SystemReset();

 2nd

uint32_t err_code = sd_softdevice_disable();
	APP_ERROR_CHECK(err_code);
	NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Een << NVMC_CONFIG_WEN_Pos;
	nrf_delay_ms(100);
	while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
	NRF_NVMC->ERASEUICR = 1;
	while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
	nrf_delay_ms(100);
	NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
	nrf_delay_ms(100);
	while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
	nrf_delay_ms(100);
	*(uint32_t *)0x100010E4 = var_register[0] ;
	*(uint32_t *)0x100010E8 = var_register[1] ;
	*(uint32_t *)0x100010EC = var_register[2] ;
	*(uint32_t *)0x100010F0 = var_register[3] ;
	nrf_delay_ms(100);
	NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
	while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
	NVIC_SystemReset();

 The first implementation was not allowing me to rewrite UICR register either some corrupted data or previously stored data were coming.

In the Second implementation, I first erased UICR register then rewrite those register, it works fine for me. 

ISSUE). With the Second implementation, System is not resetting it is going in power off. Only possible way to do a reset is plug in USB, not working on battery independently and also causing problems if I try to do the soft reset.

I then have to erase the chip, program hex with DFU bootloader and do a firmware update over the air to see a soft reset is working.

This just explains that either soft device is forgetting that bootloader is present or erasing UICR register is erasing bootloader.
I tried to check also NRFFW register which is showing value 0xFFFFFFFF, in both scenarios.

From the first implementation, everything works fine but not rewrite of UICR register.

Need some explanation and how to move forward.

Thanks,

Parents
  • Be aware of nWRITE. The UICR register is part of the Flash memory, and it must not be repeatedly written (max 181 times) as it would be by an indiscriminate register write in user code on every reset. The Nordic SystemInit() checks the value before writing when using the defines to avoid repeated writes. This also means - for example - that the NFC pins can not be easily repeatedly switched between NFC mode and I/O port mode.

    I quote:

    "11.3 Writing to user information configuration registers (UICR)
    User information configuration registers (UICR) are written in the same way as Flash. After UICR has been written, the new UICR configuration will only take effect after a reset.
    UICR can only be written nWRITE number of times before an erase must be performed using ERASEUICR or ERASEALL."

    nWRITE,BLOCK Amount of writes allowed in a block between erase 181

Reply
  • Be aware of nWRITE. The UICR register is part of the Flash memory, and it must not be repeatedly written (max 181 times) as it would be by an indiscriminate register write in user code on every reset. The Nordic SystemInit() checks the value before writing when using the defines to avoid repeated writes. This also means - for example - that the NFC pins can not be easily repeatedly switched between NFC mode and I/O port mode.

    I quote:

    "11.3 Writing to user information configuration registers (UICR)
    User information configuration registers (UICR) are written in the same way as Flash. After UICR has been written, the new UICR configuration will only take effect after a reset.
    UICR can only be written nWRITE number of times before an erase must be performed using ERASEUICR or ERASEALL."

    nWRITE,BLOCK Amount of writes allowed in a block between erase 181

Children
No Data
Related