TI中文支持网
TI专业的中文技术问题搜集分享网站

delay_us(10)与delay_us(a),long a=10 效果不同的问题

问题描述: delay_us(a),long a=10  比   delay_us(10)用定时器实测前者为15us,后者为10us   28377s,delay_us也已经定义到RAM里了,测试方法:程序在线调试通过一个定时器在CCS窗口中看的,又试了delay_us(a),long a=20  比   delay_us(20)也是多5us. a定义成int long float 都试了,都是这个现象。 delay_us是汇编写的,

请问为什么会有这样的现象?还是说汇编写的代码不可以这样用一个变量作为参数,只能写成 10 20之类的数字?

求解。

Susan Yang:您指的是下面的语句?

//
// DO NOT MODIFY THIS LINE.
//
#define DELAY_US(A)F28x_usDelay(((((long double) A * 1000.0L) / (long double)CPU_RATE) – 9.0L) / 5.0L)

这个是个宏定义,您直接给A赋值即可

问题描述: delay_us(a),long a=10  比   delay_us(10)用定时器实测前者为15us,后者为10us   28377s,delay_us也已经定义到RAM里了,测试方法:程序在线调试通过一个定时器在CCS窗口中看的,又试了delay_us(a),long a=20  比   delay_us(20)也是多5us. a定义成int long float 都试了,都是这个现象。 delay_us是汇编写的,

请问为什么会有这样的现象?还是说汇编写的代码不可以这样用一个变量作为参数,只能写成 10 20之类的数字?

求解。

user5229665:

回复 Susan Yang:

您好。是这个。请教一下您说的直接赋值是什么意思?我 比较了F28x_usDelay(((((long double) 10 * 1000.0L) / (long double)CPU_RATE) – 9.0L) / 5.0L)和F28x_usDelay(((((long double) a * 1000.0L) / (long double)CPU_RATE) – 9.0L) / 5.0L) ,long a=10,发现前者是10us,后者是15us

问题描述: delay_us(a),long a=10  比   delay_us(10)用定时器实测前者为15us,后者为10us   28377s,delay_us也已经定义到RAM里了,测试方法:程序在线调试通过一个定时器在CCS窗口中看的,又试了delay_us(a),long a=20  比   delay_us(20)也是多5us. a定义成int long float 都试了,都是这个现象。 delay_us是汇编写的,

请问为什么会有这样的现象?还是说汇编写的代码不可以这样用一个变量作为参数,只能写成 10 20之类的数字?

求解。

Susan Yang:

回复 user5229665:

;//The C assembly call from the DELAY_US(time) macro will
;//look as follows:
;//extern void Delay(long LoopCount);
;//MOVAL,#LowLoopCount
;//MOVAH,#HighLoopCount
;//LCR_Delay
;//Or as follows (if count is less then 16-bits):
;//MOVACC,#LoopCount
;//LCR_Delay

;There is a 9/10 cycle overhead and each loop;takes five cycles. The LoopCount is given by;the following formula:; DELAY_CPU_CYCLES = 9 + 5*LoopCount; LoopCount = (DELAY_CPU_CYCLES – 9) / 5; The macro DELAY_US(A) performs this calculation for you

您可以对照一下下图的反汇编

赞(0)
未经允许不得转载:TI中文支持网 » delay_us(10)与delay_us(a),long a=10 效果不同的问题
分享到: 更多 (0)