2
\$\begingroup\$

I was trying to get my EEPROM read/write working on my PIC.

I first programmed a write cycle, and then reprogrammed it to read it out. (To avoid writing every time I start the program/pic)

But I luckily found out that re-programming your PIC causes EEPROM to get... changed? I found a way to fix this, by using the setting "Preserve EEPROM".

My questions on this are:

  • Does "Preserve EEPROM" write the EEPROM everytime you program your chip? (So re-programming a million times will break EEPROM theoretically)
  • What value is EEPROM after it's programmed... (val != 0xFF) returns true Can I say it's corrupted after programming, or does it get a default value I could check on?

Using: (though it's more theoretical)

  • MPLAB X IDE
  • PICKIT3
  • PIC18F66K22
asked Mar 20, 2015 at 11:15
\$\endgroup\$
5
  • 3
    \$\begingroup\$ Typically the flash used for the program memory will wear out before the EEPROM does. \$\endgroup\$ Commented Mar 20, 2015 at 11:43
  • \$\begingroup\$ I'm, indeed, using a PICKit3 (added it to the question). And I didn't know that, but will it theoretically add up? Or well, does "Preserve EEPROM" mean it re-writes the EEPROM? \$\endgroup\$ Commented Mar 20, 2015 at 12:29
  • 1
    \$\begingroup\$ I've always understood the "preserve EEPROM" setting to mean that the EEPROM is left alone and ignored, not that it gets read out, erased and then re-programmed... \$\endgroup\$ Commented Mar 20, 2015 at 12:54
  • \$\begingroup\$ Hmm, I somehow thought my output window echo'd something like: Programming areas: Flash (0x00 to 0xFF) EEPROM. But I'm unable to replicate this. Using preserve EEPROM does not have any disadvantages? What about the value of the EEPROM after programming (withouth preserve), is it 0xFF or undefined? \$\endgroup\$ Commented Mar 23, 2015 at 20:47
  • \$\begingroup\$ The following memory area(s) will be programmed: program memory: start address = 0x0, end address = 0x347f configuration memory EEData memory Programmer output when programming the chip... ...for me it looks like it's 'rewriting' the EEPROM. As it says area(s) will be programmed ~ EEData memory \$\endgroup\$ Commented Mar 26, 2015 at 12:31

1 Answer 1

0
\$\begingroup\$

'Preserve EEPROM' suggests EEPROM content is not changed when chip is reprogrammed. I am not sure if it means the memory is not touched at all during the process. I might involve Pickit reading the data EEPROM, erasing the whole chip, programming the chip, then writing the data EEPROM with the old values.

If you are using Programmer-to-Go mode of Pickit, preserving EEPROM may not work like this.

If you have the CPD (Data EEPROM code-protected) fuse set, then Pickit can't read the EEPROM. You can work around this with 'Erase Configuration Bits' command.

Also a discussion at Microchip suggested that 'Erase all before programming' option overrides the 'Preserve EEPROM' setting.

answered Apr 17, 2015 at 14:09
\$\endgroup\$
1
  • \$\begingroup\$ Still not sure if it does re-write it. But it actually doesn't matter that much, as the flash memory is probably worn out earlier. \$\endgroup\$ Commented Apr 20, 2015 at 10:02

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.