欢迎来到天天文库
浏览记录
ID:41629078
大小:52.05 KB
页数:3页
时间:2019-08-29
《实验三定时器应用》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、实验三定时器实验一实验目的掌握定时和计数的基本概念掌握51定时器和计数器的结构和编程掌握定时器计数器典型应用方法二实验内容1计数方式应用任务:利用timer的计数功能,每按5次键则变反P1.0口;实验电路:U1191829303?12345678>XTAL1P0.0/AD0Dnv/arirU.I/AU1P0.2/AD2XTAL2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6RSTP0.7/AD7P2.0/A8P2.1/A9P2.2/A10PSENP2.3/A11ALEP2.4/A12EAP
2、2.5/A13P2.6/A14P2.7/A15P1.0P3.0/RXDP1.1P3.1/TXDP1.2P3.2/INT0P1.3P3.3/INT1P1.4P3.4/T0P1.5P3.5/T1P1.6P3.6/WRP1.7P3.7/RDAT89C51383736353433322122232425262728101112131415161739A
3、R1470RTBUTTON4oo—汇编参考程序:main:orgOOOOhajmpinainorgOOObhajmpftOsetbeasetbetOmovtmod,#
4、00000110b;TOI作在计数方式2HiovthO,#251movtl0,#251;写初值setbtrOfto:ajmp$cplpl.0retiend2定时应用任务:利用timer的定时功能,从P1.0输出2ms的方波实验电路:U1191829303?CB12345678>XTAL1XTAL2RSTPO.O/ADOP0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7P2.0/A8P2.1/A9P2.2/A10PSENAl匚P2.3/A11P2.4
5、/A12P2.5/A13ALtEAP2.6/A14P1.0P1.1P1.2P2.7/A15doc/avcro.u/nAUP3.1/TXDP3.2/INT0P1.3P3.3/INT1doarmr1・4P1.5P1.6ro.4/IUP3.5/T1P3.6/WRP1.7P37/RDAT89C5110i71314151617汇编参考程序:main:ftO:orgOOOOhajmpmainorgOOObhajmpftOsetbeasetbetOmovtmod,#00000001b;T0X作在定时方式1movthO,#6
6、4536/256;65536-1000movtlOz#64536^256;写初值setbtrOajmp$cplpl・0movthO,#64536/256;65536-1000movtl0,#64536%256;写初值retiend3秒表结合LCD,设计简易秒表任务:利用timer的定吋功能,实验电路:1-HIsimpletimers003--Icando盜卷uj8588SS8&9Qz86—zco寸.a0—GgCM•I丨<J07、誥::1-"一3-4-JZitR$TP$ENALEEAPD3心P0.1//O1PD.2//5O2P0.3/ZCGP0.4/AMP0.5/A55P0.6/AKP0.7/XXJ7P2O/X®P2.1/«P2.2/A10P2.3XA11P2.4XA12P2.5/A13P2.6/A14P2.7/A15pO.i?・p0.24-■36p0.35"-35p0.46-P4p0.57-■33p0.68・■329■P1.0H2pi.inr2Ex234567•••••■p1P1P1P1P1P1P3.0/RXDP3.1/TXDP3.8、2/1WP3.37TN1TP34/IDP35/T1P3.6/WRP3.7/R5012参考程序:#include"reg51.hM#includeTcd_1602.c"unsignedintx=0Jy=0:voidmainO{EA二1;ETO=1;TMOD=OX01;THO=(65536-50000)/256;TL0=(65536-50000)%256;TRO=1:LCD.InitialO;GotoXY(0,0):代Print("simpletimer:");for(:;)GotoXYfO,1);LCDJVri9、te(h0x30+y/100):LCD.Writed,0x30+y%100/10)LCDJVrite(h0x30+y%10):PrintC——Icando");//50毫秒定时voidtimerO(void)interrupt1{TH0=(65536-50000)/256;TL0=(65536-50000)%256;x++;尸x/20;
7、誥::1-"一3-4-JZitR$TP$ENALEEAPD3心P0.1//O1PD.2//5O2P0.3/ZCGP0.4/AMP0.5/A55P0.6/AKP0.7/XXJ7P2O/X®P2.1/«P2.2/A10P2.3XA11P2.4XA12P2.5/A13P2.6/A14P2.7/A15pO.i?・p0.24-■36p0.35"-35p0.46-P4p0.57-■33p0.68・■329■P1.0H2pi.inr2Ex234567•••••■p1P1P1P1P1P1P3.0/RXDP3.1/TXDP3.
8、2/1WP3.37TN1TP34/IDP35/T1P3.6/WRP3.7/R5012参考程序:#include"reg51.hM#includeTcd_1602.c"unsignedintx=0Jy=0:voidmainO{EA二1;ETO=1;TMOD=OX01;THO=(65536-50000)/256;TL0=(65536-50000)%256;TRO=1:LCD.InitialO;GotoXY(0,0):代Print("simpletimer:");for(:;)GotoXYfO,1);LCDJVri
9、te(h0x30+y/100):LCD.Writed,0x30+y%100/10)LCDJVrite(h0x30+y%10):PrintC——Icando");//50毫秒定时voidtimerO(void)interrupt1{TH0=(65536-50000)/256;TL0=(65536-50000)%256;x++;尸x/20;
此文档下载收益归作者所有