Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Why does'nt it work!!!!!(dual uart)

Status
Not open for further replies.

tkvenki

New Member
Hi all,

I'm using a ST16C2550 (Dual UART) to interface to my controller.
I'm using POLLING MODE in controlling the UART.
I'm writing the following configuration to the UART:

Uart_Write(LCR, 0x80); //Divisor latch enable

Uart_Write(DLL, 0x0C); //set the baud rate to 9600
Uart_Write(DLH, 0x00);

Uart_Write(LCR, 0x03); //8data bits-1 stop bit-no parity
Uart_Write(FCR, 0x01); //Enable rx and tx FIFO
Uart_Write(IER, 0x00); //Disable all interrupts.

In my code:

while (1)
{
OSTimeDlyMillisec(1000);
if(Uart_Read(LSR) & 0x01)
{
ch = Uart_Read(RXTX);
printf("\n BYTE IN RX BUFFER = %x\n",ch);
Uart_Write(RXTX, ch);
}
}

I'm polling the LSR register. THe LSB of LSR gets high as soon as a byte is present in the FIFO. Then if the check is successful i read the data and send back the same.

BUt when i read the LSR(in my read routine), I'm getting only the default value(0x60). The value is not getting updated at all. I used my oscilloscope and confirmed that the data is coming till the UART pins.

Please help me out in identifying the problem.

Best Regards
tkvenki
 
"BUt when i read the LSR(in my read routine), I'm getting only the default value(0x60). The value is not getting updated at all"

tkvenki,

*In the polling mode, LSR[0] will be a logic 1 as long as there is 1 byte in the FIFO. It will be 0 otherwise.
*In the interrupt mode the receive data ready bit(LSR[0]) is set as soon as a character is transferred from the shift register to the FIFO. It is reset when the FIFO is empty.

So, by the time you read the LSR[0], it probably must have reset because you sent and received only one byte. Try sending and receiving multiple bytes and read the LSR[0] when atleast one byte is present in the FIFO.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top