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

SOFTDEVICE: INVALID MEMORY ACCESS

Hi, 

I am working on ble_app_template.
I am trying to save a value in the flash memory of nRF52840.
I am using the following 2 functions to write/read in flash memory but getting this error.

SOFTDEVICE: INVALID MEMORY ACCESS

I am using this memory as a starting memory to save values.(As mentioned in this link:  Flash - Non-volatile memory)

uint32_t f_addr = 0x4001E001;

Any solution for this error? 
Thanks

uint32_t f_addr = 0x4001E001; 


// Create a pointer to that address
uint32_t * p_addr = &f_addr; 

uint32_t val = 123456; 

void write_T()
{
    nrf_nvmc_write_word(f_addr, val);
}

void read_T()
{
     NRF_LOG_INFO("The Data read from flash is: %d", *(p_addr));
}

Parents Reply
  • Is this the right way to write/read data in flash memory?
    In this case when I read data it shows->


    <info> app: The Data read from flash is: 1044480

    uint32_t f_addr = 0x000FF000; 
    
    
    // Create a pointer to that address
    uint32_t * p_addr = &f_addr; 
    
    uint32_t val = 123456; 
    
    void write_T()
    {
        nrf_nvmc_write_word(f_addr, val);
    }
    
    void read_T()
    {
         NRF_LOG_INFO("The Data read from flash is: %d", *(p_addr));
    }
    
    



Children
Related