PIC18F45K20: Two Kinds of “Blocked”, and Telling Them Apart
A device that will not give up its program has failed in one of two quite different ways. Either the read completed and returned a substitute value, or the read never completed at all. The first is protection working as designed. The second is an interface problem, and treating it as protection destroys devices.
The distinction is not subtle once stated, and it is constantly lost in practice, because both outcomes look like “the programmer could not read it”.
The two events
Substituted read. The device responds, in the expected number of cycles, with a value that is not the content. On this family the substitute is a fixed pattern, and it is stable: reading the same address ten times returns the same value ten times.
Failed read. The device does not respond, responds with an error, times out, or returns a value that changes between attempts.
| Symptom | Meaning | Next step |
|---|---|---|
| Stable uniform values | Protection, or genuinely erased | Read configuration |
| Values change between reads | Interface, voltage, or sampling | Fix the connection |
| No response at all | Entry sequence failed | Check programming mode |
| Response, wrong length | Wrong part selected in the tool | Correct the device selection |
The third row is the one that wastes the most bench time and is the easiest to fix: the device never entered programming mode, so nothing was ever attempted.
Entry, and why it fails quietly
Programming mode is entered by a specific sequence on specific pins, sometimes with a raised voltage. If the sequence is not applied correctly — a pin held by a circuit on the board, a capacitor slowing an edge, a supply that does not reach the required level — the device simply carries on executing its program.
Nothing reports this. The programmer’s tool may report a failure, or may report success with implausible data, depending on how it handles the absence of a response.
On this family the low-voltage programming option changes which entry methods are accepted, and a device configured without it requires the higher-voltage sequence. That is a configuration fact with a hardware consequence, and it is invisible until someone tries to connect.
Why stable values suggest protection
A protected read goes through the same path as a normal one: the address is presented, the array is accessed, and the substitution happens at the output. The timing is identical and the result is deterministic.
That determinism is the diagnostic. Protection produces the same answer every time; a marginal connection does not.
The caveat is erasure: an erased block also returns a stable value. So stability separates “device or interface” but not “protected or blank”. The configuration word separates those, and it is why every article in this series begins with it.
Protection as a set of blocks
Four blocks, each with a read bit and a write bit. The state that matters is the pattern, not the aggregate:
- all open — a development device or an oversight;
- first open, rest closed — a loader is visible;
- first closed, rest open — the vectors are gone;
- all closed — a shipped, locked product.
Each pattern leads to a different next step. The second suggests exercising the update path. The third suggests decoding without anchors. The fourth suggests behavioural work or stopping.
What is worth trying, in order
- Confirm entry: does the device respond at all, with the expected device identifier?
- Read the configuration; it states the pattern.
- Read a known-populated address; the reset vector if the first block is open.
- Read each block in turn; record the boundary.
- Only then consider the device’s behaviour.
Steps one to four take minutes and eliminate the majority of misdiagnoses. Everything expensive comes after, and most of the time it is not needed.
The cost of getting it wrong
The specific cost on this family is that the remedy for a failed entry looks like the remedy for protection: erase the device and start again.
On a device whose content was expendable, that works. On one whose content was the point of the exercise, it converts a solvable problem into an unsolvable one — and it does so at the moment when the diagnosis was least certain.
That is the argument for the sequence above, and it is why the sequence appears in every article about this family.
Related reading
- PIC18F44K20 and the order of operations — what to do once a read has succeeded.
- PIC18F43K20 and the two-block array — the same analysis with fewer boundaries.
- PIC18F23K20 and configuration as the first read — the read that distinguishes protection from erasure.
FAQ
How do I tell protection from a bad connection? Repeat the read. Protection is deterministic; a marginal connection is not.
Why does the device not enter programming mode? Usually a pin held by the circuit, an edge slowed by capacitance, or a configuration that disables the low-voltage entry.
Does an erased device read like a protected one? Yes at a single address. The configuration distinguishes them.
Which block holds the vectors? The first, along with start-up code.
What erases the protection? A full erase, which also erases the content. That is why the diagnosis comes first.
Conclusion
Two kinds of blocked read, distinguishable by repetition and by whether the device responds at all. Separating them costs minutes and prevents the one irreversible mistake available on this part — erasing a device whose contents were the reason for the exercise.