EEProm Initialize Help?

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
Collimare
Posts: 19
Joined: Thu Mar 08, 2012 9:34 pm
Been thanked: 2 times
Contact:

EEProm Initialize Help?

Post by Collimare »

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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: EEProm Initialize Help?

Post by medelec35 »

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
Martin

Collimare
Posts: 19
Joined: Thu Mar 08, 2012 9:34 pm
Been thanked: 2 times
Contact:

Re: EEProm Initialize Help?

Post by Collimare »

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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: EEProm Initialize Help?

Post by medelec35 »

Glad I could help.
Collimare wrote: I have noticed a 3 second delay after write in most of the examples. Is this correct for a 16F88??
Is the delay with simulator or with your hardware?

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

User avatar
AbhijitR
Posts: 298
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 279 times
Been thanked: 78 times
Contact:

Re: EEProm Initialize Help?

Post by AbhijitR »

medelec35 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
Hello! 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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: EEProm Initialize Help?

Post by medelec35 »

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.
Martin

User avatar
AbhijitR
Posts: 298
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 279 times
Been thanked: 78 times
Contact:

Re: EEProm Initialize Help?

Post by AbhijitR »

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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: EEProm Initialize Help?

Post by medelec35 »

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.
Martin

User avatar
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?

Post by Benj »

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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: EEProm Initialize Help?

Post by medelec35 »

Benj wrote:but the initial values field should set the EEPROM values after programming.
I thought that was introduced with Flowcode V6? ?

@Abhi
As you have posted in the v7 section previously Are you stuck with that version?
Martin

User avatar
AbhijitR
Posts: 298
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 279 times
Been thanked: 78 times
Contact:

Re: EEProm Initialize Help?

Post by AbhijitR »

medelec35 wrote: @Abhi
As you have posted in the v7 section previously Are you stuck with that version?
Hello! Martin

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, :shock: , I am still using version 6 for the moment, but willing to buy version 8 :D

Abhi

Post Reply