EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
在DSP671x上使用Timer统计信号处理算法的时间消耗
7 M, w9 p/ N( {. K) Y1 Y! e代码实例
! F3 \; o1 J4 P- |1 H( K2 s' J- `4 d8 ?3 N6 v& O' z
hTimer = TIMER_open(TIMER_DEVANY,0); /* open a timer */1 v+ v1 Y) N2 H& v; w6 M8 l
a0 w* M0 Y/ K. W3 S9 J* Z+ E. G/* Configure the timer. 1 count corresponds to 4 CPU cycles in C67 */2 Q6 b& ^+ O; E
/* control period initial value */8 h. E. S$ W {+ ]1 l
TIMER_configArgs(hTimer, 0x000002C0, 0xFFFFFFFF, 0x00000000);
6 r' j; W4 {) ~' L0 @
$ G8 M. v+ x6 { v5 H/* Compute the overhead of calling the timer. */$ `3 j2 `0 q' a* G. i( W
start = TIMER_getCount(hTimer); /* to remove L1P miss overhead */
4 b" [0 U+ }, d0 Lstart = TIMER_getCount(hTimer); /* get count */
- z* y- a5 W9 z- pstop = TIMER_getCount(hTimer); /* get count */
! N1 h) ?. k8 E/ f- p6 y: L3 o3 C8 W2 ]" r9 q6 J: z4 Y3 ?; C. h
overhead = stop - start;
9 p' T: y8 j# X+ y2 _& tstart = TIMER_getCount(hTimer); /* get count */$ ? a% e8 H, ], j0 `' n/ j) r+ s
% d# B$ `" e! g% |) O6 `0 }; e# S+ v/* Call a function here. */
5 H; W8 F' U3 j$ _9 M- Q# t5 S5 m& n
6 q% P G7 z. J. W/ ]+ y/* get count */3 i p T; Y v) S* y! j
diff = (TIMER_getCount(hTimer) – start) ? overhead;
4 n( h M6 w1 m2 \TIMER_close(hTimer);. H: a9 X2 X: N! y8 _ V s' b( T
printf(”%d cycles \n”, diff*4);
4 x% H, A* a% a' s9 L% m' A. b5 A3 [4 R
! F0 J% G% q) a6 }
注意,C6713上定时器的一个计数值对应4个时钟周期。 overhead表示Timer本身配置过程的时钟消耗,所以有diff计算, diff = (TIMER_getCount(hTimer) – start) ? overhead;
6 f4 K# g X( H$ ?6 B- K. F& J7 ~& W# Q
|