C51程式语言的基本结构.ppt

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

Homework Please design a 4 bits addition tool by the 8051training board, (using the port0-DIP switch and port1-led ) X=1010 Y=1100 X+Y=1 0110 Show at port1 class 2 I/O 、7seg、4x4 keyboard * 要分組 * Intel’s x86: 8086,8088,80386,80486, Pentium Motorola’s 680x0: 68000, 68010, 68020,68030,6040 * * * * * 內頻、外頻、倍頻 * 專為控制使用所設計的8位元單晶片。 具有位元邏輯運算能力。 32雙向且有單獨位址的I/O * * * * * * i * 乘2除2 左移右移 ANSI C51 關鍵字 MCS-51 常用變數型態 變數型態 資料型態 計憶體型態 auto static extern register unsigned char char unsigned int int float double unsigned long long data bdata idata pdata xdata code [變數型態] 資料型態 [計憶體型態] 變數名稱 [ _at_ 位址] 例: static int data i _at_ 0x20 //宣告靜態變數i位於RAM位址0x20處 Some points for attention The program body in main() ;be the ending A or a (upper and lower case ) is different mark:// /*~*/ #include is front command ? #include reg51.h #include AT89X51.h assigned front file Keil-51內有各種不同型式的8051 暫存器定義檔可以提供使用者使用 #includeAT89X51.H //#includereg51.h void delay_1m(unsigned int dly); main() { loop: P1=0xff; P1_0=0; delay_1m(100); P1_0=1; delay_1m(100); goto loop; } void delay_1m(unsigned int dly) { int count; while(dly0) { count=120; while (count0) count--; dly--; } } #include AT89X51.H #include reg51.H How to use delay time void dela_1ms(unsigned int dly)//if the crystal=12MHz { int count; while(dly!=0) { count=120; while(count0) count--; dly--; } } void delay (int dly) { while (dly0) dly--; } 精確的Delay(時間間隔)的設定是要連每一行程式的執行時間都算進去 利用8051Timer做時間控制 delay的問題 Delay :MOV R6,#250 //T1=1 cycle Del-1 :MOV R7,#200 // T2=1 cycle Del-2 : DJNZ R7, Del-2 // T3=2 cycle DJNZ R6, Del-1 // T4=2 cycle RET // T5=2 cycle T=T1+[T2+(T30*200)+T4]*250+T5 =1+[1+(2*200)+2]*250+2 =100753 Delay time =100753*1us=0.1sec C51程式語言的基本結構: C51的基本資料型態 資料型態的轉換 當不同

文档评论(0)

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

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

1亿VIP精品文档

相关文档