Jump to main content

##

# 3.37.11 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.

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 CPU Exception will be generated 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.

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_PeripheralIsProtected | Returns PAC protection status of peripheral
PAC_PeripheralProtectSetup | This function configures PAC protection for the specified peripheral

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