各位早上好。
我想尝试两个mocro(SPCEL60系列)交换一些字节。微处理器通过UART连接。我正在使用SPC5 Studio中包含的串行驱动程序。
现在我尝试使用chnWrite和chnRead ol alternatevily sdGet和sdPut。
我正在寻找指令或教程,但我发现只有简单的东西(比如连续发送一些字节)。
我试图解决的问题是随后的:
micro A做一些事情并计算一个值。
micro B做同样的事情。
micro A将值发送给B.
B收到价值验证是否与他相同。
B将值发送给A.
A收到价值。如果值匹配,则两个微启动再次进行计算,直到下一次比较。
我不清楚的是如何实现这种“对话”。这两个微不同步。
如果我正确理解,B应该等待,例如调用chnRead。但是如果在B调用之前微传输那个功能呢?当B调用chnRead时,它会在硬件管理的底层缓冲区中找到值?或者价值丢失而B等待永远?
是否有标准方法适用于通过UART连接的两个微处理器之间实现双向值交换?
问候,
Ivab
#uart
以上来自于谷歌翻译
以下为原文
Good morning to everyone.
I am trying to have two mocro (SPCEL60 family) tha exchange some bytes. The micros are connected via UART. I am using the serial driver in cluded in SPC5 Studio.
Now I am tryong to use chnWrite and chnRead ol alternatevily sdGet and sdPut.
I am searching for instruc
tions or tutorial, but I found only simple things (like continuosly send some bytes).
The problem I am trying to solve is the subsequent:
micro A do some thing and calculate a value.
micro B do the same thing.
micro A send the value to B.
B receive the value verify if is the same his.
B send the value to A.
A receive the value. If the value match, the two micro start again doing calculations, until the next comparison.
What I don't clearly understand is how to achieve this sort of ''conversation''. The two micro are not synchronous.
If I correctly understand, B should wait, for example calling a chnRead. But if micro transmit before B call that function? When B call the chnRead, it find the value in an underlying buffer managed by the hardware? Or the value is lost and B wait forever?
Are there standard methods to apply in order to achieve a two way exchange of values between tow micros connected via UART?
Regards,
Ivab
#uart