Define struct on external EEPROM

Hello all,
I'm facing a little understanding problem.
At my design I use the AT89C51RD2 micro and also two external memory devices – SRAM and parallel EEPROM.
At my code I have several structs that I want them to be at the external EEPROM. What I did (and I think it's not OK) is to define such a parameter in the global memory area and then copy him to the external EEPROM. I think it's not OK to do so because I waste global memory area on data that I don't want him to be there. Also, in this case I receive duplicate data.
As I understand I can't do something like "volatile DATA xdata stData _at_ 0x8000;"
Where DATA is a struct compose from many data types like char, int and other structs.
Can anyone know a way to define a struct (bigger then one byte) directly in external memory?

Parents
  • There are a few things that I'm assuming here:

    1. Your EEPROM is located at 0x8000 in XDATA space.

    2. You have a struct (in EEPROM) that you want to read from and write to.

    If that's the case, you can just declare the struct as:

    volatile xdata struct bob _at_ 0x8000;

    And, the first structure member of bob will be at address 0x8000 in XDATA.

    Of course, you'll probably need some special way to write to bob since EEPROM writes are "typically" slower than writes to SRAM and wait states must be inserted manually.

    Jon

Reply
  • There are a few things that I'm assuming here:

    1. Your EEPROM is located at 0x8000 in XDATA space.

    2. You have a struct (in EEPROM) that you want to read from and write to.

    If that's the case, you can just declare the struct as:

    volatile xdata struct bob _at_ 0x8000;

    And, the first structure member of bob will be at address 0x8000 in XDATA.

    Of course, you'll probably need some special way to write to bob since EEPROM writes are "typically" slower than writes to SRAM and wait states must be inserted manually.

    Jon

Children
More questions in this forum