Forums

Desperate newbie and LPC2138 or how to cook the UART1

Started by Giuseppe Marullo December 15, 2008
Hi all,
I am trying to make the uart work on a Xylo-LM board. At
this point, it does seem I fried the uart1 i/o pins (maybe
also others), I really hope I am wrong.

I adapted an example
http://www.koders.com/info.aspx?c=ProjectInfo&pid=Q1LR1U3PDE53E1T32X2TT7C63A


Look in Paparazzi3/sw/airborne/arm7/test

Oscilator clock is fixed at 24MHz, I didn't do anything to
setup the pll.

so there is a chance I am still missing something. I was
succesful in running the following code to use UART0 (that
is not connected to the FPGA normally):

int
main (int argc, char** argv) {
// IODIR0 = 0x80000300;
uart0_init(115200);
// uart1_init(115200);
MAMCR = 2;
unsigned char i = 0;
while (1) {
// IOSET0 = 0x80000300;
uart0_transmit('h');
// uart1_transmit('h');
delay();
// IOCLR0 = 0x80000000;
}
return 0;

void uart0_init ( unsigned int baud ) {
//set Line Control Register (8 bit, 1 stop bit, no parity,
enable DLAB)
U0LCR_bit.WLS = 0x3; //8 bit
U0LCR_bit.SBS = 0x0; //1 stop bit
U0LCR_bit.PE = 0x0; //no parity
U0LCR_bit.DLAB = 0x1; //enable DLAB
//U0LCR = 0x83;

unsigned int divisor = peripheral_clock_frequency() / (16 *
baud);

U0DLL = divisor & 0xFF;
U0DLM = (divisor >> 8) & 0xFF;
U0LCR &= ~0x80;

PINSEL0 = (PINSEL0 & ~0xF) | 0x5;
}
void uart1_init ( unsigned int baud ) {
//set Line Control Register (8 bit, 1 stop bit, no parity,
enable DLAB)
U1LCR_bit.WLS = 0x3; //8 bit
U1LCR_bit.SBS = 0x0; //1 stop bit
U1LCR_bit.PE = 0x0; //no parity
U1LCR_bit.DLAB = 0x1; //enable DLAB
//U0LCR = 0x83;

unsigned int divisor = peripheral_clock_frequency() / (16 *
baud);

U1DLL = divisor & 0xFF;
U1DLM = (divisor >> 8) & 0xFF;
U1LCR &= ~0x80;

// PINSEL0 = (PINSEL0 & ~0xF) | 0x5;
// PINSEL0 = (PINSEL0 & ~0xFFF0FFFF) | 0x00050000;
}
I have some questions:
-Are the TXD/RXD pins protected, specially against a
contention? They are connected to the FPGA, and maybe I did
a configuration mistake on the Spartan3, so maybe there was
a output pin on the UART1 TXD1 pin.
- is the configuration in uart1_init correct (including the
commented PINSEL0 statement for the uart1) or there is still
something to be set?
TIA

Giuseppe Marullo

An Engineer's Guide to the LPC2100 Series