2014-11-14 02:38 AM
Hi,
Is-it possible to use printf() window under Keil in debug session when using ST-Link Debugger? I possible, how to proceed, Is-there a tutorial ? Thanks2014-11-14 05:20 AM
There is Google..
As far as I'm aware the Cortex-M0/M0+ does not provide a SWV (Serial Wire Viewer) channel on SWO pin. So you aren't going to be able to use the ''Debug Serial (printf)'' pane. What you could do is use the USART and Nucleo's VCP to get serial output via a terminal application pointed at COMxx Keil provides a standard way of retargetting console output. You could look at the retarget.c/serial.c in the various board/chip examples provided by Keil. I don't have an L0 Nucleo, it doesn't use the Standard Peripheral Library, but if you've configured the USART the standard Keil mechanism would look like this//******************************************************************************
// Hosting of stdio functionality through USART1 on Keil
//******************************************************************************
#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)
{
while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
USART_SendData(USART1, ch);
return(ch);
}
int fgetc(FILE *f)
{
char ch;
while(USART_GetFlagStatus(USART1, USART_FLAG_RXNE) == RESET);
ch = USART_ReceiveData(USART1);
return((int)ch);
}
int ferror(FILE *f)
{
/* Your implementation of ferror */
return EOF;
}
void _ttywrch(int ch)
{
while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
USART_SendData(USART1, ch);
}
void _sys_exit(int return_code)
{
label: goto label; /* endless loop */
}
//******************************************************************************