Recover Chip PIC16F83 Eeprom: Reading a Part That Lost Power Mid-Write
Most recovery work starts from a device that is either working or dead. This part produces a third category that is more interesting: a device that is alive, responds to the programming interface, returns a full image, and behaves wrongly. The image is a mixture of old content, new content, erased rows and partially erased cells, and the job is to read that mixture correctly rather than to assume the read failed.
The PIC16F83 is the smaller member of the classic eighteen-pin flash pair: 512 by 14 bits of program memory, 64 bytes of data EEPROM, a few dozen bytes of RAM, one timer, no converter. It was designed into timers, chargers, access control and small appliances, and a fair number of those designs used self-programming — the device rewriting part of its own flash during operation, or writing its EEPROM at the end of a production test.
Self-programming is what makes the interrupted state a real case rather than a theoretical one.
What an interruption actually leaves
Flash erase works in blocks. A write works in words. Between the start of an erase and the completion of the write that follows it, the array is in a state that has no valid interpretation as program content.
| State | What the cells read | How it appears in a listing |
|---|---|---|
| fully erased | all ones | blank, expected after erase |
| fully written | intended value | normal code |
| erase interrupted | a rising pattern of ones across the row | runs of 0x3FF with occasional valid words |
| write interrupted | value between erased and target | words that decode to implausible instructions |
| EEPROM write interrupted | mixture of old and new bytes | settings that fail consistency checks |
The third row is the giveaway. On a 14-bit word, an erase that stops partway leaves some cells at one and some at zero, and the resulting word is usually a value with a high run of ones — 0x3FF, 0x3FE, 0x3FC, 0x3F8. A region where these appear in sequence, mixed with genuine instructions, is not corruption from a bad read. It is a physical record of where the erase stopped.
Why the read is usually still valid
It is worth stating plainly, because customers often assume otherwise: an image containing a half-erased region is a correct read of a damaged device. The programming interface reports what the cells hold, and if the cells are in an intermediate state, the image contains intermediate values.
That distinction changes the deliverable. What the customer needs is not a repaired image but a map of which regions are trustworthy. An image that has been “cleaned” — intermediate values replaced with blank or with a plausible guess — has destroyed the only evidence of what happened.
The 64 bytes that often explain the failure
On this part the data EEPROM is 64 bytes, and the code frequently writes it during operation: a run counter, a setpoint changed by the user, a state that must survive power loss. A write to EEPROM takes milliseconds, and a supply that collapses during that window leaves a byte that is neither the old nor the new value.
The signature is localised: one byte, or a short run within a row, whose value is inconsistent with the surrounding structure. A setpoint of 20 stored next to a setpoint of 200 with a value of 148 in between is an interrupted write, not an encoding.
Reading the EEPROM before anything else is the rule, because it is the block most likely to have been mid-write when the failure occurred, and it is the block whose content the customer most often wants back.
The program array: boundary and blank tail
512 words is small enough that the whole array can be read and inspected. Two boundary facts matter.
The configuration word sits at the top of the map, and on this family the last program word may also carry a factory calibration value for the internal oscillator. A read that treats the top word as configuration only will discard the calibration; a read that treats it as program only will program the wrong configuration.
The blank tail between the end of the code and the configuration word reads as all ones. It is not empty in the sense of “nothing was here” — it is erased, which is a state the array was put into deliberately at manufacture.
Telling a bad read from a bad device
| Observation | Likely cause | Next step |
|---|---|---|
| every word identical | read inhibited or interface fault | check protection state, then die |
| word zero not a jump | wrong word convention | reconvert the file |
| one region with rising-one patterns | interrupted erase | map the region, deliver as damaged |
| scattered implausible words | marginal read timing | re-read at lower clock |
| image verifies but device misbehaves | missing calibration or config | re-read the top word |
The fourth row is worth trying before any physical work. On an old device with a tired interface, lowering the programming clock often converts a noisy read into a clean one, and it costs nothing.
What a recovery on this part should contain
The full 512-word image including the top word, with the word convention stated. The configuration fields decoded. The 64 bytes of EEPROM raw, plus a note identifying which bytes look interrupted and why. And a region map marking addresses that read as intermediate values rather than as code or blank.
That map is the part that lets the customer decide whether the design is repairable: a program whose main loop is intact and whose configuration block is damaged is a candidate for reconstruction, while a program whose interrupt handler is half erased is not.
Where a larger part in the same family shows how the EEPROM contents drive the design’s behaviour, PIC16F84 code breaking covers the two-customer problem. Where the same small array is OTP and therefore cannot be half erased at all, PIC12F508 code recovery sets out the different failure set. And where the interrupted region must be reconstructed from behaviour rather than read, PIC12CE518 binary recovery describes that path.
The short version
An interrupted write produces an image that is correctly read and partly invalid. Do not clean it. Map it: which words are code, which are intermediate, which bytes of the EEPROM were mid-write, and which part of the map can be trusted. That map is the deliverable.