Skip to main content
Explorer II
April 17, 2013
Question

Storing some calibration data in FLASH memory

  • April 17, 2013
  • 1 reply
  • 1151 views
Posted on April 17, 2013 at 22:32

Hello,

I'm looking into storing some calibration data for my application into FLASH memory since my EEPROM space is very valuable and I cannot spare any of it. The cal data would only be written once (upon the first powerup of the device) and from then on would be read everytime on powerup.

What is a good way of doing this sort of thing? Can I ''reserve'' some FLASH so that the compiler doesn't use that particular location(s) for the main program?

Thanks
    This topic has been closed for replies.

    1 reply

    Visitor II
    April 27, 2013
    Posted on April 27, 2013 at 11:07

    You can do that. C compilers have special keyword which puts the data to flash(or to eeprom).

    Just reserve enough big byte array at dedicated address in the flash area (refer to ''memory organization'' in the docs).

    You could even make two projects. One of them contains the only executable code and pointer do the fixed address in your data-dedicated area in flash. The 2nd one has the only data. .hex files could be written to the chips separately.

    On the other hand, flash memory in STM8 devices can't be read and written at the same time, and, thus, the writing code can't be executed from flash. So if you wanna write calibration data to main flash area by the chip itself, you have to prepare writing procedure for storing to RAM, then copy it from Flash to RAM, then execute the writing code from RAM.

    See datasheet for your chip and STM8 Ref Man, 4.6.1.

    So, it's better for you to choose a chip with enough EEPROM, or connect any external data storage, or use STM32 devices, which are more advanced.