Break IC PIC12CE519 Flash: Twice the Memory Means a Different Program
In a catalogue the PIC12CE519 looks like the PIC12CE518 with more memory: same eight pins, same sixteen bytes of data EEPROM, same internal oscillator, twice the program space. That description is accurate and it is misleading, because doubling the program memory on this core does not add space to the same address map. It adds a second page and a bit that has to be managed.
The consequence is that code written for the larger part has a structure the smaller one never needs, and recovering it requires reading that structure. A recovered image from a 519 interpreted as though it were a 518 will jump to plausible addresses that contain the wrong code.
The address map, and where the seam is
| Property | 518 | 519 |
|---|---|---|
| program words | 512 | 1024 |
| pages | one | two |
| page select | not needed | a status bit |
| cross-page call | not possible | requires the bit to be set and cleared |
| reset vector | word 0 | word 0 |
| interrupt | none | none |
With five hundred words there is one page and every jump is a full-width target. With a thousand there are two pages of five hundred and twelve words, and a jump instruction can only reach within the current page — which means the programmer, or the compiler, must set the page bit before a target in the other page and restore it afterwards.
That is three extra instructions per cross-page call, and they appear in the image as a distinctive pattern: a bit set, a call, a bit clear. On a part with no interrupts the pattern is not interrupted, which makes it easier to read than on a larger device where the same idiom has to be protected against re-entry.
What the pattern looks like
The page bit lives in the status register. The sequence is short: a bit-set instruction on the status register, the call or jump, a bit-clear instruction.
Three consequences for analysis.
The first is that the target of the call is ambiguous without tracking the page bit. An address of 0x0A5 means page zero address 0xA5 or page one address 0xA5 depending on the state of the bit, and a disassembler that ignores the bit will label half the calls wrongly while producing a listing that looks complete.
The second is that the page bit has state across instructions. A block that sets the bit and then executes twenty instructions before calling is not unusual — hand-written code often sets the page once and works within it. Reading requires following the bit through the block rather than assuming it is set immediately before every call.
The third is that the restore is sometimes omitted. On a leaf call that never returns to code in the other page, or in a design where the author knew the following code was in the same page, the clear instruction is absent. That is not corruption; it is an optimisation that assumes knowledge of the layout.
Why the two parts are separate jobs
The technical reason is the map above: the recovered image from a 519 has a page structure that the 518 does not, and the analysis has to resolve it. A single article covering both would have to describe two address models and would do neither well.
The practical reason is that they are separate products in the field. A design that outgrew the 518 was moved to the 519, and the two versions of that product usually coexist: the older units in service carry the smaller part, the newer ones the larger. A service company working through a fleet encounters both, and the part number on the package is the only reliable way to know which image it is looking at.
There is a third reason that matters for anyone maintaining a large set of part-specific pages: the two parts are searched for separately. An engineer with a 519 in hand does not look for a page about the 518, and a page that covers both answers neither query precisely.
Reading the sixteen bytes on this part
The data EEPROM is the same size on both parts, sixteen bytes, and on this family it is reachable over two pins. That makes it the easiest block to recover and, on a failed unit, often the only block that survives.
Two cautions. The bytes are written by the program, so their meaning is defined by the code: a byte that looks like a threshold is a threshold only if the code compares against it. And the array is small enough that a single byte being wrong changes the product’s behaviour noticeably, which makes a blank read of the whole array suspicious rather than conclusive.
Protection on an OTP part of this generation
As with the rest of the family, protection on this part is not a rewritable bit. Once the array is protected, the interface returns a pattern, and the route to the content is physical.
Because the die is small, the physical route is short and the transcription is checkable: a thousand words fits in a few pages, the reset vector should decode, and the page structure should be internally consistent — every cross-page call should have a matching bit operation somewhere before it.
That consistency check is the equivalent of a checksum for this part. If the number of page-set operations is roughly equal to the number of calls whose targets lie in the other page, the transcription is probably right. If it is not, the page bit tracking has gone wrong somewhere.
Delivering an image from this part
The full address range with the word convention stated, and — specific to this part — the page structure documented: which routines live in which page, and where the page transitions occur.
That document is what allows a customer to add code to the image. On a part with two pages, adding a routine in the wrong page turns a five-instruction change into a page-management problem, and an engineer who has the map can see that before writing anything.
Where the smaller member of the pair is discussed from the failure side rather than the design side, PIC12CE518 binary recovery covers reconstruction. Where a larger part shows the same page problem at a different scale, PIC16C554 software reads the state machine within it. And where the file rather than the address map is the subject, PIC16C642 binary deals with byte order.
The short version
Twice the memory is not twice the same thing. The 519 has two pages and a bit that has to be tracked through the image, and a listing that ignores it is confidently wrong about half its calls. Read the page transitions, document which routine sits where, and deliver the map with the file.