UART Receiver in LPC1343

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

UART Receiver in LPC1343

1,505 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Prithvi on Mon Dec 06 13:15:19 MST 2010
Hi,
Isn't the code to receive the data by UART
while ( !(LPC_UART->LSR & LSR_RDR) );
ucData = LPC_UART->RBR;
I am testing this by sending the data back through UART  by the following code and the transmitting from lpc1343 code is working fine
for(;;)
        {
        while ( !(LPC_UART->LSR & LSR_RDR) );
        ucData = LPC_UART->RBR;

        while ( !(LPC_UART->LSR & LSR_THRE) );
        LPC_UART->THR = ucData;
        }
What ever I transmit from teminal to lpc1343, it responds rarely by sending back 0x00. Where am I going wrong?
Thanks in advance,
Prithvi

Original Attachment has been moved to: 1100890_SSP_LPC111_301.txt.zip

0 Kudos
Reply
7 Replies

1,431 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by domen on Wed Dec 08 01:12:21 MST 2010
I meant: do the baudrates match?

And did you enable uart pins in IOCONFIG register?

And, yes, as mentioned... build on examples. Even if they're not the nicest piece of code, they usually work.
0 Kudos
Reply

1,431 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Dec 07 18:33:04 MST 2010
No, of course it's receiving (via interrupt) and transmitting :D
See Examples in your lpcxpresso_3.5 folder or NXP Example Projects:

http://ics.nxp.com/support/lpcxpresso/#Examples
0 Kudos
Reply

1,431 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Prithvi on Tue Dec 07 13:29:31 MST 2010
The sample program of uart only has the transmission example, right? Do you have any code for the reception of data through uart?
0 Kudos
Reply

1,431 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Dec 07 11:30:03 MST 2010
1. To avoid problems with PC / level converter... you could try to use 'Loopback Mode' Chapter 11, UM10375
2. You could try a simple interrupt driven NXP sample called: UART :)
0 Kudos
Reply

1,431 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Prithvi on Tue Dec 07 10:52:25 MST 2010
Forgot to mention the baud rate. Its 9600 bps.
0 Kudos
Reply

1,431 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Prithvi on Tue Dec 07 10:50:53 MST 2010
The voltage for the lpc1343 is 3.3V from the lpcxpresso board. I have used ST3232 level converter. The TX to comp is working fine.
But the echo program which I mentioned in the last post only sends back zeros at times when I send any character from the computer.
I've modified the program to
for(;;)
    {
//    while ( !(LPC_UART->LSR & LSR_RDR) );

    for(i=0xFFFFF;i;i--);
    ucChoice = LPC_UART->RBR;

    while ( !(LPC_UART->LSR & LSR_THRE) );
    LPC_UART->THR = ucChoice;
    }
In this code even if I send characters from the computer it continuously sends only zeros. Why is the data sent from the computer not getting updated in the Receiver Buffer register (RBR)?
0 Kudos
Reply

1,431 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by domen on Tue Dec 07 03:19:11 MST 2010
Code seems correct.

Baudrate? Voltage levels?
0 Kudos
Reply