SWV Not Working - tried everything, then check the TRACE Clock source!
If you're still not seeing any "ITM printf()" output in the SWV ITM Data Console and you've checked the following;
- the SWO signal is connected to the ST Link
- provided a _write() function that calls ITM_SendChar()
- ticked Enable Port 0 in Seral Wire Viewer settings
- ticked the Serial Wire Viewer Enable box in the Debug configuration
- set the Core Clock (MHz) frequency to the system core frequency in the Debug configuration
Then I can suggest one more thing to check, this had me stuck for a while until I found out why.
The ITM/SWV Unit is not clocked directly from the System Clock, its actually clocked from the PLL1R output. If you scroll down on the CubeMX Clock Configuration page, you'll find the TRACE Clock Mux, its set to PLL1R as the source.

Go back up to the PLL1 block and see what the DIVR1 output clock frequency is - this is the Trace/SWV clock frequency you need to use.

In my design, I had changed the PLL1R divider as I needed an different frequency for another peripheral, this stopped the SWV ITM data working because the frequency no longer matched the debug configuration.
Now setting the Core Clock (MHz) frequency to the PLL1R frequency in the Debug configuration got the SWV ITM Trace working again.

