Eeprom

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

jgu1
Posts: 1179
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1104 times
Been thanked: 295 times
Contact:

Eeprom

Postby jgu1 » Fri Jul 01, 2011 8:15 am

Hello!

Hope expert team can help me. :)

I am working on a project where I need to save data in eeprom. when I save data in eeprom in the various addresses and I simulate the FC is also saved and loaded again. but when I run it in the real world (PIC16F876) it is not either read back or there will not be written to addresses after I've either reset or had the power off. I made a smallere test program with only one memo to better transparency of the program, but here the same problem. What am I doing wrong. I believe that the eeprom to store the data and could read them again after disconnecting the voltage or reset (pin1).
I've almost tried everything, looked at examples in books, it looks like I'm doing the right thing :?: :?:

Should I do something in the config?

Best regard

Jgu1
Attachments
EEEE.fcf
(10 KiB) Downloaded 130 times

User avatar
Benj
Matrix Staff
Posts: 14793
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4755 times
Been thanked: 4360 times
Contact:

Re: Eeprom

Postby Benj » Fri Jul 01, 2011 10:04 am

Hello,

Your configuration settings look correct and you are right that the EEPROM values should be retained during a reset or powerdown.

Could it be something to do with the EEPROM write macro. It seems that if you press the switch quick enough then the data would never be written and if you press the switch for a while the data could be written hundreds or thousands of times. The data retention for EEPROM is normally 10,000 erase write cycles so maybe that location has been burned out? Maybe try another location in EEPROM and add a large delay after your EEPROM write to see if this helps to solve the problem.

jgu1
Posts: 1179
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1104 times
Been thanked: 295 times
Contact:

Re: Eeprom

Postby jgu1 » Fri Jul 01, 2011 10:37 am

Hi Benj.

Thank you for your prompt reply. I took a whole new 16F876 and made a long delay 500ms, but unfortunately still the same results.
When I run the progam, it seemed to me after powering up, it not read the eproom.
I'm sure there have only been written to eeprom few times. :?: :?:

Hope you have more suggest´s.

Best regard

jgu1
Attachments
EE1.fcf
(14 KiB) Downloaded 161 times

User avatar
Benj
Matrix Staff
Posts: 14793
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4755 times
Been thanked: 4360 times
Contact:

Re: Eeprom

Postby Benj » Fri Jul 01, 2011 11:54 am

Hello,

Ok looking at the code I have something for you to try.

If you go to the View -> Project Options menu.

Enable supplementary code and then add this to the defines section of the supplementary code window.

#define MX_EE_TYPE2

Then close the supplementary code window and recompile to the chip. Hopefully now any data you write to the EEPROM will be saved correctly.

Alternativly here is an updated FCD you can try. Simply copy the file into your Flowcode v4/FCD directory and restart Flowcode. Then recompile the program as is to the device and hopefully the EEPROM will be written to correctly.
16F876.fcd
(11.46 KiB) Downloaded 164 times


Let me know how you get on.
These users thanked the author Benj for the post:
Eric Brouwer (Sat Jul 02, 2011 11:34 am)
Rating: 5%
 

jgu1
Posts: 1179
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1104 times
Been thanked: 295 times
Contact:

Re: Eeprom

Postby jgu1 » Fri Jul 01, 2011 2:13 pm

Hey Benj!

YES. I am now a big question .???? and a bit confused.

I added only this # define MX_EE_TYPE2 in Supplementary code so it worked immediately :D . subsequently, I have overwritten the file you sent.
But now I've have some more questions.

1st. Is it a bug in FC?

2nd. Will it work on all addresses in the eeprom of 16F876?

3nd. To try something, I tested with a 16f872 same problem?

4rd. Does this mean that I can not expect the eeprom does not work in all different types Pic?

5th. If not, can I just use the command you sent to all types Pic?

Hope you understand my confusion. I have no knowledge of C and expect that when the component is there, so it works.

Hope it is not too much trouble for you.

Thank´s Benj look forward to hear from you.

jgu1

User avatar
Benj
Matrix Staff
Posts: 14793
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4755 times
Been thanked: 4360 times
Contact:

Re: Eeprom

Postby Benj » Fri Jul 01, 2011 2:49 pm

Hello,

Great glad its working for you now. This FCD fix will be available as part of the up coming release.

1) Yes it was a small bug in the device definition file.

2) Yes all EEPROM addresses should now work correctly.

3) I've just checked the 16F872 FCD and it's correct and should work ok. i.e. it does not have the problem present in the 16F876. The devices found to have problems are 16F873, 16F874, 16F876, 16F877.

4) Most devices should be ok. Any devices found to not work, I should be able to fix fairly quickly.

5) Not all PICs have EEPROM but yes the Flowcode macros should work with all PIC devices with EE memory.
These users thanked the author Benj for the post:
jgu1 (Fri Jul 01, 2011 6:46 pm)
Rating: 5%
 

jgu1
Posts: 1179
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1104 times
Been thanked: 295 times
Contact:

Re: Eeprom

Postby jgu1 » Fri Jul 01, 2011 7:00 pm

Hello again! :D :D

Many thanks for your help. When will a new update for these errors and how I could find it?

A little history:
I made a small solar tracker system that charge some batteries (400A). These batteries powered using PIC, (and some other hardware) when it gets dark, some LED lights I have around my garden and house. I made in the program a button where I can calibrate how dark it must be before the light turned on and stores these values ​​in Eprom. Lamp´s must then be turned on for 5 hours then turn off, and then on again when it is getting dark, but sometimes something strange happened, the light would not turn on, or turned it on several times during the day. So I got a suspicion that these values ​​were not as they should be when I calibrated. And sure enough, after I made a small test program, (I attact) I could see they were not saved. I have now programmed a new pic with your updates and installed in the controller and, must be when it gets dark out and calibrate.
The problem was just about to make me crazy in the head.

Once again many many thanks Benj.. :lol: :lol:

Best regard and a very industrious and satisfied user of FC.

jgu1

User avatar
Benj
Matrix Staff
Posts: 14793
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4755 times
Been thanked: 4360 times
Contact:

Re: Eeprom

Postby Benj » Tue Jul 05, 2011 10:11 am

Hello,

Glad its working well for you now. Finding the cause of a problem like that can indeed be tricky. Sounds like a great project, might have a go at something like that myself.

The new modified FCD's will be included as part of the v4.5 update which is being rolled out shortly.