vxTimeBaseGetを使って時間測定計測する際に
vxTimeBaseSet(0,0)で上位下位32bitレジスタを初期化しないと
レジスタオーバーフローしてヘンテコな時間になる?
ラウンドするまで時間長いはずなので実質問題ない?
初期化やっとく分には問題ない。
vxTimeBaseSet(0,0); /* set the TBH and TBL registers to 0 */
taskDelay(rate*3600); /* suspend for 1 hour */
vxTimeBaseGet(&tbu,&tbl); /* read the TBH and TBL again */
#include <vxLib.h>
void testSysClockAccuracy(int rate)
{
UINT32 tbu, tbl, i;
printf("SysClkRate=%d\n", rate);
sysClkRateSet(rate);
taskDelay(2);
vxTimeBaseSet(0,0); /* set the TBH and TBL registers to 0 */
taskDelay(rate*3600); /* suspend for 1 hour */
vxTimeBaseGet(&tbu,&tbl); /* read the TBH and TBL again */
for(i=0; i < 3600;i++) /* Count down 3600 second from TBL and TBH (16500000 units for for 1 second) */
{ /* <TBL TBH> -= 3600*16500000; */
if (tbl < 16500000)
{
tbu--; /* borrow */
}
tbl -= 16500000;
}
printf("tbu diff =%x (%d) , tbl diff =%x (%d)", tbu, tbu,tbl, tbl);
/* print out the difference in TBL and TBH units */
}
2009年9月5日土曜日
vxWorks 時間測定計測 vxTimeBaseGet vxTimeBaseSet
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿