EasyManua.ls Logo

GigaDevice Semiconductor GD-Link V2 - Table 3-2. Trace Mode Enable; Table 3-3. Printf Retarget

Default Icon
34 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
GD-Link V2 Adapter User Guide
29
manuals of each series of MCUs.
Table 3-4. Trace mode enable
DBG_CTL |= DBG_CTL_TRACE_IOEN;
In the code, the serial printf output is redirected to the ITM output, and the added code is
shown in Table 3-5. Printf retarget.
Table 3-5. Printf retarget
#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
int fputc(int ch, FILE *f)
{
if (DEMCR & TRCENA)
{
while (ITM_Port32(0) == 0) {};
ITM_Port8(0) = ch;
}
return(ch);
}
Enter the debugging interface, select "View" -> "Serial Windows" -> "Debug(printf)Viewer",
open the serial port printing interface, run the code at full speed, and the printed information
will be displayed in the Debug(printf)Viewer window. The Debug(printf)Viewer window in is
shown in Figure 3-31. Debug (printf) viewer window in KEIL.

Table of Contents