After a device has been programmed, it is often desirable to disable debug access to the system, to hinder that others read out or tamper with the device firmware.
This section below will explain how to lock or disable debug access to the EFM32.
Lock the debug access
To lock debug access to the EFM32, clear the Debug Lock Word (DLW) and then perform a hard reset (pin reset) of the device. When the MCU comes out of reset, the debug access will be locked which means that the debugger can no longer access the internal Cortex memory bus.
Generally, user can lock the debugger with simplicity commander or JLink command line, also can lock the debugger by software. However, the lock bits of some devices (such as EFM32G, Table 7.1. of the reference manual) can only be written or erased by Debug, so it can't be locked by software.
Unlocking a device is only possible by performing a Device Erase, where all data both in flash and RAM (and cache) will be erased.
Disable the debug access
Also you can disable the debug pins through GPIO_ROUTE, and the debugger will no longer be able to connect to the EFM32.
During development, it is therefore a good idea to make sure there is a delay between reset and disabling the pins (typically a few seconds). In that way the debugger has time to connect and halt the CPU before the pins are disabled. Accordingly, disable the debug pins at the beginning will forbid the debugger connection.
If you have disabled the debug pins and are unable to connect to your device, still can unlock the device by using the AAP register, all data both in flash and RAM (and cache) will be erased.