Keil Logo

Enable Micro Trace Buffer (MTB)

To enable CoreSight MTB tracing on Freescale MKL25Z devices:

  • Connect ULINKpro to the board's Cortex Debug connector and to the host computer.
  • Configure µVision to capture MTB trace data.

Configure µVision to capture MTB trace data.

  1. Create a text file, for example DBG_MTB.ini, and enter the following code:
    ** Define the function to enable the trace port
    FUNC void MTB_Setup (void) {
      unsigned long position;
      unsigned long master;
      unsigned long watermark;
      unsigned long _flow;
      master     = 0x80000008;
      position   = 0x20000000;
      _flow      = 0x00000000;
      position  &= 0xFFFFFFF8;              // Mask POSITION.POINTER field
      watermark  = position + ((16 << (master & 0x1F)) - 32);
      _flow     |= watermark;
      _WDWORD(0xF0000004, 0x00000000);      // MASTER
      _WDWORD(0xF0000000, position);        // POSITION
      _WDWORD(0xF0000008, _flow);           // FLOW
      _WDWORD(0xF0000004, master);          // MASTER
    ** Invoke the function at debugger startup

    Use the _WDWORD command to configure the device.

  2. Open the dialog Options for Target - Debug and insert DBG_MTB.ini into the field Initialization File.

    Configure the device for tracing

  3. Also see Enabling MTB Trace on Cortex-M0+/M23 devices for additional details.

Start the debugging session and verify the captured trace data with a µVision window.


  • Use the examples delivered with the Freescale board FRDM-KL25Z as a reference.
  • MTB tracing works in Serial Wire Debug as well as in JTAG Debug mode.
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.