EEProm Initialize Help?
Moderator: Benj
EEProm Initialize Help?
Ok I have all the functionality now working well (thanks to Martin) and would like to store a variable into EEProm.
I obviously need to program an initial value either when the part is burned, or at the very first power up and then check to see if it has been changed and use the new value each time the device is restarted.
Does anyone have a simple example routine for this?
Thanks, Howard
I obviously need to program an initial value either when the part is burned, or at the very first power up and then check to see if it has been changed and use the new value each time the device is restarted.
Does anyone have a simple example routine for this?
Thanks, Howard
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: EEProm Initialize Help?
Hi Howard,
What I do is use one additional address to store a key value e.g 22 when I write to EEPROM
Then if the chip is reset and I want to read my stored data from EEPROM:
I first read the key value, if its 22 then I read from the EEPROM location that contains my stored data.
If value = 22:
Yes then read EEPROM
no: //Don't bother reading since EEPROM has not been wrote to yet.
Hope this helps.
I have explained about a similar thing here:
http://www.matrixmultimedia.com/mmforum ... 950#p28950
If your still stuck I can assist you further.
Martin
What I do is use one additional address to store a key value e.g 22 when I write to EEPROM
Then if the chip is reset and I want to read my stored data from EEPROM:
I first read the key value, if its 22 then I read from the EEPROM location that contains my stored data.
If value = 22:
Yes then read EEPROM
no: //Don't bother reading since EEPROM has not been wrote to yet.
Hope this helps.
I have explained about a similar thing here:
http://www.matrixmultimedia.com/mmforum ... 950#p28950
If your still stuck I can assist you further.
Martin
Martin
Re: EEProm Initialize Help?
Hi Martin,
Thank you again for the help. I now have it working!
I have noticed a 3 second delay after write in most of the examples. Is this correct for a 16F88??
Warm regards, Howard
Thank you again for the help. I now have it working!
I have noticed a 3 second delay after write in most of the examples. Is this correct for a 16F88??
Warm regards, Howard
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: EEProm Initialize Help?
Glad I could help.
I write to EEPROM with a project I completed, and I have not noticed any delay with the hardware.
I was writing to locations.
Martin
Is the delay with simulator or with your hardware?Collimare wrote: I have noticed a 3 second delay after write in most of the examples. Is this correct for a 16F88??
I write to EEPROM with a project I completed, and I have not noticed any delay with the hardware.
I was writing to locations.
Martin
Martin
- AbhijitR
- Posts: 300
- Joined: Fri Nov 07, 2014 12:48 pm
- Location: Pune, India
- Has thanked: 283 times
- Been thanked: 80 times
- Contact:
Re: EEProm Initialize Help?
Hello! Martinmedelec35 wrote:Hi Howard,
What I do is use one additional address to store a key value e.g 22 when I write to EEPROM
Then if the chip is reset and I want to read my stored data from EEPROM:
I first read the key value, if its 22 then I read from the EEPROM location that contains my stored data.
If value = 22:
Yes then read EEPROM
no: //Don't bother reading since EEPROM has not been wrote to yet.
Hope this helps.
I have explained about a similar thing here:
http://www.matrixmultimedia.com/mmforum ... 950#p28950
If your still stuck I can assist you further.
Martin
Kindly excuse but honestly I did not understand the above explanation, my doubt is if I want to store 0 (zero) OR 28, as the initial value of the EEPROM, while loading the *.hex file in the hardware, do I only write 28 in the "Initial Values" in the properties window of the EEPROM and I will be able to read the same value (ie 28) later while running the program in the actual hardware, or there is some other method to do so.
I tried doing the above but I notice the value (ie 28) change to 255 after loading the *.hex file to the chip.
Can you shed some light on this.
Thank you.
Regards
Abhi
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: EEProm Initialize Help?
When sending hex to chip the programmer default setting is to erase all EEPROM values = 255
So if not wrote to EEPROM after programming chip then the value will be 255, that is expected.
Your program needs to write to EEPROM if the value read is 255.
After then when power is removed/restored then EEPROM will contain expected value.
So if not wrote to EEPROM after programming chip then the value will be 255, that is expected.
Your program needs to write to EEPROM if the value read is 255.
After then when power is removed/restored then EEPROM will contain expected value.
Martin
- AbhijitR
- Posts: 300
- Joined: Fri Nov 07, 2014 12:48 pm
- Location: Pune, India
- Has thanked: 283 times
- Been thanked: 80 times
- Contact:
Re: EEProm Initialize Help?
Oh! Martin, you make it so simple to understand, but then the option to write the "Initial Value" in the EEPROM properties window is of no use, is it? And in the actual execution of the program in the hardware I can use the value till 254, did I got right.
Abhi
Abhi
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: EEProm Initialize Help?
In main, before the main loop just read the value of EEPROM.
If value = 255 then write new default value to EEPROM.
Then when power is restored next time the value won't be 255 so the new default value will not be written to EEPROM.
If value = 255 then write new default value to EEPROM.
Then when power is restored next time the value won't be 255 so the new default value will not be written to EEPROM.
Martin
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: EEProm Initialize Help?
It's been a long while since I looked at Flowcode 5 and I could be overlooking some problem but the initial values field should set the EEPROM values after programming.
Here is the programming sequence.
Delete EE Contents - all values set to 255
Program initial values - anything with an initial value is pre-programmed
Reset into First run - initial values should be available
Here is the programming sequence.
Delete EE Contents - all values set to 255
Program initial values - anything with an initial value is pre-programmed
Reset into First run - initial values should be available
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: EEProm Initialize Help?
I thought that was introduced with Flowcode V6? ?Benj wrote:but the initial values field should set the EEPROM values after programming.
@Abhi
As you have posted in the v7 section previously Are you stuck with that version?
Martin
- AbhijitR
- Posts: 300
- Joined: Fri Nov 07, 2014 12:48 pm
- Location: Pune, India
- Has thanked: 283 times
- Been thanked: 80 times
- Contact:
Re: EEProm Initialize Help?
Hello! Martinmedelec35 wrote: @Abhi
As you have posted in the v7 section previously Are you stuck with that version?
Kindly excuse me if I posted in the wrong section, it is really confusing for me, I thought I posted in the continuation of previous posts in version 5, , I am still using version 6 for the moment, but willing to buy version 8
Abhi