作者ms6163 ()
看板C_and_CPP
标题Re: [问题] 嵌入式系统的timer问题
时间Thu Apr 12 05:02:43 2007
※ 引述《niewolf (psy....................)》之铭言:
: ※ 引述《niewolf (psy....................)》之铭言:
: : 标题: [问题] 嵌入式系统的timer问题
: : 时间: Sat Apr 7 05:43:33 2007
: : 想请问一下
: : 由於要写一个计算某个function的执行时间
: : 看过一般写c的方法 有clock_t t1,t2
: : 在去相减求出来
: : 还有 struct timeval tv;
: : 再去用gettimeofday(&tv,NULL)去求出时间 再计算
: : 不过 这两种方法在嵌入式系统都不行的样子
: : 第一种 clock取出的东西很诡异
: : t1 有九位数 而t2只有八位数 相减就为负的
: : 第二种方法 取出来的数值都为0
: : 那想请问一下 在板子上跑的 要用什麽去算时间
: : 板子是Creator的
: : 因为找了一个晚上
: : 还是找不太到方法 囧
: : --
: : ◆ From: 219.68.121.117
: : 推 YuAnLee:用jiffies呢?? 04/07 13:08
: 痾..不好意思 我不会用这个耶
: 可以稍微讲一下吗..@@?
: 还有 我们版子上面的单晶片是Samsung S3C4510
: 助教是说要用hardware timer去做
: 囧 可是不知道该怎嚜弄...@@
1. Initializ timer (registers...)
2. Set handler to vector
3. Start timer
4. Timer intr occurs and goes into handler
5. Jiffies++(in handler)
On the other hand, u can write a function that would return the jiffies,
int32u GetTime(){ return jiffie; }
Then,
int32u t1, t2;
t1 = GetTime();
ur_function();
t2 = GetTime();
t2 - t1 would be the execution time of ur_function()
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 70.162.73.236
1F:推 YuAnLee:强者^_^ 04/12 10:16
2F:推 zvc1234455:好文章,有看有推:) 05/31 20:07