SAMD21 Micro Trace Buffer (MTB) Overview

The Micro Trace Buffer (MTB) provides program execution trace capability. It records the Program Counter (PC) value of the command line being executed which is known as trace data since it shows the trail of executed code. Each executed program counter value is stored in SRAM circular buffer.

The diagram below shows the main interfaces on the MTB and how they are connected in a simple Arm® Cortex®-M0+ based system.

MTB.png

The MTB simultaneously stores trace information into the SRAM and gives the processor access to it. The MTB ensures that trace write accesses have priority over processor accesses.

The execution trace packet consists of a pair of 32-bit words that the MTB generates when it detects the processor PC value changes non-sequentially. A non-sequential PC change can occur during branch instructions or during exception entry. When a jump is made it records both the program counter of where the program was and where the program counter jumped to.

The processor can cause a trace packet to be generated for any instruction.

The MTB can be programmed to stop tracing automatically when the memory fills to a specified watermark level, or to start, or stop tracing by writing directly to the MASTER.EN bit. If the watermarking mechanism is not being used and the trace buffer overflows, the buffer wraps around overwriting previous trace packets in a First-In-First-Out (FIFO) arrangement.

Debugging a Trace

An off-chip debugger tool can extract the trace information using the Debug Access Port to read the trace information from the SRAM. The debugger can then reconstruct the program flow from this information. This can help diagnose programs that run outside the intended execution due to coding or logic errors.

 Learn More

 
MTB Configuration
Learn more >
 
MTB Example Project
Learn more >
© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.