2016-05-26 09:16 AM
Hi,
Currently I am using ST nucleo L073RZ with Keil testing with stm32cubeL0 example code. Is there any way to do a printf in Keil say print out the value in the debug printf window. #printf #keil #nucleo #stm32l02016-05-26 10:44 AM
The Cortex-M0 doesn't not provide for the SWV (Serial Wire Viewer) model used on the M3/M4 designs.
You would need to use the serial port (VCP of ST-LINK) and add Retargeting code for that into your Keil project, and then use a terminal app like RealTerm, ClearTerm or TeraTerm, etc to interact with the board.http://www.keil.com/support/man/docs/gsac/gsac_retargetcortex.htm
2016-05-26 07:25 PM
2016-05-28 09:39 AM
puts(aTxBuffer); //?? via STDIO
outstring(aTxBuffer); // simple character at a time string processingvoid outstring(char *s)
{
while(*s)
{
while(!(USART1->ISR & USART_ISR_TXE));
USART1->TDR = *s++;
}
}
void outchar(char c)
{
while(!(USART1->ISR & USART_ISR_TXE));
USART1->TDR = c;
}
int SendChar(int c)
{
while(!(USART1->ISR & USART_ISR_TXE));
USART1->TDR = c;
return(c);
}
//****************************************************************************
#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) { return (SendChar(ch)); }
int ferror(FILE *f)
{
/* Your implementation of ferror */
return EOF;
}
void _ttywrch(int ch) { SendChar(ch); }
void _sys_exit(int return_code)
{
label: goto label; /* endless loop */
}
//****************************************************************************
2016-05-29 11:37 PM
I have edited the retarget.c however all the usart terms are underline. Do I need to define something or include some library?
//code////////*---------------------------------------------------------------------------- * Name: Retarget.c * Purpose: 'Retarget' layer for target-dependent low level functions * Note(s): *---------------------------------------------------------------------------- * This file is part of the µVision/ARM development tools. * This software may only be used under the terms of a valid, current, * end user licence from KEIL for a compatible version of KEIL software * development tools. Nothing else gives you the right to use this software. * * This software is supplied ''AS IS'' without warranties of any kind. * * Copyright (c) 2009 Keil - An ARM Company. All rights reserved. *----------------------------------------------------------------------------*/#include <stdio.h>#include <rt_misc.h>#pragma import(__use_no_semihosting_swi)extern int sendchar (int c);extern int getkey (void);struct __FILE { int handle; /* Add whatever you need here */ };FILE __stdout;FILE __stdin;int fputc(int c, FILE *f) { return (sendchar(c));}int fgetc(FILE *f) { return (getkey());}int ferror(FILE *f) { /* Your implementation of ferror */ return EOF;}void _ttywrch(int c) { sendchar(c);}void _sys_exit(int return_code) {label: goto label; /* endless loop */}void outstring(char *s){ while(*s) { while(!(USART1->ISR & USART_ISR_TXE)); USART1->TDR = *s++; }} void outchar(char c){ while(!(USART1->ISR & USART_ISR_TXE)); USART1->TDR = c;} int SendChar(int c){ while(!(USART1->ISR & USART_ISR_TXE)); USART1->TDR = c; return(c);}2018-01-26 06:07 PM
Hi,
look this examples:
http://www.emcu.eu/how-to-implement-printf-for-send-message-via-usb-on-stm32-nucleo-boards/
2018-01-26 07:20 PM
The Cortex-M0 can use the 'Event Recorder'
http://www.keil.com/pack/doc/compiler/RetargetIO/html/_retarget__examples_er.html