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

flash update just 1 byte

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?

Parents
  • 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.

  • 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);
    
Reply
  • 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);
    
Children
No Data
Related