1.40.14 Peripheral Access Controller (PAC)

The Peripheral Access Controller (PAC) provides interface to protect write access to a peripheral's registers to minimize risk of unintended configuration changes as a result of run-away code.

The peripheral registers that can be protected is denoted by the "PAC Write-Protection" property in each individual register description.

Using The Library

The Peripheral Access Controller (PAC) provides interface to protect write access to a peripheral's registers to minimize risk of unintended configuration changes as a result of run-away code. The Following operations are provided to manage the peripheral access.

  • Clear Protection:

    • This operation will remove the write access protection for the selected peripheral to enable write access

  • Set Protection:

    • This operation will set the write access protection for the selected peripheral to disable write access.

  • Set and Lock Protection:

    • This operation will set the write access protection for the selected peripheral to disable write access and locks the access rights of the selected peripheral registers.

    • The write access protection will only be cleared by a hardware reset.

In an application where write protection is also modified in main and interrupt context, the interrupts must be disabled so that the interrupt can not happen while the main application manipulate the write protection status.

The registered callback function will be called when Peripheral Access Error occurs due to the following:

  • If a peripheral is write protected and if a write access is attempted, data will not be written and peripheral returns an access error.

  • Attempting to set protection for the peripheral that is already set or attempting to clear protection for the peripheral that is already cleared. This is a safety feature to ensure correct program execution sequence to clear and set the protection.

  • Access to an unimplemented register within the module.

  • For write-synchronized registers an error will be reported if the register is written while a synchronization is ongoing.

The example code below demonstrates how to Clear/Set protection for DSU peripheral using PAC.

bool status = false;

status = PAC_PeripheralIsProtected(PAC_PERIPHERAL_DSU);

if (status == true)
{
    PAC_PeripheralProtectSetup(PAC_PERIPHERAL_DSU, PAC_PROTECTION_CLEAR);
}
else
{
    PAC_PeripheralProtectSetup(PAC_PERIPHERAL_DSU, PAC_PROTECTION_SET);
}

Library Interface

Peripheral Access Controller peripheral library provides the following interfaces:

Functions

Name Description
PAC_Initialize Initializes given instance of PAC peripheral
PAC_PeripheralIsProtected Returns PAC protection status of peripheral
PAC_PeripheralProtectSetup This function configures PAC protection for the specified peripheral
PAC_CallbackRegister Registers the function to be called when a PAC error has occurred

Data types and constants

Name Type Description
PAC_PERIPHERAL Enum List of available Peripheral module on which errors will be detected
PAC_PROTECTION Enum List of available Peripheral Access Control Operations
PAC_CALLBACK Typedef Defines the data type and function signature for the PAC peripheral callback function