作者:付漢杰 hankf@amd.com
1. 硬件的Vivado Block design設(shè)計(jì)中,添加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獲取時(shí)間戳
通過XTmrCtr_GetValue獲取時(shí)間戳,是以時(shí)鐘周期為單位的??梢赞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文章
5589瀏覽量
136392 -
MicroBlaze
+關(guān)注
關(guān)注
3文章
68瀏覽量
21969 -
Timer
+關(guān)注
關(guān)注
1文章
64瀏覽量
13220 -
AXI
+關(guān)注
關(guān)注
1文章
136瀏覽量
17263 -
時(shí)間戳
+關(guān)注
關(guān)注
0文章
15瀏覽量
2747
原文標(biāo)題:AMD MicroBlaze中通過AXI Timer獲取時(shí)間戳
文章出處:【微信號(hào):Hack電子,微信公眾號(hào):Hack電子】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。
發(fā)布評(píng)論請(qǐng)先 登錄
MicroBlaze串口設(shè)計(jì)

時(shí)間同步獲取時(shí)間戳
請(qǐng)問RX23T如何獲取系統(tǒng)時(shí)鐘,以便獲取類似時(shí)間戳,如何獲取此段代碼運(yùn)行時(shí)間?
請(qǐng)問如何通過MicroBlaze訪問BRAM?
請(qǐng)問microblaze如何通過串口讀寫FPGA內(nèi)部axi4總線上的寄存器?
時(shí)間戳的簡(jiǎn)介與實(shí)現(xiàn)
ulog里現(xiàn)在默認(rèn)的時(shí)間戳是從哪里獲取的呢?
如何在tilebox上獲取時(shí)間戳?
基于AXI總線的MicroBlaze雙核SoPC系統(tǒng)設(shè)計(jì)

Basys3開發(fā)板的MicroBlaze串口實(shí)驗(yàn)

AXI總線的MicroBlaze雙核SoPC系統(tǒng)設(shè)計(jì)

如何使用MicroBlaze調(diào)用AXI IP核詳細(xì)解析

uCOS-III(2) 時(shí)間戳

MicroBlaze大內(nèi)部存儲(chǔ)器(AXI BRAM)設(shè)計(jì)

評(píng)論