2013-05-02 05:13 AM
Hi, I try eeprom emulation but I have problem:
I use this function for storage variable:void write_block_eeprom(uint16_t stato,uint8_t *numberbuff){
uint16_t lsb,i;
uint16_t checksum;
uint8_t msb;
uint8_t flag;
uint16_t value;
checksum = 0;
FLASH_Unlock();
checksum = 0;
value = 0;
//stato
if(stato){
lsb = 1;
EE_WriteVariable(START_EEPROM_CONTATORE_ADD, lsb);
checksum = 1;
EE_WriteVariable(START_EEPROM_CONTATORE_ADD+1, checksum);
}else{
lsb = 0;
EE_WriteVariable(START_EEPROM_CONTATORE_ADD, lsb);
checksum = 0;
EE_WriteVariable(START_EEPROM_CONTATORE_ADD+1, checksum);
}
//number
flag = 0;
for(i=0;i<20;i++){
lsb = numberbuff[i] & 0x00FF;
if(lsb == 0x00){
flag = 1;
}
if(flag==1){
lsb = 0x0000;
EE_WriteVariable(START_EEPROM_CONTATORE_ADD+1+i, lsb);
}else{
EE_WriteVariable(START_EEPROM_CONTATORE_ADD+1+i, lsb);
}
checksum = checksum + lsb;
}
//timer
//ore
EE_WriteVariable(START_EEPROM_CONTATORE_ADD+1+20+1, timer.ore);
checksum = checksum + timer.ore;
//minuti
EE_WriteVariable(START_EEPROM_CONTATORE_ADD+1+20+2, 0x00FF & timer.minuti);
checksum = checksum + timer.minuti;
//secodni
EE_WriteVariable(START_EEPROM_CONTATORE_ADD+1+20+3, 0x00FF & timer.secondi);
checksum = checksum + timer.secondi;
//checksum
EE_WriteVariable(START_EEPROM_CONTATORE_ADD+1+20+4, checksum);
FLASH_Lock();
}
work very well, but the eeprom emulation work with 2 page, when I repeat this function ''
write_block_eeprom
'' ,
after several
repetition
itsjumps
to the
PAGE1and
I lose
the data, Is it possible storagein the same
memory location
?2013-05-02 09:04 AM
Is it possible storage
in the same
memory location
?The smart solution is to put your data in a structure, and manage the flash directly and in a fashion you want. The EE emulation adds virtualization and journalling which might not work in the way you want. The purpose of using two pages is that you don't get a case where you've erased the memory, but haven't written any content yet.
2013-05-03 08:50 AM
never done EEPROM emulation on this chip, but on another chip I realized that someone's problem with EEPROM emulation was that the ''EEPROM emulation memory section'' included a segment partially containing code. Thus when the ''EEPROM emulator'' did its erase, it also erased some code.
Erik