Storing User Input

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Storing User Input

562 Views
Thunder
Contributor III

Hi, I'm using an HCS08LG32 with an external display and keypad.  I'm looking for a method to accept user preferences, to be used later after power is recycled.  For example, when displaying a temperature, the user can input whether the default is Celcius or Fahrenheit.  All subsequent uses of the board will then default to the user preference.  I would also like to store user inputted programs (a series of keystrokes stored in an array), to be recalled for later user over the life of the product. 

  I am also using an RTC and want to store the number of hours the uP is in use (when powered with the RTC running) over multiple uses (powered on/off over a period of months).

Any suggestions ?    Do I need to use an external Flash/EEPROM ?

BTW.  I am coding in C.

Thanks.

Labels (1)
0 Kudos
1 Reply

227 Views
bigmac
Specialist III

Hello,

 

I suspect that it should be feasible to utilise a block of flash memory for the purpose of non-volatile storage for your project.  The task will be simpler if the total number of bytes required for all parameters does not exceed a single flash page (512 bytes), and you maintain an image of the parameters in RAM.  The lowest available flash page should be used so that flash block protection can be implemented, to protect your program code.

 

A possible strategy is to "pre-erase" the flash page at the start of normal operation, and to program the RAM image to flash just prior to loss of power.  For this you will need early warning of power loss so there is sufficient time to complete the programming.  This approach should minimize the amount of re-programming, and the "wear out" of the flash.

 

If you have some parameters that frequently change (such as the RTC data), and others that will rarely change, a variation of the above might be to update the infrequently changing parameters as each change occurs, and the others upon loss of power.  This will potentially reduce the amount of time required at power loss, but would require two different flash pages.

 

The erase and programming of the flash page(s) will require use of a small RAM based function when the flash array is inaccessible during the write process.  This issue has already been covered by many other threads within this forum.  Two different approaches are possible - the use of a fixed block of RAM, or the use of the stack.  The first approach is probably a little simpler.

 

Regards,

Mac

 

0 Kudos