gpt4 book ai didi

c - xil_printf 和 XUartLite_SendByte

转载 作者:太空狗 更新时间:2023-10-29 15:07:12 25 4
gpt4 key购买 nike

为什么 xil_printf 会导致堆栈溢出而 XUartLite_SendByte 不会?谁能解释一下?注释部分 (XUartLite_SendByte) 工作正常,但最终我想调用 i 上的函数并使用 xil_printf 返回结果。

代码如下所示。

使用赛灵思 SDK 的 microblaze

#include <stdio.h>
/*#include "xparameters.h" */
#include "xil_cache.h"
/*#include "uartlite_header.h"
#include "xbasic_types.h"
#include "xgpio.h"
#include "gpio_header.h"
#include "xspi.h"
#include "spi_header.h"*/

#include "xparameters.h"
#include "xutil.h"
#include "xuartlite_i.h"


#define UART_ADDR 0x40600000

int main()
{

Xil_ICacheEnable();
Xil_DCacheEnable();

print("---Entering main---\n\r");

Xuint16 i;


while(1==1)
{
while(XUartLite_IsReceiveEmpty(UART_ADDR));
i = XUartLite_RecvByte(UART_ADDR);
xil_printf("%c ", i);

/*while(XUartLite_IsTransmitFull(UART_ADDR));*/
/*XUartLite_SendByte(UART_ADDR, i);*/
//}
}

print("---Exiting main---\n\r");

Xil_DCacheDisable();
Xil_ICacheDisable();

return 0;
}

最佳答案

您在 Xilinx forum 上发布了相同的问题.赛灵思回应:

XUartLite_RecvByte() returns a u8 (or unsigned char). Not a Xuint16. And xil_printf %c will not expect Xuint16.

关于c - xil_printf 和 XUartLite_SendByte,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22973127/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com