2024-06-25 10:14 AM
#include <SWOStream.h>
SWOStream s(2000000, SWO_Async, 0, false); //swoEnable = false
void setup() {
delay(150);
}
void loop() {
s.print("Serial is alive!");
delay(500);
}
Solved! Go to Solution.
2024-06-26 11:23 AM - edited 2024-06-26 02:21 PM
That looks just like the cheap chinese ones. I know because I had one and to avoid the risk of damaging it during modding, I just spent a few bucks and got a better quality one which just worked. Are you sure you bought that from ST?
https://www.eevblog.com/forum/microcontrollers/quick-hack-to-get-swo-on-st-link-clones/
2024-06-25 02:22 PM
It needs to know the speed your MCU is clocking and the speed the SWCLK is clocking.
Here it's assuming 2 MHz, going to depend on the settings you have in STM32 Cube Programmer
2024-06-25 02:34 PM
@vs13 To see SWO output you don't need any sketches etc. The debugger or CubeProgrammer will set up the SWO automatically. All it needs to know is the SystemCoreClock value. Just provide it the value, call ITM_SendChar (or redirect printf to SWO) and enjoy.
2024-06-26 07:15 AM
@Pavel A. wrote:All it needs to know is the SystemCoreClock value. Just provide it the value, call ITM_SendChar (or redirect printf to SWO) and enjoy.
I can't find the SystemCoreClock value of this board anywhere in its documentation. Do you know where I could look for it?
2024-06-26 07:48 AM
@Tesla DeLorean wrote:It needs to know the speed your MCU is clocking and the speed the SWCLK is clocking.
Here it's assuming 2 MHz, going to depend on the settings you have in STM32 Cube Programmer
There is a clock speed of 168 MHz printed on the board that I've just changed the code and my settings to use, but I'm still not getting the output that I expect. I've attached my settings.
2024-06-26 07:49 AM
It should be a variable in your system all the same, but the SWOStream implementation has it as a default parameter in any case
https://github.com/koendv/SerialWireOutput/blob/master/SWOStream.h#L29
Typically the Debug Pod sets the baud rate knowing the connection speed it has with the device, and the MCU clock it's dividing down to meet that.
2024-06-26 09:36 AM
You need a Debugger Pod like an ST-LINK or J-LINK to connect to the SWD Debugging ports, and SWV Serial channel.
You can't manifest this via the USB DFU connection.
You'd want to attach a 10-pin debug header to the board to facilitate an SWD connection
2024-06-26 10:03 AM - edited 2024-06-30 11:02 AM
Just to be sure :
1. Are you using an ST-LINK (or clone) which provides an external SWO pin? the most common cheap chinese knock-off ones do not, unless you physicall mod them (cut a trace, run a jumper wire from the chip to the connector).
2. If your ST-LINK support the SWO pin, did you connect the SWO pin on your board to the appropriate pin on your ST-LINK? The SWO ping is not needed for debug/programming, but SWO is required for using the SWV facilities in CubeIDE.
2024-06-26 11:03 AM - edited 2024-06-26 11:03 AM
@BarryWhit wrote:Just to be sure :
1. Are you using an ST-LINK (or clone) which supports SWO, the most common cheap chinese knock-off ones do not support SWO out of the box, unless you install some jumper wires.
2. Did you connect the SWO pin on your board to the appropriate pin on your ST-LINK? This is a third optional debug pin, needed specifically for SWV.
I've attached a picture of my ST-Link. It should be genuine as I bought it through ST's website, but I don't see a SWO pin on the ST-Link or my STM32F405.
2024-06-26 11:23 AM - edited 2024-06-26 02:21 PM
That looks just like the cheap chinese ones. I know because I had one and to avoid the risk of damaging it during modding, I just spent a few bucks and got a better quality one which just worked. Are you sure you bought that from ST?
https://www.eevblog.com/forum/microcontrollers/quick-hack-to-get-swo-on-st-link-clones/