Jump to main content

##

# 3.2.15 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 and lock write access protection for the selected peripheral to disable write access. The write protection cannot be cleared until reset occurs.

The CPU Exception will be generated when Peripheral Access Error occurs due to the following:

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

    bool status = false;

    status = PAC_PeripheralIsProtected(PAC_PERIPHERAL_WDTCON);

    if (status == true)
    {
        PAC_PeripheralProtectSetup(PAC_PERIPHERAL_WDTCON, PAC_PROTECTION_CLEAR);
    }
    else
    {
        PAC_PeripheralProtectSetup(PAC_PERIPHERAL_WDTCON, 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