cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103 not working SWV

EBurk.1
Associate II

Hello here,

I tried to use SWV for debug plotting in my project.

I have STM32F103TBU6 and ST-Link V2.

0693W00000WLIjiQAH.pngI turn on Trace Async Sw:

0693W00000WLIkbQAH.pngMy clock:

0693W00000WLIlAQAX.pngIn main.c I defined "stdio.h" and _write func:

/* USER CODE BEGIN 0 */
 
int _write(int file, char *ptr, int len) {
	int i = 0;
	for (i = 0; i < len; i++) {
		ITM_SendChar((*ptr++));
	}
	return len;
}
 
uint8_t count = 0;
 
/* USER CODE END 0 */

After I made while cycle with printf:

/* USER CODE END 0 */
 
/**
 * @brief  The application entry point.
 * @retval int
 */
int main(void) {
	/* USER CODE BEGIN 1 */
 
	/* USER CODE END 1 */
 
	/* MCU Configuration--------------------------------------------------------*/
 
	/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
	HAL_Init();
 
	/* USER CODE BEGIN Init */
 
	/* USER CODE END Init */
 
	/* Configure the system clock */
	SystemClock_Config();
 
	/* USER CODE BEGIN SysInit */
 
	/* USER CODE END SysInit */
 
	/* Initialize all configured peripherals */
	MX_GPIO_Init();
	MX_DMA_Init();
	MX_I2C1_Init();
	MX_USART1_UART_Init();
	MX_SPI1_Init();
	/* USER CODE BEGIN 2 */
 
	while (1) {
		count++;
		printf("Hi count=%d\r\n", count);
		HAL_Delay(250);
	}

Setting up debug:

0693W00000WLIkXQAX.pngStart debug:

STMicroelectronics ST-LINK GDB server. Version 7.0.0
Copyright (c) 2022, STMicroelectronics. All rights reserved.
 
Starting server with the following options:
        Persistent Mode            : Disabled
        Logging Level              : 1
        Listen Port Number         : 61234
        Status Refresh Delay       : 15s
        Verbose Mode               : Disabled
        SWD Debug                  : Enabled
        InitWhile                  : Enabled
 
Waiting for debugger connection...
Debugger connected
Waiting for debugger connection...
Debugger connected
Waiting for debugger connection...
      -------------------------------------------------------------------
                       STM32CubeProgrammer v2.11.0                  
      -------------------------------------------------------------------
 
 
 
Log output file:   C:\Users\wooffie\AppData\Local\Temp\STM32CubeProgrammer_a09776.log
ST-LINK SN  : 404219003213344A414D4E00
ST-LINK FW  : V2J37S7
Board       : --
Voltage     : 3.23V
SWD freq    : 4000 KHz
Connect mode: Under Reset
Reset mode  : Hardware reset
Device ID   : 0x410
Revision ID : Rev X
Device name : STM32F101/F102/F103 Medium-density
Flash size  : 64 KBytes
Device type : MCU
Device CPU  : Cortex-M3
BL Version  : --
 
 
 
Memory Programming ...
Opening and parsing file: ST-LINK_GDB_server_a09776.srec
  File          : ST-LINK_GDB_server_a09776.srec
  Size          : 27.70 KB 
  Address       : 0x08000000 
 
 
Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 27]
Download in Progress:
 
 
File download complete
Time elapsed during download operation: 00:00:01.754
 
 
 
Verifying ...
 
 
 
 
Download verified successfully 

Now SWV:

0693W00000WLInpQAH.pngPressing "Start Trace" and resume code.

And I see nothing in SWV tabs =(

What wrong in my program?

With best regards,

Egor

1 ACCEPTED SOLUTION

Accepted Solutions

PB3/SWO pin connectivity required.​

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

View solution in original post

6 REPLIES 6

PB3/SWO pin connectivity required.​

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

Ogh, thank a lot. My fault...

EBurk.1
Associate II

This programmer should be enough for SWV trace? I can't find some more info about it :p0693W00000Y6s1GQAR.jpg

AScha.3
Chief II

if you can solder a thin wire - just mod your old stlinkV2 :

https://lujji.github.io/blog/stlink-clone-trace/

works fine.

here statistics:

0693W00000Y6sYFQAZ.png

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

Yes, I will do it. But I need "plan b" if it wont work as well. As I understand in ST-Link as shown upper have SWO and JNRST pins, right? And I can use it for SWV Data Trace...

how we can connect PB3/SWO pin.