UART Status

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

UART Status

Jump to solution
885 Views
bpdohertyman
Contributor I

I have a LPC2138 and am using UART0 to communicate with my Windows program by sending and receiving data through a USB translator chip. Is there a way to determine whether my connection is valid at any time?  I want to be sure that my user has not just pulled the plug on me. Is there a method for doing this in my code?

 

Thanks!

0 Kudos
1 Solution
854 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Brian,

From Uart protocol, it does not use handshaking signal, so the uart does not detect whether it is connected to another uart.

But I think you can get a workaround, as you know that the RXD0 pin of LPC is multiplexed with pin interrupt pin: P0[1]/RXD0/PWM3/EINT0, so you can configure the pin as EINT0. From hardware perspective, you can connect an external large pull-up resistor on the LPC board. On the USB-SCI board, you can connect a small pull-down resistor, when the two board are connected, the P0_0 pin will become low from high, which can trigger an pin interrupt, so you can know than the board is connected. Then you can configure the pin P0_0 as RXD0, and communicate.

Hope it can help you

BR

XiangJun rong

 

View solution in original post

3 Replies
869 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Brian,

First of all, pls check your hardware whether the USB translator accept RS232 logic voltage or just uart logic voltage(0~3.3V).

If you still have issue, I suggest you connect the TXD0 to a scope and have the TXD0 output characters continuously, and check if the TXD0 can output signal.

Anyway, pls follow up the procedures to initialize the uart0.

1)TXD0/RXD0 pins assignment:

P0[0]/TXD0/PWM1

P0[1]/RXD0/PWM3/EINT0

PINSEL0&=~(0x0F);

PINSEL0|=0x05;

2)set the baud rate of uart0

 
 

uart0_2138.png

 

3)write the UART0 Transmit Enable Register to enable transmitting.

4)write the U0THR register.

5)poll the bit 5 of UART0 Line Status Register, repeat (4)

Hope it can help you

BR

XiangJun rong

 

 

 

 

0 Kudos
864 Views
bpdohertyman
Contributor I

Hi Xiangjun,

Thank you for your reply. My circuit works correctly in its current configuration. When I connect the USB from my board to any PC that has our Application Program running, the USB bus sees it and our App displays available USBs. When the user selects the USB, a handshake occurs and communication is established. From that point on, data is sent back and forth.

I am hoping to be able to test the existence of a connection to the computer from my microcontroller during operation. If the connection has been established and at some point has been broken (like the USB cable has been disconnected) I need my microcontroller to become aware of this so that appropriate action can be taken. I had looked at the UART status register and I am not sure if something like this is possible. 

 

Thanks again,

Brian 

0 Kudos
855 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Brian,

From Uart protocol, it does not use handshaking signal, so the uart does not detect whether it is connected to another uart.

But I think you can get a workaround, as you know that the RXD0 pin of LPC is multiplexed with pin interrupt pin: P0[1]/RXD0/PWM3/EINT0, so you can configure the pin as EINT0. From hardware perspective, you can connect an external large pull-up resistor on the LPC board. On the USB-SCI board, you can connect a small pull-down resistor, when the two board are connected, the P0_0 pin will become low from high, which can trigger an pin interrupt, so you can know than the board is connected. Then you can configure the pin P0_0 as RXD0, and communicate.

Hope it can help you

BR

XiangJun rong