2017-01-02 03:42 AM
Posted on January 02, 2017 at 12:42
I'm unable to get the printf output in the keil µVision IDE, so I need a
https://community.st.com/tags♯/?tags=checklist
to know if my setup is correct.
In the Keil project, I configured ST-Link Trace with Core Clock 32Mhz and all ITM port ticked (only number 0 needed, perhaps ?).
I run the debugger with the 'printf window' open.
I tried:
And nothing shows in the printf window. Is there something I missed to check?
#checklist
Solved! Go to Solution.
2017-01-02 06:57 AM
It is where the trace data comes out, so yes.
For printf() to work in Keil you must supply supporting routines to use ITM_SendChar()
//******************************************************************************
// Rough SWV support in Keil, requires PB3/SWO to be connected to debugger
//******************************************************************************
#include <rt_misc.h>
#pragma import(__use_no_semihosting_swi)
struct __FILE { int handle; /* Add whatever you need here */ };
FILE __stdout;
FILE __stdin;
int fputc(int ch, FILE *f)
{
ITM_SendChar(ch);
return(ch);
}
int fgetc(FILE *f)
{
char ch;
ch = 1;
return((int)ch);
}
int ferror(FILE *f)
{
/* Your implementation of ferror */
return EOF;
}
void _ttywrch(int ch)
{
ITM_SendChar(ch);
}
void _sys_exit(int return_code)
{
label: goto label; /* endless loop */
}
//******************************************************************************
�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
2017-01-02 03:50 AM
Is PB3 SWO connected to the ST-LINK?
2017-01-02 06:35 AM
Thanks for the reply and happy new year.
No, PB3 is not connected.
According to my doc, only PB4 (TRST), PA14 (SWCLK) and PA13 (SWIO) are connected.
I try to use Serial Wire, am I required to connect PB3?
2017-01-02 06:57 AM
It is where the trace data comes out, so yes.
For printf() to work in Keil you must supply supporting routines to use ITM_SendChar()
//******************************************************************************
// Rough SWV support in Keil, requires PB3/SWO to be connected to debugger
//******************************************************************************
#include <rt_misc.h>
#pragma import(__use_no_semihosting_swi)
struct __FILE { int handle; /* Add whatever you need here */ };
FILE __stdout;
FILE __stdin;
int fputc(int ch, FILE *f)
{
ITM_SendChar(ch);
return(ch);
}
int fgetc(FILE *f)
{
char ch;
ch = 1;
return((int)ch);
}
int ferror(FILE *f)
{
/* Your implementation of ferror */
return EOF;
}
void _ttywrch(int ch)
{
ITM_SendChar(ch);
}
void _sys_exit(int return_code)
{
label: goto label; /* endless loop */
}
//******************************************************************************
�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
2017-01-06 02:55 AM
For the record, I added the connection to PB3, and I only needed to include stdio.h and to define fputc.