cancel
Showing results for 
Search instead for 
Did you mean: 

Blue and Black Pill SWO debugging

mkigor
Associate

Split from STM32H5 SWO debugging.


I want use SWO pin like standalone debug. Send data by "ITM_SendChar('A');" and want to read data from SWO pin by USB-UART dongle, SWO pin => Rx pin UART-USB on PC.

I try blue and black pill (STM32F103 and STM32F411), in stm32 cube ide I configured SysremCore->SYS->Debug: Trace Asynchronus Sw. In "Debug configuration" is Enable for SWV and clock core 8Mhz (SYSCLK and HCLK = 8MHz).

In main sycle:

  while (1)
  {
    /* USER CODE END WHILE */
	  HAL_GPIO_TogglePin(Led_GPIO_Port, Led_Pin);
	  HAL_Delay(1000);
	for (int i = 0; i < 10000; ++i) ITM_SendChar('A');
	  HAL_GPIO_TogglePin(Led_GPIO_Port, Led_Pin);
	  HAL_Delay(1000);
    /* USER CODE BEGIN 3 */
  }

LED is blinking, but SWO pin out is NO SIGNAL (Checking by oscillograph).
Where is it possible problem?

8 REPLIES 8
Andrew Neil
Super User

Note that Blue & Black Pills are not ST products, and likely do not have genuine STM32 chips.

In the other thread@AScha.3 said that it's important to end your output with \r\n - did you try that?

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.
mfgkw
Associate III

you wrote:

> SWO pin => Rx pin UART-USB on PC

Are you sure this is correct?

I would expect to send from STM32-SWO via a pin labeled Tx or TxD to the PC. Maybe you want to double check the doc of your USB converter.


@mfgkw wrote:

I would expect to send from STM32-SWO via a pin labeled Tx or TxD to the PC


Really?

SWO = Serial Wire Output - so I'd expect it to go to RX (an input) on the PC (a DTE) ?

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.
mfgkw
Associate III

It will depend on how the developer of the converter looks on its baby.

The doc should tell...

TDK
Super User

> want to read data from SWO pin by USB-UART dongle, SWO pin => Rx pin UART-USB on PC.

The SWO signal is not a UART signal. This has no hope of working.

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

>and want to read data from SWO pin by USB-UART dongle, SWO pin => Rx pin UART-USB on PC.

This wont work.

Its more complex, than you are thinking : 

AScha3_3-1757523226349.png

 

+

AScha3_2-1757523084230.png

 

AScha3_0-1757522635139.png

You can connect with the CubeProgrammer -> ST-link -> to the ITM :  then see SWV  -> SWO output:

AScha3_1-1757522764415.png

+

>want to read data .. by USB-UART dongle, .. pin => Rx pin UART-USB on PC.

If you just want serial "debug" messages, use an UART at "some speed" .(I use 3 Mbit for this.)

Or the USB , as CDC device , so you can connect to a PC /USB directly. 

 

 

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

@TDK wrote:

The SWO signal is not a UART signal. 


In principle, it could be:

https://developer.arm.com/documentation/ddi0314/h/Serial-Wire-Output/SWO-trace-port/Physical-pin-protocol#:~:text=Manchester%20encoding%20example-,UART%20encoding,bit%20%5B11%5D%20of%20the%20Device%20ID%20Register%2C%200xFC8%2C%20is%20set,-.%20It%20is%20enabled

Do (any) STM32 support that ?

@mkigor Generally, it's connected to the debug probe; eg, ST-Link.

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.

>Do (any) STM32 support that ?

Yes.  On the "clone" ST-link V2 just need to connect to PB7 , UART1 Rx , to get the SWO data.

(The pic i showed, with CubeProgrammer connected to a H743 cpu showing SWV data, is made with an modified 

ST-link V2 , working 100% reliably at 2 Mbit. With a ST-link V3 higher speed is no problem.)

here with cmsis-DAP , also STM32F103 cpu :

AScha3_0-1757526247105.png

 

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