Hi,
I read your message with interest and finally I looked up the code that caused all those problems you were refeering to.
Ohoh!! It was my code!
Let me try to answer the questions you had:
a.) add this line
EEPROM = READ_ONLY 0xE000 to 0xE1FF // reserve space to prevent overlap of code
b) modify
ROM = READ_ONLY 0xE200 to 0xFFAD //
c) add
CODE_RELOC = READ_ONLY 0xE200 to 0xE240 RELOCATE_TO 0x0060
a) sets up the EEPROM segment. It should be at least 1 page long.
b) the ROM code should be modified to avoid collisions with the EEPROM buffer.
c) this is to tell the compiler that the code that is between 0xE200 - 0xE240 will be moved to address 0x60. So a label at eg 0xE245 should be moved to 0x65.
You write
"Finally, if you want to "write" certain address, you must run the "CopyErase" first, the "CopyErase" routine will clear (or reset?) the content of the EEPROM to 0xff so that you can "write" this address again.
This is because the "write" process only set the required bits to "0", not "1". For example, if writing a value "0xa5" into address 0xE000, the process will be
1. call CopyErase
2. call CopyProgram
3. call RunProgram"
CopyErase() copies part of itself down to address 0x60 and calls the entry address there.
It will then erase a bit of the Flash EPROM
CopyProgram() copies itself into 0x60. It doesn't do anything else.
The RunProgram() calls address 0x60.
The routine stored in this position, will take the R[] and program it into the Flash EPROM.
Your last questions was:
"Finally, if you want to "write" certain address, you must run the "CopyErase" first, the "CopyErase" routine will clear (or reset?) the content of the EEPROM to 0xff so that you can "write" this address again."
Answer: If you want to write a value to a Flash EPROM, it must contain 0xff. Everything else, it must be erased. And you cannot erase a single byte, so therefore to change a single byte, you must save a page of Flash EPROM, erase it, modify the byte in the RAM buffer and write everything back again.
I hope I have answered some of your questions.
If not please tell me!
Regards,
Ake