Meaning
Firmware safety feature prevents modifications to configuration registers after an initial setup phase to ensure system stability. Once a value is written to a protected bit, register locking makes that bit read-only until the next hardware reset. This prevents subsequent code execution from altering critical hardware parameters.
State Persistence
Settings for clock dividers and voltage regulators must remain constant during operation. Utilizing register locking ensures that these values do not drift or change due to software errors. The hardware state is effectively frozen once the lock bit is set.
Accidental Modification
Errant pointers in code can occasionally overwrite memory locations that map to hardware control. Because register locking is enforced by the hardware, these stray writes are ignored by the peripheral. This provides a layer of defense against common programming mistakes that could lead to hardware damage.
By shielding the core configuration from unplanned updates, the system maintains its operational integrity even during a software failure. The firmware sets the final parameters during the boot sequence and immediately engages the lock. This prevents a secondary task from interfering with the hardware configuration.
Hardware designers include this feature in safety-critical modules.
Write Restriction
Designating a register as locked is an irreversible action during a single power cycle that requires a specific sequence of commands to execute. The sequence usually involves writing the desired configuration followed by a specific key to engage the lock. This ensures that the locking process itself is intentional.