PostHeaderIcon Break MCU PIC12CE674 Software: Comparison Is Not Verification

When a file is delivered, three questions can be asked of it. Is it the same as what was read. Does it produce a device that behaves like the original. Does it produce a device that meets the product’s specification. The first is easy, the second is harder, and the third is the only one the customer actually cares about.

On a flash part, the second question has a cheap answer: program a blank device and run it. On an OTP part there is no blank device, so the answer has to be built differently — and a delivery that stops at the first question leaves the second and third entirely to chance.

The PIC12CE674 is an eight-pin OTP part with two thousand words of program memory and sixteen bytes of data EEPROM over an external two-wire interface. Two thousand words is enough for a real application: a control loop, a display or a small protocol, plus the constants that define how it behaves.

Why a read-back comparison is weak evidence

What is compared What the comparison proves What it cannot see
file against file the two files are identical whether either is correct
device against file programming succeeded configuration, calibration, timing
device behaviour against behaviour the product works whether it meets specification
device behaviour against a test spec the product is conforming nothing, if the spec is complete

The second row is the one that misleads. On a part where the configuration word is set by the programmer rather than taken from the file, a device can pass a full read-back comparison of the program array and fail to run, because the configuration was never written.

The gap is widest on three items that a file comparison cannot reach: the oscillator calibration value, the configuration word, and the EEPROM’s initial contents. All three are invisible to a comparison of the program array, and all three change behaviour.

The substitute-device route

Because there is no blank OTP part to test with, the practical way to answer the second question is to use an equivalent device that can be programmed and reprogrammed.

Three options exist, in decreasing order of fidelity.

A flash-based equivalent in the same family. If a flash member exists with the same core, the same instruction set and a compatible pinout, programming it with the recovered image and running it in the product is a strong test — with the caveat that peripheral behaviour may differ slightly and the test proves code correctness rather than die equivalence.

An in-circuit emulator or a debug-capable variant. Where the family supports one, running the image under a debugger gives more information than running it in a product, because the state at a failure is visible.

A behavioural model. For a small image, rewriting an equivalent in a modern part is feasible, and it is the route a customer usually takes when the original part is obsolete. It is not verification of the recovered image, it is a port, and the two should not be confused.

Each option answers a different question, and the delivery should say which was used.

What to test, and in what order

Four tests cover the behaviour of a small embedded product, in increasing order of effort.

Start-up. Power the device and observe every output for the first second. A product that drives its outputs in a defined sequence is executing its initialisation; one that leaves them floating is not. This test catches a missing configuration word and a missing calibration value more often than any other.

The primary function. Whatever the product does — measure, time, switch, display — exercise it once. On a device with one input and one output, this is a minute’s work.

The timing. Measure the period of any repetitive output and compare against the original. On a part with an internal oscillator, this is the test that detects a calibration value that was not carried across, and it detects it as a small percentage error rather than a failure.

The stored data. Read the EEPROM through the external interface and compare against the original sixteen bytes. This is the only test that confirms the data block was programmed, and it is trivial on this family because the interface is external.

Test Catches Cost
start-up output sequence missing configuration, missing calibration seconds
primary function code faults, wrong table entries minutes
output timing calibration error, oscillator mismatch minutes
EEPROM read-back unprogrammed data block seconds

What “verified” should mean in the report

The word should be attached to a specific statement, not used as a general assurance. Three formulations are honest and one is not.

“File verified by read-back against the device” — the first question, answered.

“Image executed on a flash equivalent; start-up sequence and primary function matched the original” — the second question, answered for those two tests.

“Output timing measured at 1.02 times the original, consistent with an untrimmed oscillator” — a specific defect found by verification and reported as a defect.

“Fully verified” — a claim without content, and the one that leads to disputes.

Why the original unit cannot be the test bed

There is a tempting shortcut: leave the source unit in place, change one output, and see whether the behaviour changes as the recovered image predicts. It answers a question about the image without consuming anything.

It also answers it badly, for three reasons.

The source unit has its own EEPROM contents, and those contents may be the reason it behaves as it does. A test that leaves them in place tests the pair, not the image.

The source unit’s protection state is whatever it is, and on a part where the array reads normally there is no way to know whether the read was complete or partial without a second source of truth.

And the source unit is the only evidence. A test that damages it — an accidental write, a supply fault during the probe — removes the baseline against which everything else is measured.

Using a flash equivalent avoids all three: it can be reprogrammed, its EEPROM can be set to known values, and losing it costs a part rather than the reference.

Delivering with the verification attached

The image, the configuration decoded, the sixteen bytes raw, the note on the analogue or timing constants that define the product’s behaviour, and the verification statement with its specific tests listed.

For a customer continuing production, the last item is what they will rely on when their own test station finds a difference. A report that states what was tested and what was not allows that difference to be diagnosed; a report that claims full verification converts it into an argument.

Where the sixteen bytes are discussed as a security question rather than a verification one, PIC12CE673 flash covers the external interface. Where an eight-pin part’s entire verification problem is the interface rather than the behaviour, PIC12C509A binary sets out the constraints. And where the verification has to scale to a production run, PIC16F877 program covers that process.

The short version

A comparison proves equality, not function. With no blank OTP part to test with, verify on a flash equivalent and be specific about which behaviours were checked. State the verification in the report as a list of tests, never as an adjective.

Comments are closed.