发 帖  
张飞软硬开源基于STM32 BLDC直流无刷电机驱动器开发视频套件, 👉戳此立抢👈
[问答] 怎么在同一引脚上连接TX和RX
238 波特率 PSoc 电缆
分享
大家好!我正在用PSoC 1 CY8C24123A做一个项目。硬件:我在PC -COM电缆上的软件-RS485到COMLATE(有最大的223(1设备)-最大值485(1设备))-CY8C24123A板(有SN75 176B……)。SN17176B的A、B信号与A、B信号最大值一致。(我使用RS485标准,波特率为19200)。通过UART用户模块实现PC与CY8C24123A之间的通信,但TX和RX连接到同一个PIN。PIN P0.4是TX和RX。我必须配置PIN 0.4。-P0.2控制SN75 176B发送或接收数据。P0.2=1发送;P0.2=0接收。内容:PC将发送数据到PSoC,之后PSoC将数据发送到PC。如果PSoC从PC接收3字节0xAA。PSOC发送0xAA、0x31、0x00到PC。如果PSoC从PC接收3字节0xBB。PSOC发送0xBB、0x33、0x00到PC。但是通信不好。有时,PC接收数据失败或不真实地接收数据。我想当我切换TX和RX在同一个引脚不好!你能告诉我解决这个问题的方法吗?多谢。下面是我的计划!
ADC16RS55V2.ZIP
251.5 K

以上来自于百度翻译


     以下为原文
  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
2019-1-16 13:47:58   评论 分享淘帖 邀请回答
3个回答
你必须考虑一个要发送的字节将首先从FIFO缓冲器中删除(然后是空的),然后放入TX寄存器中,它现在不是空的。在切换到接收模式之前,必须等待传输完成。
鲍勃

以上来自于百度翻译


     以下为原文
  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
2019-1-16 13:55:09 评论

举报

嗨,鲍伯,
你有没有告诉我“ValueSunDATAQAR(无符号CHAR CDATA)”?
我修改了:
无符号char数据
{
而(!)(UARTHULSTTXXSTATUS(和);UARTHARTXBAUBELSIOL空)){}
UTARTH PUCHCHAR(CDATA);
而(!)(UARTHULSTOTXSTATUS(和)和UARTHARTXIOFFULT){}
}
另外,您能检查Stup04totx(空隙)、空隙SETP04TROX(空隙)吗?
切换模式后,需要延时吗?
多谢!

以上来自于百度翻译


     以下为原文
   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!
2019-1-16 14:02:36 评论

举报

没有延迟的销模式切换后,你只需要相信,其实是没有传输运行,你将中止通过重新编程的IO引脚。
我dubuous大约是事实,你不能够告诉你错过了一个字符,你是否想到现在的第三秒等待3相似的特征(或第一)。当你有影响力的协议,我建议把导入字符(不是一个很好的候选人)得到一个消息的开始。
鲍勃

以上来自于百度翻译


     以下为原文
  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
2019-1-16 14:08:38 评论

举报

谢谢你的支持!

以上来自于百度翻译


     以下为原文
   Thanks for your support! 
2019-1-16 14:21:58 评论

举报

只有小组成员才能发言,加入小组>>

327个成员聚集在这个小组

加入小组

创建小组步骤

关闭

站长推荐 上一条 /8 下一条

快速回复 返回顶部 返回列表