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
  • Hi Susheel,

    Thank you for your inputs.

    1) You mean nrf_nvmc_write_bytes() will wait for flash ready before writing into flash. I kept even after writing and before soft reset. Whether even this is taken care. My intention is not to do soft reset before writing into UICR. 

    2) Good to know Soft reset will not reset RAM. In other chips, usually Soft reset will also reset RAM. After writing UICR, its mentioned to reset chip. So in this case Soft reset is good enough or do I need to do hard reset after writing UICR register to take effect.

    3) Yes, that's what I am mentioned. nrfjprog will not allow (This is fine). 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.

    Thanks & Regards

    Vishnu Beema

Reply
  • Hi Susheel,

    Thank you for your inputs.

    1) You mean nrf_nvmc_write_bytes() will wait for flash ready before writing into flash. I kept even after writing and before soft reset. Whether even this is taken care. My intention is not to do soft reset before writing into UICR. 

    2) Good to know Soft reset will not reset RAM. In other chips, usually Soft reset will also reset RAM. After writing UICR, its mentioned to reset chip. So in this case Soft reset is good enough or do I need to do hard reset after writing UICR register to take effect.

    3) Yes, that's what I am mentioned. nrfjprog will not allow (This is fine). 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.

    Thanks & Regards

    Vishnu Beema

Children
No Data
Related