[U-Boot-Users] USART on at91rm9200

larytet.54154763 at bloglines.com larytet.54154763 at bloglines.com
Wed Aug 15 07:21:10 CEST 2007


hello,



it looks  that function serial_putc() is called before serial_init()
(file cpu/arm920t/at91rm9200/serial.c. Function serial_putc() enters loop
forever.



Suggested quick patch 



static int initialized = 0;



/* bring
flag initialized up in the end of the function serial_init() */

int serial_init
(void)

{

	/* make any port initializations specific to this port */

#ifdef
CONFIG_DBGU

	*AT91C_PIOA_PDR = AT91C_PA31_DTXD | AT91C_PA30_DRXD;	/* PA 31
& 30 */

	*AT91C_PMC_PCER = 1 << AT91C_ID_SYS;	/* enable clock */

#endif

#ifdef CONFIG_USART0

	*AT91C_PIOA_PDR = AT91C_PA17_TXD0 | AT91C_PA18_RXD0;

	*AT91C_PMC_PCER |= 1 << AT91C_ID_USART0;	/* enable clock */

#endif

#ifdef
CONFIG_USART1

	*AT91C_PIOB_PDR = AT91C_PB21_TXD1 | AT91C_PB20_RXD1;

	/*
arkady - this is not enough to write PDR

		i want to make sure, that alternative
function A is set */

	*AT91C_PIOB_ASR = AT91C_PB21_TXD1 | AT91C_PB20_RXD1;

	*AT91C_PMC_PCER |= 1 << AT91C_ID_USART1;	/* enable clock */

	/* arkady
- i am not sure, that port B is enabled in the PCER */

	*AT91C_PMC_PCER |=
1 << AT91C_ID_PIOB;	/* enable PIOB */

#endif

	serial_setbrg ();



	us->US_CR
= AT91C_US_RSTRX | AT91C_US_RSTTX;

	us->US_CR = AT91C_US_RXEN | AT91C_US_TXEN;

	us->US_MR =

		(AT91C_US_CLKS_CLOCK | AT91C_US_CHRL_8_BITS |

		 AT91C_US_PAR_NONE
| AT91C_US_NBSTOP_1_BIT);

	us->US_IMR = ~0ul;

	initialized = 1;

	return
(0);

}





void serial_putc (const char c)

{

	if (!initialized) return;



	if (c == '\n')

		serial_putc ('\r');

	while ((us->US_CSR & AT91C_US_TXRDY)
== 0);

	us->US_THR = c;

}






More information about the U-Boot mailing list