Keil Logo

Enable 4-Pin Trace (ETM)

To enable CoreSight ETM tracing on Freescale MK70FN1M devices:

  • Connect ULINKpro to the board's Cortex Debug+ETM connector and to the host computer.
  • Enable the Trace Port Interface.
  • Configure µVision to capture ETM trace data.

Enable the Trace Port Interface

  1. Create a text file, for example K70_TracePort.ini, and enter the following code:
    /*-------------------------------------------------------------------
    ** Define the function to enable the trace port
    **-----------------------------------------------------------------*/
    FUNC void SetupTrace(void) {
    
      _wDWORD(0x40048038,(_RDWORD(0x40048038) | 0x00000200));      // SIM_SCGC5  : Enable PORT A clock
      _wDWORD(0x40048004,(_RDWORD(0x40048004) | 0x00001000));      // SIM_SOPT2  : Trace Clock Source is set as "Core/system clock"
      _wDWORD(0x40048068,(_RDWORD(0x40048068) & 0xFFFFFFF0));      // SIM_CLKDIV4: Set TRACEDIV = b000 & TRACEFRAC = b0
                                                                   // Note: Do not change the value of SIM_CLKDIV4[0..3] in your application!
      _wDWORD(0x40049018, 0x00000740);  // PTA5: TraceClock, High drive strength
      _wDWORD(0x4004901C, 0x00000740);  // PTA6: TRACED3   , High drive strength
      _wDWORD(0x40049020, 0x00000740);  // PTA7: TRACED2   , High drive strength
      _wDWORD(0x40049024, 0x00000740);  // PTA8: TRACED1   , High drive strength
      _wDWORD(0x40049028, 0x00000740);  // PTA9: TRACED0   , High drive strength
    }
    
    /*-------------------------------------------------------------------
    ** Invoke the function at debugger startup
    **-----------------------------------------------------------------*/
    SetupTrace();
    
    /*-------------------------------------------------------------------
    ** Execute upon software RESET
    **-----------------------------------------------------------------*/
    FUNC void OnResetExec(void)  {
      SetupTrace();
    }
    

    Use the _WDWORD command to configure the device.

    The special function OnResetExec() executes upon software RESET. Refer to TPUI Initialization after RESET (Cortex-M) for details.

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

    Configure the device for tracing

Configure µVision to capture ETM trace data

  1. Enable Use, select ULINK Pro Cortex Debugger, and click Settings to open the Target Driver Setup dialog.

    Select ULINKpro as the debugger adapter

  2. Click the Trace tab.

    Options for ETM trace

  3. The Core Clock must correspond to the device configuration.
  4. Set Trace Port to Sync Trace Port with 4-bit Data.
  5. Set Trace Enable and ETM Trace Enable.
  6. Optionally, enable Unlimited Trace to navigate through the complete data stream history. Make sure to enable this option when measuring the system's energy consumption with PowerScale.

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

Note

  • Use the examples delivered with the Freescale board TWR-K70FN1M as a reference.
  • ETM 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.