Printf in Keil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-03-19 1:36 AM
Printf in Keil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5: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?A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:28 AM
Yes I want a function that sends its output to two destinations simultaneously, any suggestions ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5: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 */ }Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:28 AM
''have your 'sendchar()' function send characters to both''
See:
http://www.keil.com/forum/18511/
(it's for C51, but the principle is the same)A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:28 AM
Spooky
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5: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 you- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5: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.Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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.