37. Debug support (DBG)

37.1 Overview

The STM32F469xx and STM32F479xx are built around a Cortex ® -M4 core containing hardware extensions for advanced debugging features. The debug extensions allow the core to be stopped either on a given instruction fetch (breakpoint) or data access (watchpoint). When stopped, the core internal state and the system external state can be examined. Once examination is complete, the core and the system may be restored and program execution resumed.

The debug features are used by the debugger host when connecting to and debugging the STM32F469xx and STM32F479xx MCUs.

Two interfaces for debug are available:

Figure 495. Block diagram of STM32 MCU and Cortex ® -M4-level debug support

Block diagram of STM32 MCU and Cortex-M4-level debug support. The diagram shows the internal architecture of the STM32F4xx MCU, highlighting the debug support features. On the left, external debug pins are listed: JTMS/SWDIO, JTDI, JTDO/TRACESWO, NJTRST, JTCK/SWCLK. These connect to an internal SWJ-DP block. The SWJ-DP connects to an AHB-AP block. The AHB-AP is connected to an Internal private peripheral bus (PPB). The PPB contains several blocks: Bridge, NVIC, DWT, FPB, and ITM. The AHB-AP also connects to a Bus matrix. The Bus matrix connects to the Cortex-M4 core, Data, and DCode interface. The Cortex-M4 core also connects to the System interface. The Bridge block connects to an External private peripheral bus (PPB). The External PPB connects to a TPIU block. The TPIU block connects to a Trace port, which outputs TRACESWO, TRACECK, and TRACED[3:0]. The TPIU also connects to a DBGMCU block. The entire internal structure is labeled 'STM32F4xx debug support' and 'Cortex-M4 debug support'. The diagram is labeled MS19908V3 at the bottom right.
Block diagram of STM32 MCU and Cortex-M4-level debug support. The diagram shows the internal architecture of the STM32F4xx MCU, highlighting the debug support features. On the left, external debug pins are listed: JTMS/SWDIO, JTDI, JTDO/TRACESWO, NJTRST, JTCK/SWCLK. These connect to an internal SWJ-DP block. The SWJ-DP connects to an AHB-AP block. The AHB-AP is connected to an Internal private peripheral bus (PPB). The PPB contains several blocks: Bridge, NVIC, DWT, FPB, and ITM. The AHB-AP also connects to a Bus matrix. The Bus matrix connects to the Cortex-M4 core, Data, and DCode interface. The Cortex-M4 core also connects to the System interface. The Bridge block connects to an External private peripheral bus (PPB). The External PPB connects to a TPIU block. The TPIU block connects to a Trace port, which outputs TRACESWO, TRACECK, and TRACED[3:0]. The TPIU also connects to a DBGMCU block. The entire internal structure is labeled 'STM32F4xx debug support' and 'Cortex-M4 debug support'. The diagram is labeled MS19908V3 at the bottom right.

Note: The debug features embedded in the Cortex ® -M4 core are a subset of the Arm ® CoreSight Design Kit.

The Arm ® Cortex ® -M4 core provides integrated on-chip debug support. It is comprised of:

It also includes debug features dedicated to the STM32F469xx and STM32F479xx:

Note: For further information on debug functionality supported by the Arm ® Cortex ® -M4 core, refer to the Cortex ® -M4-r0p1 Technical Reference Manual and to the CoreSight Design Kit-r0p1 TRM (see Section 37.2: Reference Arm ® documentation ).

37.2 Reference Arm ® documentation

37.3 SWJ debug port (serial wire and JTAG)

The core of the STM32F469xx and STM32F479xx integrates the Serial Wire / JTAG Debug Port (SWJ-DP). It is an Arm ® standard CoreSight debug port that combines a JTAG-DP (5-pin) interface and a SW-DP (2-pin) interface.

In the SWJ-DP, the two JTAG pins of the SW-DP are multiplexed with some of the five JTAG pins of the JTAG-DP.

Figure 496. SWJ debug port

Figure 496. SWJ debug port block diagram showing internal logic for JTAG and SWD interfaces.

The diagram illustrates the internal architecture of the SWJ debug port. It features two main debug port blocks: SWJ-DP and JTAG-DP, and a SW-DP block. The SWJ-DP block is connected to external pins: TRACESWO (asynchronous trace), JTDO, JTDI, NJTRST, JTMS/SWDIO, and JTCK/SWCLK. The JTAG-DP block has pins for TDO, TDI, nTRST, TCK, and TMS. The SW-DP block has pins for DBGDI, DBGDO, DBGDOEN, and DBGCLK. A 'SWD/JTAG select' block is used to switch between the two modes. The TRACESWO signal is multiplexed with the TDO signal. The SWD/JTAG select block is controlled by the SWDITMS signal and the nPOTRST signal (from power-on reset). The JTAG-DP block is also controlled by the nPOTRST signal. The SW-DP block is controlled by the DBGRESETn signal.

Figure 496. SWJ debug port block diagram showing internal logic for JTAG and SWD interfaces.

Figure 496 shows that the asynchronous TRACE output (TRACESWO) is multiplexed with TDO. This means that the asynchronous trace can only be used with SW-DP, not JTAG-DP.

37.3.1 Mechanism to select the JTAG-DP or the SW-DP

By default, the JTAG-Debug Port is active.

If the debugger host wants to switch to the SW-DP, it must provide a dedicated JTAG sequence on TMS/TCK (respectively mapped to SWDIO and SWCLK) which disables the JTAG-DP and enables the SW-DP. This way it is possible to activate the SWDP using only the SWCLK and SWDIO pins.

This sequence is:

  1. 1. Send more than 50 TCK cycles with TMS (SWDIO) =1
  2. 2. Send the 16-bit sequence on TMS (SWDIO) = 01111001111100111 (MSB transmitted first)
  3. 3. Send more than 50 TCK cycles with TMS (SWDIO) =1

37.4 Pinout and debug port pins

The STM32F469xx and STM32F479xx MCUs are available in various packages with different numbers of available pins. As a result, some functionality (ETM) related to pin availability may differ between packages.

37.4.1 SWJ debug port pins

Five pins are used as outputs from the STM32F469xx and STM32F479xx for the SWJ-DP as alternate functions of general-purpose I/Os. These pins are available on all packages.

Table 280. SWJ debug port pins

SWJ-DP pin nameJTAG debug portSW debug portPin assignment
TypeDescriptionTypeDebug assignment
JTMS/SWDIOIJTAG Test Mode SelectionIOSerial Wire Data Input/OutputPA13
JTCK/SWCLKIJTAG Test ClockISerial Wire ClockPA14
JTDIIJTAG Test Data Input--PA15
JTDO/TRACE SWOOJTAG Test Data Output-TRACE SWO if async trace is enabledPB3
NJTRSTIJTAG Test nReset--PB4

37.4.2 Flexible SWJ-DP pin assignment

After RESET (SYSRESETn or PORESETn), all five pins used for the SWJ-DP are assigned as dedicated pins immediately usable by the debugger host (note that the trace outputs are not assigned except if explicitly programmed by the debugger host).

However, the STM32F469xx and STM32F479xx MCUs offers the possibility of disabling some or all of the SWJ-DP ports and so, of releasing the associated pins for general-purpose IO (GPIO) usage. For more details on how to disable SWJ-DP port pins, refer to Section 7.3.2: I/O pin multiplexer and mapping .

Table 281. Flexible SWJ-DP pin assignment

Available debug portsSWJ IO pin assigned
PA13 / JTMS / SWDIOPA14 / JTCK / SWCLKPA15 / JTDIPB3 / JTDOPB4 / NJTRST
Full SWJ (JTAG-DP + SW-DP) - Reset StateXXXXX
Full SWJ (JTAG-DP + SW-DP) but without NJTRSTXXXX
JTAG-DP disabled and SW-DP enabledXX
JTAG-DP disabled and SW-DP disabledReleased

37.4.3 Internal pull-up and pull-down on JTAG pins

It is necessary to ensure that the JTAG input pins are not floating as they are directly connected to flip-flops to control the debug mode features. Special care must be taken with the SWCLK/TCK pin, which is directly connected to the clock of some of these flip-flops.

To avoid any uncontrolled IO levels, the device embeds internal pull-ups and pull-downs on the JTAG input pins:

Once a JTAG IO is released by the user software, the GPIO controller takes control again. The reset states of the GPIO control registers put the I/Os in the equivalent state:

The software can then use these I/Os as standard GPIOs.

Note: The JTAG IEEE standard recommends to add pull-ups on TDI, TMS and nTRST but there is no special recommendation for TCK. However, for JTCK, the device needs an integrated pull-down.

Having embedded pull-ups and pull-downs removes the need to add external resistors.

37.4.4 Using serial wire and releasing the unused debug pins as GPIOs

To use the serial wire DP to release some GPIOs, the user software must change the GPIO (PA15, PB3 and PB4) configuration mode in the GPIO_MODER register. This releases PA15, PB3 and PB4 which now become available as GPIOs.

When debugging, the host performs the following actions:

Note: For user software designs, note that:

To release the debug pins, remember that they will be first configured either in input-pull-up (nTRST, TMS, TDI) or pull-down (TCK) or output tristate (TDO) for a certain duration after reset until the instant when the user software releases the pins.

When debug pins (JTAG or SW or TRACE) are mapped, changing the corresponding IO pin configuration in the IOPORT controller has no effect.

37.5 STM32F469xx and STM32F479xx JTAG TAP connection

The STM32F469xx and STM32F479xx MCUs integrate two serially connected JTAG TAPs, the boundary scan TAP (IR is 5-bit wide) and the Cortex ® -M4 TAP (IR is 4-bit wide).

To access the TAP of the Cortex ® -M4 for debug purposes:

  1. 1. First, it is necessary to shift the BYPASS instruction of the boundary scan TAP.
  2. 2. Then, for each IR shift, the scan chain contains 9 bits (=5+4) and the unused TAP instruction must be shifted in using the BYPASS instruction.
  3. 3. For each data shift, the unused TAP, which is in BYPASS mode, adds 1 extra data bit in the data scan chain.

Note: Important: Once Serial-Wire is selected using the dedicated Arm® JTAG sequence, the boundary scan TAP is automatically disabled (JTMS forced high).

Figure 497. JTAG TAP connections

Diagram of JTAG TAP connections for STM32F4xxx. It shows two TAPs: a Boundary scan TAP (IR is 5-bit wide) and a Cortex-M4 TAP (IR is 4-bit wide). The Boundary scan TAP's TMS and nTRST pins are connected to the STM32F4xxx's JTMS and NJTRST pins respectively. Its TDI pin is connected to the STM32F4xxx's JTDI pin, and its TDO pin is connected to the Cortex-M4 TAP's TDI pin. The Cortex-M4 TAP's TMS and nTRST pins are also connected to the STM32F4xxx's JTMS and NJTRST pins. Its TDI pin is connected to the Boundary scan TAP's TDO pin, and its TDO pin is connected to the STM32F4xxx's JTDO pin. A logic gate labeled 'SW-DP Selected' is connected to the TMS pin of the Boundary scan TAP, indicating that the TAP is disabled when Serial-Wire Debug is selected.

The diagram illustrates the JTAG TAP connections for an STM32F4xxx microcontroller. It features two TAPs: a Boundary scan TAP (IR is 5-bit wide) and a Cortex-M4 TAP (IR is 4-bit wide). The Boundary scan TAP's TMS and nTRST pins are connected to the STM32F4xxx's JTMS and NJTRST pins respectively. Its TDI pin is connected to the STM32F4xxx's JTDI pin, and its TDO pin is connected to the Cortex-M4 TAP's TDI pin. The Cortex-M4 TAP's TMS and nTRST pins are also connected to the STM32F4xxx's JTMS and NJTRST pins. Its TDI pin is connected to the Boundary scan TAP's TDO pin, and its TDO pin is connected to the STM32F4xxx's JTDO pin. A logic gate labeled 'SW-DP Selected' is connected to the TMS pin of the Boundary scan TAP, indicating that the TAP is disabled when Serial-Wire Debug is selected.

Diagram of JTAG TAP connections for STM32F4xxx. It shows two TAPs: a Boundary scan TAP (IR is 5-bit wide) and a Cortex-M4 TAP (IR is 4-bit wide). The Boundary scan TAP's TMS and nTRST pins are connected to the STM32F4xxx's JTMS and NJTRST pins respectively. Its TDI pin is connected to the STM32F4xxx's JTDI pin, and its TDO pin is connected to the Cortex-M4 TAP's TDI pin. The Cortex-M4 TAP's TMS and nTRST pins are also connected to the STM32F4xxx's JTMS and NJTRST pins. Its TDI pin is connected to the Boundary scan TAP's TDO pin, and its TDO pin is connected to the STM32F4xxx's JTDO pin. A logic gate labeled 'SW-DP Selected' is connected to the TMS pin of the Boundary scan TAP, indicating that the TAP is disabled when Serial-Wire Debug is selected.

MS19929V2

37.6 ID codes and locking mechanism

There are several ID codes inside the STM32F469xx and STM32F479xx MCUs. ST strongly recommends tools designers to lock their debuggers using the MCU DEVICE ID code located in the external PPB memory map at address 0xE0042000.

37.6.1 MCU device ID code

The STM32F469xx and STM32F479xx MCUs integrate an MCU ID code. This ID identifies the ST MCU part-number and the die revision. It is part of the DBG_MCU component and is mapped on the external PPB bus (see Section 37.16 on page 1597 ). This code is accessible using the JTAG debug pCat.2ort (4 to 5 pins) or the SW debug port (two pins) or by the user software. It is even accessible while the MCU is under system reset.

Only the DEV_ID[11:0] should be used for identification by the debugger/programmer tools.

DBGMCU_IDCODE

Address: 0xE004 2000

Only 32-bits access supported. Read-only.

31302928272625242322212019181716
REV_ID
rrrrrrrrrrrrrrrr
1514131211109876543210
Res.Res.Res.Res.DEV_ID
rrrrrrrrrrrr

Bits 31:16 REV_ID[15:0] Revision identifier

This field indicates the revision of the device:

0x1000 = Revision A and Revision 1

Bits 15:12 Reserved, must be kept at reset value.

Bits 11:0 DEV_ID[11:0] : Device identifier

The device ID is 0x434

37.6.2 Boundary scan TAP

JTAG ID code

The TAP of the STM32F469xx and STM32F479xx BSC (boundary scan) integrates a JTAG ID code equal to 0x06434041.

37.6.3 Cortex ® -M4 TAP

The TAP of the Arm ® Cortex ® -M4 integrates a JTAG ID code. This ID code is the Arm ® default one and has not been modified. This code is only accessible by the JTAG Debug Port.

This code is 0x4BA00477 (corresponds to Cortex ® -M4 r0p1, see Section 37.2: Reference Arm ® documentation ).

37.6.4 Cortex ® -M4 JEDEC-106 ID code

The Arm ® Cortex ® -M4 integrates a JEDEC-106 ID code. It is located in the 4KB ROM table mapped on the internal PPB bus at address 0xE00FF000_0xE00FFFFF.

This code is accessible by the JTAG Debug Port (4 to 5 pins) or by the SW Debug Port (two pins) or by the user software.

37.7 JTAG debug port

A standard JTAG state machine is implemented with a 4-bit instruction register (IR) and five data registers (for full details, refer to the Cortex ® -M4 r0p1 Technical Reference Manual (TRM) , for references, see Section 37.2: Reference Arm ® documentation ).

Table 282. JTAG debug port data registers

IR(3:0)Data registerDetails
1111BYPASS
[1 bit]
-
1110IDCODE
[32 bits]
ID CODE
0x4BA00477 (Arm ® Cortex ® -M4 r0p1 ID Code)
1010DPACC
[35 bits]
Debug port access register
This initiates a debug port and allows access to a debug port register.
– When transferring data IN:
Bits 34:3 = DATA[31:0] = 32-bit data to transfer for a write request
Bits 2:1 = A[3:2] = 2-bit address of a debug port register.
Bit 0 = RnW = Read request (1) or write request (0).
– When transferring data OUT:
Bits 34:3 = DATA[31:0] = 32-bit data which is read following a read request
Bits 2:0 = ACK[2:0] = 3-bit Acknowledge:
010 = OK/FAULT
001 = WAIT
OTHER = reserved
Refer to Table 283 for a description of the A(3:2) bits

Table 282. JTAG debug port data registers (continued)

IR(3:0)Data registerDetails
1011APACC
[35 bits]

Access port access register

Initiates an access port and allows access to an access port register.

  • – When transferring data IN:
    • Bits 34:3 = DATA[31:0] = 32-bit data to shift in for a write request
    • Bits 2:1 = A[3:2] = 2-bit address (sub-address AP registers).
    • Bit 0 = RnW= Read request (1) or write request (0).
  • – When transferring data OUT:
    • Bits 34:3 = DATA[31:0] = 32-bit data which is read following a read request
    • Bits 2:0 = ACK[2:0] = 3-bit acknowledge:
      • 010 = OK/FAULT
      • 001 = WAIT
      • OTHER = reserved

There are many AP Registers (see AHB-AP) addressed as the combination of:

  • – The shifted value A[3:2]
  • – The current value of the DP SELECT register
1000ABORT
[35 bits]

Abort register

  • – Bits 31:1 = reserved
  • – Bit 0 = DAPABORT: write 1 to generate a DAP abort.
Table 283. 32-bit debug port registers addressed through the shifted value A[3:2]
AddressA(3:2) valueDescription
0x000Reserved, must be kept at reset value.
0x401DP CTRL/STAT register. Used to:
– Request a system or debug power-up
– Configure the transfer operation for AP accesses
– Control the pushed compare and pushed verify operations.
– Read some status flags (overrun, power-up acknowledges)
0x810DP SELECT register: Used to select the current access port and the active 4-words register window.
– Bits 31:24: APSEL: select the current AP
– Bits 23:8: reserved
– Bits 7:4: APBANKSEL: select the active 4-words register window on the current AP
– Bits 3:0: reserved
0xC11DP RDBUFF register: Used to allow the debugger to get the final result after a sequence of operations (without requesting new JTAG-DP operation)

37.8 SW debug port

37.8.1 SW protocol introduction

This synchronous serial protocol uses two pins:

The protocol allows two banks of registers (DPACC registers and APACC registers) to be read and written to.

Bits are transferred LSB-first on the wire.

For SWDIO bidirectional management, the line must be pulled-up on the board (100 k \( \Omega \) recommended by Arm ® ).

Each time the direction of SWDIO changes in the protocol, a turnaround time is inserted where the line is not driven by the host nor the target. By default, this turnaround time is one bit time, however this can be adjusted by configuring the SWCLK frequency.

37.8.2 SW protocol sequence

Each sequence consist of three phases:

  1. 1. Packet request (8 bits) transmitted by the host
  2. 2. Acknowledge response (3 bits) transmitted by the target
  3. 3. Data transfer phase (33 bits) transmitted by the host or the target
Table 284. Packet request (8-bits)
BitNameDescription
0StartMust be “1”
1APnDP0: DP Access
1: AP Access
2RnW0: Write Request
1: Read Request
4:3A(3:2)Address field of the DP or AP registers (refer to Table 283 )
5ParitySingle bit parity of preceding bits
6Stop0
7ParkNot driven by the host. Must be read as “1” by the target because of the pull-up

Refer to the Cortex ® -M4r0p1 TRM for a detailed description of DPACC and APACC registers.

The packet request is always followed by the turnaround time (default 1 bit) where neither the host nor target drive the line.

Table 285. ACK response (3 bits)
BitNameDescription
0..2ACK001: FAULT
010: WAIT
100: OK

The ACK Response must be followed by a turnaround time only if it is a READ transaction or if a WAIT or FAULT acknowledge has been received.

Table 286. DATA transfer (33 bits)
BitNameDescription
0..31WDATA or RDATAWrite or Read data
32ParitySingle parity of the 32 data bits

The DATA transfer must be followed by a turnaround time only if it is a READ transaction.

37.8.3 SW-DP state machine (reset, idle states, ID code)

The State Machine of the SW-DP has an internal ID code which identifies the SW-DP. It follows the JEP-106 standard. This ID code is the default Arm ® one and is set to 0x2BA01477 (corresponding to Cortex ® -M4 r0p1).

Note: Note that the SW-DP state machine is inactive until the target reads this ID code.

Further details of the SW-DP state machine can be found in the Cortex®-M4 r0p1 TRM and the CoreSight Design Kit r0p1 TRM .

37.8.4 DP and AP read/write accesses

37.8.5 SW-DP registers

Access to these registers are initiated when APnDP=0

Table 287. SW-DP registers

A(3:2)R/WCTRLSEL bit of SELECT registerRegisterNotes
00Read-IDCODEThe manufacturer code is not set to ST code. 0x2BA01477 (identifies the SW-DP)
00Write-ABORT-

Table 287. SW-DP registers (continued)

A(3:2)R/WCTRLSEL bit of SELECT registerRegisterNotes
01Read/Write0DP-CTRL/STATPurpose is to:
– request a system or debug power-up
– configure the transfer operation for AP accesses
– control the pushed compare and pushed verify operations.
– read some status flags (overrun, power-up acknowledges)
01Read/Write1WIRE CONTROLPurpose is to configure the physical serial port protocol (like the duration of the turnaround time)
10Read-READ RESENDEnables recovery of the read data from a corrupted debugger transfer, without repeating the original AP transfer.
10Write-SELECTThe purpose is to select the current access port and the active 4-words register window
11Read/Write-READ BUFFERThis read buffer is useful because AP accesses are posted (the result of a read AP request is available on the next AP transaction).
This read buffer captures data from the AP, presented as the result of a previous read, without initiating a new transaction

37.8.6 SW-AP registers

Access to these registers are initiated when APnDP=1

There are many AP Registers (see AHB-AP) addressed as the combination of:

37.9 AHB-AP (AHB access port), valid for JTAG-DP and SW-DP

Features:

The address of the 32-bits AHP-AP resisters are 6-bits wide (up to 64 words or 256 bytes) and consists of:

The AHB-AP of the Cortex ® -M4 includes 9 x 32-bits registers:

Table 288. Cortex ® -M4 AHB-AP registers

Address offsetRegister nameNotes
0x00AHB-AP Control and Status WordConfigures and controls transfers through the AHB interface (size, hprot, status on current transfer, address increment type)
0x04AHB-AP Transfer Address-
0x0CAHB-AP Data Read/Write-
0x10AHB-AP Banked Data 0Directly maps the 4 aligned data words without rewriting the Transfer Address Register.
0x14AHB-AP Banked Data 1
0x18AHB-AP Banked Data 2
0x1CAHB-AP Banked Data 3
0xF8AHB-AP Debug ROM addressBase address of the debug interface
0xFCAHB-AP ID register-

Refer to the Cortex ® -M4 r0p1 TRM for further details.

37.10 Core debug

Core debug is accessed through the core debug registers. Debug access to these registers is by means of the Advanced High-performance Bus (AHB-AP) port. The processor can access these registers directly over the internal Private Peripheral Bus (PPB).

It consists of 4 registers:

Table 289. Core debug registers

RegisterDescription
DHCSRThe 32-bit Debug Halting Control and Status Register
This provides status information about the state of the processor enable core debug halt and step the processor
DCRSRThe 17-bit Debug Core Register Selector Register:
This selects the processor register to transfer data to or from.
DCRDRThe 32-bit Debug Core Register Data Register:
This holds data for reading and writing registers to and from the processor selected by the DCRSR (Selector) register.
DEMCRThe 32-bit Debug Exception and Monitor Control Register:
This provides Vector Catching and Debug Monitor Control. This register contains a bit named TRCENA which enable the use of a TRACE.

Note: Important: these registers are not reset by a system reset. They are only reset by a power-on reset.

Refer to the Cortex®-M4 r0p1 TRM for further details.

To Halt on reset, it is necessary to:

37.11 Capability of the debugger host to connect under system reset

The reset system of the STM32F469xx and STM32F479xx MCU comprises the following reset sources:

The Cortex ® -M4 differentiates the reset of the debug part (generally PORRESETn) and the other one (SYSRESETn)

This way, it is possible for the debugger to connect under System Reset, programming the Core Debug Registers to halt the core when fetching the reset vector. Then the host can release the system reset and the core will immediately halt without having executed any instructions. In addition, it is possible to program any debug features under System Reset.

Note: It is highly recommended for the debugger host to connect (set a breakpoint in the reset vector) under system reset.

37.12 FPB (Flash patch breakpoint)

The FPB unit:

The use of a Software Patch or a Hardware Breakpoint is exclusive.

The FPB consists of:

37.13 DWT (data watchpoint trigger)

The DWT unit consists of four comparators. They are configurable as:

The DWT also provides some means to give some profiling informations. For this, some counters are accessible to give the number of:

37.14 ITM (instrumentation trace macrocell)

37.14.1 General description

The ITM is an application-driven trace source that supports printf style debugging to trace Operating System (OS) and application events, and emits diagnostic system information. The ITM emits trace information as packets which can be generated as:

The packets emitted by the ITM are output to the TPIU (Trace Port Interface Unit). The formatter of the TPIU adds some extra packets (refer to TPIU) and then output the complete packets sequence to the debugger host.

The bit TRCEN of the Debug Exception and Monitor Control Register must be enabled before you program or use the ITM.

37.14.2 Time stamp packets, synchronization and overflow packets

Time stamp packets encode time stamp information, generic control and synchronization. It uses a 21-bit timestamp counter (with possible prescalers) which is reset at each time stamp packet emission. This counter can be either clocked by the CPU clock or the SWV clock.

A synchronization packet consists of 6 bytes equal to 0x80_00_00_00_00_00 which is emitted to the TPIU as 00 00 00 00 00 80 (LSB emitted first).

A synchronization packet is a timestamp packet control. It is emitted at each DWT trigger.

For this, the DWT must be configured to trigger the ITM: the bit CYCCNTENA (bit0) of the DWT Control Register must be set. In addition, the bit2 (SYNCENA) of the ITM Trace Control Register must be set.

Note: If the SYNENA bit is not set, the DWT generates Synchronization triggers to the TPIU which will send only TPIU synchronization packets and not ITM synchronization packets.

An overflow packet consists is a special timestamp packets which indicates that data has been written but the FIFO was full.

Table 290. Main ITM registers

AddressRegisterDetails
@E0000FB0ITM lock accessWrite 0xC5ACCE55 to unlock Write Access to the other ITM registers
@E0000E80ITM trace controlBits 31-24 = Always 0
Bits 23 = Busy
Bits 22-16 = 7-bit ATB ID, identifies the source of the trace data.
Bits 15-10 = Always 0
Bits 9:8 = TSPrescale = Time Stamp Prescaler
Bits 7-5 = Reserved
Bit 4 = SWOENA = Enable SWV behavior (to clock the timestamp counter by the SWV clock).
Bit 3 = DWTENA: Enable the DWT Stimulus
Bit 2 = SYNCENA: this bit must be to 1 to enable the DWT to generate synchronization triggers so that the TPIU can then emit the synchronization packets.
Bit 1 = TSENA (Timestamp Enable)
@E0000E40ITM trace privilegeBit 0 = ITMENA: Global Enable Bit of the ITM
Bit 3: mask to enable tracing ports31:24
Bit 2: mask to enable tracing ports23:16
Bit 1: mask to enable tracing ports15:8
@E0000E00ITM trace enableBit 0: mask to enable tracing ports7:0
Each bit enables the corresponding Stimulus port to generate trace.
@E0000000-E000007CStimulus port registers 0-31Write the 32-bit data on the selected Stimulus Port (32 available) to be traced out.

Example of configuration

To output a simple value to the TPIU:

37.15 ETM (Embedded trace macrocell)

37.15.1 General description

The ETM enables the reconstruction of program execution. Data are traced using the Data Watchpoint and Trace (DWT) component or the Instruction Trace Macrocell (ITM) whereas instructions are traced using the Embedded Trace Macrocell (ETM).

The ETM transmits information as packets and is triggered by embedded resources. These resources must be programmed independently and the trigger source is selected using the Trigger Event Register (0xE0041008). An event could be a simple event (address match from an address comparator) or a logic equation between 2 events. The trigger source is one of the fourth comparators of the DWT module, The following events can be monitored:

For more informations on the trigger resources refer to Section 37.13 .

The packets transmitted by the ETM are output to the TPIU (Trace Port Interface Unit). The formatter of the TPIU adds some extra packets (refer to Section 37.17 ) and then outputs the complete packet sequence to the debugger host.

37.15.2 Signal protocol, packet types

This part is described in the chapter 7 ETMv3 Signal Protocol of the Arm® IHI 0014N document.

37.15.3 Main ETM registers

For more information on registers refer to the chapter 3 of the Arm® IHI 0014N specification.

Table 291. Main ETM registers

AddressRegisterDetails
0xE0041FB0ETM Lock AccessWrite 0xC5ACCE55 to unlock the write access to the other ETM registers.
0xE0041000ETM ControlThis register controls the general operation of the ETM, for instance how tracing is enabled.
0xE0041010ETM StatusThis register provides information about the current status of the trace and trigger logic.
0xE0041008ETM Trigger EventThis register defines the event that will control trigger.
0xE004101CETM Trace Enable ControlThis register defines which comparator is selected.
0xE0041020ETM Trace Enable EventThis register defines the trace enabling event.
0xE0041024ETM Trace Start/StopThis register defines the traces used by the trigger source to start and stop the trace, respectively.

37.15.4 Configuration example

To output a simple value to the TPIU:

37.16 MCU debug component (DBGMCU)

The MCU debug component helps the debugger provide support for:

37.16.1 Debug support for low-power modes

To enter low-power mode, the instruction WFI or WFE must be executed.

The MCU implements several low-power modes which can either deactivate the CPU clock or reduce the power of the CPU.

The core does not allow FCLK or HCLK to be turned off during a debug session. As these are required for the debugger connection, during a debug, they must remain active. The MCU integrates special means to allow the user to debug software in low-power modes.

For this, the debugger host must first set some debug configuration registers to change the low-power mode behavior:

37.16.2 Debug support for timers, watchdog, bxCAN and I 2 C

During a breakpoint, it is necessary to choose how the counter of timers and watchdog should behave:

For the bxCAN, the user can choose to block the update of the receive register during a breakpoint.

For the I 2 C, the user can choose to block the SMBUS timeout during a breakpoint.

37.16.3 Debug MCU configuration register

This register allows the configuration of the MCU under DEBUG. This concerns:

This DBGMCU_CR is mapped on the External PPB bus at address 0xE0042004

It is asynchronously reset by the PORESET (and not the system reset). It can be written by the debugger under system reset.

If the debugger host does not support these features, it is still possible for the user software to write to these registers.

DBGMCU_CR register

Address: 0xE004 2004

Only 32-bit access supported

POR Reset: 0x0000 0000 (not reset by system reset)

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.TRACE_MODE[1:0]TRACE_IOENRes.Res.DBG_STANDBYDBG_STOPDBG_SLEEP
rwrwrwrwrw

Bits 31:8 Reserved, must be kept at reset value.

Bits 7:5 TRACE_MODE[1:0] and TRACE_IOEN : Trace pin assignment control

– With TRACE_IOEN=0:

TRACE_MODE=xx: TRACE pins not assigned (default state)

– With TRACE_IOEN=1:

Bits 4:3 Reserved, must be kept at reset value.

Bit 2 DBG_STANDBY : Debug Standby mode

0: (FCLK=Off, HCLK=Off) The whole digital part is unpowered.

From software point of view, exiting from Standby is identical than fetching reset vector (except a few status bit indicated that the MCU is resuming from Standby)

1: (FCLK=On, HCLK=On) In this case, the digital part is not unpowered and FCLK and HCLK are provided by the internal RC oscillator which remains active. In addition, the MCU generate a system reset during Standby mode so that exiting from Standby is identical than fetching from reset

Bit 1 DBG_STOP : Debug Stop mode

0: (FCLK=Off, HCLK=Off) In STOP mode, the clock controller disables all clocks (including HCLK and FCLK). When exiting from STOP mode, the clock configuration is identical to the one after RESET (CPU clocked by the 8 MHz internal RC oscillator (HSI)). Consequently, the software must reprogram the clock controller to enable the PLL, the Xtal, etc.

1: (FCLK=On, HCLK=On) In this case, when entering STOP mode, FCLK and HCLK are provided by the internal RC oscillator which remains active in STOP mode. When exiting STOP mode, the software must reprogram the clock controller to enable the PLL, the Xtal, etc. (in the same way it would do in case of DBG_STOP=0)

Bit 0 DBG_SLEEP : Debug Sleep mode

0: (FCLK=On, HCLK=Off) In Sleep mode, FCLK is clocked by the system clock as previously configured by the software while HCLK is disabled.

In Sleep mode, the clock controller configuration is not reset and remains in the previously programmed state. Consequently, when exiting from Sleep mode, the software does not need to reconfigure the clock controller.

1: (FCLK=On, HCLK=On) In this case, when entering Sleep mode, HCLK is fed by the same clock that is provided to FCLK (system clock as previously configured by the software).

37.16.4 Debug MCU APB1 freeze register (DBGMCU_APB1_FZ)

The DBGMCU_APB1_FZ register is used to configure the MCU under Debug. It concerns APB1 peripherals. It is mapped on the external PPB bus at address 0xE004 2008.

The register is asynchronously reset by the POR (and not the system reset). It can be written by the debugger under system reset.

Address : 0xE004 2008

Only 32-bits access are supported.

Power-on reset (POR): 0x0000 0000 (not reset by system reset)

31302928272625242322212019181716
Res.Res.Res.Res.Res.DBG_CAN2_STOPDBG_CAN1_STOPDBG_I2CFMP_SMBUS_TIMEOUTDBG_I2C3_SMBUS_TIMEOUTDBG_I2C2_SMBUS_TIMEOUTDBG_I2C1_SMBUS_TIMEOUTRes.Res.Res.Res.Res.
r/wr/wr/wr/wr/wr/w
1514131211109876543210
Res.Res.Res.DBG_IWDG_STOPDBG_WWDG_STOPDBG_RTC_STOPRes.DBG_TIM14_STOPDBG_TIM13_STOPDBG_TIM12_STOPDBG_TIM7_STOPDBG_TIM6_STOPDBG_TIM5_STOPDBG_TIM4_STOPDBG_TIM3_STOPDBG_TIM2_STOP
r/wr/wr/wr/wr/wr/wr/wr/wr/wr/wr/w

Bits 31:27 Reserved, must be kept at reset value.

Bit 26 DBG_CAN2_STOP : Debug CAN2 stopped when Core is halted

0: Same behavior as in normal mode

1: The CAN2 receive registers are frozen

Bit 25 DBG_CAN1_STOP : Debug CAN2 stopped when Core is halted

0: Same behavior as in normal mode

1: The CAN2 receive registers are frozen

  1. Bit 24 DBG_I2CFMP_SMBUS_TIMEOUT : SMBUS timeout mode stopped when Core is halted
    0: Same behavior as in normal mode
    1: The SMBUS timeout is frozen
  2. Bit 23 DBG_I2C3_SMBUS_TIMEOUT : SMBUS timeout mode stopped when Core is halted
    0: Same behavior as in normal mode
    1: The SMBUS timeout is frozen
  3. Bit 22 DBG_I2C2_SMBUS_TIMEOUT : SMBUS timeout mode stopped when Core is halted
    0: Same behavior as in normal mode
    1: The SMBUS timeout is frozen
  4. Bit 21 DBG_I2C1_SMBUS_TIMEOUT : SMBUS timeout mode stopped when Core is halted
    0: Same behavior as in normal mode
    1: The SMBUS timeout is frozen
  5. Bits 20:13 Reserved, must be kept at reset value.
  6. Bit 12 DBG_IWDG_STOP : Debug independent watchdog stopped when core is halted
    0: The independent watchdog counter clock continues even if the core is halted
    1: The independent watchdog counter clock is stopped when the core is halted
  7. Bit 11 DBG_WWDG_STOP : Debug Window Watchdog stopped when Core is halted
    0: The window watchdog counter clock continues even if the core is halted
    1: The window watchdog counter clock is stopped when the core is halted
  8. Bit 10 DBG_RTC_STOP : RTC stopped when Core is halted
    0: The RTC counter clock continues even if the core is halted
    1: The RTC counter clock is stopped when the core is halted
  9. Bit 9 Reserved, must be kept at reset value.
  10. Bits 8:0 DBG_TIMx_STOP : TIMx counter stopped when core is halted (x=2..7, 12..14)
    0: The clock of the involved Timer Counter is fed even if the core is halted
    1: The clock of the involved Timer counter is stopped when the core is halted

37.16.5 Debug MCU APB2 Freeze register (DBGMCU_APB2_FZ)

The DBGMCU_APB2_FZ register is used to configure the MCU under Debug. It concerns APB2 peripherals.

This register is mapped on the external PPB bus at address 0xE004 200C

It is asynchronously reset by the POR (and not the system reset). It can be written by the debugger under system reset.

Address: 0xE004 200C

Only 32-bit access is supported.

POR: 0x0000 0000 (not reset by system reset)

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.DBG_TIM11_STOPDBG_TIM10_STOPDBG_TIM9_STOP
r/wr/wr/w
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.DBG_TIM8_STOPDBG_TIM1_STOP
r/wr/w

Bits 31:19 Reserved, must be kept at reset value.

Bits 18:16 DBG_TIMx_STOP : TIMx counter stopped when core is halted (x=9..11)

0: The clock of the involved Timer Counter is fed even if the core is halted

1: The clock of the involved Timer counter is stopped when the core is halted

Bits 15:2 Reserved, must be kept at reset value.

Bit 1 DBG_TIM8_STOP : TIM8 counter stopped when core is halted

0: The clock of the involved Timer Counter is fed even if the core is halted

1: The clock of the involved Timer counter is stopped when the core is halted

Bit 0 DBG_TIM1_STOP : TIM1 counter stopped when core is halted

0: The clock of the involved Timer Counter is fed even if the core is halted

1: The clock of the involved Timer counter is stopped when the core is halted

37.17 TPIU (trace port interface unit)

37.17.1 Introduction

The TPIU acts as a bridge between the on-chip trace data from the ITM and the ETM.

The output data stream encapsulates the trace source ID, that is then captured by a trace port analyzer (TPA).

The core embeds a simple TPIU, especially designed for low-cost debug (consisting of a special version of the CoreSight TPIU).

Figure 498. TPIU block diagram

Figure 498. TPIU block diagram. The diagram shows the internal architecture of the TPIU. It is divided into two clock domains: CLK domain and TRACECLKIN domain. In the CLK domain, there are two input blocks, ETM and ITM, which feed into two separate Asynchronous FIFOs. These FIFOs then feed into a TPIU formatter. The TPIU formatter is connected to a Trace out (serializer) block. The Trace out (serializer) block has four output pins: TRACECLKIN, TRACECK, TRACEDATA [3:0], and TRACESWO. An External PPB bus is connected to the TPIU formatter and the Trace out (serializer) block. The diagram is labeled 'ai17114' in the bottom right corner.
Figure 498. TPIU block diagram. The diagram shows the internal architecture of the TPIU. It is divided into two clock domains: CLK domain and TRACECLKIN domain. In the CLK domain, there are two input blocks, ETM and ITM, which feed into two separate Asynchronous FIFOs. These FIFOs then feed into a TPIU formatter. The TPIU formatter is connected to a Trace out (serializer) block. The Trace out (serializer) block has four output pins: TRACECLKIN, TRACECK, TRACEDATA [3:0], and TRACESWO. An External PPB bus is connected to the TPIU formatter and the Trace out (serializer) block. The diagram is labeled 'ai17114' in the bottom right corner.

37.17.2 TRACE pin assignment

The asynchronous mode requires 1 extra pin and is available on all packages. It is only available if using Serial Wire mode (not in JTAG mode).

Table 292. Asynchronous TRACE pin assignment

TPUI pin nameTrace synchronous mode
TypeDescription
TRACESWOOTRACE Async Data Output (1)
  1. 1. Refer to the Alternate function mapping table in the datasheet

The synchronous mode requires from 2 to 6 extra pins depending on the data trace size and is only available in the larger packages. In addition it is available in JTAG mode and in Serial Wire mode and provides better bandwidth output capabilities than asynchronous trace.

Table 293. Synchronous TRACE pin assignment
TPUI pin nameTrace synchronous mode
TypeDescription
TRACECKOTRACE Clock (1)
TRACED[3:0]OTRACE Sync Data Outputs (1)
Can be 1, 2 or 4.

1. Refer to the Alternate function mapping table in the datasheet

TPUI TRACE pin assignment

By default, these pins are NOT assigned. They can be assigned by setting the TRACE_IOEN and TRACE_MODE bits in the Debug MCU configuration register . This configuration has to be done by the debugger host.

In addition, the number of pins to assign depends on the trace configuration (asynchronous or synchronous).

To assign the TRACE pin, the debugger host must program the bits TRACE_IOEN and TRACE_MODE[1:0] of the Debug MCU configuration Register (DBGMCU_CR). By default the TRACE pins are not assigned.

This register is mapped on the external PPB and is reset by the PORESET (and not by the SYSTEM reset). It can be written by the debugger under SYSTEM reset.

Table 294. Flexible TRACE pin assignment
DBGMCU_CR registerPins assigned for:TRACE IO pin assigned
TRACE_IOENTRACE_MODE [1:0]PB3 /JTDO/ TRACESWOPE2/ TRACECKTRACED[0] (1)TRACED[1] (1)TRACED[2] (1)TRACED[3] (1)
0XXNo Trace (default state)Released (2)-
100Asynchronous TraceTRACESWO--Released (usable as GPIO)

Table 294. Flexible TRACE pin assignment (continued)

DBGMCU_CR registerPins assigned for:TRACE IO pin assigned
TRACE_IOENTRACE_MODE [1:0]PB3 /JTDO/ TRACESWOPE2/ TRACECKTRACED[0] (1)TRACED[1] (1)TRACED[2] (1)TRACED[3] (1)
101Synchronous Trace 1 bitTRACECKTRACED[0]---
110Synchronous Trace 2 bitReleased (2)TRACECKTRACED[0]TRACED[1]--
111Synchronous Trace 4 bitTRACECKTRACED[0]TRACED[1]TRACED[2]TRACED[3]

1. Refer to the Alternate function mapping table in the datasheets.

2. When Serial Wire mode is used, it is released. But when JTAG is used, it is assigned to JTDO.

Note: By default, the TRACECLKIN input clock of the TPIU is tied to GND. It is assigned to HCLK two clock cycles after the bit TRACE_IOEN has been set.

The debugger must then program the Trace Mode by writing the PROTOCOL[1:0] bits in the SPP_R (Selected Pin Protocol) register of the TPIU.

It then also configures the TRACE port size by writing the bits [3:0] in the CPSPS_R (Current Sync Port Size Register) of the TPIU:

37.17.3 TPIU formatter

The formatter protocol outputs data in 16-byte frames:

Note: Refer to the Arm ® CoreSight Architecture Specification v1.0 (Arm ® IHI 0029B) for further information

37.17.4 TPUI frame synchronization packets

The TPUI can generate two types of synchronization packets:

It is output periodically between frames.

In continuous mode, the TPA must discard all these frames once a synchronization frame has been found.

These packets are only generated in continuous mode and enable the TPA to detect that the TRACE port is in IDLE mode (no TRACE to be captured). When detected by the TPA, it must be discarded.

37.17.5 Transmission of the synchronization frame packet

There is no Synchronization Counter register implemented in the TPIU of the core. Consequently, the synchronization trigger can only be generated by the DWT . Refer to the registers DWT Control Register (bits SYNCTAP[11:10]) and the DWT Current PC Sampler Cycle Count Register.

The TPUI Frame synchronization packet (0x7F_FF_FF_FF) is emitted:

37.17.6 Synchronous mode

The trace data output size can be configured to 4, 2 or 1 pin: TRACED(3:0)

The output clock is output to the debugger (TRACECK)

Here, TRACECLKIN is driven internally and is connected to HCLK only when TRACE is used.

Note: In this synchronous mode, it is not required to provide a stable clock frequency.

The TRACE I/Os (including TRACECK) are driven by the rising edge of TRACLKIN (equal to HCLK). Consequently, the output frequency of TRACECK is equal to HCLK/2.

37.17.7 Asynchronous mode

This is a low cost alternative to output the trace using only 1 pin: this is the asynchronous output pin TRACESWO. Obviously there is a limited bandwidth.

TRACESWO is multiplexed with JTDO when using the SW-DP pin. This way, this functionality is available in all STM32F469xx and STM32F479xx packages.

This asynchronous mode requires a constant frequency for TRACECLKIN. For the standard UART (NRZ) capture mechanism, 5% accuracy is needed. The Manchester encoded version is tolerant up to 10%.

37.17.8 TRACECLKIN connection in STM32F469xx and STM32F479xx

In the STM32F469xx and STM32F479xx, this TRACECLKIN input is internally connected to HCLK. This means that when in asynchronous trace mode, the application is restricted to use to time frames where the CPU frequency is stable.

Note: Important: when using asynchronous trace: it is important to be aware that:

The default clock of the STM32F469xx and STM32F479xx MCUs is the internal RC oscillator. Its frequency under reset is different from the one after reset release. This is because the RC calibration is the default one under system reset and is updated at each system reset release.

Consequently, the trace port analyzer (TPA) should not enable the trace (with the TRACE_IOEN bit) under system reset, because a Synchronization Frame Packet will be issued with a different bit time than trace packets which will be transmitted after reset release.

37.17.9 TPIU registers

The TPIU APB registers can be read and written only if the bit TRCENA of the Debug Exception and Monitor Control Register (DEMCR) is set. Otherwise, the registers are read as zero (the output of this bit enables the PCLK of the TPIU).

Table 295. Important TPIU registers

AddressRegisterDescription
0xE0040004Current port sizeAllows the trace port size to be selected:
Bit 0: Port size = 1
Bit 1: Port size = 2
Bit 2: Port size = 3, not supported
Bit 3: Port Size = 4
Only 1 bit must be set. By default, the port size is one bit. (0x00000001)
0xE00400F0Selected pin protocolAllows the Trace Port Protocol to be selected:
Bit1:0=
00: Sync Trace Port Mode
01: Serial Wire Output - manchester (default value)
10: Serial Wire Output - NRZ
11: reserved

Table 295. Important TPIU registers (continued)

AddressRegisterDescription
0xE0040304Formatter and flush controlBits 31-9 = always '0
Bit 8 = TrigIn = always '1 to indicate that triggers are indicated
Bits 7-4 = always 0
Bits 3-2 = always 0
Bit 1 = EnFCont. In Sync Trace mode (Select_Pin_Protocol register bit1:0=00), this bit is forced to '1: the formatter is automatically enabled in continuous mode. In asynchronous mode (Select_Pin_Protocol register bit1:0 <> 00), this bit can be written to activate or not the formatter.
Bit 0 = always 0
The resulting default value is 0x102
Note: In synchronous mode, because the TRACECTL pin is not mapped outside the chip, the formatter is always enabled in continuous mode -this way the formatter inserts some control packets to identify the source of the trace packets).
0xE0040300Formatter and flush statusNot used in Cortex®-M4, always read as 0x00000008

37.17.10 Example of configuration

37.18 DBG register map

Table 296. DBG register map and reset values

Addr.Register313029282726252423222120191817161514131211109876543210
0xE004 2000DBGMCU_IDCODEREV_IDRes.Res.Res.Res.DEV_ID
Reset value (1)XXXXXXXXXXXXXXXXXXXXXXXXXXXX
0xE004 2004DBGMCU_CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.DBG_TIM7_STOPDBG_TIM6_STOPDBG_TIM5_STOPDBG_TIM8_STOPDBG_I2C2_SMBUS_TIMEOUTRes.Res.Res.Res.Res.Res.Res.Res.Res.TRACE_MODE [1:0]TRACE_Res.Res.DBG_STANDBYDBG_STOPDBG_SLEEP
Reset value00000000000
0xE004 2008DBGMCU_APB1_FZRes.Res.Res.Res.Res.DBG_CAN2_STOPDBG_CAN1_STOPReservedDBG_I2C3_SMBUS_TIMEOUTDBG_I2C2_SMBUS_TIMEOUTDBG_I2C1_SMBUS_TIMEOUTRes.Res.Res.Res.Res.Res.Res.Res.DBG_IWDG_STOPDBG_WWDG_STOPDBG_I2C3_SMBUS_TIMEOUTRes.Res.DBG_RTC_STOPDBG_TIM14_STOPDBG_TIM13_STOPDBG_TIM12_STOPDBG_TIM7_STOPDBG_TIM6_STOPDBG_TIM5_STOPDBG_TIM4_STOP
Reset value00000000000000000
0xE004 200CDBGMCU_APB2_FZRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.DBG_TIM11_STOPDBG_TIM10_STOPDBG_TIM9_STOPRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.DBG_TIM8_STOPDBG_TIM1_STOP
Reset value00000

1. The reset value is product dependent. For more information, refer to Section 37.6.1: MCU device ID code .