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

Writing into UICR register by disabling SoftDevice

Hello,

 

I am using nRF52840, SDK_16.0.0, SoftDevice S140 V7.0.1 and Segger for flashing the image. I am using ‘ble_app_blinky’.

 

1) I want to write Serial number into UICR register. Since SoftDevice is enabled, I am not able to update UICR register. If we can update UICR even with SoftDevice, please let me know the procedure.

 

2) I follower below approach. Write UICR register with 5 bytes of Serial number and then reset the chip. Is this approach fine.

a) Is waiting for busy state of NVMC is correct ?

         

void writeSerialNumber(uint8_t* p8SeralNumber)
{
    // Disable Soft Device
    sd_softdevice_disable();
    
    // Write Serial Number into UICR register
    nrf_nvmc_write_bytes((uint32_t)0x1000108C,  (const uint8_t *) p8SeralNumber, 5);

    while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
    NVIC_SystemReset();
}

 

3) Whether NVIC_SystemReset() do a complete reset. To my understanding it’s a Soft reset. Correct me if I am working.

a) How about RAM during Soft reset. Will it be erased ?

 

4) Using nrfjprog, if I try to re-write I will get error. But I dont see such mechanism when I use nrf_nvmc_write_byte(). It is a void function. In this case, do I need check before writing.

 Thanks & Regards

Vishnu Beema

Parents
  • beemavishnu said:
    You mean nrf_nvmc_write_bytes() will wait for flash ready before writing into flash.

     No, I mean that it will wait that the flash write has been successful by checking that NRF_NVMC->READY state is NOT busy.

     

    beemavishnu said:
    But when I call nrf_nvmc_write_byte() and try to write same location with different values, in this case, I am not getting any error and able to write.

     But you should not write to an already written flash address with another value unless you just want to toggle few bits with value '1' to bits with value '0'. NVMC only can toggle bits from 1's to 0's and cannot toggle bits from 0's to 1's unless you do a full page erase.

Reply
  • beemavishnu said:
    You mean nrf_nvmc_write_bytes() will wait for flash ready before writing into flash.

     No, I mean that it will wait that the flash write has been successful by checking that NRF_NVMC->READY state is NOT busy.

     

    beemavishnu said:
    But when I call nrf_nvmc_write_byte() and try to write same location with different values, in this case, I am not getting any error and able to write.

     But you should not write to an already written flash address with another value unless you just want to toggle few bits with value '1' to bits with value '0'. NVMC only can toggle bits from 1's to 0's and cannot toggle bits from 0's to 1's unless you do a full page erase.

Children
No Data
Related