PIC18F85K22: When the Array Is Not the Only Memory in the Design
Forty pins on the smaller members, eighty here, and with the extra pins comes a parallel memory interface. A design that uses it places data — sometimes code — outside the package, and everything said on this site about “the image” becomes conditional.
The array still holds the program that drives the interface. It does not necessarily hold what the program works on, and it may not hold all of the program.
What the interface changes
Three consequences, in order of importance:
| Consequence | Effect on recovery |
|---|---|
| Data may be external | The image describes the algorithm, not its inputs |
| Code may be external | The image may be incomplete as a program |
| Timing depends on wait states | Behaviour reflects bus configuration, not only flash |
The second is rare on a PIC18 design and happens; the first is common wherever a large table is needed. A lookup table of a few tens of kilobytes is cheaper in an external device than in an 80-pin microcontroller’s flash.
Recognising the arrangement
Four indicators, all obtainable without reading the array:
Pin activity on the upper ports. Address and data lines toggling in bursts, synchronous with execution or with a periodic task.
Configuration of the interface registers. Written early in start-up; their presence in a readable portion of the image is conclusive.
Waiting states in the timing. Execution that slows in proportion to bus configuration rather than to flash access.
Memory size beyond the die. A data structure that cannot fit in the internal RAM and is not in the flash image must be somewhere.
The fourth is the inference that resolves most cases. A design processing a table larger than the array can hold is either computing values or reading them from outside.
What an external table costs in analysis
A table on the bus is not in the image, and its contents may be the most product-specific part of the design. A calibration curve, a characterisation map, a protocol translation table — these often encode the engineering effort that the firmware merely applies.
Recovering them requires either reading the external device directly, which is usually trivial since it is an ordinary memory on an accessible bus, or capturing the bus while the device operates.
The first is preferable and is often overlooked. An external serial flash or EEPROM on a board is readable with a clip and a programmer in minutes; there is no protection on it, because the protection was applied to the microcontroller.
When the design executes from the bus
Executing from external memory is unusual on this family but not unheard of, typically in designs that outgrew the array late in development.
Where it happens, three things follow:
- The image from the array is a loader plus part of the application.
- The bus carries instructions, so a capture reveals them.
- Wait states dominate timing, so behaviour measured on a bench reflects the bus rather than the flash.
The third is a diagnostic. A device whose execution speed changes when the external device is removed is executing from it.
Recovering content from this arrangement
- Read the configuration and the array.
- Determine whether the interface is configured; if not, the design is self-contained.
- If it is, identify the external device from the board and read it directly.
- If it cannot be read directly, capture the bus during operation.
- Reconcile: the array’s code refers to external addresses, and the external content refers back.
Step five is where the two halves become one description. A table read at an address that appears in the disassembly is confirmed as that table by the reference; the pair is far stronger evidence than either alone.
What the array still tells you best
The array holds the decisions: when to read, how to interpret, what to do with the result. The external memory holds the data those decisions operate on. Analysis of behaviour needs both, and the array is the half that explains the other.
That is the reason to recover the array even when the external content is easy to obtain. Content without the code is a list of numbers; the code without the content is an algorithm with missing constants.
Related reading
- PIC18F67K22 and 128K of internal memory — the largest internal-only arrangement.
- PIC18F66K22 and reading the protection pattern — what gates the array itself.
- TMS320F2812 and the same problem on a DSP — external memory as a security boundary, on different silicon.
FAQ
Does the interface mean the program is incomplete? Only if code executes from the bus. Data being external is far more common.
Can the external device be read? Usually directly — it is an ordinary memory with no protection, because the protection was applied elsewhere.
How do I detect the interface in use? Pin activity on the upper ports, interface registers written at start-up, and wait-state-dependent timing.
Is the array still worth recovering? Yes. It holds the interpretation of the external content, which is what makes the content meaningful.
What if the external device is damaged? The code still describes what it expected: address ranges, strides, value ranges. That is enough to reconstruct a functional equivalent.
Conclusion
An external memory interface makes the array one source among several, and the recovery question becomes which source holds the part that matters. On most designs the array holds the interpretation and the bus holds the data — and the cheapest first move is reading the external device, which usually has no protection at all.