EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册  
 
x
 
在DSP671x上使用Timer统计信号处理算法的时间消耗3 s0 v( m: i% v: V9 }$ n 
代码实例 
  D8 C0 s4 l4 [% x8 Q" C% t2 x: c$ i" J9 G8 Q% N 
hTimer = TIMER_open(TIMER_DEVANY,0); /* open a timer */  }! v: N* F- N3 o 
 
7 Q6 Z6 t( i9 ~- x# |6 Q& d1 _/* Configure the timer. 1 count corresponds to 4 CPU cycles in C67 */2 q7 v: q+ h1 [  c$ U 
/* control period initial value */ 
4 R8 l& `! k) k( ?# T  x: QTIMER_configArgs(hTimer, 0x000002C0, 0xFFFFFFFF, 0x00000000);+ d8 U& [- Z6 M6 M 
) S3 {) r" L% y( N5 S. H 
/* Compute the overhead of calling the timer. */ 
( A& R( p! }$ w$ G# b- h6 |$ y" Ostart = TIMER_getCount(hTimer); /* to remove L1P miss overhead */ 
8 |( ?4 {7 F0 e, Cstart = TIMER_getCount(hTimer); /* get count */1 @0 x& N0 r5 {' _* ^7 H& r 
stop = TIMER_getCount(hTimer); /* get count */ 
) o7 a: s+ ?8 B4 Z4 h# D  f2 f+ R9 u5 ]# p! b! x7 A7 c2 e 
overhead = stop - start; 
6 N8 n( ^3 D% b# g/ p% Tstart = TIMER_getCount(hTimer); /* get count */ 
; c6 T) {' ]0 V 
4 `& ]. j0 v' [- C/* Call a function here. */ 
' L" \: Z" x5 |( U3 H) L6 i9 a7 r* }. Y: x0 S 
/* get count */ 
- ?6 o6 a" h1 v1 ~: bdiff = (TIMER_getCount(hTimer) – start) ? overhead; : y  Z% t2 _3 E6 S 
TIMER_close(hTimer);; ^. D& q$ g' a# {- [# K 
printf(”%d cycles \n”, diff*4);3 k; ]( _1 @% q- O 
 
5 L& C1 `$ c4 s. ~  q  f* k5 o7 H: b6 v' d 
注意,C6713上定时器的一个计数值对应4个时钟周期。 overhead表示Timer本身配置过程的时钟消耗,所以有diff计算, diff = (TIMER_getCount(hTimer) – start) ? overhead;* M& W& C2 M/ i2 d6 Q1 }" k 
1 X3 D# g5 }! E; n' j7 p$ e 
 |