Break MCU PIC16F630 Firmware

The PIC16F630 is the fourteen-pin version of a very small idea: a kiloword of flash, 64 bytes of RAM, 128 bytes of EEPROM, twelve I/O and a single comparator, with no converter anywhere on the die. It was designed for front panels, timers, relay boards and simple chargers, and it is still found in all of them because a part with twelve I/O in a 14-pin package solves a surprising number of layout problems. Its firmware is almost always hand-written, almost always undocumented, and frequently the only surviving record of how a product behaves.

Twelve I/O and no converter

Ports A and C together provide twelve bidirectional lines, with RA0 through RA5 on one side and RC0 through RC5 on the other. Every line can sink or source enough current to drive an LED directly, which is why these parts end up behind front-panel indicators with no driver stage. Timer0 handles eight-bit counting with a prescaler, Timer1 provides sixteen bits with an external gate, and the comparator brings its own programmable reference. There is no PWM module, no serial port and no Timer2, so anything that looks like a protocol is bit-banged in software with cycle-counted delays.

A package built around a comparator

The comparator’s inputs are multiplexed across RA0, RA1, RA2 and RA3, its output can be steered to RA2, and the internal reference divides VDD into sixteen steps. With hysteresis enabled it becomes a usable threshold detector for a photo-resistor divider or a battery-sense chain; with the output fed back through firmware it becomes a relaxation oscillator. Designs of this kind put the intelligence in the reference value and the timing, which is good news for anyone reconstructing behaviour and bad news for anyone hoping the code will explain itself.

EEPROM as the only non-volatile extra

One hundred and twenty-eight bytes of data EEPROM sit outside the program array and are read and written through their own command pair. In panel products those bytes usually hold a setpoint, a calibration offset or an hour meter – values that must survive a power cut and that the firmware reads at startup. A program-only readout that omits them produces a unit that powers up with zero everywhere. Because data protection is configured separately from program protection, it is entirely possible to recover the parameters from a part whose code is locked.

The trim word at 0x3FF

Like its eight-pin relatives, the 630 keeps its oscillator calibration as a RETLW instruction at the last program address. The startup code calls that address and moves the literal into OSCCAL. A complete read captures it; a bulk erase destroys it; a replacement programmed without it runs at a noticeably different frequency. On a panel product that only blinks an LED this may never be noticed, but on anything that times a relay or bit-bangs a display refresh it shows up immediately as drift.

Entry, protection, and the legible part

The two-wire ICSP interface uses RA0 and RA1 with the high voltage on RA3/MCLR, and configuration is reached by a load-configuration command that points the program counter at 0x2000. Protected reads return zeros; row erase is refused while protection is set; bulk erase clears protection and the array together. Configuration memory stays readable throughout, so the watchdog setting, the oscillator mode and the brown-out threshold can be documented from a locked part – often enough to tell two product revisions apart when the labels have worn off.

Scope of a realistic reconstruction

With twelve I/O and no analog converter, the behavioural surface of a 630 design is small enough to enumerate: exercise each input, record each output, measure the delays, and the state machine falls out of the table. That makes the part a good candidate for a rebuild when the array is protected, provided the client accepts a functional equivalent rather than a copy. Where a readout succeeds, the deliverable should pair the image with the EEPROM content and a list of the timing constants that were verified on the bench – microcontroller flash content evidence rather than assertion. The same scope discussion recurs on the PIC16F677 firmware and on PIC16F870 boards built around the same core.

Front panels and the values they keep

Panel products accumulate small decisions that never reach a schematic: how long a button must be held, how many times a display flashes before an error, what setpoint a unit returns to after a power cut. Those numbers are the reason a recovered image is useful even when the code itself is trivial, and they are the first thing a behavioural reconstruction gets wrong. Reading the EEPROM and the literal tables gives them back exactly, which is why the two-array capture is standard here rather than an optional extra. Where the part is locked, the same numbers can sometimes be recovered by exercising the panel and timing it – slower, but often sufficient for a spares programme. Either way the result belongs in a written specification; IC reverse engineering work that stays in an engineer’s head does not survive the next staff change, and the PIC16F631 heximal jobs from the same product generation show how quickly those details are lost.