summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorJiaojinxing <jiaojinxing1987@gmail.com>2015-04-19 13:47:06 (GMT)
committer Jiaojinxing <jiaojinxing1987@gmail.com>2015-04-19 13:47:06 (GMT)
commita9be28472068087b39c85e2ccf7512a4a29231f1 (patch)
treef5d165a9a4aa4e871983ab1a0f95f4c774d6a8b6
parent11cc2f2d8a4fa0f9c8e5784aa679c74ebf219a95 (diff)
downloadbspam335x-a9be28472068087b39c85e2ccf7512a4a29231f1.zip
bspam335x-a9be28472068087b39c85e2ccf7512a4a29231f1.tar.gz
bspam335x-a9be28472068087b39c85e2ccf7512a4a29231f1.tar.bz2
Improve the calculation accuracy of high resolution timing.
-rw-r--r--SylixOS/bsp/bspLib.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/SylixOS/bsp/bspLib.c b/SylixOS/bsp/bspLib.c
index dd24430..422f0d3 100644
--- a/SylixOS/bsp/bspLib.c
+++ b/SylixOS/bsp/bspLib.c
@@ -747,7 +747,7 @@ static VOID __tickThread (VOID)
精确时间换算参数
*********************************************************************************************************/
static UINT32 _G_uiTimerCntPerTick;
-static UINT32 _G_uiTimerNSecPerCnt;
+static UINT64 _G_ui64TimerNSecPerCnt7;
static UINT32 _G_uiTimerReloadValue;
/*********************************************************************************************************
** 函数名称: __tickTimerIsr
@@ -816,9 +816,9 @@ VOID bspTickInit (VOID)
*/
#define __TIMER_OVERFLOW 0xFFFFFFFF
- _G_uiTimerCntPerTick = 24 * 1000000 / LW_TICK_HZ;
- _G_uiTimerNSecPerCnt = (1000 * 1000 * 1000 / LW_TICK_HZ) / _G_uiTimerCntPerTick;
- _G_uiTimerReloadValue = __TIMER_OVERFLOW - _G_uiTimerCntPerTick;
+ _G_uiTimerCntPerTick = 24 * 1000000 / LW_TICK_HZ;
+ _G_ui64TimerNSecPerCnt7 = ((1000 * 1000 * 1000 / LW_TICK_HZ) << 7) / _G_uiTimerCntPerTick;
+ _G_uiTimerReloadValue = __TIMER_OVERFLOW - _G_uiTimerCntPerTick;
/*
* This function will enable clocks for the DMTimer2 instance
@@ -895,7 +895,7 @@ VOID bspTickHighResolution (struct timespec *ptv)
}
}
- ptv->tv_nsec += uiDone * _G_uiTimerNSecPerCnt;
+ ptv->tv_nsec += (LONG)((_G_ui64TimerNSecPerCnt7 * uiDone) >> 7);
if (ptv->tv_nsec >= 1000000000) {
ptv->tv_nsec -= 1000000000;
ptv->tv_sec++;