Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2000] can't get printf() to print on UART0 with GNU

2005-02-24 by Anton Erasmus

On 24 Feb 2005 at 15:19, tiogate wrote:

> 
> 
> Hello, gentlemen,
> 
>    I am experiencing something that does not make sense to me. To make
> my debugging easier I wish to use the printf function to send
> formatted output to UARTO. 
> 
>    Fine. As far as I can see, I did everything right: I rewrote the
> putchar function so it writes to UART0, and the putchar function works
> OK. 
> 
>    However, when I use the printf function, it does not output to
> UART0 (if it outputs to something at all), and I can't understand why
> not.
> 
>    Checking the .MAP file, I see the compiler takes the putchar 
> function that is in my main.o and the remaining functions that 
> printf uses (such as puts, fflush, etc) it takes from libc.a .
> 
>    If I DO NOT write my putchar, I see from the .MAP file that the
> compiler takes putchar.o from libc.a -- and then I understand why it
> wouldn't send anything to the UART0. But why doesn't printf send to
> the UART0 if my putchar function tells it to?
> 
> Hoping for some enlightening from you gurus,
> 

If you are using the gcc toolset, then you are probably  using newlib. Hence
you need to port newlib to your specific hardware. Look for "Porting Newlib" and
you should find a fair amount of info. There is such a porting library for the LPC.
You can download it at http://www.aeolusdevelopment.com/Articles/download.html.
There are some issues when using the interrupt uart routines in this package. ( The 
assembler portion is not linked in from the library) 

Regards
  Anton Erasmus-- 
A J Erasmus

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.