- 1、本文档共26页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 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
您可能关注的文档
- (二)、人物故事((two) character stories).doc
- (世袭金银财富金银争霸)如何做一名成功的黄金操盘手((hereditary gold and silver wealth, gold and silver contend for hegemony) how to be a successful gold trader).doc
- (精)麦肯锡提案标准流程((standard) McKinsey proposal standard process).doc
- (沙锅面)一品砂锅面(附秘制麻辣料、鲜汤、酱卤配方制作)((a casserole casserole (surface) of secret material, spicy soup, sauce recipe)).doc
- (沙锅土豆粉)一品砂锅土豆粉(附秘制麻辣料、鲜汤、酱卤配方)文库((a casserole casserole potato powder) potato flour (with special material, spicy soup, sauce recipe) library).doc
- (沙锅粉)一品砂锅粉(附秘制麻辣料、鲜汤、酱卤配方制作)((casserole powder) a casserole powder (with special material, spicy soup, sauce recipe)).doc
- 00150 金融理论与实务笔记(00150 notes on financial theory and Practice).doc
- (魔兽世界)盗贼的100条守则((World of Warcraft) the 100 code of Thieves).doc
- )浅谈、步行街的规划设计(Talking about the planning and design of pedestrian streets).doc
- 0-播放指南(0- play guide).doc
- 2024年秋三年级英语上册Unit1Hello教案4人教PEP版.doc
- 2024年中考历史一轮复习第一部分中国古代史课时训练03开放与革新的隋唐时代练习岳麓版.docx
- 2024高中地理第一单元人口与地理环境第一节人口增长与人口问题学案含解析鲁教版必修2.doc
- 2024高中生物第6章第4节细胞的癌变教案新人教版必修1.doc
- 2025版高三政治一轮复习每课一测二十九坚持中国特色社会主义文化发展道路.doc
- 2025版高考数学一轮复习第九篇统计与统计案例必修3选修1_2第3节变量的相关性与统计案例习题理含解析.doc
- 2024年高考地理一轮复习专题1.1地图和等高线地形图教案含解析.doc
- 2024高中物理第八章3理想气体的状态方程教学案含解析新人教版选修3_3.docx
- 2025版高考地理大一轮复习第二章区域可持续发展第29讲荒漠化的危害与治理__以我国西北地区为例教案含解析湘教版必修3.docx
- 2024高考生物一轮复习配餐作业25现代生物进化理论含解析.doc
最近下载
- 学前儿童学习与发展核心经验健康领域.pdf
- 新人教版七年级下册英语U4词汇分类循环训练单(学生版).docx
- 2023年下半年教师资格证《高中生物》真题及答案.pdf VIP
- 电子版个人简历模板简历表格 个人简历.docx VIP
- 国家秘密载体印制资质现场审查必威体育官网网址知识测试试题库.pdf VIP
- 2025年新疆乌鲁木齐市高考数学二模试卷(理科)+答案解析(附后).pdf VIP
- 我的家乡黑龙江双鸭山.pptx
- 初级注册安全工程师考试(安全生产法律法规)考点重点资料梳理.pdf VIP
- (最全)山东省2016建筑工程消耗量定额.pdf
- 2025年徐州工业职业技术学院单招职业技能测试题库(历年真题).docx VIP
文档评论(0)