UART0
2004-11-19 by k10elex
I am using Olimex LPC2106 board with 14.7456Mhz crystal.
i am facing problem with the Serial port. i initialise the register
for 9600 baudrate but its not working. some times it sending some
garbage data endless!!
here is the code
it should send A to I and then it should respond to the received byte.
please look in to it.
Thanks,
Ketan
int temp;
char str[10] = "ABCDEFGHI";
char ch;
/* initialize the serial interface */
PCONP &= 0x08;
PINSEL0 = 0x00000005; /* Enable RxD1 and TxD1 */
U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
U0DLL = 96; /* 9600 Baud Rate @ 14.7456MHz VPB
Clock */
U0LCR = 0x03; /* DLAB = 0 */
for(temp=0;temp < 10;temp++)
{
while((U0LSR & 0x40) == 0){}
U0THR = str[temp];
}
while(1)
{
if (!(U0LSR & 0x01))
{
ch = U0RBR;
while((U0LSR & 0x40) == 0){}
U0THR = ch;
}
}