我使用的是一个ZedBoard,它有一个Zynq-7000全可编程SoC.我正在尝试提供的一个示例(可以从Xilinx导入),它称为xuartps_intr_example.c
此文件包含用于中断模式的UART驱动程序。应用程序发送数据,并期望使用本地回送模式通过设备接收相同的数据。
我希望通过这样一种方式来调整代码,使我能够从一个终端或某种实现串行通信的程序将数据发送到我的ZedBoard。我尝试过使用XUartPs_Recv函数从外部接收数据,并从我的PC机的不同终端发送数据(通过禁用Xilinx中的控制台,否则无法访问串口),但是板没有接收任何信息。另一方面,将数据从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 )向ZedBoard发送数据。目前,每一次尝试都没有成功。
提前谢谢你
克里斯蒂安
发布于 2020-04-13 18:09:44
要从PC终端接收ZedBoard上的数据,您必须处于正常操作模式中,这是PS启动时的默认模式。请查看Zynq-7000技术参考手册,第598页,图19-7,以了解UART操作模式。
https://stackoverflow.com/questions/48083940
复制相似问题