基于zynq7020 AD9361 no-os 串口相关的配置
本文介绍了AD9361裸机程序开发中的串口实验实现方法。文章首先说明了硬件设计中通过CP2102芯片实现USB转串口功能,详细给出了原理图连接和Vivado配置方法。在软件设计部分,提供了一个简单的UART打印程序示例代码,展示了如何通过print函数输出"Hello World"信息。文中特别强调了stdin/stdout重定向的配置注意事项,并指出当前使用的是print打印
目前在AD9361的裸机中肯定少不了硬件(FPGA)跟软件(C语言)的协同,所以我们在后续的章节中会分别从软硬件的角度来分析AD9361的裸机程序,另外,我们之前介绍过FPGA的硬件开发大概的流程(vivado)以及软件的开发流程(vitis),所以我们在后面就不那么详细的对工具做手把手介绍了,有疑问的可以参照下前面的文章来复习下
整个AD9361的裸机验证连接如下:https://wlink.blog.csdn.net/article/details/151620972?spm=1001.2014.3001.5502
本文也是针对这个工程来做拆解分析,主要内容是ad9361 no-os裸机程序的串口实验,这块是整个打印的基础,没有这块的配置,你是无法实时debug你写的代码是否正确,本文的实验目的也是可以能够打印出来log.
一. 硬件设计
在看配置前,我们首先来看下原理图,这样才能清楚对应的关系,开发板子上的是通过一个USB转串口来打印log,芯片是用的CP2102,也是比较常见的usb转串口,原理图如下:



通过原理图我们可以看到uart是挂在BANK500上的MIO12/13上,也就是PS核上的,不同为啥在PS核可以参照我这篇文章:https://wlink.blog.csdn.net/article/details/151676741?spm=1001.2014.3001.5502
我们我们对应的vivado的配置如下:



有了这块,其实就可以了,其他的外设我们先不管,当然你也可以自己写一个程序来验证下,我自己也做过实验了,所以这块就省略了。
二. 软件设计
这块我觉得你也可以自己写一个vivado来做下,具体方法可以参照我这篇文章中的软件部分
https://wlink.blog.csdn.net/article/details/151185631
整个代码如下,非常简单哈
/******************************************************************************
*
* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Use of the Software is limited solely to applications:
* (a) running on a Xilinx device, or
* (b) that interact with a Xilinx device through a bus or interconnect.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name of the Xilinx shall not be used
* in advertising or otherwise to promote the sale, use or other dealings in
* this Software without prior written authorization from Xilinx.
*
******************************************************************************/
/*
* helloworld.c: simple test application
*
* This application configures UART 16550 to baud rate 9600.
* PS7 UART (Zynq) is not initialized by this application, since
* bootrom/bsp configures it to baud rate 115200
*
* ------------------------------------------------
* | UART TYPE BAUD RATE |
* ------------------------------------------------
* uartns550 9600
* uartlite Configurable only in HW design
* ps7_uart 115200 (configured by bootrom/bsp)
*/
#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
int main()
{
print("Hello World\n\r");
print("Successfully ran Hello World application");
return 0;
}
就是一个打印,效果如下:
![]()
当然有一个配置,你们可能要注意下


也就是这里stdin,stdout,其实就是重定向而已,不过我们暂时也只是用到了print打印,而不是C语言标准库中的printf打印,这点需要注意一下
火山引擎开发者社区是火山引擎打造的AI技术生态平台,聚焦Agent与大模型开发,提供豆包系列模型(图像/视频/视觉)、智能分析与会话工具,并配套评测集、动手实验室及行业案例库。社区通过技术沙龙、挑战赛等活动促进开发者成长,新用户可领50万Tokens权益,助力构建智能应用。
更多推荐
所有评论(0)