单片机delay函数延迟时间计算,delay(80);为什么是600us左右?函数定义void delay(unsigned int t){while(t--);}主函数中delay(80);为什么是600us左右?
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/05 17:59:47
![单片机delay函数延迟时间计算,delay(80);为什么是600us左右?函数定义void delay(unsigned int t){while(t--);}主函数中delay(80);为什么是600us左右?](/uploads/image/z/2165090-50-0.jpg?t=%E5%8D%95%E7%89%87%E6%9C%BAdelay%E5%87%BD%E6%95%B0%E5%BB%B6%E8%BF%9F%E6%97%B6%E9%97%B4%E8%AE%A1%E7%AE%97%2Cdelay%2880%29%3B%E4%B8%BA%E4%BB%80%E4%B9%88%E6%98%AF600us%E5%B7%A6%E5%8F%B3%3F%E5%87%BD%E6%95%B0%E5%AE%9A%E4%B9%89void+delay%28unsigned+int+t%29%7Bwhile%28t--%29%3B%7D%E4%B8%BB%E5%87%BD%E6%95%B0%E4%B8%ADdelay%2880%29%3B%E4%B8%BA%E4%BB%80%E4%B9%88%E6%98%AF600us%E5%B7%A6%E5%8F%B3%3F)
单片机delay函数延迟时间计算,delay(80);为什么是600us左右?函数定义void delay(unsigned int t){while(t--);}主函数中delay(80);为什么是600us左右?
单片机delay函数延迟时间计算,delay(80);为什么是600us左右?
函数定义
void delay(unsigned int t)
{
while(t--);
}
主函数中delay(80);为什么是600us左右?
单片机delay函数延迟时间计算,delay(80);为什么是600us左右?函数定义void delay(unsigned int t){while(t--);}主函数中delay(80);为什么是600us左右?
只有汇编语言才能得到精确的时间.C编译成汇编时,不同的编译器,不同的编译策略都会使最终的程序不一样.
如果短时间的延时,可以利用_nop_()来控制,如果是长时间的可以用定时器中断来控制.
你自己写函数的话,可以在KEIL调试模式下,单步运行,看左侧窗口中的second,那个是程序从复位到当前的运行秒数(可以看到微妙级的),用不同的参数调用delay,比较下,记住差值就可以了.别忘了把项目使用的晶振数填正确.