作者:付漢杰 hankf@amd.com
1. 硬件的Vivado Block design設(shè)計中,添加AXI Timer
2. 包含AXI Timer的頭文件
#include "xtmrctr.h"
3. 定義timer的參數(shù)和全局變量
/* * The following constants map to the XPAR parameters created in the * xparameters.h file. They are only defined here such that a user can easily * change all the needed parameters in one place. */ #define TMRCTR_DEVICE_ID XPAR_TMRCTR_0_DEVICE_ID /* * This example only uses the 1st of the 2 timer counters contained in a * single timer counter hardware device */ #define TIMER_COUNTER_0 0 // #define XPAR_AXI_TIMER_0_CLOCK_FREQ_HZ 100000000U 100 000 000U #define TMRCTR_DEVICE_FREQ_MS (XPAR_TMRCTR_0_CLOCK_FREQ_HZ/1000) #define TMRCTR_DEVICE_FREQ_US (TMRCTR_DEVICE_FREQ_MS/1000) #define TMRCTR_DEVICE_PERIOD_NS ( (1000*1000*1000)/XPAR_AXI_TIMER_0_CLOCK_FREQ_HZ ) XTmrCtrTimerCounter;/*TheinstanceoftheTmrctrDevice*/
4. 初始化AXI Timer
調(diào)用TmrCtrPolledInit()初始化AXI Timer, 也初始化了全局變量TimerCounter。
TmrCtrPolledInit(TMRCTR_DEVICE_ID,TIMER_COUNTER_0);
其中TmrCtrPolledInit()來自于xtmrctr_polled_example.c中的TmrCtrPolledExample(),可以在BSP中從AXI Timer的“Import Example”中導(dǎo)入。
5. 通過XTmrCtr_GetValue獲取時間戳
通過XTmrCtr_GetValue獲取時間戳,是以時鐘周期為單位的??梢赞D(zhuǎn)化成微妙、毫秒、秒等單位。
time_begin = XTmrCtr_GetValue(TmrCtrInstancePtr, TmrCtrNumber); for (i=0; i<100000; i++ ) { g_iLoopTest++; } time_end = XTmrCtr_GetValue(TmrCtrInstancePtr, TIMER_COUNTER_0); if( time_end < time_begin ){ time_diff = 0xffffffff - time_begin; time_diff = time_diff + time_end + 1; } else { time_diff = time_end - time_begin; } time_diff_us = time_diff/TMRCTR_DEVICE_FREQ_US; xil_printf("100K loop: %x : Timer diff: 0x%08x = %d Cycles, %d us, %d ms at %s : %d ", ????????????g_iLoopTest,?time_diff,?time_diff,?time_diff_us,?time_diff_us/1000,?__
-
amd
+關(guān)注
關(guān)注
25文章
5503瀏覽量
134696 -
MicroBlaze
+關(guān)注
關(guān)注
3文章
68瀏覽量
21609 -
Timer
+關(guān)注
關(guān)注
1文章
64瀏覽量
12832 -
AXI
+關(guān)注
關(guān)注
1文章
128瀏覽量
16730 -
時間戳
+關(guān)注
關(guān)注
0文章
15瀏覽量
2640
原文標(biāo)題:AMD MicroBlaze中通過AXI Timer獲取時間戳
文章出處:【微信號:Hack電子,微信公眾號:Hack電子】歡迎添加關(guān)注!文章轉(zhuǎn)載請注明出處。
發(fā)布評論請先 登錄
相關(guān)推薦
MicroBlaze串口設(shè)計
![<b class='flag-5'>MicroBlaze</b>串口設(shè)計](https://file1.elecfans.com/web2/M00/8E/BB/wKgaomTJssCAavRQAAA6bks6iy4937.png)
請問RX23T如何獲取系統(tǒng)時鐘,以便獲取類似時間戳,如何獲取此段代碼運行時間?
請問如何通過MicroBlaze訪問BRAM?
請問microblaze如何通過串口讀寫FPGA內(nèi)部axi4總線上的寄存器?
ulog里現(xiàn)在默認(rèn)的時間戳是從哪里獲取的呢?
如何在tilebox上獲取時間戳?
基于AXI總線的MicroBlaze雙核SoPC系統(tǒng)設(shè)計
![基于<b class='flag-5'>AXI</b>總線的<b class='flag-5'>MicroBlaze</b>雙核SoPC系統(tǒng)設(shè)計](https://file.elecfans.com/web2/M00/49/51/pYYBAGKhtEWAa7E1AAARRr9h8EA440.jpg)
Basys3開發(fā)板的MicroBlaze串口實驗
![Basys3開發(fā)板的<b class='flag-5'>MicroBlaze</b>串口實驗](https://file1.elecfans.com//web2/M00/A6/A7/wKgZomUMP2uAEFVWAAAep7WtGmw813.png)
AXI總線的MicroBlaze雙核SoPC系統(tǒng)設(shè)計
![<b class='flag-5'>AXI</b>總線的<b class='flag-5'>MicroBlaze</b>雙核SoPC系統(tǒng)設(shè)計](https://file.elecfans.com/web2/M00/49/3B/poYBAGKhwJGAH2KeAAAmCmtIcwA138.png)
如何使用MicroBlaze調(diào)用AXI IP核詳細(xì)解析
![如何使用<b class='flag-5'>MicroBlaze</b>調(diào)用<b class='flag-5'>AXI</b> IP核詳細(xì)解析](https://file.elecfans.com/web1/M00/ED/21/pIYBAGCHg4CABdTEAAAK3e87scY616.jpg)
MicroBlaze大內(nèi)部存儲器(AXI BRAM)設(shè)計
![<b class='flag-5'>MicroBlaze</b>大內(nèi)部存儲器(<b class='flag-5'>AXI</b> BRAM)設(shè)計](https://file.elecfans.com/web2/M00/1F/62/poYBAGGYHraAE2EZAAH2PDEJATg114.png)
評論