EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
在DSP671x上使用Timer统计信号处理算法的时间消耗
( R w, u5 q6 R8 H A% H, X+ b! h% ^代码实例& s6 I) t2 e" }% h, H
6 _5 y) E3 h7 z
hTimer = TIMER_open(TIMER_DEVANY,0); /* open a timer */
& }- Q' e/ r7 F# X; L. q. z8 a8 W7 i' t* C
/* Configure the timer. 1 count corresponds to 4 CPU cycles in C67 */
) [% B: C( Y3 D& H9 [& }, k' O/* control period initial value */2 W+ O$ p8 s4 \# p$ g
TIMER_configArgs(hTimer, 0x000002C0, 0xFFFFFFFF, 0x00000000);) T. J6 _% x" A+ l1 Q* A
' `/ w/ E" U/ @$ F6 V% D& |9 q! G$ J/* Compute the overhead of calling the timer. */- ^' u" y! n* z y
start = TIMER_getCount(hTimer); /* to remove L1P miss overhead */
" {7 A+ }! B3 j1 Ystart = TIMER_getCount(hTimer); /* get count */
; }2 {7 w( `% s2 W, w7 M, Vstop = TIMER_getCount(hTimer); /* get count */
, h' }( ^+ \5 x7 d
u" w) \0 S8 U' moverhead = stop - start;
6 U1 f! N% h* \0 h$ ^% Y istart = TIMER_getCount(hTimer); /* get count */
% \" K o9 O# o
7 @) O# i9 U! P) E3 v7 c' ?, _" r/ a/* Call a function here. */
; b5 R5 n! L* N
$ k5 @- `+ E2 r# B. p+ Z/* get count */; i! D* g) y: O( X& f+ x& h
diff = (TIMER_getCount(hTimer) – start) ? overhead; ) p: F/ k# \6 C5 W
TIMER_close(hTimer);% p4 f! ? h% Z. u" B. s; u* [; s/ Z
printf(”%d cycles \n”, diff*4);
% N# l# F. h% E7 S6 @/ C
* N; n) o0 E( R2 `) d9 Q6 d2 A- H6 G! w+ M$ F% @
注意,C6713上定时器的一个计数值对应4个时钟周期。 overhead表示Timer本身配置过程的时钟消耗,所以有diff计算, diff = (TIMER_getCount(hTimer) – start) ? overhead;
# S! H# x0 g- U D! i" t
$ @$ H" S1 E% o4 X0 B |