How can I load EEPROM without uploading program

johndk

Senior Member
I've been working on an application using two 28x2 (great little chips!) in master-slave configuration. Programming works great. But I've been scratching my head as to how to solve this final problem.

The master runs a program which can take different setting parameters. Whenever I want to change the settings, I find myself reloading the entire program. At the moment the settings are entered as constants. But it is set up so that it can read the settings from EEPROM. Trouble is, I haven't figured out how I can change the EEPROM data without overwriting the program. As I understand the EEPROM directive, it would write the data, but clear any existing programming.

It's not a huge problem. But is would make changes quicker. And it would make the application more robust if end users can be guaranteed not to tinker with the programming or accidentally change the wrong settings (I have MANY, most of which should be left alone as constants).

Does anyone know of a method I can use?

Just as a quick aside. In this master-slave configuration, I tried temporarily swapping the master-slave roles to do some calibrations. That didn't work out, they lost communication. Is there a reason one should not be able to re-assign roles on the fly? Or did I just not get the programming right. I realize I didn't post the code, I'll work that out if the role-reversal is possible.

John
 

hippy

Technical Support
Staff member
You can use multiple programs slots, one for the EEPROM data, the other for the program code. Then when the slot holding the EEPROM data is updated the program code in the other remains intact -

Code:
#Picaxe 28X2
#Terminal 9600
#Slot 0
Run 1
Eeprom 0, (99)
Code:
#Picaxe 28X2
#Terminal 9600
#Slot 1
#No_Data
Do
  Read 0, b0
  SerTxd( #b0, " " )
  Pause 1000
Loop
 

techElder

Well-known member
Hippy, nothing like restating the obvious to us sinners! I knew that, but when I read what you wrote, it clicked. You just solved another of my programming problems! Thanks!
 

Skiwi

New Member
Another option for you - use an external EEPROM chip (28C64, 28C128 etc..) They are cheap and easy to use with hi2c commands
Advantage of using these is that they are non-volatile. So EEproms can be changed, or taken out for re-programming or reading data externally if required.
Loading the initial data to it could be done by running one of the slots as per hippys suggestion, at initial startup, or on a special interupt,(manual button to a spare input) so that it is loaded only once.
Your program could also set a variable, that relates to an EEprom address (start point), such that when directed to read from the EEprom, it reads the data from that particular location range.

If you wanted to change parameters without re-programming the working Picaxe, you could set up a test program to load the EEprom from a separate chip (e.g. on a breadboard), then just swap the EEprom on the working unit
 
Top