Unlock Chip PIC16F785 Heximal

Two operational amplifiers, two high-speed comparators, a two-phase PWM with asynchronous feedback, a 1.2-volt band gap and a twelve-channel converter, all in a 20-pin package: the PIC16F785 is less a microcontroller than a power-supply controller with a CPU attached. It was designed for switching regulators, LED drivers and battery chargers, where the analog loop has to close faster than software can respond. Extracting its firmware means extracting a control law whose constants are spread across registers and tables.

A power controller with a CPU attached

Inside the 20-pin body: 2048 words of flash, 128 bytes of SRAM, 256 bytes of EEPROM, 18 I/O, a CCP module, Timer0 and Timer2 as eight-bit counters and Timer1 as a sixteen-bit counter, an internal oscillator from 32 kHz to 8 MHz, and the analog array that gives the part its purpose. Supply range is two to five and a half volts, and the HV variant replaces the upper limit with an internal shunt regulator. The EEPROM is what separates this part from the 7X7 generation: trim values and protection thresholds have somewhere to live outside the code.

Two op amps with every terminal brought out

Both amplifiers have their inverting input, non-inverting input and output available on package pins – an unusual and deliberate choice, because it lets the designer build a gain stage, an integrator or a current-sense amplifier entirely in the analog domain and use the core only to supervise. Pins RC3, RC4, RC5 and RC6, RC7 and RB4, RB5 carry the amplifier terminals and the comparator inputs, with the converter channels overlapping the same set. A firmware image for this part therefore contains fewer numeric computations than a typical control design; the work is done by the analog loop, and the code sets references, watches comparators and handles fault recovery.

Two-phase PWM with asynchronous feedback

The PWM block produces two phases with programmable dead time and can be terminated asynchronously by the comparator, which is how cycle-by-cycle current limiting is implemented without software in the loop. That single feature explains the part’s popularity in LED drivers and small converters: an over-current event shuts the output down within the switching cycle rather than at the next interrupt. Recovering the timing constants – dead time, blanking interval, shutdown threshold – is more valuable than recovering the arithmetic, and those constants are visible as register writes in the startup block.

The band gap as the reference

An internal 1.2-volt band gap supplies the comparator and converter references, and its stability is what lets the part regulate without an external reference. Firmware typically selects it at startup, waits for it to settle, and then trims the converter’s own offset against it. On a rebuilt device, that sequence has to be reproduced in order: skipping the settling delay produces readings that drift for the first few milliseconds after power-up, which in a charger means a brief over-current at every connection.

Memory, protection and what a readout returns

Configuration sits at 0x2007 with the calibration word at 0x2008 and user IDs from 0x2000, protected reads return zeros, and the 256 bytes of EEPROM are protected separately. Because the EEPROM holds the trim and threshold values that make a specific board work, a job that recovers only the code is half a job. Capture both arrays, record the configuration word, and note which EEPROM addresses are read during startup – that set is the per-unit calibration, and reproducing it by calculation is rarely possible without the original fixture.

Recovering a control loop

The honest way to validate a 785 recovery is to run the board: apply the specified input, load the output, and compare efficiency, ripple and transient response against a known-good unit. A functionally identical image with one wrong dead-time constant will pass a no-load test and fail under load, so the bench procedure matters as much as the extraction. Where the array is protected, the behavioural route is more productive than usual because the analog loop is external and measurable – IC reverse engineering work that characterises the compensator rather than the code. Either way, document the constants that were verified and the conditions under which they were measured; that record is what a production engineer needs, and it is the same standard applied to the PIC16F684 binary attack and PIC16F685 flash designs and to newer parts like the PIC16F1827.

Thermal behaviour as a verification signal

A converter controller that is regulating correctly runs cool; one with a wrong dead-time or a missing blanking interval runs hot at the same output. That makes temperature a cheap end-to-end check on a rebuilt 785, and it catches errors that a scope on the switching node might miss because the waveform still looks plausible. Record the case temperature at a known load on the original and on the replacement, and the comparison becomes evidence rather than impression – the same practical standard used on the PIC16F631 heximal and on other analog-heavy parts in this range.