Connect TX and RX at the same pin

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi every body!
I'm doing a project with PSoC 1 CY8C24123A.
Hardware:
-My software on PC - COM cable - RS485 to COM circuit (have MAXIM232 (1 device)- MAXIM485(1 device)) - CY8C24123A board (have a SN75176B...).
A,B signal of SN75176B conect to A,B signal MAXIM485.
(I'm using RS485 standard, baudrate is 19200).
-Communication between PC and CY8C24123A via UART user module, but TX and RX connect to same pin.
-Pin P0.4 is TX and RX. I have to configure pin 0.4.
-P0.2 control SN75176B to transmit or receive data. P0.2 = 1 transmit; P0.2 = 0 receive.
Contents:
- PC will send data to PSoC, after that PSoC send data to PC.
-If PSoC received 3 bytes 0xAA from PC. After that  PSoC send 0xAA ,0x31, 0x00 to PC.
-If PSoC received 3 bytes 0xBB from PC. After that  PSoC send 0xBB ,0x33, 0x00 to PC.
But communication is not good.
Some times, PC received data fail or receive data not truely.
I think when I switch between TX and RX at the same pin not well!
Can you tell me solutions to solve that problem?
Many thanks.
Below is my project!
 

0 Likes
4 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You have to consider that a byte to send will first be removed from the FIFO-buffer (which is empty then) and put into the TX-register which is not empty now. You have to wait until the transmission is done before switching to receive mode.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 Hi Bob,

   

Did you tell me about "void SendDataChar(unsigned char cData)"?

   

I modified:

   

void SendDataChar(unsigned char cData)

   

{

   

while(!(UART_bReadTxStatus()&UART_TX_BUFFER_EMPTY)){}

   

UART_PutChar(cData);

   

        while(!(UART_bReadTxStatus()&UART_TX_COMPLETE)){}

   

   

Further more, can you check void SetP04ToTX(void), void SetP04ToRX(void), please?

   

After switching mode, need time delay?

   

Many thanks!

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

There is no delay needed after switching the pin modes, you only have to be sure that there is actually no transmission running that you will abort by reprogramming the IO-pin.

   

What I am dubuous about is the fact, that you wait for 3 similar characters so that you are not able to tell when you missed one char whether you expect now the second to the third (or the first). When you have influence on the protocol I would suggest to send a lead-in character (SOT is a good candidate) to get the begin of a message.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 Thanks for your support! 

0 Likes