PostHeaderIcon Reverse Engineering Microcontroller PIC12C509A Binary: Five Signals in an Eight-Pin Body

Eight pins. Two are the supply. One is the reset, which doubles as the programming voltage input. Two more carry the clock and data of the programming interface. That leaves three for everything the product does, and it leaves nothing spare for diagnostics.

The PIC12C509A is a 1024-word twelve-bit OTP part with forty-one bytes of RAM, an internal oscillator trimmed at manufacture, a timer, and six I/O pins of which three are consumed by the interface during programming. Every constraint that matters in recovering its content follows from that pin budget.

The five connections and what each one has to do

Pin Function in circuit Function during programming Common failure
supply high VDD, usually 3 to 5 V same, must be clean ripple from the product’s own load
supply low VSS same shared ground with a noisy return
data GP0, often an output bidirectional serial data driven by an external device on the board
clock GP1, often an input clock from the programmer loaded by a capacitor or a pull-up
reset GP3, input only raised to the programming voltage clamped by an external supervisor or diode

The last row is where most attempts fail on a populated board. The reset pin is input-only on this part, which means it has no output driver to fight, but it often has an external pull-up, a supervisor IC, or a diode to the supply rail. A diode from the pin to VDD is there to clamp transients, and it will also clamp the programming voltage, which the programmer interprets as a device that does not respond.

The fourth row produces a subtler failure. A capacitor on the data or clock line — part of a filter, or an unused pin tied to ground through a capacitor — rounds the edges enough that the interface works at low clock rates and fails at high ones. Lowering the programming clock often recovers the connection without any hardware change.

Why the package matters more than the die

The die is small and the array is small, so the extraction itself is not the difficulty. What varies is how the five signals are reached.

A plastic dual-in-line part goes into a socket and the job is trivial. A small-outline part goes onto a clip or an adapter. A dual flat no-lead package has no leads: the contacts are pads underneath, and reaching them means either a custom footprint that the part is placed on, or removal of the part followed by treatment as a bare die.

Removal is the step that costs units. On an eight-pin device the pads are small, the package is thin, and the adhesive under it is often stronger than the pad-to-substrate bond. A removal that lifts a pad takes the connection with it.

For a single unit with no spare, the decision to remove should be taken deliberately rather than as a first step: a socketed or clipped approach that works is always preferable, even if it takes longer to set up.

What the array looks like when it is read

A thousand words of twelve-bit instructions is 2048 bytes in the conventional two-bytes-per-word representation. The image is short enough to inspect, and three checks cover most of it.

Word zero should decode to a jump or a load of a working register, never to an arbitrary value. The top of the map should contain the configuration word, which on this family also carries or neighbours the oscillator calibration value. And the distribution of values should look like code: frequent small literals, frequent calls and returns, a few long runs of one value where a delay loop sits.

A file where every word is the same value is a protected part or a failed interface, not an empty part. A file where every second word is identical is a byte-order error.

The calibration word, once more

This part uses an internal oscillator with a factory trim. The trim value is stored in the last program word on many family members, and it is the single most commonly lost piece of information in a recovery.

The loss is not visible at programming. A part programmed without the trim runs, executes correctly, and keeps time badly. On a design that uses the oscillator to time a relay pulse or a charge cycle, the error shows up as a product that behaves differently at temperature extremes, and it is attributed to the recovered code rather than to the missing word.

Deliver the full address range, always, and state which word carries the trim.

Where the analysis goes next

Once the image is out, the reading of a twelve-bit baseline program is straightforward because the code is small and hand-written. The productive order is: identify the delay loops and convert their counts into milliseconds using the trimmed frequency; identify the table dispatches; identify the port writes and what they drive.

On a three-I/O design, the port usage is nearly the whole product description. A pin that toggles at a fixed period is a clock or a PWM output. A pin that is read in a loop with a debounce delay is a switch. A pin that is driven high and then read as an input is a charge-time measurement, which is how these parts measure resistance without a converter.

That last pattern is worth knowing: on a part with no analogue-to-digital converter, a sensor is often read by timing the charge of a capacitor through it. Recognising the pattern identifies the sensor class and the measurement range from the timing constants alone.

Delivering a binary that can be trusted

The image over the full range with the word convention stated. The configuration word decoded. The calibration value called out with its address. And a note on which pins the product uses and what the code does with them, which is the part of the delivery that survives after the file has been archived and forgotten.

Where an eight-pin part has a data EEPROM that can be read separately, PIC12CE518 binary recovery covers the second array. Where the same part is mask-programmed and there is no electrical read at all, PIC16CR83 heximal sets out that path. And where the package question is complicated by an unidentified device, CF755 dump recovery deals with identification first.

The short version

Five signals, eight pins, three left for the product. Expect the interface rather than the memory to be the obstacle, check the reset pin for clamping before blaming the device, and deliver the calibration word along with the image.

Comments are closed.