我正在使用ZedBoard,它有一个Zynq-7000全可编程SoC。我正在尝试提供的示例之一(可以从 Xilinx SDK 导入),它称为xuartps_intr_example.c
此文件包含一个 UART 驱动程序,该驱动程序在中断模式下使用。应用程序发送数据,并期望使用本地环回模式通过设备接收相同的数据
我想调整该代码,以便我可以将数据从终端或实现串行通信的某种程序发送到我的 ZedBoard。我尝试使用XUartPs_Recv函数从外部接收数据,并从PC中的不同终端发送数据(通过在Xilinx SDK中禁用控制台,否则无法访问串口),但开发板没有收到任何内容。另一方面,将数据从 ZedBoard 发送到我的 PC 工作正常,我可以在不同的终端中看到来自开发板的消息。
我附上了我无法理解的源代码,我认为这给我带来了问题。我的问题前面有一个哈希符号:
XUartPs_SetInterruptMask(UartInstPtr, IntrMask);
XUartPs_SetOperMode(UartInstPtr, XUARTPS_OPER_MODE_LOCAL_LOOP);
#WHAT IS LOCAL LOOPBACK MODE?? DOES THIS PREVENT THE BOARD FROM RECEIVING
DATA COMING FROM MY PC?
/*
* Set the receiver timeout. If it is not set, and the last few bytes
* of data do not trigger the over-water or full interrupt, the bytes
* will not be received. By default it is disabled.
*
* The setting of 8 will timeout after 8 x 4 = 32 character times.
* Increase the time out value if baud rate is high, decrease it if
* baud rate is low.
*/
XUartPs_SetRecvTimeout(UartInstPtr, 8);
/*
* Initialize the send buffer bytes with a pattern and the
* the receive buffer bytes to zero to allow the receive data to be
* verified
*/
for (Index = 0; Index < TEST_BUFFER_SIZE; Index++) {
SendBuffer[Index] = (Index % 26) + 'A';
RecvBuffer[Index] = 0;
}
/*
* Start receiving data before sending it since there is a loopback,
* ignoring the number of bytes received as the return value since we
* know it will be zero
*/
XUartPs_Recv(UartInstPtr, RecvBuffer, TEST_BUFFER_SIZE);
/*
* Send the buffer using the UART and ignore the number of bytes sent
* as the return value since we are using it in interrupt mode.
*/
XUartPs_Send(UartInstPtr, SendBuffer, TEST_BUFFER_SIZE);
#HOW DOES THIS ACTUALLY WORK? WHY DO WE START RECEIVING BEFORE WE SEND ANY
BYTES?
/*
* Wait for the entire buffer to be received, letting the interrupt
* processing work in the background, this function may get locked
* up in this loop if the interrupts are not working correctly.
*/
while (1) {
if ((TotalSentCount == TEST_BUFFER_SIZE) &&
(TotalReceivedCount == TEST_BUFFER_SIZE)) {
break;
}
}
/* Verify the entire receive buffer was successfully received */
for (Index = 0; Index < TEST_BUFFER_SIZE; Index++) {
if (RecvBuffer[Index] != SendBuffer[Index]) {
BadByteCount++;
}
}
/* Set the UART in Normal Mode */
XUartPs_SetOperMode(UartInstPtr, XUARTPS_OPER_MODE_NORMAL);
#WHAT DOES SETTING THE UART IN NORMAL MODE MEAN??
另外,我想知道是否可以通过SDK终端(Xilinx SDK)将数据发送到ZedBoard。目前,每一次尝试都没有成功。
提前谢谢你
基督教
要从PC终端接收ZedBoard上的数据,您必须处于正常运行模式,这是PS启动时的默认模式。查看 Zynq-7000 技术参考手册,第 598 页,图 19-7,了解 UART 操作模式。
-
本地环回模式不会向外部应用程序发送任何内容,而只是将其发送的流循环回自身。
-
我们实际上并没有开始接收数据。我们开始等待接收数据。
-
正如@Cesar正确提到的,只需在代码开头将XUARTPS_OPER_MODE_LOCAL_LOOP更改为XUARTPS_OPER_MODE_NORMAL,您就可以开始了。正常环回模式将数据发送到外部应用程序。