Originally from ticket #6209.
I have tried changing the prototype to: #define PUTCHAR_PROTOTYPE int putchar(int ch) as suggested in the corrected samples section, but this does not work either to output to UART. I have tested the UART the old fashion way and it works fine...i.e.
// /* Wait until end of transmit */
// while(USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET)
But it would be nice to get it to work with something like:
/* Write a character to the USART */
USART_SendData(USARTx, (u8) ch);
/* Loop until the end of transmission */
while(USART_GetFlagStatus(USARTx, USART_FLAG_TXE) == RESET)
Why does this not work? It seems all output is going to the debug terminal instead...Is there a linker option to redirect this to USART instead? thanks...
Check what you have the "Library Options > I/O Library Name" project property set to - if it is "debug", then stdout output will go to the debug terminal. If it is set to "target" then all you should need to do is implement a function named __putchar, for example:
... write ch to the uart ...
Please sign in to leave a comment.