Hi: I have problems with the printf() function. I have the UART0 initialised, and the putchar() working fine, so I can send characters to the serial. But the printf() only works if I send only 1 character at a time (printf("A")), and if I use printf("Hello") it doesn't work. This happen with the GNU compiler. With the Keil ARM Compiler, everithing works fine. What could be the problem? Thanks
Two comments: 1) The problems with printf() actually suggest your putchar() isn't working quite as fine as you think it is. 2) "It doesn't work" is about as useless a description of a problem as you can possibly come up with. Please try to be more specific: how does it fail to do what you think it should?
Ok. When I try putchar('A') it sends the A character. If I try printf("A") it sends the A character too. But if I try printf("ABC"), it doesn't send anything. I tried to see what does printf() return: int ret; ret=printf("Hello"); putchar(ret+0x30); and it sends the number 5 (according the printf() doc's, it must return the number of characters sent), but nothing appears in hyperterminal window. Here is my putchar function implementation: int putchar(int ch) { /* Write character to Serial Port */ if (ch == '\n') { while (!(U0LSR & 0x20)); U0THR = CR; /* output CR */ } while (!(U0LSR & 0x20)); return (U0THR = ch); } Some idea? Thanks in Advance
what if you do:
putchar( 'A' ); putchar( 'B' ); putchar( 'C' );
In this case, it sends 'A' 'B' and 'C'...It seems that works normally...The problem arise when I use printf(). Thanks
This happen with the GNU compiler. With the Keil ARM Compiler, everithing works fine. What could be the problem? Yep. This is the same kind of problems we had with the GNU compiler for ARM. That's why we decided to write our own. The GNU tools required a lot of time getting started. There are several examples for GNU that all work just fine. Have you taken a look at the HELLO example? Jon
Hi Jon: Yes I saw the Hello example, but it's targered for ATMEL, and I 'm working with Philips LPC2106. Also, I saw the Syscalls.c, but I don's know if this is neccesary in the LPC2106 case.... By the way..What do you mean when you say "Yep. This is the same kind of problems we had with the GNU compiler for ARM. That's why we decided to write our own..."? What do you write ? Thanks
What do you write ? I work for Keil. Jon