Hi, I'm using nrf51 without ble.
I want to update flash but not want to delete PAGE every time.
NRF_NVMC->ERASEPAGE = (uint32_t) page_address;
How can i do?
Hi, I'm using nrf51 without ble.
I want to update flash but not want to delete PAGE every time.
NRF_NVMC->ERASEPAGE = (uint32_t) page_address;
How can i do?
If the specific address you're writing to is already erased (i.e. its value is 0xFFFFFFFF) you don't need to erase the whole page before the write.
If the address is not erased, you may be able to write to it a second time. The absolute maximum ratings of the nRF51 state that an address can be written to 2 times without an erase. However, I believe you would be you could only change '1's to '0's on the second write.
Thank you for your answer. Can you give me an example?
Here:
uint32_t* p_Write = (uint32_t*) addressToWriteTo;
// Enable write
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} // Wait for flash ready
// Perform write
*p_Write = valueToWrite;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} // Wait for flash ready
// Disable write
NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos);
I am doing it this way and how do we update it? without erase?
So you have a write address that has already been written to and you want to change the value? You could attempt a second write, but as I said above, it would likely only change the '1's to '0's, you couldn't change '0's to '1's without an erase. That's a physical limitation of flash.
The solution is to move the physical address of the data every time you need to write it. That way you limit your erases. Then the problem is managing where variable actually is.
You could take a look at some of the flash managing libraries from Nordic. See this answer