9.7 Peripheral Access Controller (PAC)

Legacy dsPIC/PIC devices used a locking mechanism where the user wrote 0xAA and 0x55 into NVMKEY in a sequence. This was to prevent accidental enabling or disabling of critical peripherals. This feature has been replaced with a dedicated module called the Peripheral Access Controller (PAC).

Register Locking and Unlocking

The module implements an OR gate between the associated peripheral’s PACCONx lock bit and the inverse of the PACCONx write-enable bit. See Figure 9-3 for a diagram of the PAC locking behavior. If the target peripheral LK bit or the inverse of the WR bit is set, the target register or registers cannot be written to, and only read access is allowed. Also, whenever the LK or WR bit in PACCON is set or cleared, a minimum of two cycles is required for the lock or unlock to take effect.

At device Reset, all WR bits are set to '1' and all LK bits are set to '0'. This means that writes to all peripheral registers are allowed. The user can then configure access to the peripherals using the WR and LK bits. Please note that LK bits are 'One Way Settable' and will remain set until next device Reset and cannot be cleared in software.

Figure 9-3. PAC Locking Behavior
Note: If the LK bit is set OR the WR bit is clear, peripheral access is DISABLED. Any updates to the LK or WR bits require a minimum of two cycles to take effect. Therefore, it is recommended to insert two NOP instructions between statements that modify these bits and access the respective register.

Individual and Range Mode

The PAC module can lock/unlock individual registers and lock/unlock a range of registers depending on which registers are the target registers. If the PAC module uses Range mode, the entire range of target peripheral registers are covered by that lock and write-enable bit. Table 9-5 is used to determine which registers use Individual or Range mode.

Table 9-5. Individual and Range Mode
RegisterIndividual or Range Mode
IVTBASEIndividual
IVTCREGIndividual
BMXIRAMLIndividual
BMXIRAMHIndividual
PCLKCONIndividual
IOIMCON1Individual
IOIMCON2Individual
IOIMCON3Individual
IOIMCON4Individual
IOIMCON5Individual
IOIMCON6Individual
IOIMCON7Individual
IOIMCON8Individual
IOIMCON9Individual
IOIMCON10Individual
IOIMCON11Individual
IOIMCON12Individual
IOIMCON13Individual
IOIMCON14Individual
IOIMCON15Individual
IOIMCON16Individual
NVMCONIndividual
OSCCTRLIndividual
CM1CONIndividual
CM1RANGERange
CM2CONIndividual
CM2RANGERange
CM3CONIndividual
CM3RANGERange
CM4CONIndividual
CM4RANGERange
WDTCONIndividual
RPCONIndividual
MBISTCONIndividual
APCLKCONIndividual
OPAMP1Range
OPAMP2Range
OPAMP3Range
IBIASCONIndividual