This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Regarding Flash Read and Write

Hi All,

We are in design phase of our project, which uses two NRF52 chipset one as master and Central , We have some prewritten content in Flash, which need to be read when BLE connection is up. So am currently working on checking how much time it will take to read 256 KB from Flash, Here is my test code for write and read ........ Am using memcpy for read and write in Flash. Is this correct way ?

// flash write

static void flash_write(uint32_t * address, char * value) { // Turn on flash write enable and wait until the NVMC is ready:

NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos);

while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
{
    // Do nothing.
}

	memcpy(address,value,4096);



while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
{
    // Do nothing.
}

// Turn off flash write enable and wait until the NVMC is ready:
NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos);

while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
{
    // Do nothing.
}

}

// flash read

memcpy(a,addr,1024);

Thanks a Lot in Advance

Parents
  • You are right, you can use memcpy for read operation, but i see that there some small issue in you code below for write operation

    memcpy(address,value,4096);
    while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
    {
        // Do nothing.
    }
    

    Above is wrong as you need to wait for every word you write to the flash. That is why it takes so much time for flash writes.

    for (i = 0; i < size; i++)
    {
      *address = value;
    
        // Wait flash write to finish
        while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
        {
            // Do nothing.
        }
    }
    
  • Thank you very much Aryan for your quick response !!!!!!!!!!!!!! .........

Reply Children
No Data
Related