Posts Tagged ‘copy cpld mcu flash program’

PostHeaderIcon Copy CPLD and MCU Software Data: Two Time Scales in One System

A board with a CPLD and a microcontroller contains two programmable devices and, usually, one power supply. At steady state the two cooperate through a bus, and their cooperation is defined by timing. A copy of each device preserves its own contents exactly, which suggests the pair should work. Frequently it does not, and the failures cluster at one moment: power-up.

The reason is a difference in what each device considers a valid starting condition. A CPLD’s registers come up in whatever state the fabric defines, and the logic begins evaluating combinationally the instant power crosses a threshold. A microcontroller begins executing instructions from a reset vector after its own internal startup, which is later. Between those two events the system is in a state that neither device was designed to be in, and the duration of that window is a property of the silicon rather than of the code.

The two time scales

Property CPLD MCU
First meaningful state As soon as the supply crosses the trip point After reset release and startup
Behaviour without clock Combinational logic already active Nothing
Initial register state Defined by the fabric, not by a load Defined by the program
Response to a partial supply Undefined but physical Held in reset, usually
Time to operational Microseconds Milliseconds, sometimes longer

The last row is the whole problem. A CPLD is operational three orders of magnitude earlier than the microcontroller. Everything the CPLD does in that window happens with no supervision, and if the design assumed a supervising processor, the assumption is false for a few milliseconds.

Where cloned pairs fail

Failure Mechanism Detectable by
Bus contention at power-up CPLD drives before MCU pins are configured Current spike, warm regulator
Spurious write to an external device CPLD asserts a strobe during an undefined window Device in a wrong mode after boot
Latch-up Cloned CPLD drives a pin the MCU also drives, in opposite directions Dead board, sometimes recoverable
Missing handshake MCU waits for a signal the CPLD never asserts Hang at boot
Intermittent start Marginal timing on the reset release path Fails one time in fifty

The first and third rows are the ones that damage hardware, and they are the reason a cloned pair should never be powered for the first time on a customer’s board. A bench supply with a current limit is the minimum precaution, and a current-limited supply plus a thermal camera is better.

Why the original worked

The original pair worked because the two devices were designed together, and the design accounted for the startup window. That accounting is invisible in either file: it is in the choice of pull-up resistors, in the reset supervisor, in the order in which the CPLD enables its outputs, and in whether the CPLD’s outputs are tri-stated until a specific signal arrives.

Design element Where it lives Preserved by a device copy
Output enable controlled by a handshake CPLD equations Yes, if the copy is exact
Reset supervisor threshold External component Not part of either file
Pull-up and pull-down values Board Not part of either file
Power sequencing order Board and regulator Not part of either file
MCU pin configuration timing MCU code Yes

The middle three rows are outside both programmable devices, which means a perfect copy of both files can still produce a board that fails. This is the point at which a cloning project stops being a copying exercise and becomes a system exercise.

Verifying interoperation, not just contents

The verification protocol has to test the pair, and it has to test the boundary between them.

Test What it covers What it misses
Read back each device and compare Contents Everything about timing
Program a blank pair and boot Basic interoperation Marginal cases
Boot under current limit with a scope on the bus Contention and strobes Long-term drift
Repeated power cycles, cold and hot Start-up margin Rare events
Full functional test at supply extremes Timing across the envelope Wear-out

The second row catches gross errors and is where most projects stop. The third and fourth rows are where the interesting failures appear, and the fourth is cheap to run: a hundred power cycles at each of three temperatures will find a start-up margin problem that a single boot never shows.

The reset release path

The single most valuable thing to measure is the interval between the CPLD becoming active and the microcontroller releasing its pins from the reset state. If the CPLD drives a signal that the microcontroller also drives, that interval is a contention window, and its length is what determines whether the board survives.

Observation Interpretation
Both devices drive the same net during the window Contention; redesign or add a series resistor
CPLD output floats until an MCU strobe Designed handshake; safe
MCU samples an input before the CPLD is stable Race; the first read may be wrong
No overlap at all Either good design or luck; check margins

The fourth row is the ambiguous one. A board can pass because the timing happens to work, and the same design on a different batch of parts can fail. Repeating the test across several boards is the only way to tell design margin from coincidence.

What a system-level deliverable contains

A clone that is only two device files is an incomplete deliverable. The useful package adds the boundary conditions that make the pair work.

Item Why it belongs in the package
Both device images The contents
Reset and sequencing description The window nobody documents
Board-level dependencies Pull-ups, supervisors, sequencing
Test protocol and results Evidence that the pair works
Known deviations Anything that could not be matched

The fifth item is the one that protects both parties. A clone that documents a small deviation is a clone that can be maintained; a clone that claims perfection is a clone that will be blamed for every unrelated failure.

Where this sits

The device-level copying is covered in copying CPLD IC code and copying Lattice CPLD encrypted files. The mixed-device reading problem is in reading DSP and CPLD dump information, which deals with the same two-clock issue from the acquisition side. Where the pair is a DSP and a logic device rather than an MCU and a logic device, the failure mode is the same one described in copying DSP and CPLD firmware, with wait states replacing pin configuration as the thing that changed.

Services at this boundary

Work covers device copying, power-up boundary analysis, contention measurement, repeated-cycle and temperature testing, and documentation of board-level dependencies. It does not cover redesigning a board that has a genuine sequencing defect, and it does not cover guaranteeing a clone on hardware that was not supplied for testing.

The expectation worth setting is that a clone is finished when the pair boots reliably a hundred times, not when both files verify.