4.5.2 Overview

When enabled, the MTB records changes in program flow reported by the Cortex-M0+ processor over the execution trace interface shared between the Cortex-M0+ processor and the CoreSight MTB-M0+. This information is stored as trace packets in SRAM by the MTB. An off-chip debugger can extract the trace information using the Debug Access Port to read the trace data from SRAM. The debugger can then reconstruct the program flow from this information.

The MTB simultaneously stores trace information in SRAM while providing the processor with access to SRAM. The MTB ensures that trace write accesses have priority over processor accesses.

The execution trace packet consists of a pair of 32-bit words generated by the MTB when it detects a non-sequential change in the processor PC value. A non-sequential PC change can occur during branch instructions or exception entry. Refer to the CoreSight MTB-M0+ Technical Reference Manual for details on the MTB execution trace packet format.

Tracing is enabled when the MASTER.EN bit in the Host Trace Control Register set to 1. There are various ways to set the bit to ‘1’ to start tracing or to ‘0’ to stop tracing. Refer to the CoreSight Cortex-M0+ Technical Reference Manual for details on starting and stopping trace operations, as well as for a detailed description of the MTB MASTER register. The MTB can be programmed to stop tracing automatically when the memory reaches a specified watermark level, or to start or stop tracing by directly writing to the MASTER.EN bit. If the watermark mechanism is not used and the trace buffer overflows, the buffer wraps around and overwrites previous trace packets.

The base address of the MTB registers is 0x41008000, and this address is also listed in the CoreSight ROM table. The offset of each register from the base address is fixed, as defined by the CoreSight MTB-M0+ Technical Reference Manual. The MTB has four programmable registers that control the behavior of the trace features:

  • POSITION: Contains the trace write pointer and the wrap bit
  • MASTER: Contains the main trace enable bit and other trace control fields
  • FLOW: Contains the WATERMARK address and the AUTOSTOP and AUTOHALT control bits
  • BASE: Indicates where the SRAM is located in the processor memory map. This register is provided to enable auto-discovery of the MTB SRAM location, by a debug agent.

Refer to the CoreSight MTB-M0+ Technical Reference Manual for a detailed description of these registers.