EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
在DSP671x上使用Timer统计信号处理算法的时间消耗 x' N1 h0 \- X# ?; Y% |7 U
代码实例
; r5 }2 J, }" \; F# @7 \- G0 f# N+ P: P2 b" w# @% c$ C
hTimer = TIMER_open(TIMER_DEVANY,0); /* open a timer */
K- t3 s- B: m" t! t+ B S% r/ r; i# p M4 c& s% B! j
/* Configure the timer. 1 count corresponds to 4 CPU cycles in C67 */
6 y g5 o0 d8 ~/ D8 q1 R3 R/* control period initial value */8 ~" v8 Z: X R P
TIMER_configArgs(hTimer, 0x000002C0, 0xFFFFFFFF, 0x00000000);
5 w9 u- B1 z: {. A
2 d" E5 Q9 |: M$ M6 r( P/* Compute the overhead of calling the timer. */2 T2 g. j5 M& O/ a
start = TIMER_getCount(hTimer); /* to remove L1P miss overhead */
/ L$ {. |5 w& ^1 z3 Lstart = TIMER_getCount(hTimer); /* get count */
3 a, o% E" B2 i" ^stop = TIMER_getCount(hTimer); /* get count */. p0 Z: `' m; @3 I& n
o. s1 T5 w! y5 t; y! a. @7 L1 o
overhead = stop - start;
' n2 l; x* a* ?7 l' T( j2 ?, lstart = TIMER_getCount(hTimer); /* get count */
3 @& U( @9 J( |+ w; E
, K S$ V8 ], t \6 F! Y3 M/* Call a function here. */
$ n5 g+ E! [8 Q$ A
* D" I# Y3 z! T9 G* Y. f: j- K0 }+ N/* get count */8 T5 b' Y3 I k2 V6 b
diff = (TIMER_getCount(hTimer) – start) ? overhead;
. `& {" l# A; |! u# F8 ~/ W% wTIMER_close(hTimer);$ D' `1 w; C4 ]
printf(”%d cycles \n”, diff*4);% A9 Q5 U9 Z, m2 I& }& l
7 j, I @1 i) R% x( P2 u$ ?
# ^; z% l+ j9 Y4 {! ^ s3 ?4 y
注意,C6713上定时器的一个计数值对应4个时钟周期。 overhead表示Timer本身配置过程的时钟消耗,所以有diff计算, diff = (TIMER_getCount(hTimer) – start) ? overhead;6 C5 F' e1 Q! N3 X. O- @
5 }6 ] G* O- b) I4 g7 v) j |