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)
returnstrue
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
Best Answer
'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.