PostHeaderIcon PIC18F26K80: What the Protection Bits Actually Block, Field by Field

A protection mechanism is easier to think about when it is enumerated. On this device the configuration word carries a set of fields, each of which blocks one access and leaves the others alone. Treated as a list, the behaviour of any particular device becomes predictable; treated as a single “protected” state, it becomes a source of contradictory observations.

The list is short, and each entry answers a question that arises on a bench.

The fields, and what each one stops

Field Blocks Does not affect
Code protect, per block Reads of that block from outside Execution, other blocks
Table-read protect, per block Reads of that block from code elsewhere Execution, external reads
Write protect, per block Erase and program of that block Reads
Boot region protect Reads and writes of the boot region Application blocks
Data EEPROM protect Reads of the data array Program array
Low-voltage programming disable Entry through the low-voltage interface High-voltage entry

Two of these deserve emphasis because they are misread most often. Table-read protection applies to code, not to a programmer: a device can be readable from the programmer and unreadable from its own application, or the reverse. And disabling low-voltage programming does not protect anything — it changes how you must connect, and it is the field most often responsible for a “device will not respond” diagnosis.

The interaction that produces zeros

A block with code protection set returns zeros to a programmer. A block with table-read protection set returns zeros to code. A block with neither set returns its contents.

The ambiguity is that zeros look like erased flash. On a device where every block returns zeros, three explanations remain:

  • every block is protected;
  • the device is erased;
  • the programmer is reading the wrong address range, so it is reading a genuinely blank region.

The configuration word distinguishes the first from the second. The third is distinguished by reading a known-populated address, which requires knowing one — and on a device whose contents are unknown, the only address guaranteed to be populated on a working device is the reset vector, which is in the boot region.

Executing but not reading

The combination that most confuses readers is a block that executes normally and reads as zeros from everywhere except code inside it. That is table-read protection doing its job: the fetch path is permitted, the data path is not.

From outside, such a device is indistinguishable from a working device — because it is one. There is no fault, no error, no symptom. The only evidence is that a read returns zeros where a read should return code.

This is the case where behavioural analysis is the only analysis. The block runs; its behaviour is observable; its instructions are not.

What a locked device still answers

Four sources remain open on a fully locked device, and each has been discussed elsewhere on this site in a different context. Together they form the practical evidence base:

The configuration word. States the protection state, the oscillator, the watchdog and the programming interface.

The identification area. Part number, revision, and on this generation a unique identifier.

Behaviour. Timing, bus traffic, responses, fault handling.

The update path, if present. A loader cannot be protected out of existence, because then updates would not work.

Reading the protection as intent

The pattern of set bits records decisions. A device with the boot region protected and the application open was built to be updated by the vendor and read by the customer. A device with everything protected was built to be opaque, and the vendor accepted that field service would require replacement rather than repair.

That reading is more useful than the technical state, because it predicts what else exists: whether an update image is likely to be obtainable, whether production records are likely to include a password (none here, but the pattern generalises), and whether a sibling unit is likely to exist with the same build.

Order of operations, again

  1. Configuration, always first.
  2. Known-populated address, to test whether the read path works at all.
  3. Per-block reads, where the configuration permits.
  4. Behavioural measurement, where it does not.
  5. Update path, if one exists.

Steps one and two together eliminate the majority of false conclusions, and they take minutes. The expensive techniques are for the residue.

Related reading

FAQ

Does table-read protection affect a programmer? No. It applies to reads issued by code. The programmer is governed by code protection.

Can low-voltage programming disable be used as protection? It restricts the entry method, not the contents. It is an inconvenience, not a gate.

Why does a read return zeros on an erased device? Because erased flash reads as ones or zeros depending on the representation; the configuration distinguishes the cases.

Can a locked device be updated? If a loader exists and is reachable, yes. The loader writes, and protection gates reads.

Is the identification area readable when locked? Yes, and it gives the part number and revision, which decide which procedures apply.

Conclusion

Six fields, six distinct effects, and a set of observations that only contradict each other when the fields are conflated. Read the configuration, test the read path against a known address, and treat the remaining unknowns as behavioural questions. The word “protected” never needed to be more than a summary of that list.

Comments are closed.