This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to use the Debug (Printf) Viewer

Hello,

I am new to the Keil interface and I want to configure the interface for using the Debug (Printf) Viewer. I am using the uVision 5.14. I am using a ST-Link as a debugger and I am following the Keil User’s Guide: www.keil.com/.../dapdebug_trace_itm_viewer.htm

I configured properly the ITM Port 0 (Step 4 of the user’s guide) and placed the printf function (Step 3). But I am having problems to introduce the register definitions and functions (Steps 1 and 2):

---------------------------------------------------------------
1. Add ITM Port register definitions to the source code.
#define ITM_Port8(n) (*((volatile unsigned char *)(0xE0000000+4*n)))
#define ITM_Port16(n) (*((volatile unsigned short*)(0xE0000000+4*n)))
#define ITM_Port32(n) (*((volatile unsigned long *)(0xE0000000+4*n)))

#define DEMCR (*((volatile unsigned long *)(0xE000EDFC)))
#define TRCENA 0x01000000

2. Add an fputc function to the source code that writes to the ITM Port 0 register. The fputc function enables printf to output messages.
struct __FILE { int handle; /* Add whatever is needed */ };
FILE __stdout;
FILE __stdin;

int fputc(int ch, FILE *f) { if (DEMCR & TRCENA) { while (ITM_Port32(0) == 0); ITM_Port8(0) = ch; } return(ch);
---------------------------------------------------------------

The compiler complains about that the FILE type is unknown. Where is the correct file to place this code?

Is there any example code to show how it works?

Many thanks in advance,

Albert

Parents Reply Children
No data