Keil Logo

Introduction Enable Serial Wire Trace

To enable Serial Wire Trace on STMicroelectronics STM32F2xx devices:

  • Connect ULINKplus to the board's Cortex Debug connector and to the host computer.
  • Enable the Trace Port Interface as described in the STM32F2xx Reference Manual, chapters Pinout and Debug Port Pins and TRACE Pin Assignment.
  • Configure µVision to capture trace data.

Enable the Trace Port Interface

  1. Create a text file, for example Trace.ini, and enter the following code:
    /*-------------------------------------------------------------------
    ** Define the function to enable the trace port
    **-----------------------------------------------------------------*/
    FUNC void EnableTPIU(void) {
    
      _WDWORD(0xE0042004, 0x00000020);    // Set asynchronous communication via DBGMCU_CR
    }
    
    /*-------------------------------------------------------------------
    ** Invoke the function at debugger startup
    **-----------------------------------------------------------------*/
    EnableTPIU();
    

    Use the _WDWORD command to configure the TRACE_IOEN and TRACE_MODE bits of the DBGMCU_CR register: _WDWORD(0xE0042004, 0x00000020);

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

    Configure the device for tracing

Configure µVision to capture trace data

  1. Open the dialog Options for Target — Debug.

    Select ULINKplus as the debugger adapter

  2. Enable Use, select ULINKplus Debugger, and click Settings to open the Target Driver Setup dialog.

    Configure the Serial Wire Debug mode

  3. Enable SWJ and select SW.
  4. Click the Trace tab.

    Set the Serial Wire Trace options

  5. Set Trace Enable.
  6. Enable Autodetect.
  7. The Core Clock must correspond to the device configuration.

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

Note

  • Always synchronize the settings in the *.ini file with the settings in the Target Driver Setup—Trace Port dialog.
  • Use the examples delivered with the Keil board MCBSTM32F200 as a reference.
  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.