CTRL-AP — Control access port

The control access port (CTRL-AP) is a custom access port that enables control of the device when other access ports (AP) have been disabled by the access port protection.

For an overview of the other debug access ports, see DAP.

Figure 1. Control access port details

Control access port details

Access port protection (APPROTECT) blocks the debugger from accessing the AHB-AP and prevents read and write access to all CPU registers and memory-mapped addresses. To enable access port protection for both secure and non-secure modes, use the registers UICR.SECUREAPPROTECT and UICR.APPROTECT.

Erase protection (ERASEPROTECT) protects the entire non-volatile memory, SICR, and UICR from being erased. Erase protection is enabled through UICR and disabled through cooperation between the firmware and debugger. For more information about disabling erase protection, see Erase protection.

CTRL-AP has the following features:
The CTRL-AP peripheral has the following types of registers:

Reset request

The debugger can request the device to perform a reset.

The register RESET is used to request the reset. Once the reset is performed, the reset reason is accessible through the RESETREAS register. For more information about reset, see RESET — Reset control.

Erase all

The erase all function lets the debugger trigger an erase of non-volatile memory, user information configuration registers (UICR), secure information configuration region (SICR), RAM, all peripheral settings, and also temporarily removes the access port protection.

To trigger an erase all function, follow the sequence in the following flowchart. After the sequence has completed, the access port protection is removed until the next pin reset, power-on reset, brownout reset, or watchdog timer reset.

Figure 2. Erase all states
Erase all states

Erase all protection

It is possible to prevent the debugger from performing an erase all operation by using either the TAMPC TAMPC.PROTECT.ERASEPROTECT register, or the UICR.ERASEPROTECT register followed by a device reset.

Once this has been configured, the CTRL-AP ERASEALL operation is disabled.

The register ERASEPROTECT.STATUS holds the status for erase protection.

Erase protection

Erase protection can be used to prevent a device from being erased.

A device ERASEALL operation can be initiated either by the non-volatile memory controller, or through the control access port. The following table describes the protection of the CTRL-AP ERASEALL operation. For more information, see Access port protection

Table 1. Erase all protection
Access port protection stateERASEALL operation
UICR.­ERASEPROTECTTAMPC.­PROTECT.­ERASEPROTECTERASEALL
UnprotectedUnprotectedAllowed
Protected-Disabled
-ProtectedDisabled

The debugger can read the erase protection status in the register ERASEPROTECT.STATUS.

When erase protection is enabled, both the debugger and on-board firmware are required to disable it. The same non-zero 32-bit KEY value must be written to the debugger register ERASEPROTECT.DISABLE and CPU register ERASEPROTECT.DISABLE to disable erase protection. When both registers have been written with the same non-zero 32-bit KEY value, the device is automatically erased as described in Erase all. The access ports will be re-enabled on the next reset once the secure erase sequence has completed.

Write to the write-once register ERASEPROTECT.LOCK as early as possible in the start-up sequence, preferably as soon as the on-chip firmware has determined it does not need to communicate with a debugger over the CTRL-AP mailbox interface. Once written, it will not be possible to remove the erase protection until the next pin reset, power-on reset, brownout reset, or watchdog timer reset, and therefore ERASEPROTECT.DISABLE is also disabled.

Mailbox interface

CTRL-AP implements a mailbox interface which enables the CPU to communicate with a debugger over the SWD interface.

The mailbox interface consists of a transmit register MAILBOX.TXDATA with its corresponding status register MAILBOX.TXSTATUS, and a receive register MAILBOX.RXDATA with its corresponding status register MAILBOX.RXSTATUS. Status bits in registers TXSTATUS/RXSTATUS will be set and cleared automatically when registers TXDATA/RXDATA are written to and read from, independently of the direction.

Figure 3. Mailbox register interface
Mailbox register interface, illustrating the data flow between debugger and CPU

Mailbox transfer sequence

  1. Sender writes TXDATA
  2. CTRL-AP sets sender's TXSTATUS to DataPending
  3. CTRL-AP sets receiver's RXSTATUS to DataPending
  4. Receiver reads RXDATA
  5. CTRL-AP sets receiver's RXSTATUS to NoDataPending
  6. CTRL-AP sets sender's TXSTATUS to NoDataPending

Events

EVENTS_RXREADY is generated when MAILBOX.RXSTATUS changes to DataPending. This indicates that a debugger has written new data to MAILBOX.RXDATA.

EVENTS_TXDONE is generated when the MAILBOX.TXSTATUS changes to NoDataPending. This indicates that a debugger has read the data from MAILBOX.TXDATA.

Device information

Device information, such as part number and hardware revision, can be read using CTRL-AP.

CTRL-AP provides the following information about the device:The information is available even for protected devices.

Debugger registers

CTRL-AP has a set of registers that can only be accessed from the debugger through the SWD interface. These are not accessible from the CPU.

Debug side registers

Register overview
RegisterOffsetTZDescription
RESET0x000System reset request and status
ERASEALL0x004Perform a secure erase of the device, where flash, SRAM, and UICR will be erased in sequence. The device will be returned to factory default settings upon next reset.
ERASEALLSTATUS0x008This is the status register for the ERASEALL operation.
ERASEPROTECT.STATUS0x00CErase protection status.
ERASEPROTECT.DISABLE0x010This register disables ERASEPROTECT and performs Erase all.
APPROTECT.STATUS0x014This is the status register for the access port protection.
MAILBOX.TXDATA0x020Data sent from the debugger to the device.
MAILBOX.TXSTATUS0x024Status to indicate if data sent from the debugger to the device has been read.
MAILBOX.RXDATA0x028Data sent from the device to the debugger.
MAILBOX.RXSTATUS0x02CStatus to indicate if data sent from the device to the debugger has been read.
INFO.PARTNO0x030Part number of the device
INFO.HWREVISION0x034Hardware Revision of the device
IDR0x0FCCTRL-AP Identification Register, IDR

RESET

Address offset: 0x000

System reset request and status

Only the enumerated values are supported, writing other values has unpredictable effect.

The Erase all operation cannot be interrupted by this reset request. Once the Erase all operation has started, CTRL-AP reset requests are ignored.

Bit number313029282726252423222120191817161514131211109876543210
IDAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
AWRESETReset request
NoReset0Release the RESET register value.
SoftReset1Trigger soft reset of the device. Use NoReset after the device has been reset.
HardReset2

Trigger hard reset of the device. Use NoReset after the device has been reset.

Use as part of the ERASEALL sequence.

PinReset4Trigger pin reset of the device. Use NoReset after the device has been reset.

ERASEALL

Address offset: 0x004

Perform a secure erase of the device, where flash, SRAM, and UICR will be erased in sequence. The device will be returned to factory default settings upon next reset.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
AWERASEALLReturn device to factory default settings
NoOperation0No operation
Erase1Erase flash, SRAM, and UICR in sequence

ERASEALLSTATUS

Address offset: 0x008

This is the status register for the ERASEALL operation.

Bit number313029282726252423222120191817161514131211109876543210
IDAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARERASEALLSTATUSStatus bits for the ERASEALL operation
Ready0ERASEALL is ready
ReadyToReset1Device is ready to be reset
Busy2ERASEALL is busy (on-going)
Error3Error during ERASEALL

ERASEPROTECT.STATUS

Address offset: 0x00C

Erase protection status.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARPALLErase protection status.
Enabled1Erase protection is enabled.
Disabled0Erase protection is not enabled and ERASEALL can be performed.

ERASEPROTECT.DISABLE

Address offset: 0x010

This register disables ERASEPROTECT and performs Erase all.

Bit number313029282726252423222120191817161514131211109876543210
IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWKEYThe Erase all sequence will be initiated if value of the KEY fields are non-zero and the KEY fields match on both the CPU and debugger sides.

APPROTECT.STATUS

Address offset: 0x014

This is the status register for the access port protection.

Bit number313029282726252423222120191817161514131211109876543210
IDBA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARAPPROTECTStatus bit for access port protection.
Enabled1APPROTECT is enabled
Disabled0APPROTECT is disabled
BRSECUREAPPROTECTThis is the status register for the secure access port protection.
Enabled1SECUREAPPROTECT is enabled
Disabled0SECUREAPPROTECT is disabled

MAILBOX.TXDATA

Address offset: 0x020

Data sent from the debugger to the device.

Writing to this register will automatically set field DataPending in register TXSTATUS.

Bit number313029282726252423222120191817161514131211109876543210
IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWDataData sent from debugger

MAILBOX.TXSTATUS

Address offset: 0x024

Status to indicate if data sent from the debugger to the device has been read.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARStatusStatus of register DATA
NoDataPending0No data pending in register TXDATA
DataPending1Data pending in register TXDATA

MAILBOX.RXDATA

Address offset: 0x028

Data sent from the device to the debugger.

Reading from this register will automatically set field NoDataPending in register RXSTATUS.

Bit number313029282726252423222120191817161514131211109876543210
IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARDataData sent from device

MAILBOX.RXSTATUS

Address offset: 0x02C

Status to indicate if data sent from the device to the debugger has been read.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARStatusStatus of register DATA
NoDataPending0No data pending in register RXDATA
DataPending1Data pending in register RXDATA

INFO.PARTNO

Address offset: 0x030

Part number of the device

This register is retained on system on idle.

Bit number313029282726252423222120191817161514131211109876543210
IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARPARTNOPart number

INFO.HWREVISION

Address offset: 0x034

Hardware Revision of the device

This register is retained on system on idle.

Bit number313029282726252423222120191817161514131211109876543210
IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARIDPart Variant

IDR

Address offset: 0x0FC

CTRL-AP Identification Register, IDR

Bit number313029282726252423222120191817161514131211109876543210
IDEEEEDDDDCCCCCCCBBBBAAAAAAAA
Reset 0x3288000000110010100010000000000000000000
IDR/WFieldValue IDValueDescription
ARAPIDAP Identification
BRCLASSAccess Port (AP) class
NotDefined0x0No defined class
MEMAP0x8Memory Access Port
CRJEP106IDJEDEC JEP106 identity code
DRJEP106CONTJEDEC JEP106 continuation code
ERREVISIONRevision

Peripheral registers

CTRL-AP has a set of registers that can be accessed by the CPU.

CPU side registers

Instances
InstanceDomainBase addressTrustZoneSplit accessDescription
MapAttDMA
CTRLAP : S
CTRLAP : NS
GLOBAL0x50052000
0x40052000
USSNSANoControl access port CPU side
Register overview
RegisterOffsetTZDescription
EVENTS_RXREADY0x100RXSTATUS is changed to DataPending.
EVENTS_TXDONE0x104TXSTATUS is changed to NoDataPending.
INTEN0x300Enable or disable interrupt
INTENSET0x304Enable interrupt
INTENCLR0x308Disable interrupt
INTPEND0x30CPending interrupts
MAILBOX.RXDATA0x400Data sent from the debugger to the CPU.
MAILBOX.RXSTATUS0x404Status to indicate if data sent from the debugger to the CPU has been read.
MAILBOX.TXDATA0x480Data sent from the CPU to the debugger.
MAILBOX.TXSTATUS0x484Status to indicate if data sent from the CPU to the debugger has been read.
ERASEPROTECT.LOCK0x500This register locks the ERASEPROTECT.DISABLE register from being written until next reset.
ERASEPROTECT.DISABLE0x504This register disables the ERASEPROTECT register and performs an ERASEALL operation.
RESET0x520System reset request.

EVENTS_RXREADY

Address offset: 0x100

RXSTATUS is changed to DataPending.

New data is available in MAILBOX.RXDATA.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWEVENTS_RXREADY

RXSTATUS is changed to DataPending.

New data is available in MAILBOX.RXDATA.

NotGenerated0Event not generated
Generated1Event generated

EVENTS_TXDONE

Address offset: 0x104

TXSTATUS is changed to NoDataPending.

MAILBOX.TXDATA has been read.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWEVENTS_TXDONE

TXSTATUS is changed to NoDataPending.

MAILBOX.TXDATA has been read.

NotGenerated0Event not generated
Generated1Event generated

INTEN

Address offset: 0x300

Enable or disable interrupt

Bit number313029282726252423222120191817161514131211109876543210
IDBA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWRXREADY

Enable or disable interrupt for event RXREADY

New data is available in MAILBOX.RXDATA.

Disabled0Disable
Enabled1Enable
BRWTXDONE

Enable or disable interrupt for event TXDONE

MAILBOX.TXDATA has been read.

Disabled0Disable
Enabled1Enable

INTENSET

Address offset: 0x304

Enable interrupt

Bit number313029282726252423222120191817161514131211109876543210
IDBA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARW
W1S
RXREADY

Write '1' to enable interrupt for event RXREADY

New data is available in MAILBOX.RXDATA.

Set1Enable
Disabled0Read: Disabled
Enabled1Read: Enabled
BRW
W1S
TXDONE

Write '1' to enable interrupt for event TXDONE

MAILBOX.TXDATA has been read.

Set1Enable
Disabled0Read: Disabled
Enabled1Read: Enabled

INTENCLR

Address offset: 0x308

Disable interrupt

Bit number313029282726252423222120191817161514131211109876543210
IDBA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARW
W1C
RXREADY

Write '1' to disable interrupt for event RXREADY

New data is available in MAILBOX.RXDATA.

Clear1Disable
Disabled0Read: Disabled
Enabled1Read: Enabled
BRW
W1C
TXDONE

Write '1' to disable interrupt for event TXDONE

MAILBOX.TXDATA has been read.

Clear1Disable
Disabled0Read: Disabled
Enabled1Read: Enabled

INTPEND

Address offset: 0x30C

Pending interrupts

Bit number313029282726252423222120191817161514131211109876543210
IDBA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARRXREADY

Read pending status of interrupt for event RXREADY

New data is available in MAILBOX.RXDATA.

NotPending0Read: Not pending
Pending1Read: Pending
BRTXDONE

Read pending status of interrupt for event TXDONE

MAILBOX.TXDATA has been read.

NotPending0Read: Not pending
Pending1Read: Pending

MAILBOX.RXDATA

Address offset: 0x400

Data sent from the debugger to the CPU.

Reading from this register will automatically set field NoDataPending in register RXSTATUS.

Bit number313029282726252423222120191817161514131211109876543210
IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARRXDATAData received from debugger.

MAILBOX.RXSTATUS

Address offset: 0x404

Status to indicate if data sent from the debugger to the CPU has been read.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARRXSTATUSStatus of data in register RXDATA.
NoDataPending0No data is pending in register RXDATA.
DataPending1Data is pending in register RXDATA.

MAILBOX.TXDATA

Address offset: 0x480

Data sent from the CPU to the debugger.

Writing to this register will automatically set field DataPending in register TXSTATUS.

Bit number313029282726252423222120191817161514131211109876543210
IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWTXDATAData sent to debugger.

MAILBOX.TXSTATUS

Address offset: 0x484

Status to indicate if data sent from the CPU to the debugger has been read.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARTXSTATUSStatus of data in register TXDATA.
NoDataPending0No data is pending in register TXDATA.
DataPending1Data is pending in register TXDATA.

ERASEPROTECT.LOCK

Address offset: 0x500

This register locks the ERASEPROTECT.DISABLE register from being written until next reset.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARW1LOCKWriting any value will lock the ERASEPROTECT.DISABLE register from being written until next reset.
Locked1Register ERASEPROTECT.DISABLE is read-only.

ERASEPROTECT.DISABLE

Address offset: 0x504

This register disables the ERASEPROTECT register and performs an ERASEALL operation.

Bit number313029282726252423222120191817161514131211109876543210
IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
AW1KEYThe ERASEALL sequence is initiated if the value of the KEY fields are non-zero and the KEY fields match on both the CPU and debugger sides.

RESET

Address offset: 0x520

System reset request.

Only the enumerated values are supported, writing other values has unpredictable effect.

Bit number313029282726252423222120191817161514131211109876543210
IDAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
AWRESETReset request
NoReset0No reset is generated
SoftReset1Perform a device soft reset
HardReset2Perform a device hard reset
PinReset4Perform a device pin reset