EEPROM data lost

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
DirkB
Posts: 116
Joined: Wed Feb 08, 2012 2:45 pm
Has thanked: 7 times
Been thanked: 11 times
Contact:

EEPROM data lost

Post by DirkB »

Hello,

I use Pic 12F1840 and Pic 16f1825. Everything works very well but data stored in the internal eeprom are lost.
Sometimes after a few days, sometimes after a few weeks or even months. Nothing has been changed and all
data is deleted when switching device on (or off?). How can this be? The codes were created with flowcode 5.
Flash memory self-write protection is enabled to "no address may be modified by EECON control".
Can it be a problem like this post? And is there the same Problem in FC8?

viewtopic.php?f=29&t=7192&p=17668&hilit ... ost#p17668

Thanks

Dirk

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 data lost

Post by Benj »

Hi Dirk,

I'm not aware of any problems like this where it works but then at some point becomes corrupt. I would likely need to see your program but if as you say the config is set so that no writes are allowed then this seems very odd indeed. Have you checked the microchip website specifically for the errata documents for your devices to see if there are any known silicone issues.

Also could it be down to a voltage thing, maybe the chip is going into a semi brown out state and not running correctly from that point. Another point of failure could be a stack overflow if you are calling macros which call macros which call macros etc which gets progressivley worse over time. In both of these cases a power cycle should restore the chip back to normal operation.

DirkB
Posts: 116
Joined: Wed Feb 08, 2012 2:45 pm
Has thanked: 7 times
Been thanked: 11 times
Contact:

Re: EEPROM data lost

Post by DirkB »

Hi Ben,

there is actually only 1 macro, the midi-macro. it receives program changes and control changes. there are also global variables,
such as the midi channel and midi cc number, which are also stored in the eeprom and are read out and written to the variables
every time the eeprom is switched on. the brown out is also disabled. the pic often runs for several weeks or even months without
Problems. Can it be because I only use global variables? Is there a way to prevent instabilities of the chip when it is switched off and
to keep the content of the EEPROM safe?
In the 16F1825.fcd file on my FC5 the line "Define22=#define MX_EE_TYPE2" the entry is "Define22=#define MX_EE_TYPE3".
Is this Right?

thanks

Dirk

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 data lost

Post by Benj »

Hi Dirk,

Type 3 looks correct to me for the 16F1825, at least that's what we are using in Flowcode 8. If it's working at all then chances are the type is ok.

The difference is this. So it basically boils down to if the EECON1 register has the CFGS bit. Which it does.

Code: Select all

				#ifdef MX_EE_TYPE2
					cr_bit(EECON1, EEPGD);
				#endif
				#ifdef MX_EE_TYPE3
					cr_bit(EECON1, EEPGD);
					cr_bit(EECON1, CFGS);
				#endif
Can you enable brownout reset in the config, this will protect you from brownout problems which might be doing unpredictable things such as writing to your EE memory.

How often do you write to the EE locations? Each location has a maximum write limit, normally ranging from 10,000 to 1,000,000 cycles. If you were to write to a single location once every second then the location would be burnt out between 3 hours and 11 days.

DirkB
Posts: 116
Joined: Wed Feb 08, 2012 2:45 pm
Has thanked: 7 times
Been thanked: 11 times
Contact:

Re: EEPROM data lost

Post by DirkB »

Hi Ben,

only a few times something is written. Actually only 1 x the global variables (setup of the device), like midi channel e.g.
Then the program changes, like on-off of the port pins for each program are written into the first 128 bytes of the EEPROM.
These are later only retrieved via midi with a program change or control change. Only a few times something is written.
There are only changes when a program location is changed. This is then rewritten.

regards

Dirk

kejam
Posts: 7
Joined: Sat Oct 27, 2018 5:04 am
Has thanked: 1 time
Been thanked: 8 times
Contact:

Re: EEPROM data lost

Post by kejam »

Hi Dirk,
I've had a similar problem on a few different PICs.
In the microchip errata for one of the devices it confirmed an issue did exist with the EEPROM module.
The work around was to make the last operation before shutting down a dummy Read.
Apparently on reboot the last status of the control registers affects the data somehow.
So on all my code, no matter which PIC device, I now do a dummy Read after a Write, and I've not experienced the problem again since.

Cheers
Kev.

Post Reply