본문 바로가기
MCU/STM32

ST-LINK의 SWO핀을 이용한 printf 함수 사용

by mokhwasomssi 2021. 5. 13.

개발환경 : STM32CubeIDE

MCU : stm32f411ceu6

디버거 : ST-LINK/V2

프로젝트 타입: STM32Cube

프로젝트 리포지토리 : https://github.com/mokhwasomssi/STM32Cube_Example_Project.git

 

mokhwasomssi/STM32Cube_Example_Project

Contribute to mokhwasomssi/STM32Cube_Example_Project development by creating an account on GitHub.

github.com

 


 

1. Debug : Trace Asynchronous Sw

 

2. Run → Debug Configuration → STM32 Cortex-M C/C++ Application → Debugger

 

3. Serial Wire Viewer (SWV) enable. 사용 중인 mcu의 Core Clock 입력.

 

4. #include <stdio.h> 추가
main.c 에 _write 함수 작성
while 문에 printf 함수 넣음

int _write(int file, char *ptr, int len)
{
	for(int i = 0; i < len; i++)
	{
		ITM_SendChar(*ptr++);
	}
	return len;
}

 

5. Debug(F11) -> SWV ITM Data Console 창 띄움

 

5. 타임 스태프  활성화 -> ITM 활성포트 0에 체크

 

6. Start Trace -> Resume (F8)