PostHeaderIcon Copy IC PIC12C671 Eeprom: The Part Has Program Memory, Not a Data Array

A request arrives asking for the EEPROM content of a PIC12C671. The device has no EEPROM. It has one array, it is program memory, it is one-time programmable, and it is where every byte of interest on the product lives. Getting to a useful answer means correcting the vocabulary without discarding the request, because what the customer actually needs — the persistent content of the device — is entirely present.

The distinction is not pedantic. EEPROM implies byte granularity, in-circuit rewriting and a separate address space. None of that applies here. Treating the array as if it were EEPROM leads to wrong expectations about how much can be modified, and occasionally to a plan that involves writing to the part when the part cannot be written again at all.

What the device actually is

The 12-bit core family sits at the small end of the mid-1990s Microchip line. Fourteen-bit instruction words, a small register file, a handful of I/O, an analogue-to-digital converter on the variants that carry one, and an eight-pin package.

Attribute This device
Core 12-bit, 14-bit instruction words
Program memory 1K words, one-time programmable
Data EEPROM none
RAM small, volatile, 128 bytes class
Configuration word one word at the top of the map
Package eight pins, shared with the oscillator and programming pins

The absence of a data array is the structural fact that shapes everything else. On later flash parts, parameters live in a separate byte-writable region and the program array can be treated as pure code. Here there is nowhere else for parameters to go, so a product built on this device either keeps its settings in RAM and loses them at power-off, or burns them into the program array as constants.

Where the parameters go when there is nowhere to put them

Three patterns turn up on real products, and the image itself says which one was used.

The first is constants in code. A trim value, a gain, a serial-number range, a timing table — all assembled into the program at build time. The image then contains them as literal operands, and finding them means reading the code, not scanning for a record structure.

The second is a table near the top of the array. Engineers who knew the part would never be rewritten still often reserved a block of words for per-unit data, and programmed the block differently for each unit at the end of the production line. The tell is a run of words whose values differ between two units of the same product while the surrounding code is identical.

The third is an external serial memory on two of the eight pins. On a device this small, that is a common answer to the parameter problem, and it has the pleasant property of being readable without touching the microcontroller at all.

Reading a one-time-programmable array

The array cannot be erased, which changes the risk profile of the job rather than the mechanics of reading it. Nothing in the read path writes, so a read is non-destructive by construction — provided the tool does not perform an erase-then-verify cycle as a matter of habit. Many production programmers do exactly that. On this family it destroys the device and the job at the same time.

The read itself is a linear walk of the address space returning 14-bit words. Two properties of the result need attention.

The first is word width. Fourteen bits do not fit a byte, so any representation in a file has to choose: two bytes per word with the top two bits unused, or a packed form. Mixing the two conventions between two halves of a job produces an image that looks plausible and disassembles to nonsense. The convention has to be fixed before the first byte is written.

The second is the erased state. On a one-time-programmable part the unprogrammed word is all ones, and a partially used array shows a long tail of all-ones words. That tail is information: it locates the end of the code, and its position tells you whether the production line programmed the full array or stopped early.

Why the erase state matters more than it looks

On a flash device the erased pattern is a baseline that can be restored, so a wrong read can be repeated. Here the programmed state is permanent. That makes verification of the read the single most important step, and it has to be done against the device rather than against a second file.

The practical method is a checksum computed by the device itself. The programmer reads the array and computes a checksum over the words; the interface offers the same computation on its side. Agreement between the two does not prove the content is correct, but disagreement proves the read is wrong, and on a part that cannot be re-read after a failure has been diagnosed, catching it at that point is the difference between a finished job and a scrapped unit.

Configuration is one word and it is not optional

The configuration word at the top of the map selects the oscillator mode, the watchdog, the code protection and the reset behaviour of the part. It is programmed along with the code and it is read along with the code, and it must be delivered along with the code.

The reason is that a copy without it is not a copy. Take the oscillator selection: a product designed to run from an external clock source will not start on a device configured for an internal oscillator, and the reverse is also true. The failure presents as a dead board, which sends people looking for a hardware fault that does not exist.

Configuration also carries the protection state. Recording it tells you what the original was set to, which is sometimes the most valuable single fact in the delivery — a device that was locked and a device that was never locked look identical from the outside, and only the configuration word distinguishes them.

Delivering the result

For a device of this size, a complete delivery is short and should stay short.

  • the full program image, start and end addresses stated
  • the configuration word, decoded into named fields
  • any per-unit block identified by address range, with the values listed separately
  • the word-width and file convention used, stated explicitly
  • the identifier or signature bytes, as read

The last item is easy to skip on a part this small and it should not be. It costs one read and it settles the question of which member of the family the image came from, which matters when a customer has several products in the field built on sibling parts.

The wider point

Requests get their vocabulary from the last project the customer worked on. A device described as having an EEPROM may have none, a job described as reading code may really be about a calibration block, and a part described as flash may be one-time programmable. The first ten minutes are better spent establishing which array exists than in starting a read that answers the wrong question.

The same correction shows up on siblings with a data array present, where the split between program and data becomes real — PIC16F88 data recovery covers that case. For a slightly larger part in the same era with a genuine sixteen-byte data array, PIC12CE518 binary recovery shows how small the data side can be while still mattering. And for the smallest flash members of the eight-pin line, where the array can be rewritten but not read under protection, PIC16F506 binary recovery follows the same reasoning to a different conclusion. Where the array is mask-programmed rather than one-time programmable, the constraints change again and no amount of reading recovers the ability to reproduce it.

Comments are closed.