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

Flash erased when read

Hello, i'm trying to store data in the flash, i manage to write a correct data in the flash but when i try to read it the address is erased.

I use this function to write in the flash (softdevice is enabled) :

void flash_write(uint32_t * addr,uint32_t word)
{
		uint32_t err_code;
		uint32_t returned_value = flash_word_read(addr);
	
		if(returned_value == 0xFFFFFFFF)
		{
				do{
						err_code = sd_flash_write(addr, &word, 1);
				} while (err_code == NRF_ERROR_BUSY || *addr != word);
				APP_ERROR_CHECK(err_code);
				NRF_LOG_INFO("memory written \r\n");
		}	
		flash_word_read(addr);
}

the flash_word_read() is a simple address read (return *address).

At the second flash read the value stored is the correct one but when i try to read it again it prints something completely different.

same thing happen in the debug mode on keil with the memory window.

I read the address like this :

NRF_LOG_INFO("addr1 %x \r\n",(uint32_t)*addr);

I work on SDK 13.1.

Do you have any idea where it could come from ?

Parents Reply Children
No Data
Related