【发布时间】:2013-12-13 18:15:55
【问题描述】:
我有两个使用 XUartLite 进行通信的 FPGA。其中一个是 Spartan,另一个是 Kintex-7。 Kintex 在发送端,Spartan 在接收端。
Kintex 读取内存并通过 uart 发送的相关代码:
static volatile uint32_t data=0;
while(len<cnt ){
data = XIo_In32(adr);
XUartLite_Send(&UartLite, (u8 *)&data, sizeof(uint32_t));
adr+=sizeof(uint32_t);
len++;
}
在 Sparatan/接收端:它一直接收直到达到寄存器给出的整个长度(len):
static volatile uint32_t RBuf;
while(bt<len){
XUartLite_DisableInterrupt(&UartLite);
XUartLite_Recv(&UartLite, (u8 *)&RBuf, sizeof(uint32_t));
xil_printf("Recv: %x \n\r",RBuf);
XIo_Out32(ADDR+bt, RBuf);
XUartLite_EnableInterrupt(&UartLite);
bt+=sizeof(uint32_t);
}
由于某种原因,Recv: %x 在第 5 个数据包之后停滞在之前的值。见下文(我正在读取 10 个地址值):
Recv: 0
Recv: 1D /*This is a control character here*/
Recv: 1
Recv: 2
Recv: 3
Recv: 3
Recv: 3
Recv: 3
Recv: 3
Recv: 3
我相信它正在发生,因为 Kintex 的传输速度太快,而 Spartan 的接收速度很慢。任何解决此问题的想法将不胜感激!
【问题讨论】:
-
猜测:XUartLite_Recv() 返回一个值,您没有检查它是否为 sizeof(uint32_t)。
-
可以在IP的配置中配置每个xuartlite的码率。
-
@MartinJames check os sizeof(uint32_t) 应该总是返回正确的数字,因为它被之前的值停止了。
-
XUartLite_Recv() 是否记录在收到请求的字节数之前不返回?传统上,阻塞“接收”方法将返回已收集到的任何非零数据量,或在任何错误条件下。就此而言,这种方法是否被证明是阻塞的?
-
嗯.. 如果它总是接收到与请求一样多的字节,为什么还要费心返回接收到的字节数?
标签: c embedded fpga xilinx uart