Microchip
直播中

何羽衣

8年用户 225经验值
私信 关注

USART PIC16F系列(688,690)

嗨,这里有什么遗漏的东西吗?我使用LT1791实现半双工485,并且根据需要在输入和输出之间切换。有没有方法可以确定当发送串行串中的字节串时,传输是否已经完成?我问的原因是我发送,然后希望听,这涉及切换485接收。看来,除非我在最后一次传输之后手动插入一个延迟,在切换到监听的过程中,在结束之前,我会切断最后一个字节。我是否漏掉了一些明显的东西?

以上来自于百度翻译


      以下为原文

    Hi folks have a missed something here? I am implementing half duplex 485 and so using an LT1791, and switching between input and output as required.
Is there a way I can determine if the transmission has completely finished when sending a string of bytes out of the serial port? The reason I ask is that I transmit, then wish to listen, which involves switching the 485 to receive. It seems that unless I manually insert a delay after the last transmission, on switching to listen I end up cutting the last byte off before it is completed.

Have I missed something obvious?

回帖(7)

张娜

2018-9-3 16:43:30
通常是这样做的……你必须在TIC上完成“TX完成”的标志:一个告诉你字节已经移动到TX'Enter寄存器,一个告诉它已经完成了传输-所以你通常使用这个。然后我添加一些时间延迟…确保线路稳定。这有点TBD,但工作!

以上来自于百度翻译


      以下为原文

    Usually this is how it's done...
 
You have to "TX done" flags, usually, on PICs: one tells you that the byte has been moved to TX'ing shift register, and one tells that it is done transmitting - so you usually use this one.
 
Then I add some bit-time delay... to make sure line is stable. This is somewhat TBD, but works!
举报

代瑜

2018-9-3 16:57:54
谢谢,达里奥,是的,我发现依靠旗子是不够好的,这真让我吃惊!我原以为可以用硬件来实现。

以上来自于百度翻译


      以下为原文

    Thanks, Dario, yeah I have found that relying on the flags is simply not good enough, which surprised me really! I would have thought something could be implemented in hardware. 
举报

张娜

2018-9-3 17:07:53
嗯,是的,但这并不容易:较长的线路,以及类型的司机可能会有所不同,所以…

以上来自于百度翻译


      以下为原文

    Well, yes, but It's not easy: longer lines, and also type of drivers may make a difference, so...
举报

张蕾

2018-9-3 17:19:07
HiIn与PIC输出(TX)有关的最佳方法是知道TrMT位,如果内存没有欺骗我,它就住在TXSTA寄存器中。TXIF标志只告诉您TXBUFF是空的,当最后一个字节被传递到发送器移位寄存器时,会发生什么?在最后一个字节的起始位时,TunIn继续运行。

以上来自于百度翻译


      以下为原文

    Hi

In what relates to the PIC output (TX) the best way to know when the tranmission is finished is the TRMT bit, if memory isd not tricking me it lives in the TXSTA register.
The TXIF flag only tells you TXBUFF is empty what happens when the last byte is passed on to the transmiter shift register, meaning TXIF goes on at the time of the start bit of the last byte.
举报

更多回帖

发帖
×
20
完善资料,
赚取积分