cancel
Showing results for 
Search instead for 
Did you mean: 

Use Serial Wire Viewer on Cube Programmer for STM32 F405 Feather

vs13
Associate
I want to read the serial output from the STM32 F405 Feather using the SWV on Cube Programmer, but I do not receive Serial output from the board. I am running the .hex file from this Arduino sketch on the board:

 

#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);
}

 

I have searched through the board documentation over and over and I can't find what clock frequency to use in my program and in the SWV terminal on Cube Programmer, so if anyone could point me in the right direction, it would be appreciated!
1 ACCEPTED SOLUTION

Accepted Solutions

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/

 

- If you feel a post has answered your question, please click "Accept as Solution".
- Once you've solved your issue, please consider posting a summary with any additional details you've learned. Your new knowledge may help others in the future.

View solution in original post

12 REPLIES 12

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Pavel A.
Evangelist III

@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.

 


@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?


@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.

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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

f405_swd_debug_header.jpg

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
BarryWhit
Senior

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.

- If you feel a post has answered your question, please click "Accept as Solution".
- Once you've solved your issue, please consider posting a summary with any additional details you've learned. Your new knowledge may help others in the future.

@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. 

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/

 

- If you feel a post has answered your question, please click "Accept as Solution".
- Once you've solved your issue, please consider posting a summary with any additional details you've learned. Your new knowledge may help others in the future.