Helton Marques wrote:
> This is right ?
No. It doesn't even compile.
Had you tried to compile this (before posting), you'd get this error
test.c:1: parse error: token -> '0x8000' ; column 13
The correct syntax is:
xdata at 0x8000 unsigned char EEPROM_Page[0x1F];
Please refer to section 3.12 for details:
> xdata (0x8000) unsigned char EEPROM_Page[0x1F];
> void write_eeprom(unsigned char address, unsigned char value)
> EEPROM_Page[address] = value;
While that change will make this code at least compile. But it won't do
what you describe:
> The addressing is right, for example ...
> - write the value = 10 in 0x8200...
> write_eeprom(0x02, 10);
This cause a write of value 10 into location 0x8002. Maybe your typing
"0x8200" was a mistake and you really meant 0x8002 ?
The other big question about wether this will actually work is wether
your "eeprom" will actually be written by a normal write cycle (eg, movx
instruction on mcs51 architecture). Most eeproms require more work than
that. Even if you have a simple 28C64 type eeprom that might be able to
write this way, to "work properly", you'd need to have some code to wait
for the chip to not be busy... as in polling the toggle bit. You need
to refer to the datasheet for whatever eeprom chip your design uses....
the proper algorithm for writing to an eeprom is far outside the scope
of help with the compiler..... I only mention is because a simple write
cycle is unlikely to be enough for almost any eeprom chips.
Next time, please at least try compiling your code.