您好,
我要提出一个delay_US()循环计数,它与 DSP28x_usDelay()函数的源文件中描述的计数不同。
请您验证我的分析如下。
斯蒂芬
DSP28x_usDelay函数文件中的注释如下:
;每个循环都有一个9/10的周期开销
;需要五个周期。 LoopCount由提供
;下面的公式:
; DELAY CPU_CYCLES =9+5*LoopCount
; LoopCount =(DELAY CPU_CYCLES -9)/ 5
;宏delay_US(A)将为您执行此计算
我数了3 (3个mov指令)+4 (LCR)+4 (LRETR)=11个开销周期(参见 下面的main()和DSP28x_usDelay()组件)。 是这样吗?
此外,如果传递给 DSP28x_usDelay()的计算延迟循环计数为n,我发现 DSP28x_usDelay()中的循环间期数为n+1。 是这样吗?
例如,如果n=4 (即 150MHz 2.8335万的总周期计数为11+(n+1)*5=11+25=36个周期,相当于36*6.667ns =0.240us。 是这样吗?
C代码:
/*
* main.c
*/
#define CPU_rate 6.667L
extern void DSP28x_usDelay (Long int DelayTime);
#define computed_loop_count(A)(long int)((((((((((( long double) a * 1000.0L)/(long double) cpu_rate)- 9.0L)/5.0L)
#define delay_US (a) DSP28x_usDelay ((long int)(((((( long double) a * 1000.0L)/(long double) cpu_rate)-9.0L)/5.0L)
volatile long int a = 0;
int main (void)
{
a = computed_loop_count (0.210);
DELAY _US (0.210);
返回0;
}
main()汇编代码:
主要: 0.9101万:0204 MOVB ACC,#400.9102万 :761F0300 MOVW DP,#0x3亿 :1E0A MOVL @0xA,符合 14 Delay_US (0.210); 0.9105万:7640.005万 LCR $../DSP2833x_usDelay.ASM:62:75$ 15 返回0; 0.9107万:9A00 MOVB AL,#0x0 16 } 0.9108万:0006 LRETR
DSP28x_usDelay组件代码:
62. 子附件,1号 $../DSP2833x_usDelay.ASM:62:75$(),DSP28x_usDelay: 0.005万:1901 副B ACC,1号 63. BF _DSP28x_usDelay,GEQ;;Loop if ACC >= 0.0051万 :56C3FFFF BF -1,GEQ 64 LRETR