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

Able to write only one time in NVMC

Hi ,

Here is my code used to write in to non volatile memory.

#include "nrf.h" //#include "uicr_config.h" #include <stdint.h> #include <stdbool.h> #include "nrf_nvmc.h"

int main(void) {

			uint32_t     address   =  0x10001088;
			uint32_t     value       =  0x13345652;
			uint32_t     b            =   0;
			nrf_nvmc_write_word(address,	value);

			b = *(uint32_t *)address;
			
			//nrf_nvmc_write_word(address+12,	b);
			while (true)
			{
						/* Do nothing */
			}

}

But for first time i able to see the data whatever i have written in memory.

But if i change the value, i cant see the changed data. it remains as old data.

means i am not able to write one more time.

i check by reset the device also , but not able to write.

but if increase address value to 4 more bytes, i am able to write data in new address.

Kindly suggest me, where i am wrong.

Regards Balaji

Parents
  • Hi Ole,

    Here i done changes in code. but not yet worked.

    Kindly confirm where i am wrong.

    uint32_t address = 0x10001080; uint32_t value = 0x13345621; uint32_t b=0;

    NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Een; while (NRF_NVMC->READY == NVMC_READY_READY_Busy) {

    } // Erase the page NRF_NVMC->ERASEUICR=1; while (NRF_NVMC->READY == NVMC_READY_READY_Busy) { } NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren; while (NRF_NVMC->READY == NVMC_READY_READY_Busy) { }

    nrf_nvmc_write_word(address, value); while (true) { /* Do nothing */ }

    }

    Regards Balaji

  • I'm not sure why you want to erase UICR, but you should not do so in normal operation.

    To erase a flash area, you need to find out which page it is part of, and then erase this page. There are registers in FICR for page size and number of pages, so if you have an address it should be easy to do the math to find the page number. Remember that flash operations halt the CPU, so you should make sure that you have enough time to do so.

Reply
  • I'm not sure why you want to erase UICR, but you should not do so in normal operation.

    To erase a flash area, you need to find out which page it is part of, and then erase this page. There are registers in FICR for page size and number of pages, so if you have an address it should be easy to do the math to find the page number. Remember that flash operations halt the CPU, so you should make sure that you have enough time to do so.

Children
No Data
Related