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 ?
> >
>
> 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.
>Message
Re: UART0 and Printf
2006-04-24 by brendanmurphy37
Attachments
- No local attachments were found for this message.