The Peripheral Access Controller (PAC) provides write protection for registers of the peripherals.
The user can use periph_lock to enable a selected peripheral's write-protection, and periph_unlock to disable the selected peripheral's write-protection.
If a peripheral is write-protected, and if a write access is performed, data will not be written.
Lock(enable write-protection)
Unlock(disable write-protection)
Get the write-protection state
No PAC parameter needed to be configured in START.
Double write-protection or double unprotection may lead to an access error
The following shows a simple example of using the PAC to lock GCLK peripheral.
/**
* Lock GCLK.
*/
void pac_example(void)
{
bool stat;
periph_get_lock_state(GCLK, &stat);
if (!stat) {
periph_lock(GCLK);
}
}
PAC peripheral and clocks