跳转到主要内容

zcu102(6)AXI_TIMER精确计时

demi 提交于

<font color="#FD8900">作者:bt(CSDN)</font>

配套原码工程已上传https://download.csdn.net/download/botao_li/10915619

<font size="4" style="line-height: 45px;"><strong>AXI Timer</strong></font>

axi_timer模块即为PS可以访问的PL计数器,通过计数值以及接入axi_timer的计数时钟周期,可以在PS内取得比较精确的计时

axi_timer有2种使用方式,一种是作为计数器使用,另一种是作为定时器使用

<font size="4" style="line-height: 45px;"><strong>Block Designr</strong></font>

建立Vivado工程,新建Block Design,并且添加zynq模块,AXI Timer模块,以及ILA模块

保持zynq模块的默认配置

使能UART0,连接至MIO 18 19,用于串口显示调试信息

<center><img width="600" src="http://xilinx.eetrend.com/files/2019-09/%E5%8D%9A%E5%AE%A2/100045060-79…; alt=""></center><br>

添加PL至PS的中断输入接口

<center><img width="600" src="http://xilinx.eetrend.com/files/2019-09/%E5%8D%9A%E5%AE%A2/100045060-79…; alt=""></center><br>

双击axi_timer模块,按下图设置

<center><img width="600" src="http://xilinx.eetrend.com/files/2019-09/%E5%8D%9A%E5%AE%A2/100045060-79…; alt=""></center><br>

在Block Design中自动连接和手动连接之后,完成设计

<center><img width="600" src="http://xilinx.eetrend.com/files/2019-09/%E5%8D%9A%E5%AE%A2/100045060-79…; alt=""></center><br>

在Vivado中生成bitstream,并且Export to Hardware,之后打开SDK

<font size="4" style="line-height: 45px;"><strong>SDK</strong></font>

建立helloworld模板工程,双击helloworld.c添加功能代码

注意,无论axi_timer模块作为计数器还是定时器,都是每个时钟周期计数增1或者减1,由于在Block Design中时钟输入接口来源于PS模块的时钟输出,注意需要打开PS模块设置界面确认Actual Frequency

<center><img width="600" src="http://xilinx.eetrend.com/files/2019-09/%E5%8D%9A%E5%AE%A2/100045060-79…; alt=""></center><br>

在SDK建立的BSP工程中,xparameters.h也保存该频率值XPAR_AXI_TIMER_0_CLOCK_FREQ_HZ

具体编程参考自BSP中system.mss中导入的示例程序

<img src="http://xilinx.eetrend.com/files/2019-09/%E5%8D%9A%E5%AE%A2/100045060-79…; alt=""><br>

<strong>计数器代码</strong>
<embed style="background-color:#e9e9e9;" src="http://xilinx.eetrend.com/files/2019-09/%E5%8D%9A%E5%AE%A2/100045060-79…; width="600" height="480" />

<strong>定时器代码:</strong>
<embed style="background-color:#e9e9e9;" src="http://xilinx.eetrend.com/files/2019-09/%E5%8D%9A%E5%AE%A2/100045060-79…; width="600" height="480" />

<font color="#FD8900">版权声明:本文为CSDN博主「bt_」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。</font>
原文链接:https://blog.csdn.net/botao_li/article/details/86475467