Yahoo Groups archive

Lpc2000

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

Thread

UART0 and Printf

UART0 and Printf

2006-04-24 by jstamos111

Hey all,

I am trying to get UART0 output to display on hyperterminal for a 
board I made based on the LPC2106 processor.  I use the ISP and 
UART0 to program the board with Philips flash utility, then start 
hyperterminal with the following settings: 9600 bits/second, 8 
databits, no parity, 1 stop bit, and no flow control.  I set 
hyperterminal to listen on the same com port as the one I used to 
program the flash memory.  I also have the computer's com port 
connected to the LPC2106's same UART (UART0?) that I used to program 
the flash memory.  Finally, I hit reset, but the output is not 
displayed in hyperterminal.

Any thoughts on why I am not seeing any output in hyperterminal?

Here is my code which I compiled uvision by keil tools.  I pretty 
much stole this code from hitex's book for the philips LPC 
processors.

void UART0 (void)	
{
PINSEL0 = 0x05; 	// Select TxD and RxD on pin connect block
U0LCR = 0x80;		//Enable programming of divisor latches

U0DLL = 0xC2;		//Program the divisor latch for 19200 baud
U0DLM = 0x00;

U0LCR = 0x33;		//Program the line control 8\N\1
U0FCR = 0x4F;		//enable the FIFO's
			
}

int main() {
	UART0();

	printf("Hello World\n"); //Call the printf function
        while(1) {}
        return 0;
}

Much Thanks.
- John

Re: [lpc2000] UART0 and Printf

2006-04-24 by George M. Gallant, Jr.

John,

Without looking in detail, your narrative say setting hyperterm to 9600
and the code comment says 19200.

George

On Mon, 2006-04-24 at 10:49 +0000, jstamos111 wrote:

> Hey all,
> 
> I am trying to get UART0 output to display on hyperterminal for a 
> board I made based on the LPC2106 processor.  I use the ISP and 
> UART0 to program the board with Philips flash utility, then start 
> hyperterminal with the following settings: 9600 bits/second, 8 
> databits, no parity, 1 stop bit, and no flow control.  I set 
> hyperterminal to listen on the same com port as the one I used to 
> program the flash memory.  I also have the computer's com port 
> connected to the LPC2106's same UART (UART0?) that I used to program 
> the flash memory.  Finally, I hit reset, but the output is not 
> displayed in hyperterminal.
> 
> Any thoughts on why I am not seeing any output in hyperterminal?
> 
> Here is my code which I compiled uvision by keil tools.  I pretty 
> much stole this code from hitex's book for the philips LPC 
> processors.
> 
> void UART0 (void)      
> {
> PINSEL0 = 0x05;       // Select TxD and RxD on pin connect block
> U0LCR = 0x80;            //Enable programming of divisor latches
> 
> U0DLL = 0xC2;            //Program the divisor latch for 19200 baud
> U0DLM = 0x00;
> 
> U0LCR = 0x33;            //Program the line control 8\N\1
> U0FCR = 0x4F;            //enable the FIFO's
>                   
> }
> 
> int main() {
>       UART0();
> 
>       printf("Hello World\n"); //Call the printf function
>         while(1) {}
>         return 0;
> }
> 
> Much Thanks.
> - John
> 
> 
> 
> 
> 
> 
> 
> ______________________________________________________________________
> YAHOO! GROUPS LINKS
> 
> 
>      1.  Visit your group "lpc2000" on the web.
>           
>      2.  To unsubscribe from this group, send an email to:
>          lpc2000-unsubscribe@yahoogroups.com
>           
>      3.  Your use of Yahoo! Groups is subject to the Yahoo! Terms of
>         Service.
> 
> 
> 
> ______________________________________________________________________
> 
> 


[Non-text portions of this message have been removed]

Re: UART0 and Printf

2006-04-24 by ian.scanlon

--- In lpc2000@yahoogroups.com, "jstamos111" <jstamos111@...> wrote:
>
> Hey all,
> 
> I am trying to get UART0 output to display on hyperterminal for a 
> board I made based on the LPC2106 processor.  I use the ISP and 
> UART0 to program the board with Philips flash utility, then start 
> hyperterminal with the following settings: 9600 bits/second, 8 
> databits, no parity, 1 stop bit, and no flow control.  I set 
> hyperterminal to listen on the same com port as the one I used to 
> program the flash memory.  I also have the computer's com port 
> connected to the LPC2106's same UART (UART0?) that I used to 
program 
> the flash memory.  Finally, I hit reset, but the output is not 
> displayed in hyperterminal.
> 
> Any thoughts on why I am not seeing any output in hyperterminal?
> 
> Here is my code which I compiled uvision by keil tools.  I pretty 
> much stole this code from hitex's book for the philips LPC 
> processors.
> 
> void UART0 (void)	
> {
> PINSEL0 = 0x05; 	// Select TxD and RxD on pin connect block
> U0LCR = 0x80;		//Enable programming of divisor latches
> 
> U0DLL = 0xC2;		//Program the divisor latch for 19200 baud
> U0DLM = 0x00;
> 
> U0LCR = 0x33;		//Program the line control 8\N\1
> U0FCR = 0x4F;		//enable the FIFO's
> 			
> }
> 
> int main() {
> 	UART0();
> 
> 	printf("Hello World\n"); //Call the printf function
>         while(1) {}
>         return 0;
> }
> 
> Much Thanks.
> - John
>
John,

There are only a few places for this not to work.  Look at rxd and 
txd pins (with a scope) at cpu and determine if you have any signals. 
If you have signals check the bit time - you can use 'A' (0x55) for 
its bit pattern. Check both TX and RX.  If you don't have signals use 
putc(0x55) in a while loop or better yet, write directly to the TX 
data register. If that works then there may be config problem with 
the character write routine used by printf.  

Ian

Re: UART0 and Printf

2006-04-24 by fordp2002

Three things to try.

1) Check your code is running at all can you flash a LED or are you
still in Boot Selector mode when you think you are running your code.

2) You have closed your Philips Flash Unitily before connecting with
Hyperterninal.

3) Try writing bytes to the U0THR, if you enable the fifo you can
write upto 16 in one go without checking if the UART is busy.

Good Luck.

--- In lpc2000@yahoogroups.com, "jstamos111" <jstamos111@...> wrote:
Show quoted textHide quoted text
>
> Hey all,
> 
> I am trying to get UART0 output to display on hyperterminal for a 
> board I made based on the LPC2106 processor.  I use the ISP and 
> UART0 to program the board with Philips flash utility, then start 
> hyperterminal with the following settings: 9600 bits/second, 8 
> databits, no parity, 1 stop bit, and no flow control.  I set 
> hyperterminal to listen on the same com port as the one I used to 
> program the flash memory.  I also have the computer's com port 
> connected to the LPC2106's same UART (UART0?) that I used to program 
> the flash memory.  Finally, I hit reset, but the output is not 
> displayed in hyperterminal.
> 
> Any thoughts on why I am not seeing any output in hyperterminal?
> 
> Here is my code which I compiled uvision by keil tools.  I pretty 
> much stole this code from hitex's book for the philips LPC 
> processors.
> 
> void UART0 (void)	
> {
> PINSEL0 = 0x05; 	// Select TxD and RxD on pin connect block
> U0LCR = 0x80;		//Enable programming of divisor latches
> 
> U0DLL = 0xC2;		//Program the divisor latch for 19200 baud
> U0DLM = 0x00;
> 
> U0LCR = 0x33;		//Program the line control 8\N\1
> U0FCR = 0x4F;		//enable the FIFO's
> 			
> }
> 
> int main() {
> 	UART0();
> 
> 	printf("Hello World\n"); //Call the printf function
>         while(1) {}
>         return 0;
> }
> 
> Much Thanks.
> - John
>

Re: [lpc2000] UART0 and Printf

2006-04-24 by Robert Adsett

Quoting jstamos111 <jstamos111@...>:
> Any thoughts on why I am not seeing any output in hyperterminal?
>
> Here is my code which I compiled uvision by keil tools.  I pretty
> much stole this code from hitex's book for the philips LPC
> processors.
>
> void UART0 (void)
> {
> PINSEL0 = 0x05; 	// Select TxD and RxD on pin connect block
> U0LCR = 0x80;		//Enable programming of divisor latches
>
> U0DLL = 0xC2;		//Program the divisor latch for 19200 baud
> U0DLM = 0x00;
>
> U0LCR = 0x33;		//Program the line control 8\N\1
> U0FCR = 0x4F;		//enable the FIFO's
>
> }
>
> int main() {
> 	UART0();
>
> 	printf("Hello World\n"); //Call the printf function
>        while(1) {}
>        return 0;
> }

I don't see any code for connecting printf to the serial port.

Robert

Re: UART0 and Printf

2006-04-24 by ian.scanlon

--- In lpc2000@yahoogroups.com, Robert Adsett <subscriptions@...> 
wrote:
>
> Quoting jstamos111 <jstamos111@...>:
> > Any thoughts on why I am not seeing any output in hyperterminal?
> >
> > Here is my code which I compiled uvision by keil tools.  I pretty
> > much stole this code from hitex's book for the philips LPC
> > processors.
> >
> > void UART0 (void)
> > {
> > PINSEL0 = 0x05; 	// Select TxD and RxD on pin connect block
> > U0LCR = 0x80;		//Enable programming of divisor 
latches
> >
> > U0DLL = 0xC2;		//Program the divisor latch for 19200 
baud
> > U0DLM = 0x00;
> >
> > U0LCR = 0x33;		//Program the line control 8\N\1
> > U0FCR = 0x4F;		//enable the FIFO's
> >
> > }
> >
> > int main() {
> > 	UART0();
> >
> > 	printf("Hello World\n"); //Call the printf function
> >        while(1) {}
> >        return 0;
> > }
> 
> I don't see any code for connecting printf to the serial port.
> 
> Robert
>

Does writing directly to the uart tx register work? How about putc ?

Re: UART0 and Printf

2006-04-24 by fordp2002

--- In lpc2000@yahoogroups.com, "ian.scanlon" <scanlon.design@...> wrote:
> 
> Does writing directly to the uart tx register work? How about putc ?
>

writing directly works very well as long as you do not overfill the
fifo's.

here is some code I wrote earlier ;)

typedef union
{
	unsigned long whole;
	unsigned char part_byte[4];
} four_bytes;

void UNDEF_Routine(void)
{
	register unsigned int *lr_ptr asm("r14");
	
	four_bytes temp;
	temp.whole = (usigned long) lr_ptr;
	UART0_THR = 	temp.part_byte[3];
	UART0_THR = 	temp.part_byte[2];
	UART0_THR = 	temp.part_byte[1];
	UART0_THR = 	temp.part_byte[0];
}

By the way thanks to the guys who helped me with reading the Link
Regitser.

Re: [lpc2000] UART0 and Printf

2006-04-24 by mfrazier@governors-america.com

You need to create a link to the printf ( )  function with writing a 
putchar( ) function that links to your Comm write functions so that printf 
( ) can link to the comm port such as:

/************************************************************************************************************************
Name:       putchar
Descr:      This routine is called by printf to output character strings 
to the
                                console. The function sends data out com1.

Inputs:     INT_32  ch = character to send to serial port
Outputs:    INT_32 status -   0 = Character written OK
 1 = Error
Rev:        0
************************************************************************************************************************/
INT_32 putchar ( INT_32 ch )
{
        return(Com1_write(ch));  // Write character to Serial Port
} 


Goog Luck!

Mike F.

[Non-text portions of this message have been removed]

Re: UART0 and Printf

2006-04-24 by brendanmurphy37

A more general, simpler alternative is as follows:

/* Transmit specified string to DEBUG port, using polled i/o */

void polled_write_to_uart_0(char *s)

{
  unsigned int status;

  while (*s)
  {
    do
    {
      status = REG(UART0_LSR);
    } while (!(status & 0x20));

    REG(UART0_THR) = (uint) *s;

    s++;
  }

  return;
}

/* example call: */

  polled_write_to_uart_0("Hello world\n");

This assumes the UART has been initialsed correctly and interrupts 
disabled.

It's a handy "first test" to do to see if the UART setup is correct.

Brendan

--- In lpc2000@yahoogroups.com, "fordp2002" <SimonEllwood@...> wrote:
>
> --- In lpc2000@yahoogroups.com, "ian.scanlon" <scanlon.design@> 
wrote:
> > 
> > Does writing directly to the uart tx register work? How about 
putc ?
Show quoted textHide quoted text
> >
> 
> writing directly works very well as long as you do not overfill the
> fifo's.
> 
> here is some code I wrote earlier ;)
> 
> typedef union
> {
> 	unsigned long whole;
> 	unsigned char part_byte[4];
> } four_bytes;
> 
> void UNDEF_Routine(void)
> {
> 	register unsigned int *lr_ptr asm("r14");
> 	
> 	four_bytes temp;
> 	temp.whole = (usigned long) lr_ptr;
> 	UART0_THR = 	temp.part_byte[3];
> 	UART0_THR = 	temp.part_byte[2];
> 	UART0_THR = 	temp.part_byte[1];
> 	UART0_THR = 	temp.part_byte[0];
> }
> 
> By the way thanks to the guys who helped me with reading the Link
> Regitser.
>

Re: [lpc2000] UART0 and Printf

2006-04-27 by John Stamos

Thanks for the help guys.  I finally got things working and  ultimately George was right in that I inited some of the UART0  parameters wrong.  In addition to initing the UART0 for 19200 and  setting Hyperterminal to 9600, I selected UART1 in the pinselect0  register, no UART0.
  
  - John

"George M. Gallant, Jr." <ggallant571@...> wrote:        John,
  
  Without looking in detail, your narrative say setting hyperterm to 9600
  and the code comment says 19200.
  
  George
  
  On Mon, 2006-04-24 at 10:49 +0000, jstamos111 wrote:
  
  > Hey all,
  > 
  > I am trying to get UART0 output to display on hyperterminal for a 
  > board I made based on the LPC2106 processor.  I use the ISP and 
  > UART0 to program the board with Philips flash utility, then start 
  > hyperterminal with the following settings: 9600 bits/second, 8 
  > databits, no parity, 1 stop bit, and no flow control.  I set 
  > hyperterminal to listen on the same com port as the one I used to 
  > program the flash memory.  I also have the computer's com port 
  > connected to the LPC2106's same UART (UART0?) that I used to program 
  > the flash memory.  Finally, I hit reset, but the output is not 
  > displayed in hyperterminal.
  > 
  > Any thoughts on why I am not seeing any output in hyperterminal?
  > 
  > Here is my code which I compiled uvision by keil tools.  I pretty 
  > much stole this code from hitex's book for the philips LPC 
  > processors.
  > 
  > void UART0 (void)      
  > {
  > PINSEL0 = 0x05;       // Select TxD and RxD on pin connect block
  > U0LCR = 0x80;            //Enable programming of divisor latches
  > 
  > U0DLL = 0xC2;            //Program the divisor latch for 19200 baud
  > U0DLM = 0x00;
  > 
  > U0LCR = 0x33;            //Program the line control 8\N\1
  > U0FCR = 0x4F;            //enable the FIFO's
  >                   
  > }
  > 
  > int main() {
  >       UART0();
  > 
  >       printf("Hello World\n"); //Call the printf function
  >         while(1) {}
  >         return 0;
  > }
  > 
  > Much Thanks.
  > - John
  > 
  > 
  > 
  > 
  > 
  > 
  > 
  > ______________________________________________________________________
  > YAHOO! GROUPS LINKS
  > 
  > 
  >      1.  Visit your group "lpc2000" on the web.
  >           
  >      2.  To unsubscribe from this group, send an email to:
  >          lpc2000-unsubscribe@yahoogroups.com
  >           
  >      3.  Your use of Yahoo! Groups is subject to the Yahoo! Terms of
  >         Service.
  > 
  > 
  > 
  > ______________________________________________________________________
  > 
  > 
  
  
  [Non-text portions of this message have been removed]
  
                
        
---------------------------------
    YAHOO! GROUPS LINKS  
  
      
    Visit your group "lpc2000" on the web.
     
    To unsubscribe from this group, send an email to:
 lpc2000-unsubscribe@yahoogroups.com
     
    Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.  
  
      
---------------------------------
  
  
          

		
---------------------------------
Love cheap thrills? Enjoy PC-to-Phone  calls to 30+ countries for just 2ยข/min with Yahoo! Messenger with Voice.

[Non-text portions of this message have been removed]

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.