USART to printf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2010-09-29 12:18 PM
@page {margin:2cm;} .ExternalClassB84147A5E35D4D54A6663AEC4519B806 P {margin-bottom:0.21cm;}
I can compile and download the attach project to the STM32VLDISCOVERY without any warnings or errors. The code is sort of working because I can toggle LED3 and LED4 but the code just hangs when is comes to the printf(.
This is my first project with the STM32 and I can't figure out whats wrong ? I hope some of you can help me.
Thx.
#semihosting #retargetting #printf #rtfm- Labels:
-
UART-USART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2010-09-29 3:16 PM
solved :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-12 6:57 PM
sourcefiles
with the thread. Cheers, Sam- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-12 6:57 PM
sourcefiles
with the thread. Cheers, Sam- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-13 12:35 PM
Good to hear that you solved it. I'm having the same problem, and would appreciate if you can attach your
sourcefiles
with the thread. This is surely going to depend on your tool chain. It's probably a matter of including the right libraries and turning off the Semi Hosting SWI calls, and replacing the fputc() and __ttywrch(), or equivalents, with suitable code to emit characters on a USART of your choice.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-15 10:51 PM
''This is surely going to depend on your tool chain.''
Yes, it certainly is! The necessary details - and, probably, examples too - will be in the toolchain documentation... Keil also use the term ''retargetting'' Some toolchains give you options on the level of printf support - from ''simple'' to ''full''...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-01-05 11:58 PM
Hi,
I've the same problem. I'using Keil MDK-ARM 4.72.1.0 toolchain.I can't find the solution in the documentation, can you help me?Thanks- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-01-06 3:06 AM
//******************************************************************************
// Hosting of stdio functionality through USART2
//******************************************************************************
#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(USART2, USART_FLAG_TXE) == RESET);
USART_SendData(USART2, ch);
return(ch);
}
int fgetc(FILE *f)
{
char ch;
while(USART_GetFlagStatus(USART2, USART_FLAG_RXNE) == RESET);
ch = USART_ReceiveData(USART2);
return((int)ch);
}
int ferror(FILE *f)
{
/* Your implementation of ferror */
return EOF;
}
void _ttywrch(int ch)
{
while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET);
USART_SendData(USART2, 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..
