2011-03-19 01:36 AM
Printf in Keil
2011-05-17 05:28 AM
printf is a standard library function; it is defined by the 'C' standard: it sends its output to stdout - nothing else.
So adding a parameter is not just ''retargetting'' - it is completely changing the standard behaviour! If you want to specify the output destingation in a standard library file, you will have to us fprintf or similar. Or you could redefine stdout between calls. Or create your own function that specifies a destination. Or did you want a function that sends its output to two destinations simultaneously?2011-05-17 05:28 AM
Yes I want a function that sends its output to two destinations simultaneously, any suggestions ?
2011-05-17 05:28 AM
Look at how you've hosting the lcd/usart now, and have your ''sendchar()'' function send characters to both.
Or use sprintf() to generate data for both in your own ''DebugPrintf()'' function. #include <stdio.h> #include <rt_misc.h> #pragma import(__use_no_semihosting_swi) struct __FILE { int handle; /* Add whatever you need here */}; FILE __stdout; extern int sendchar (int ch); 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 */ }2011-05-17 05:28 AM
''have your 'sendchar()' function send characters to both''
See: (it's for C51, but the principle is the same)
2011-05-17 05:28 AM
Spooky
2011-05-17 05:28 AM
Thank you Clive
already I know this and I am retarget it to my lcd routine, my question is it possible to retarget it to 2 routinesor more? seial send char, glcd ? Thank you2011-05-17 05:28 AM
The point Andrew and I made is that you could do it like this :
int sendchar (int ch) // Hosting function character output routine { sendchar_usart(ch); sendchar_lcd(ch); return(ch); } Why would this NOT work? If your clocks remain busted I could see the USART not outputing at the right baud rate. But that could be fixed by tweaking the baud rate register.2012-07-27 10:47 PM
Yeah somebody help me out here.
I'm using Keil and STLink on the STM32F4Discovery board and I see in uVision there's a window for ''Debug (printf) Viewer''. Which I assume takes printf() and xfers it through the attached STLink I'm debugging with, which sounds great to me!But I use printf() and it jumps to the reset vector. There's no compile warning about stdout being unimplemented or anything. What do I need to put in to transfer the data across the STLink?2012-07-28 12:01 AM
I've tried following the instructions here:
http://armcortexm.blogs.upv.es/stm32f4-discovery-and-printf-redirection-to-debug-viewer-in-keil/
Yeah the Keil tab I was using was ''STLink (deprecated)'' but just changing to ''STLink Debugger'' led to ''Device Not Found''. I made all the changes specified up there and the debugger works again. It doesn't bomb on printf, however, I don't see anything printing out in the printf() Viewer window.