cancel
Showing results for 
Search instead for 
Did you mean: 

SWV Data Trace Timeline Graph Error

diktril
Associate III

I am making use of the SWV to plot a 5Hz Sine Wave.

The output on the plotter does not resemble a sine wave:

Screenshot 2026-03-27 at 22.15.41.png
Any recommendations to fix this?

6 REPLIES 6
AScha.3
Super User

How did you set the scala ?

->

To set scaling for SWV plots in STM32CubeIDE, use the toolbar icons in the SWV graph view: switch between seconds and cycles for the X-axis, use the Y-axis best fit button, and zoom in/out as needed. These features allow you to tailor the plot scaling for effective data analysis during debugging.

 

1. Setting Scaling for SWV Plots

To set scaling for SWV (Serial Wire Viewer) plots in STM32CubeIDE, you can use the dedicated toolbar icons available in the SWV graph views. These controls allow you to customize both the X-axis (time base) and Y-axis scaling for optimal data visualization:

  • Switch between seconds and cycle scale: Click the clock toolbar button to toggle the X-axis between time (seconds) and processor cycles.
  • Adjust the Y-axis to best fit: Click the Y-axis toolbar button to automatically fit the Y-axis to the current data range.
  • Zoom in and out: Use the [+] and [–] toolbar buttons to zoom the X-axis (time base) in or out. Note that the zoom range is limited during active debugging, but more detailed zoom is available when the debug session is paused.

2. Adjusting Y-Axis and Time Base Scaling

  • Y-Axis Scaling: Use the "Adjust the Y-axis to best fit" toolbar button to automatically scale the Y-axis to fit your data.
  • Time Base (X-Axis) Scaling: The default display is in seconds, but you can switch to cycles using the clock icon. Zoom in and out on the time base using the respective toolbar buttons. More detailed zoom is possible when the debug session is paused.

3. Toolbar Controls for SWV Plots

The SWV graph view toolbar provides the following controls for scaling and visualization:

  • Save graph as image
  • Switch between seconds and cycles
  • Best fit Y-axis
  • Zoom in/out

These controls are accessible directly from the SWV graph view, making it easy to interactively explore and analyze your trace data.

 

If you feel a post has answered your question, please click "Accept as Solution".
Andrew Neil
Super User

Are you sure that the data being sent actually represents a sinewave?

Have you tried sending the data over a UART, and capturing in a terminal?

Please show your sinewave generation code

How to insert source code

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Function I am calling in while loop inside main.c

  static void plotInputSignal(void)
  {
	  int i;
	  for (i = 0; i < HZ_5_SIG_LEN; i++)
	  {
		  g_in_sig_sample = _5hz_signal[i];
	  }
  }


5Hz samples (301):

float _5hz_signal[HZ_5_SIG_LEN]=
{
	0,0.30902,0.58779,0.80902,0.95106,1,0.95106,0.80902,0.58779,0.30902,1.2246e-16,-0.30902,-0.58779,-0.80902,-0.95106,-1,-0.95106,-0.80902,-0.58779,-0.30902,-2.4493e-16,0.30902,0.58779,0.80902,0.95106,1,0.95106,0.80902,0.58779,0.30902,3.6739e-16,-0.30902,-0.58779,-0.80902,-0.95106,-1,-0.95106,-0.80902,-0.58779,-0.30902,-4.8986e-16,0.30902,0.58779,0.80902,0.95106,1,0.95106,0.80902,0.58779,0.30902,6.1232e-16,-0.30902,-0.58779,-0.80902,-0.95106,-1,-0.95106,-0.80902,-0.58779,-0.30902,-7.3479e-16,0.30902,0.58779,0.80902,0.95106,1,0.95106,0.80902,0.58779,0.30902,-2.6955e-15,-0.30902,-0.58779,-0.80902,-0.95106,-1,-0.95106,-0.80902,-0.58779,-0.30902,-9.7972e-16,0.30902,0.58779,0.80902,0.95106,1,0.95106,0.80902,0.58779,0.30902,1.1022e-15,-0.30902,-0.58779,-0.80902,-0.95106,-1,-0.95106,-0.80902,-0.58779,-0.30902,-1.2246e-15,0.30902,0.58779,0.80902,0.95106,1,0.95106,0.80902,0.58779,0.30902,-2.2056e-15,-0.30902,-0.58779,-0.80902,-0.95106,-1,-0.95106,-0.80902,-0.58779,-0.30902,-1.4696e-15,0.30902,0.58779,0.80902,0.95106,1,0.95106,0.80902,0.58779,0.30902,-1.9607e-15,-0.30902,-0.58779,-0.80902,-0.95106,-1,-0.95106,-0.80902,-0.58779,-0.30902,5.3909e-15,0.30902,0.58779,0.80902,0.95106,1,0.95106,0.80902,0.58779,0.30902,5.3897e-15,-0.30902,-0.58779,-0.80902,-0.95106,-1,-0.95106,-0.80902,-0.58779,-0.30902,-9.0649e-15,0.30902,0.58779,0.80902,0.95106,1,0.95106,0.80902,0.58779,0.30902,5.6346e-15,-0.30902,-0.58779,-0.80902,-0.95106,-1,-0.95106,-0.80902,-0.58779,-0.30902,-2.2044e-15,0.30902,0.58779,0.80902,0.95106,1,0.95106,0.80902,0.58779,0.30902,5.8795e-15,-0.30902,-0.58779,-0.80902,-0.95106,-1,-0.95106,-0.80902,-0.58779,-0.30902,-2.4493e-15,0.30902,0.58779,0.80902,0.95106,1,0.95106,0.80902,0.58779,0.30902,-9.8096e-16,-0.30902,-0.58779,-0.80902,-0.95106,-1,-0.95106,-0.80902,-0.58779,-0.30902,4.4112e-15,0.30902,0.58779,0.80902,0.95106,1,0.95106,0.80902,0.58779,0.30902,6.3694e-15,-0.30902,-0.58779,-0.80902,-0.95106,-1,-0.95106,-0.80902,-0.58779,-0.30902,-2.9392e-15,0.30902,0.58779,0.80902,0.95106,1,0.95106,0.80902,0.58779,0.30902,-4.911e-16,-0.30902,-0.58779,-0.80902,-0.95106,-1,-0.95106,-0.80902,-0.58779,-0.30902,3.9213e-15,0.30902,0.58779,0.80902,0.95106,1,0.95106,0.80902,0.58779,0.30902,-7.3516e-15,-0.30902,-0.58779,-0.80902,-0.95106,-1,-0.95106,-0.80902,-0.58779,-0.30902,-3.429e-15,0.30902,0.58779,0.80902,0.95106,1,0.95106,0.80902,0.58779,0.30902,-1.238e-18,-0.30902,-0.58779,-0.80902,-0.95106,-1,-0.95106,-0.80902,-0.58779,-0.30902,-1.0779e-14

};



Thank you for the suggestion. Tried it, but it does not work unfortunately. 

diktril
Associate III

Screenshot 2026-03-30 at 22.37.09.png
In this example I am incrementing a variable in the while loop with a delay of 500ms.

Wasilewski.Piotr
Associate III

Hey @diktril have you tried MCUViewer? It seems it might be the right tool for you - it can visualize both SWD data using STLink and SWO trace data. If you're interested here're the docs: https://docs.mcuviewer.com