当需要使用到PL端的IO口用作串口的时候可以使用EMIO对UART的引脚进行扩展
这里使用UART1 进行EMIO扩展
EMIO本质上是属于PL FPGA的资源所以需要进行综合然后再指定管脚
然后把UART1,TX RX做外部引脚
生成bit流文件,然后导入到SDK
创建一个API,方便初始化自己的串口
#include "xuartps.h"XUartPs Uart_Ps2;
u8 HelloWorld[] = "Hello World UART22";
int uart_init(u16 DeviceId,XUartPs uart_ins)
{int SentCount = 0;int Status;XUartPs_Config *Config;/** Initialize the UART driver so that it's ready to use* Look up the configuration in the config table and then initialize it.*/Config = XUartPs_LookupConfig(DeviceId);if (NULL == Config) {return XST_FAILURE;}Status = XUartPs_CfgInitialize(&uart_ins, Config, Config->BaseAddress);if (Status != XST_SUCCESS) {return XST_FAILURE;}XUartPs_SetBaudRate(&uart_ins, 115200);while (SentCount < (sizeof(HelloWorld) - 1)) {/* Transmit the data */SentCount += XUartPs_Send(&uart_ins,&HelloWorld[SentCount], 1);}return SentCount;}