Break IC PIC16F88 Data: Reading the Byte-Writable Array Properly
Two arrays live inside this device and they could hardly be more different in character. Program memory is read as instruction words, written in blocks, and protected by one bit. The data array is read and written one byte at a time, through a small set of registers, with a timing requirement and a handshake — and it is protected by a different bit.
That difference is not a curiosity. It decides the order in which a recovery should proceed, it explains why the data array often survives when the code does not, and it leaves a fingerprint in the firmware that tells you how the product uses its store.
How the array is reached
Three registers form the interface: one holds an address, one holds a byte of data, and one carries the control and status bits that start a read or a write and report when it is finished. The sequence for a read is short — write the address, set the read control bit, wait one cycle, take the byte. A write is longer, because the array needs a programming pulse and the firmware must wait for it to complete.
| Operation | Steps | Constraint that catches people out |
|---|---|---|
| read a byte | address, set read bit, one cycle, read data register | the address register is not auto-incremented |
| write a byte | address, data, unlock sequence, set write bit, wait | the unlock sequence must be uninterrupted |
| erase then write | the same, with a separate erase step on some variants | a write without erase may not settle correctly |
The unlock sequence is the detail worth knowing. Writing to the array requires a specific sequence of writes to a control register that must occur without interruption — no branch, no interrupt, no call between them. Firmware that gets this right is visible in the listing as a short straight-line block with interrupts disabled around it. Firmware that gets it wrong does not write reliably, which produces a product that loses settings intermittently and is very hard to diagnose from the outside.
What the content tells you about the product
A blank data array reads as a uniform pattern. A used one rarely does, and the shape of the non-uniformity is informative.
Where a product keeps a single parameter, the array shows one or two bytes of real data and the rest blank. Where it keeps a structured record, the array shows a block with internal consistency — sequential numbers, a checksum, a version byte. Where it logs over time, the array shows repeated records with increasing counters.
Three inspection habits pay off.
First, look at the first few bytes. A magic value there is the convention for distinguishing a virgin device from a populated one, and its presence tells you whether the product performs first-run initialisation.
Second, look for a checksum. Where one exists, the array validates itself, and a validation failure on a recovered copy is a strong indication that the read was incomplete rather than that the data was corrupted.
Third, look for asymmetry. A block of identical non-blank values in an otherwise diverse array is usually a factory default written once and never updated.
Why the data array survives when the code does not
Data protection is a separate configuration bit. On a great many products it is left unset even when code protection is engaged, for a simple reason: the production line needs to write per-unit parameters into the array after the code has been locked. Leaving the data array open is the convenient choice, and convenience wins.
That asymmetry is the single most useful fact in this kind of work. It means the order of operations should be data first, code second — the opposite of what the phrase read the firmware suggests.
The asymmetry also means that a device whose code is unrecoverable may still yield a complete parameter set, which for a repair operation is often enough. A replacement controller loaded with a known-good image plus the original unit’s calibration is a working repair, even if the original code was never read.
Order of operations on an unknown device
- Read the identifier and the configuration bits. This establishes the part, the revision, and which arrays are protected.
- Read the data array. It is usually accessible and it is usually the part with the least redundancy elsewhere.
- Validate the data array against its own internal structure, if it has one.
- Read the program array, accepting that it may be refused.
- Read the configuration bits again, in case the first read was affected by the device’s state at power-up.
Step five sounds superstitious and is not: configuration bits on this generation can be read reliably only when the device is in programming mode, and a tool that reports them from a running device is reporting something slightly different.
When only the data array is available
A parameter set without code is still a deliverable, and it needs its own presentation.
- the raw bytes, with the blank regions marked rather than omitted
- a field map guessed from the structure, clearly labelled as inferred
- any values that look like calibration, identified with their plausible range
- the count of times a record appears, where the array looks like a log
The labelling matters because a field map inferred from structure can be wrong in ways that are expensive. A four-byte value that looks like a counter may be a serial number; treating it as a counter and incrementing it destroys the identity of the unit.
Where this device sits in the family
The sibling without the analogue converter has the same data array and a slightly smaller peripheral set, and the copy question there is about which parts of the image are shared between variants — covered in PIC16F87 code copying. The larger 40-pin relative adds a fourth region to the delivery and is treated in PIC18F4220 binary copying. And the classic C-series part where the parameter store is often external to the device entirely is covered in PIC16F76 EEPROM recovery.
The habit that makes this repeatable
Read the data array on every job, even when the request is explicitly about code. It costs seconds, it is rarely blocked, and it is the one part of the device that cannot be reconstructed from anywhere else. Where it turns out to be blank, that is also an answer — it says the product keeps its state somewhere else, which redirects the whole investigation.