ST意法半导体
直播中

刘溪

7年用户 192经验值
私信 关注
[问答]

请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?

各位早上好。


我想尝试两个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 instructions 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

回帖(1)

刘鑫

2019-6-26 10:50:39
你好伊万,
 
 
您不需要同步2微处理器。
通信2个设备应该共享相同的参数
 
您是否使用了输出格式化程序组件(来自OS-Less或RLE)或Chibios输出格式化程序?
通常,当我通过UART(ESP8266(Arduino),Other Micros ..)进行通信时,我使用此组件。
 
附件中与ESP8266进行AT通信的源代码示例
 
 最好的祝福
 
 
 二万

以上来自于谷歌翻译


以下为原文





Hello Ivan ,


You do not need to synchronize the 2 micros.
to communicate the 2 devices should share the same parameters

Did you use the Output Formatter component (From OS-Less or RLE) or Chibios Output formatter ?
Often , when i communicate by UART (ESP8266 (Arduino), Other Micros ..) , i use this component.

Example of source code with AT communication with ESP8266 in attachment

    Best regards


                     Erwan
举报

更多回帖

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