2016-10-18 12:51 AM
Hello,
i have problem with eeprom, then i erasing eeprom (writing 0 or any other values) then everything is working without problem , later then i write 0 then everything is working fine, but if i write other value then i got error 2, please help,i am suing STM32F103RBi provided test code:#include <EEPROM.h>byte ReadStatus ;uint32 as; int as1 = 0;void setup() { Serial.begin(115200); delay(5000); uint32 *mem = (uint32 *)0x08019000 + 1010; as = *mem & 0xFFFF; if (as != 0) { // if value is not zero then erase memory FLASH_Unlock(); for (int i = 0 ; i < 2040 ; i++ ) { ReadStatus = FLASH_ProgramHalfWord(0x08019000 + (i * 4), 0); Serial.println(ReadStatus); } FLASH_Lock(); } for (int i = 0 ; i < 2040 ; i++ ) { // debug - check erased memory uint32 *mem = (uint32 *)0x08019000 + i; as = *mem & 0xFFFF; Serial.print(*mem); Serial.print(''-''); Serial.println(as); delay(1); } delay(5000);}void loop() { ReadStatus = FLASH_WaitForLastOperation(1000); Serial.print(String(ReadStatus)); Serial.print(''-''); FLASH_Unlock(); ReadStatus = FLASH_ProgramHalfWord(0x08019000 + 4, as1); // there i got error code 2 FLASH_Lock(); Serial.print(String(ReadStatus)); Serial.println(''-''); as1++; delay(5000);}2016-10-18 01:08 AM
FLASH is not erased by writing zeros into it.
The library you are using will probably provide a function like FLASH_EraseSector() to erase a sector in FLASH. Check your library's documentation and RM0008. JW2016-10-18 01:20 AM
you are right, there is not erasing, just writing zeros, but where is the problem ? in first step after code upload then i writing to memory any values (from 0 to 65535) then everything work fine, later then i need to write some value in memory except 0 then i got error !?
i cant find out why i can write anything after first startup after code upload, and why i cant write later !?