Shop OBEX P1 Docs P2 Docs Learn Events
[Propgcc] Memory Mapping Calibration Constants from EEPROM into RAM. — Parallax Forums

[Propgcc] Memory Mapping Calibration Constants from EEPROM into RAM.

TomUdaleTomUdale Posts: 75
edited 2015-05-04 11:45 in Propeller 1
Greetings,

I am making a device that has some associated analog circuitry. We want to be able to access device specific calibration constants in our C code.

We have written a small spin program that allows our techs to run a calibration with the help of the terminal. The program takes the data points and calculates a series of parameters that we want to write into EEPROM.

We have a second EEPROM that we could write them to and then simply read them back explicitly with a routine.

It occurs to me however that I could have our spin program write them to a known address in the EEPROM used by the boot loader. Then (somehow) we would define variables in C that would be linked to that "known" location but which would not be part of the image so that the values written by the spin program would not get overwritten by the programmer.

The hopeful end result is that my C routines would then simply be able to directly read from some variables that magically have the values written by the spin program.

It is kind of like a merge of bss and data - you want the variables to not be part of the image you write (like bss), but you want them to be filled from the image when it is read (like data).

Any ideas if this is possible and if so, how to do this? Maybe something like declare them as uninitialized, but then use some linker script to force the address of those variables to be past the end of the image and then update the length of the image as it is written out to the propeller?

All the best,

Tom

Comments

  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-05-01 14:31
    I believe you're looking for the existing functions ee_getInt and family. They are available in the Simple libraries.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-05-01 14:41
    If you're using a 64K EEPROM (most Propeller boards sold by Parallax have 64K EEPROMs) you could store the calibration data in the upper half of the EEPROM. This section is not overwritten when loading new code so you wouldn't have to reload the calibration data when updating the program.

    At least this is the way it works with Spin. I'm not so sure about C.
  • David BetzDavid Betz Posts: 14,516
    edited 2015-05-01 15:00
    Duane Degn wrote: »
    If you're using a 64K EEPROM (most Propeller boards sold by Parallax have 64K EEPROMs) you could store the calibration data in the upper half of the EEPROM. This section is not overwritten when loading new code so you wouldn't have to reload the calibration data when updating the program.

    At least this is the way it works with Spin. I'm not so sure about C.
    This is also the way it works in C if you're using the LMM or CMM memory model or if you use XMM but don't use the EEPROM as external memory and instead use SPI flash or something like that.
  • TomUdaleTomUdale Posts: 75
    edited 2015-05-04 11:45
    Thanks everyone. I kind of figured that simply reading directly from the EEPROM was the easy way. I do have a second EEPROM to play with so I will use that.

    All the best,

    Tom
Sign In or Register to comment.