Skip to main content
Visitor II
July 18, 2007
Question

how can I save 2 bytes in eeprom using c

  • July 18, 2007
  • 16 replies
  • 3434 views
Posted on July 18, 2007 at 15:47

how can I save 2 bytes in eeprom using c

    This topic has been closed for replies.

    16 replies

    apytel1Author
    Visitor II
    December 28, 2006
    Posted on December 28, 2006 at 16:47

    Thank you very much.

    Tomorow i try again.

    best regards

    andrzej

    Visitor II
    July 17, 2007
    Posted on July 17, 2007 at 14:28

    Apologees but I'd like to finish up a few things on this thread.

    I'm trying to use the Cosmic compiler to read and write to EEPROM on a ST7FLITE39.

    I'm using ST7VD to develop my code.

    I have added eeprom.s and eeprom.i to my project.

    I declare my variables as

    e.g. @near @eeprom unsigned char myVar = 0;

    Then I disable automatic linker file generation in Project Settings > Linker > Input.

    Then I add line to my linker file

    +seg .eeprom -b 0x1000 -m 0x20

    And in my code I set myVar:

    myVar = 1;

    When I attempt to load this in ST7VP I receive :

    Address 0x1000 is out of range and is ignored!

    If I ignore this and program I can program the Program memory. On running the application I expect to see 0x01 in Data Memory location 0x1000 when I read the Data Memory tab from the IC using ST7VP.

    This is not the case.

    My remaining questions are:

    Should I receive the address out of range error?

    Are there any further modifications required for the eeprom code to work?

    Visitor II
    July 18, 2007
    Posted on July 18, 2007 at 06:36

    Following another post from ''mjg21cncn'' I notice that I can continue to allow STVD7 to generate auto link file by going to following:

    Project Settings->Linker->Input

    Expand Item ''Zero Page''

    Add entry .eeprom

    If I do this then I notice that I am able to read back my initial entry from the eeprom.

    Visitor II
    July 18, 2007
    Posted on July 18, 2007 at 07:02

    OK on further inspection it appears I am wrong. 8 chars all value 0x00 appear to get written to my EEPROM regardless of what the values are set to in the application.

    Visitor II
    July 18, 2007
    Posted on July 18, 2007 at 08:02

    please post your linker file and the listing file (the .la is better than the .ls, look in the manual to see how to produce it) so that we can take a look.

    Regards,

    Luca (Cosmic)

    PS: I'll be on holiday soon and I'm not sure I'll be able to follow this thread. If you don't get useful support here please contact

    mailto:support@cosmic.fr

    .

    Visitor II
    July 18, 2007
    Posted on July 18, 2007 at 15:47

    I received some great advice from our ST7 supplier which allowed me to build and run the application successfully.

    I copied eeprom.s and eeprom.i to my project directory, then changed the line in eeprom.i to point to the address of the EEPROM in the datasheet (Listed as EECSR in the ST7FLITE39 hardware register map)

    EEPCR: equ $30 ; control register

    I also added a function in my C code to reset the watchdog timer

    void reset_watchdog(void)

    {

    WDGCR = 255;

    }

    and added a function declaration to my eeprom.s

    xref _reset_watchdog

    which I call from within the wait loop of c_eewrc

    Finally I edited the line in the linker file associated with the .eeprom space:

    +seg .eeprom -b 0x1000 -m 0x100 -n .eeprom -c

    Adding the ''-c'' at the end.

    Now ST7VP does not complain about the out of range (eeprom) variables. And my application can read and write from the EEPROM on the IC.

    :D