网站大量收购独家精品文档,联系QQ:2885784924

c51中精确的延时与计算的实现(Precise delay and calculation implementation in C51).doc

c51中精确的延时与计算的实现(Precise delay and calculation implementation in C51).doc

  1. 1、本文档共26页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
c51中精确的延时与计算的实现(Precise delay and calculation implementation in C51)

c51中精确的延时与计算的实现(Precise delay and calculation implementation in C51) Precise delay and calculation implementation in C51 C51 due to its readability and portability is very strong, has been widely used in the MCU, but at some point the C51 program in the exact time requirements, would be written in assembly language, but in the precise control of whether C51 can also realize the time? The answer is yes. In C51, there are several ways to achieve accurate time delay One: for a very short delay, required in the US level, using the _nop_ function, this function is a compilation of NOP instructions, delay a few microseconds, insert such a function. Second: for longer delay, requires more than 10us, using C51 in the loop statement to achieve. When you choose a loop statement in C51, you should pay attention to the following questions First, define the cyclic variables in C51, and use unsigned character variables as much as possible. Second, in the FOR statement, how to do as far as possible the use of variable cycle. Third, at do... While, a while statement, the variable is used by the body of the loop method. This is because in the C51 compiler, different loops are used with different instructions. Here are some examples: Unsigned char I; For (i=0; i255; i++); Unsigned char I; For (i=255; I0; i--); Of these, the second loop statement, C51, is compiled with the DJNZ instruction, which corresponds to the following instructions: MOV, 09H, 0FFH LOOP:DJNZ, 09H, LOOP The instructions are fairly concise and well calculated for accurate time delays. Same for do... The same is true in the while and while loop statements Cases: Unsigned char n; N=255; Do{n--} While (n); or N=255; While (n) {n--}; These two loop statements are compiled by C51 to form a method for DJNZ to complete, so it is convenient to calculate the exact time. Third: for the exact delay time is longer, then the loop nesting method is used, so the nested loop method is often used to achieve ms level delay. For loop

您可能关注的文档

文档评论(0)

f8r9t5c + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8000054077000003

1亿VIP精品文档

相关文档