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

C implementation for writing to NVMC

Hello,

I am looking through the data sheet for the NRF52 and do not see anything for writing to NVMC.

I see you can erase and configure the NVMC using:

NRF_NVMC -> CONFIG = 0x2; NRF_NVMC -> ERASEPAGE = 0x0150;

I was expecting see some thing like

NRF_NVMC -> WRITEPAGE = 0x0150; NRF_NVMC -> DATA = 0x3350;

How would I go about writing data to a specific address in flash?

Thanks,

Eric

Parents
  • The nrf_nvmc_write_word() function looks like this:

    void nrf_nvmc_write_word(uint32_t address, uint32_t value)
    {
        // Enable write.
        NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen;
        while (NRF_NVMC->READY == NVMC_READY_READY_Busy){
        }
    
        *(uint32_t*)address = value;
        while (NRF_NVMC->READY == NVMC_READY_READY_Busy){
        }
    
        NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren;
        while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
        {
        }
    }
    

    So now you can implement this in your own function ; )

Reply
  • The nrf_nvmc_write_word() function looks like this:

    void nrf_nvmc_write_word(uint32_t address, uint32_t value)
    {
        // Enable write.
        NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen;
        while (NRF_NVMC->READY == NVMC_READY_READY_Busy){
        }
    
        *(uint32_t*)address = value;
        while (NRF_NVMC->READY == NVMC_READY_READY_Busy){
        }
    
        NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren;
        while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
        {
        }
    }
    

    So now you can implement this in your own function ; )

Children
Related