Skip to main content
Visitor II
December 19, 2022
Solved

STM32F103 not working SWV

  • December 19, 2022
  • 5 replies
  • 3336 views

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

    This topic has been closed for replies.
    Best answer by Tesla DeLorean

    PB3/SWO pin connectivity required.​

    5 replies

    Graduate II
    December 19, 2022

    PB3/SWO pin connectivity required.​

    Visitor II
    February 8, 2024

    how we can connect PB3/SWO pin.

    EBurk.1Author
    Visitor II
    December 21, 2022

    Ogh, thank a lot. My fault...

    EBurk.1Author
    Visitor II
    December 26, 2022

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

    Super User
    December 26, 2022

    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

    EBurk.1Author
    Visitor II
    December 26, 2022

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