PIC16C770: What Copying an OTP Part Actually Involves
The PIC16C770 is a 20-pin mid-range part with 2048 × 14 words of program memory, 128 bytes of RAM, 256 bytes of data EEPROM and a 12-bit A/D converter. It is the smaller of the two parts in its family — the PIC16C771 has twice the program memory — and both exist for one reason: a 12-bit converter in a 20-pin package at a time when that combination was unusual.
The C in the part number is what shapes the question. This is an EPROM device, one-time programmable in the plastic package. “Copy” on a Flash part means writing an image back to the same chip. “Copy” here means building a second unit out of blank silicon, which is a different operation with different constraints.
What the PIC16C770 actually contains
| Item | PIC16C770 |
|---|---|
| Core | 14-bit instruction word, 35 instructions |
| Program memory | 2048 × 14-bit EPROM (OTP) |
| Data RAM | 128 bytes |
| Data EEPROM | 256 bytes |
| I/O pins | 16 (PORTA 6, PORTB 8, PORTC 2) |
| A/D converter | 12-bit successive approximation, 5 channels |
| Comparators | 2, with programmable reference |
| PWM | CCP1 |
| Serial | SSP (SPI/I²C), USART |
| Timers | Timer0, Timer1 (16-bit), Timer2 |
| Packages | 20-pin PDIP, SOIC, SSOP |
| Programming | high voltage on MCLR, OTP |
Note the mismatch that defines this family: 128 bytes of RAM and 2048 words of program against 256 bytes of data EEPROM and a 12-bit converter. The ratio is unusual — twice as much non-volatile data storage as volatile scratch — and it tells you where the design expected its state to live. Filter coefficients, offset corrections and calibration points were meant to sit in EEPROM, not in RAM.
Three separate things have to line up
A functional copy requires all of the following, and each one is a separate constraint:
The image. Program memory, the configuration word, the four user ID words and the 256 bytes of data EEPROM. The data array is separately protected by CPD, and on this part it is not optional baggage — it usually holds the calibration the program reads at start-up. An image without it produces a device that runs and measures wrong.
Blank silicon. OTP parts cannot be rewritten. A copy program needs unscheduled blank devices of the same part number, and this is where the practical difficulty concentrates: the PIC16C77X family reached end-of-life long ago, and blank stock exists only as residual inventory. Windowed ceramic parts can be erased and reused, which makes them useful for validation, but they are not a production path.
The same die revision. Silicon revisions of an OTP part are not always interchangeable. Errata change behaviour in corners — a timer flag that latches late, an ADC sequence that needs a settling delay, a serial framing edge — and firmware written against one revision can fail intermittently on another. The device ID and revision are readable, and they should be matched, not assumed.
What the copy does not fix
Two categories of content are outside the image and stay outside it.
Values written at runtime. If the firmware writes to its own data EEPROM — accumulating run hours, storing a learned zero, storing a serial number on first power-up — then the array in the source device holds values produced by operation, not by manufacture. Copying them reproduces one specific unit’s history. Whether that is correct depends on what the field means, and the only way to know is to read the routines that touch EEPROM, not to compare bytes.
Per-unit identity. Some production lines program a unique identifier into the user ID words or into EEPROM at test time, and the firmware compares it against something external. A copy that carries the source unit’s identifier will behave identically to the source unit — including any licensing check that was supposed to distinguish them.
Both of these are visible in the listing. EEADR/EEDATA writes immediately after reset point at initialisation patterns; reads at start-up followed by a comparison point at identity checks.
The configuration word at 2007h
| Bit | Field | Meaning |
|---|---|---|
| 13:7 | — | Unimplemented, read as 1 |
| 6 | CP | Program memory protection; 1 = disabled, 0 = enabled |
| 5 | CPD | Data EEPROM protection; 1 = disabled, 0 = enabled |
| 4 | BOREN | Brown-out reset; 1 = enabled |
| 3 | PWRTEN | Power-up timer; 1 = disabled, 0 = enabled |
| 2 | WDTEN | Watchdog; 1 = enabled |
| 1:0 | FOSC1:FOSC0 | 11 RC, 10 HS, 01 XT, 00 LP |
Because the word is EPROM, its state in a source device is a permanent record of how that unit was programmed — there is no interface command that returns a programmed bit to 1. On a plastic part the protection state cannot be changed at all; on a windowed part, ultraviolet erasure clears the whole die, configuration word included, so protection cannot be lifted while preserving the array.
Verification is the part that catches mistakes
A copy that appears to work is not a copy that matches. Three checks, in increasing order of usefulness:
- Read back the programmed device and compare against the source image, byte for byte, including the configuration word and the data EEPROM. This catches programming errors and wrong device settings.
- Compare the analog path. With a 12-bit converter, feed the same known input to both devices and compare raw counts, not converted values. A one-count difference in the raw result is a calibration difference; a difference of 64 or 4096 indicates an alignment error in how the 12-bit result was assembled.
- Exercise the timing-dependent paths. Serial baud rates, PWM periods and watchdog resets all depend on the oscillator field and the external components around the chip. A copy on a board with a different crystal value will pass checks 1 and 2 and fail in the field.
The second check is specific to this part and easy to skip. Twelve bits means the result is split across ADRESH and ADRESL with justification bits deciding the alignment, and a copy that shifts the pair the wrong way produces values that look like sensor readings and are off by a fixed factor.
Related notes
The 4K-word PIC16C771 is the same die with more program memory. The 40-pin PIC16C77 is the larger part with a 10-bit converter, and the Flash-era replacement for this whole family’s role is described under the PIC16F684.
FAQ
Can a PIC16C770 be reprogrammed with a different program? No. It is OTP EPROM in the plastic package. A windowed ceramic part can be UV-erased and reused, but only as a whole die.
What has to be copied besides the program? The configuration word, the four user ID words and the 256 bytes of data EEPROM, which is where the calibration usually sits.
Is the copy limited by blank part availability? Yes. OTP silicon cannot be rewritten, so a copy program depends on blank devices of the same part number and preferably the same revision.
Why compare raw ADC counts instead of converted values? Because the 12-bit result is assembled from two registers, and an alignment error shows up as a fixed factor in raw counts while converted values can still look plausible.
What if the firmware writes to EEPROM at runtime? Then part of the source array is operational history rather than factory data. Copying it reproduces one unit’s state, which may or may not be what the field is meant to hold.
Conclusion
Copying a PIC16C770 is less about reading the code than about everything around it. The image is the easy part; blank silicon of a matching revision, a data array that carries the calibration, a 12-bit result that has to be assembled the same way, and an oscillator field whose frequency lives on the board rather than in the chip. Get any one of those wrong and the copy runs — just not identically.