十天学会单片机中的源程序_第1页
十天学会单片机中的源程序_第2页
十天学会单片机中的源程序_第3页
十天学会单片机中的源程序_第4页
十天学会单片机中的源程序_第5页
已阅读5页,还剩39页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

LESSON21INCLUDESBITP1_1P10UNSIGNEDINTAVOIDMAINWHILE1A51000P1_10WHILEAA51000WHILEAP1_11A51000WHILEAA51000WHILEALESSON22INCLUDEDEFINEUINTUNSIGNEDINTDEFINEUCHARUNSIGNEDCHARSBITD1P10/VOIDDELAYVOIDDELAYUINTVOIDMAINWHILE1D10DELAY100D11DELAY100/VOIDDELAYUINTX,YFORX100X0XFORY600Y0Y/VOIDDELAYUINTZUINTXUCHARYFORXZX0XFORY20Y0YLESSON23INCLUDEINCLUDEDEFINEUINTUNSIGNEDINTDEFINEUCHARUNSIGNEDCHARUCHARTEMP,NUM,NUM1SBITBEEPP23VOIDDELAYUINTVOIDMAINTEMP0XFEWHILE1FORNUM10NUM10XFORY110Y0YLESSON31INCLUDESBITDULAP26SBITWELAP27VOIDMAINWELA1P00XC0WELA0DULA1P00X06DULA0WHILE1LESSON32INCLUDEDEFINEUINTUNSIGNEDINTDEFINEUCHARUNSIGNEDCHARSBITDULAP26SBITWELAP27UCHARNUMUCHARCODETABLE0X3F,0X06,0X5B,0X4F,0X66,0X6D,0X7D,0X07,0X7F,0X6F,0X77,0X7C,0X39,0X5E,0X79,0X71VOIDDELAYUINTZVOIDMAINWELA1/11101010P00XEAWELA0WHILE1FORNUM0NUM0XFORY110Y0YLESSON33INCLUDEDEFINEUINTUNSIGNEDINTDEFINEUCHARUNSIGNEDCHARSBITDULAP26SBITWELAP27SBITD1P10UCHARNUMUCHARCODETABLE0X3F,0X06,0X5B,0X4F,0X66,0X6D,0X7D,0X07,0X7F,0X6F,0X77,0X7C,0X39,0X5E,0X79,0X71VOIDDELAYUINTZVOIDMAINEA1/开总中断EX01/开外部中断0/IT01TCON0X01WELA1/11101010P00XEAWELA0WHILE1FORNUM0NUM0XFORY110Y0YVOIDEXTER0INTERRUPT0D10LESSON34INCLUDEDEFINEUINTUNSIGNEDINTDEFINEUCHARUNSIGNEDCHARSBITDULAP26SBITWELAP27SBITD1P10UCHARNUM,NUM1TTUCHARCODETABLE0X3F,0X06,0X5B,0X4F,0X66,0X6D,0X7D,0X07,0X7F,0X6F,0X77,0X7C,0X39,0X5E,0X79,0X71VOIDDELAYUINTZVOIDMAINNUM0TT0TMOD0X11/设置定时器0为工作方式1TH06553610000/256TL06553610000256TH16553620000/256TL16553620000256/EA1/开总中断ET01/开定时器0中断ET11TR01/启动定时器0TR11WELA1/11101010P00XEAWELA0DULA1P00X3FDULA0WHILE1IFNUM125NUM10P1P1IFTT100TT0NUMIFNUM16NUM0DULA1P0TABLENUMDULA0VOIDDELAYUINTZUINTX,YFORXZX0XFORY110Y0YVOIDTIME0INTERRUPT1TH06553610000/256TL06553610000256TTVOIDTIME1INTERRUPT3TH16553620000/256TL16553620000256NUM1LESSON41INCLUDEINCLUDEDEFINEUINTUNSIGNEDINTDEFINEUCHARUNSIGNEDCHARUCHARTEMP,AA,NUMSBITDULAP26SBITWELAP27UCHARCODETABLE0X3F,0X06,0X5B,0X4F,0X66,0X6D,0X7D,0X07,0X7F,0X6F,0X77,0X7C,0X39,0X5E,0X79,0X71VOIDDELAYUINTZVOIDMAINNUM0AA0TMOD0X01TH06553650000/256TL06553650000256EA1ET01TR01TEMP0XFEP1TEMPDULA1P0TABLE0DULA0WELA1P00XC0WELA0WHILE1DELAY1000TEMP_CROL_TEMP,1P1TEMP/IFAA40AA0NUMIFNUM16NUM0DULA1P0TABLENUMDULA0/VOIDDELAYUINTZUINTX,YFORXZX0XFORY110Y0YVOIDTIMER0INTERRUPT1TH06553650000/256TL06553650000256AAIFAA40AA0NUMIFNUM16NUM0DULA1P0TABLENUMDULA0LESSON42INCLUDEINCLUDEDEFINEUINTUNSIGNEDINTDEFINEUCHARUNSIGNEDCHARUCHARTEMP,AA,NUMDU,NUMWESBITDULAP26SBITWELAP27UCHARCODETABLE0X3F,0X06,0X5B,0X4F,0X66,0X6D,0X7D,0X07,0X7F,0X6F,0X77,0X7C,0X39,0X5E,0X79,0X71UCHARCODETABLEWE0XFE,0XFD,0XFB,0XF7,0XEF,0XDF/VOIDDELAYUINTZVOIDMAINNUMDU0NUMWE0AA0TMOD0X01TH0655365000/256TL0655365000256EA1ET01TR01WHILE1/DELAY1000/TEMP_CROL_TEMP,1/P1TEMPIFAA1AA0NUMDUIFNUMDU7NUMDU1DULA1P0TABLENUMDUDULA0WELA1P0TABLEWENUMWEWELA0NUMWEIFNUMWE6NUMWE0/VOIDDELAYUINTZUINTX,YFORXZX0XFORY110Y0Y/VOIDTIMER0INTERRUPT1TH0655365000/256TL0655365000256AALESSON43INCLUDEDEFINEUINTUNSIGNEDINTDEFINEUCHARUNSIGNEDCHARUCHARTEMP,AA,BAI,SHI,GESBITDULAP26SBITWELAP27UCHARCODETABLE0X3F,0X06,0X5B,0X4F,0X66,0X6D,0X7D,0X07,0X7F,0X6F,0X77,0X7C,0X39,0X5E,0X79,0X71VOIDDISPLAYUCHARBAI,UCHARSHI,UCHARGEVOIDDELAYUINTZVOIDINITVOIDMAININIT/初始化子程序WHILE1IFAA20AA0TEMPIFTEMP100TEMP0BAITEMP/100SHITEMP100/10GETEMP10DISPLAYBAI,SHI,GEVOIDDELAYUINTZUINTX,YFORXZX0XFORY110Y0YVOIDDISPLAYUCHARBAI,UCHARSHI,UCHARGEDULA1P0TABLEBAIDULA0/送百位数P00XFF/打开瞬间一个都不亮,消影WELA1P00XFE/位选通百位数WELA0DELAY1DULA1P0TABLESHIDULA0P00XFFWELA1P00XFDWELA0DELAY1DULA1P0TABLEGEDULA0P00XFFWELA1P00XFBWELA0DELAY1VOIDINIT/对所有数进行初始化/WELA0DULA0TEMP0TMOD0X01TH06553650000/256TL06553650000256EA1ET01TR01VOIDTIMER0INTERRUPT1TH06553650000/256TL06553650000256AALESSON51INCLUDEINCLUDEDEFINEUCHARUNSIGNEDCHARDEFINEUINTUNSIGNEDINTSBITDULAP26SBITWELAP27UCHARCODETABLE0X3F,0X06,0X5B,0X4F,0X66,0X6D,0X7D,0X07,0X7F,0X6F,0X77,0X7C,0X39,0X5E,0X79,0X71,0X76,0X79,0X38,0X3F,0UCHARTEMP,T0,T1,BAI,SHI,GE,FLAG,FLAG1UINTSHUVOIDINITVOIDDISPLAYUCHAR,UCHAR,UCHAR,UCHAR,UCHAR,UCHARVOIDDELAYUINTZUINTT1,YFORT1ZT10T1FORY110Y0YVOIDMAININITWHILE1IFFLAG11DISPLAY7,6,5,BAI,SHI,GEELSEDISPLAY16,17,18,18,19,20VOIDINITSHU432TEMP0XFEP1TEMPTMOD0X11TH06553650000/256TL06553650000256TH16553650000/256TL16553650000256EA1ET01ET11TR01TR11VOIDTIMER0INTERRUPT1TH06553650000/256TL06553650000256T0IFFLAG1IFT010T01TEMP_CROL_TEMP,1P1TEMPELSEIFT040P1P1IFT060TR00P10XFFFLAG11VOIDTIMER1INTERRUPT3TH16553650000/256TL16553650000256T1IFT12T10SHUBAISHU/100SHISHU100/10GESHU10IFSHU398TR00TH06553650000/256TL06553650000256TR01FLAG1T00P10XFFTR10VOIDDISPLAYUCHARAA,UCHARBB,UCHARCC,UCHARBA,UCHARSH,UCHARGDULA1P0TABLEAADULA0P00XFFWELA1P00XFEWELA0DELAY1DULA1P0TABLEBBDULA0P00XFFWELA1P00XFDWELA0DELAY1DULA1P0TABLECCDULA0P00XFFWELA1P00XFBWELA0DELAY1DULA1P0TABLEBADULA0P00XFFWELA1P00XF7WELA0DELAY1DULA1P0TABLESHDULA0P00XFFWELA1P00XEFWELA0DELAY1DULA1P0TABLEGDULA0P00XFFWELA1P00XDFWELA0DELAY1LESSON52INCLUDEDEFINEUINTUNSIGNEDINTDEFINEUCHARUNSIGNEDCHARSBITD1P10SBITDULAP26SBITWELAP27SBITKEY1P34UCHARCODETABLE0X3F,0X06,0X5B,0X4F,0X66,0X6D,0X7D,0X07,0X7F,0X6F,0X77,0X7C,0X39,0X5E,0X79,0X71UCHARNUMVOIDDELAYUINTZUINTX,YFORXZX0XFORY110Y0YVOIDMAINWELA1P00XFEWELA0P30XFFWHILE1IFKEY10DELAY5IFKEY10D10NUMIFNUM10NUM0WHILEKEY1DELAY5WHILEKEY1ELSED11DULA1P0TABLENUMDULA0LESSON53INCLUDEDEFINEUINTUNSIGNEDINTDEFINEUCHARUNSIGNEDCHARSBITDULAP26SBITWELAP27SBITKEY1P34UCHARCODETABLE0X3F,0X06,0X5B,0X4F,0X66,0X6D,0X7D,0X07,0X7F,0X6F,0X77,0X7C,0X39,0X5E,0X79,0X71,0UCHARNUM,TEMP,NUM1VOIDDELAYUINTZUINTX,YFORXZX0XFORY110Y0YUCHARKEYSCANVOIDDISPLAYUCHARAAVOIDMAINNUM17DULA1P00DULA0WELA1P00XC0WELA0WHILE1DISPLAYKEYSCANVOIDDISPLAYUCHARAADULA1P0TABLEAA1DULA0UCHARKEYSCANP30XFETEMPP3TEMPTEMPWHILETEMP0XF0DELAY5TEMPP3TEMPTEMPWHILETEMP0XF0TEMPP3SWITCHTEMPCASE0XEENUM1BREAKCASE0XDENUM2BREAKCASE0XBENUM3BREAKCASE0X7ENUM4BREAKWHILETEMP0XF0TEMPP3TEMPTEMPP30XFDTEMPP3TEMPTEMPWHILETEMP0XF0DELAY5TEMPP3TEMPTEMPWHILETEMP0XF0TEMPP3SWITCHTEMPCASE0XEDNUM5BREAKCASE0XDDNUM6BREAKCASE0XBDNUM7BREAKCASE0X7DNUM8BREAKWHILETEMP0XF0TEMPP3TEMPTEMPP30XFBTEMPP3TEMPTEMPWHILETEMP0XF0DELAY5TEMPP3TEMPTEMPWHILETEMP0XF0TEMPP3SWITCHTEMPCASE0XEBNUM9BREAKCASE0XDBNUM10BREAKCASE0XBBNUM11BREAKCASE0X7BNUM12BREAKWHILETEMP0XF0TEMPP3TEMPTEMPP30XF7TEMPP3TEMPTEMPWHILETEMP0XF0DELAY5TEMPP3TEMPTEMPWHILETEMP0XF0TEMPP3SWITCHTEMPCASE0XE7NUM13BREAKCASE0XD7NUM14BREAKCASE0XB7NUM15BREAKCASE0X77NUM16BREAKWHILETEMP0XF0TEMPP3TEMPTEMPRETURNNUMLESSON61INCLUDESBITCSDAP32SBITWRP36VOIDMAINCSDA0WR0P00WHILE1LESSON62INCLUDEDEFINEUCHARUNSIGNEDCHARDEFINEUINTUNSIGNEDINTSBITWRP36SBITRDP37VOIDDELAYUINTZUINTT1,YFORT1ZT10T1FORY110Y0YVOIDINITVOIDSTARTVOIDMAININITWHILE1STARTDELAY20RD0DELAY10RD1DELAY10VOIDINITP00VOIDSTARTWR1WR0WR1LESSON7INCLUDEUNSIGNEDCHARFLAG,AVOIDMAINTMOD0X20/设置定时器1为工作方式2TH10XFDTL10XFDTR11REN1SM00SM11EA1ES1WHILE1/IFRI1RI0P1SBUF/IFFLAG1ES0FLAG0SBUF1/28WHILETITI0SBUF2/28WHILETITI0SBUF3/28WHILETITI0ES1VOIDSERINTERRUPT4RI0/P1SBUFASBUFFLAG1LESSON8INCLUDEDEFINEUCHARUNSIGNEDCHARDEFINEUINTUNSIGNEDINTUCHARCODETABLE“ILIKEMCU“UCHARCODETABLE1“WWWTXMCUCOM“SBITLCDENP34SBITLCDRSP35SBITDULAP26SBITWELAP27UCHARNUMVOIDDELAYUINTZUINTX,YFORXZX0XFORY110Y0YVOIDWRITE_COMUCHARCOMLCDRS0P0COMDELAY5LCDEN1DELAY5LCDEN0VOIDWRITE_DATAUCHARDATELCDRS1P0DATEDELAY5LCDEN1DELAY5LCDEN0VOIDINITDULA0WELA0LCDEN0WRITE_COM0X38WRITE_COM0X0EWRITE_COM0X06WRITE_COM0X01WRITE_COM0X800X10VOIDMAININITFORNUM0NUMDEFINEUCHARUNSIGNEDCHARSBITSDAP20SBITSCLP21UCHARAVOIDDELAYVOIDSTART/开始信号SDA1DELAYSCL1DELAYSDA0DELAYVOIDSTOP/停止SDA0DELAYSCL1DELAYSDA1DELAYVOIDRESPONS/应答UCHARISCL1DELAYWHILESDA1AFORB100B0BVOIDWRITE_ADDUCHARADDRESS,UCHARDATESTARTWRITE_BYTE0XA0RESPONSWRITE_BYTEADDRESSRESPONSWRITE_BYTEDATERESPONSSTOPUCHARREAD_ADDUCHARADDRESSUCHARDATESTARTWRITE_BYTE0XA0RESPONSWRITE_BYTEADDRESSRESPONSSTARTWRITE_BYTE0XA1RESPONSDATEREAD_BYTESTOPRETURNDATEVOIDMAININITWRITE_ADD23,0XAADELAY1100P1READ_ADD23WHILE1LESSON10INCLUDEDEFINEUCHARUNSIGNEDCHARDEFINEUINTUNSIGNEDINTSBITDULAP26SBITWELAP27SBITRSP35SBITLCDENP34SBITS1P30SBITS2P31SBITS3P32SBITRDP37UCHARCOUNT,S1NUMCHARMIAO,SHI,FENUCHARCODETABLE“2007730MON“UCHARCODETABLE1“000000“VOIDDELAYUINTZUINTX,YFORXZX0XFORY110Y0YVOIDWRITE_COMUCHARCOMRS0LCDEN0P0COMDELAY5LCDEN1DELAY5LCDEN0VOIDWRITE_DATEUCHARDATERS1LCDEN0P0DATEDELAY5LCDEN1DELAY5LCDEN0VOIDINITUCHARNUMDULA0WELA0LCDEN0/FEN59/MIAO53/SHI23WRITE_COM0X38WRITE_COM0X0CWRITE_COM0X06WRITE_COM0X01WRITE_COM0X80FORNUM0NUMINCLUDEVOIDDELAYUINTZUINTX,YFORXZX0XFORY110Y0YVOIDDIDIBEEP0DELAY50BEEP1DELAY100BEEP0DELAY50BEEP1VOIDWRITE_COMUCHARCOMRS0LCDEN0P0COMDELAY5LCDEN1DELAY5LCDEN0VOIDWRITE_DATEUCHARDATERS1LCDEN0P0DATEDELAY5LCDEN1DELAY5LCDEN0VOIDINITUCHARNUMEA1EX01IT01DULA0WELA0LCDEN0/SET_TIMESET_ALARM14,13,10WRITE_DS0X0B,0X26READ_DS0X0C/FEN59/MIAO53/SHI23WRITE_COM0X38WRITE_COM0X0CWRITE_COM0X06WRITE_COM0X01WRITE_COM0X80FORNUM0NUM15NUMWRITE_DATETABLENUMDELAY5WRITE_COM0X800X40FORNUM0NUM12NUMWRITE_DATETABLE1NUMDELAY5VOIDWRITE_SFMUCHARADD,UCHARDATEUCHARSHI,GESHIDATE/10GEDATE10WRITE_COM0X800X40ADDWRITE_DATE0X30SHIWRITE_DATE0X30GEVOIDKEYSCANRD0IFFLAG11IFS20DELAY5IFS20WHILES2FLAG10IFS30DELAY5IFS30WHILES3FLAG10IFS10DELAY5IFS10S1NUMFLAG1FLAG10WHILES1IFS1NUM1TR00WRITE_COM0X800X4010WRITE_COM0X0FIFS1NUM2WRITE_COM0X800X407IFS1NUM3WRITE_COM0X800X

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论