17.4.2.3 Write Access Protection Management Errors

Only word-wise writes to the Write Control (WRCTRL) register will effectively change the access protection. Other type of accesses have no effect and will cause a PAC write access error. This error is reported in the Peripheral Interrupt Flag Status and Clear (INTFLAGA.PAC) bit.

The PAC also offers an additional safety feature to ensure correct program execution by generating an interrupt on double write clear protection or double write set protection operation. If a peripheral is already write-protected and a subsequent set protection operation is detected, the PAC returns an error; similarly, an error is returned for a double clear protection operation.

In addition, an error is generated when writing a “set and lock” protection to a write-protected peripheral, or when a write access is performed on a locked set protection. This mechanism can be used to ensure that the application follows the intended program flow by always alternating between write-protect and unprotect operations. However, in applications where a write-protected peripheral is used in several contexts (for example in an interrupt), care must be taken to ensure either the interrupt cannot occur while the main application or other interrupt levels manipulate the write protection status, or that the interrupt handler unprotects the peripheral based on the current protection status by reading the Peripheral Write Protection Status (STATUSn) register.

The Errors generated while accessing the PAC module registers (for example, key error, double-protect error, and so on) will set the Peripheral Interrupt Flag Status and Clear (INTFLAGA.PAC) bit.