




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
-4推算阴历日期的程序流程图5测试结果设计完成后,给系统上电,液晶显示屏显示结果如图5-1所示。滚动显示天津工程师范学院自动化0302班许宁毕业设计SOLAR2000/01/01LUNAR2095/11/25滚动显示天津工程师范学院自动化0302班许宁毕业设计SOLAR2000/01/01LUNAR2095/11/2500:00:00SUN闹铃关闰月00:00滚动显示图5-1液晶显示屏的显示结果调节10K电位器R4可调整液晶显示屏的亮度。调整到合适亮度后,按控制按钮,光标会从阳历年位开始闪烁,进入设定调整状态。此时按加按钮,当前数字就可改变。按一次,数字加1;若长按,则数字连续加。此时,调整的位一直在闪烁,直到再次按光标移动控制位,光标跳到下一位闪烁。调整顺序依次为:阳历年、月、日,阴历年、月、日,时、分、秒,闹铃时、分。当全部参数调整完毕后,按退出按钮,光标停止闪烁,退出设定调整状态;当再次按下此按钮,闹铃显示“开”;当第三次按下此键,闹铃显示“关”。若当前月为闰月,则屏幕左下角会显示“闰月”;若不是闰月,则无显示。调试分为硬件调试和软件调试。硬件调试主要是检测硬件电路是否有短路、断路、虚焊等。DS1302的硬件电路很简单,只通过3根线与单片机相连,很容易检测,主要是检查其引脚,如晶振和电源等是否接好。另外可以通过软件来调试硬件,如为了测试显示电路连接是否正确,可以编写一个简单的显示程序来测试它。接下来可进行软件调试,可以编写只含DS1302的计时和读写程序、显示程序,测试DS1302是否正常工作。最后调试时间调整程序和阴历推算程序。计时器最关键的是计时的精度。电子万年历中DS1302电路使用专用的晶振,经测试制作的电子万年历,一星期快了3s左右,误差较大,实验设计中可换用标准晶振或用软件进行修正。6结论本设计硬件电路的使用比较简单,所用元器件较少,电路中使用了AT89S52单片机、DS1302时钟芯片、24C02FLASH存储器和HY-12864液晶显示器等主要芯片,实现了预计的功能。在对芯片的管脚功能和用法有了充分的了解后,根据原先的选择好的设计要求设计硬件电路,包括单片机控制电路、时钟电路、存储电路、键盘接口电路、显示电路和闹铃电路。然后通过软件编程,实现了对年、月、日、时、分、秒、星期、闰年和阴历的自动调整,用按键进行控制,用液晶模块进行显示,并具有闹铃功能。电子万年历可以正常显示时间并进行时间调整,基本完成了预期要实现的目标。但是本设计中还有许多不尽如人意的地方,比如说电路板设计不太合理,体积过大,不便于摆放,阴历查询日期从2000年至2050年,时间过于局限等等。希望老师多多指点和帮助。参考文献[1]吴金戌,沈庆阳.8051单片机实践与应用,北京:清华大学出版社,2003.12,26-38.[2]何立民.单片机应用文集,北京:北京航空航天大学出版社,1991,53-72.[3]公茂法.单片机人机接口实例集,北京:北京航空航天大学出版社,1998.2,32-59.[4]何立明.单片机高级教程——应用与设计,北京:北京航天航空大学出版社,2000.4,149-173.[5]李广弟,朱月秀.单片机基础,北京:北京航空航天大学出版社,2001.8,36-85.[6]楼然苗,李光飞.MCS-51系列单片机设计实例,北京:北京航天航空大学出版社,2001.3,75-83.[7]李华.单片机原理与接口技术,北京:清华大学出版社,33-80.[8]王伟.高性能、低功耗带RAM实时时钟芯片DS1302(上),电子世界:第一期,1995,26-35.[9]王伟.高性能、低功耗带RAM实时时钟芯片DS1302(下),电子世界:第四期,1995,32-41.[10]刘光潭.中外集成电路简明速察手册,上海:电子工业出版社,1991.[11]一九九九年产品目录(第一期),武汉力源股份有限公司,1999.[12]刘利.液晶显示原理,上海:电子工业出版社,2002.5,52-70.[13]李宏,张家田.液晶显示器件应用技术,北京:机械工业出版社,2004,156-183.[14]沈庆阳.汉字显示应用技术,上海:电子工业出版社,2002.3,128-139.[15]MAXIM.NEWRELEASESDATABOOK(VOLUMEV),AMERICA,1996.附录1:电子万年历设计电路原理图附录2:主程序MAIN:MOVSP,#70HLCALLDELAY;LCALLDELAY;LCALLDELAYMOV59H,#00H;判断调整地址CLR22H;停止周期第三位闪烁CLR23H;判断是否开闹铃CLRP3.5MOVIE,#00H;关所有中断MOVTMOD,#10HMOVTL1,#0F0HMOVTH1,#00H;MOVIP,#01H;SETBEX0 ;开外中断SETBEA ;开总中断允许LCALLVIICREAD;将EEPROM中原频率数据调入内存;MOV65H,#00H;MOV66H,#00H;MOV67H,#00H;MOV68H,#00HLCALLINTLCALLCLEARLCALLINTSHILCALLDDD;静态字显示DONGXIAN:MOVDPTR,#CCTAB;以下字为动态显示MOVZIDI,DPLMOVZIGAO,DPHMOVDONGXH,#1CHDXH1:MOVPAGER,#00H;16X16点阵字体,第2页MOVCOLUMN,#00H;起始列为第0列MOVCODER,#00H;字符代码LCALLCCW_PRMOVPAGER,#00HMOVCOLUMN,#10HMOVCODER,#01HLCALLCCW_PRMOVPAGER,#00HMOVCOLUMN,#20HMOVCODER,#02HLCALLCCW_PRMOVPAGER,#00H;16X16点阵字体,第2页MOVCOLUMN,#30H;起始列为第0列MOVCODER,#03H;字符代码LCALLCCW_PRMOVPAGER,#00HMOVCOLUMN,#40HMOVCODER,#04HLCALLCCW_PRMOVPAGER,#00HMOVCOLUMN,#50HMOVCODER,#05HLCALLCCW_PRMOVPAGER,#00HMOVCOLUMN,#60HMOVCODER,#06HLCALLCCW_PRMOVPAGER,#00HMOVCOLUMN,#70HMOVCODER,#07HLCALLCCW_PRLCALLDELAYCLRC;动态显示循环程序控制MOVA,ZIDIADDA,#20HMOVZIDI,AMOVA,ZIGAOADDCA,#00HMOVZIGAO,AL1:MOV3CH,#0F7H;开始键扫描MOV3DH,#00HL2:MOVA,3CHMOVP2,AMOVA,P2MOV3EH,ASETBCMOV3FH,#04HL3:RLCAJNCMNJIXUINC3DHDJNZ3FH,L3LCALLDISP1MOVA,3CHSETBCRRCAMOV3CH,AJCL2JMPMNMNMNJIXU:MOVA,P2XRLA,3EHJNZDF3AJMPDF3;MNJIXUDF3:CLRCMOVA,3DHRLCAMOVDPTR,#TABLEJMP@A+DPTRAJMPDONGXIANTABLE:AJMPMN0;键盘入口地址AJMPMN1AJMPMN2AJMPMN3AJMPMN4AJMPMN5AJMPMN6AJMPMN7AJMPMN8AJMPMN9AJMPMN10AJMPMN11AJMPMN12AJMPMN13AJMPMN14AJMPMN15MNFH:AJMPDXH1MNMN:DJNZDONGXH,MNFHAJMPDONGXIAN;键盘入口地址MN0:CLREAMOVBAOHUDI2,ZIDIMOVBAOHUGAO2,ZIGAOMOVCDAT1,#10001110B;打开写保护MOVCDAT2,#00000000BLCALLDSWORD;判断调整的地址SETBTR1SETBET1MOVA,59HCJNEA,#00H,JIANPAN1MOV5AH,#8CHINC59H;年时间MOVYJSSDZ0,#82HMOVYJSSDZ1,#40HMOVYJSSDZ2,#82HMOVYJSSDZ3,#48HLJMPJIAN1_0JIANPAN1:MOVA,59HCJNEA,#01H,JIANPAN2MOV5AH,#88HINC59H;月时间MOVYJSSDZ0,#82HMOVYJSSDZ1,#58HMOVYJSSDZ2,#82HMOVYJSSDZ3,#60HLJMPJIAN1_0JIANPAN2:MOVA,59HCJNEA,#02H,JIANPAN3MOV5AH,#86HINC59H;日时间MOVYJSSDZ0,#82HMOVYJSSDZ1,#70HMOVYJSSDZ2,#82HMOVYJSSDZ3,#78HLJMPJIAN1_0JIANPAN3:MOVA,59HCJNEA,#03H,JIANPAN4MOV5AH,#84HINC59H;时时间MOVYJSSDZ0,#84HMOVYJSSDZ1,#10HMOVYJSSDZ2,#84HMOVYJSSDZ3,#18HLJMPJIAN1_0JIANPAN4:MOVA,59HCJNEA,#04H,JIANPAN6MOV5AH,#82HINC59H;分时间MOVYJSSDZ0,#84HMOVYJSSDZ1,#28HMOVYJSSDZ2,#84HMOVYJSSDZ3,#30HLJMPJIAN1_0JIANPAN6:MOVA,59HCJNEA,#05H,JIANPAN7MOV5AH,#8AHINC59H;周期SETB22H;启动周期第三位闪烁MOVYJSSDZ0,#84HMOVYJSSDZ1,#58HMOVYJSSDZ2,#84HMOVYJSSDZ3,#60HMOVYJSSDZ4,#84HMOVYJSSDZ5,#68HLJMPJIAN1_0JIANPAN7:MOVA,59HCJNEA,#06H,JIANPAN8MOV5AH,#01H;判断是否能执行键2键3INC59H;时闹铃MOVYJSSDZ0,#87HMOVYJSSDZ1,#30HMOVYJSSDZ2,#87HMOVYJSSDZ3,#38HCLR22H;停止周期第三位闪烁LJMPJIAN1_0JIANPAN8:MOVA,59HCJNEA,#07H,JIANPAN9INC59H;分闹铃MOVYJSSDZ0,#87HMOVYJSSDZ1,#48HMOVYJSSDZ2,#87HMOVYJSSDZ3,#50HCLR22H;停止周期第三位闪烁LJMPJIAN1_0JIANPAN9:MOV59H,#01H;年时间MOV5AH,#8CHMOVYJSSDZ0,#82HMOVYJSSDZ1,#40HMOVYJSSDZ2,#82HMOVYJSSDZ3,#48HJIAN1_0:LCALLDSWRPRT;写保护MOVZIDI,BAOHUDI2MOVZIGAO,BAOHUGAO2;LCALLVIICWRITE;频率数据存入EEPROMSETBEAAJMPMNMNMN1:CLREAMOVBAOHUDI2,ZIDIMOVBAOHUGAO2,ZIGAOMOVA,5AH;看是否进入调整状态CJNEA,#00H,JIAN1_1LJMPJIAN1_11JIAN1_1:MOVA,59HCJNEA,#01H,JIAN1_2MOVCDAT1,#10001110B;打开写保护MOVCDAT2,#00000000BLCALLDSWORDMOVCDAT1,#8Dh;读年LCALLDSRORD;MOVA,CDAT2LCALLADD1MOVCDAT2,ACJNEA,#51H,NIAN1_01MOVCDAT2,#01HNIAN1_01:MOVCDAT1,#8CHLCALLDSWORD;写年LCALLDSWRPRT;写保护LJMPJIAN1_11JIAN1_2:MOVA,59HCJNEA,#02H,JIAN1_3MOVCDAT1,#10001110B;打开写保护MOVCDAT2,#00000000BLCALLDSWORDMOVCDAT1,#89h;读月LCALLDSRORD;MOVA,CDAT2LCALLADD1MOVCDAT2,ACJNEA,#13H,NIAN1_02MOVCDAT2,#01HNIAN1_02:MOVCDAT1,#88HLCALLDSWORD;写月LCALLDSWRPRT;写保护LJMPJIAN1_11JIAN1_3:MOVA,59HCJNEA,#03H,JIAN1_4ALJMPNEXXIJIAN1_4A:LJMPJIAN1_4NEXXI:MOVCDAT1,#10001110B;打开写保护MOVCDAT2,#00000000BLCALLDSWORDMOVCDAT1,#87h;读日LCALLDSRORD;MOVA,CDAT2LCALLADD1MOVCDAT2,AMOVR0,CYEAR;判断日期是30还是31还是28还是29LCALLBCD_10MOVA,R0MOVB,#04HDIVABMOVA,BJNZGGG11MOVA,CMONTHCJNEA,#02H,GGG11MOVA,CDAT2CJNEA,#30H,NIAN1_031MOVCDAT2,#01HNIAN1_031:MOVCDAT1,#86HLCALLDSWORD;写日LCALLDSWRPRT;写保护LJMPJIAN1_11GGG11:MOVA,CMONTH;非闰年CJNEA,#01H,NIAN1_033LJMPNIAN1_032NIAN1_033:MOVA,CMONTHCJNEA,#02H,NIAN1_034MOVA,CDAT2CJNEA,#29H,NIAN1_0333MOVCDAT2,#01HNIAN1_0333:MOVCDAT1,#86HLCALLDSWORD;写日LCALLDSWRPRT;写保护LJMPJIAN1_11NIAN1_034:MOVA,CMONTHCJNEA,#03H,NIAN1_035LJMPNIAN1_032NIAN1_035:MOVA,CMONTHCJNEA,#04H,NIAN1_036LJMPNIAN1_0336NIAN1_036:MOVA,CMONTHCJNEA,#05H,NIAN1_037LJMPNIAN1_032NIAN1_037:MOVA,CMONTHCJNEA,#06H,NIAN1_038LJMPNIAN1_0336NIAN1_038:MOVA,CMONTHCJNEA,#07H,NIAN1_039LJMPNIAN1_032NIAN1_039:MOVA,CMONTHCJNEA,#08H,NIAN1_040LJMPNIAN1_032NIAN1_040:MOVA,CMONTHCJNEA,#09H,NIAN1_041LJMPNIAN1_0336NIAN1_041:MOVA,CMONTHCJNEA,#10H,NIAN1_042LJMPNIAN1_032NIAN1_042:MOVA,CMONTHCJNEA,#11H,NIAN1_043LJMPNIAN1_0336NIAN1_043:LJMPNIAN1_032NIAN1_032:MOVA,CDAT2CJNEA,#32H,NIAN1_03MOVCDAT2,#01HNIAN1_03:MOVCDAT1,#86HLCALLDSWORD;写日31LCALLDSWRPRT;写保护LJMPJIAN1_11NIAN1_0336:MOVA,CDAT2CJNEA,#31H,NIAN1_03AMOVCDAT2,#01HNIAN1_03A:MOVCDAT1,#86HLCALLDSWORD;写日30LCALLDSWRPRT;写保护LJMPJIAN1_11JIAN1_4:MOVA,59HCJNEA,#04H,JIAN1_5MOVCDAT1,#10001110B;打开写保护MOVCDAT2,#00000000BLCALLDSWORDMOVCDAT1,#85h;读时LCALLDSRORD;MOVA,CDAT2LCALLADD1MOVCDAT2,ACJNEA,#24H,NIAN1_04MOVCDAT2,#00HNIAN1_04:MOVCDAT1,#84HLCALLDSWORD;写时LCALLDSWRPRT;写保护LJMPJIAN1_11JIAN1_5:MOVA,59HCJNEA,#05H,JIAN1_6MOVCDAT1,#10001110B;打开写保护MOVCDAT2,#00000000BLCALLDSWORDMOVCDAT1,#83h;读分LCALLDSRORD;MOVA,CDAT2LCALLADD1MOVCDAT2,ACJNEA,#60H,NIAN1_05MOVCDAT2,#00HNIAN1_05:MOVCDAT1,#82HLCALLDSWORD;写分LCALLDSWRPRT;写保护LJMPJIAN1_11JIAN1_6:MOVA,59HCJNEA,#06H,JIAN1_7MOVCDAT1,#10001110B;打开写保护MOVCDAT2,#00000000BLCALLDSWORDMOVCDAT1,#8Bh;读星期LCALLDSRORD;MOVA,CDAT2LCALLADD1MOVCDAT2,ACJNEA,#08H,NIAN1_06MOVCDAT2,#01HNIAN1_06:MOVCDAT1,#8AHLCALLDSWORD;写星期LCALLDSWRPRT;写保护LJMPJIAN1_11JIAN1_7:MOVA,59HCJNEA,#07H,JIAN1_8MOVA,65H;写闹时SWAPAORLA,66HADDA,#01HDAAMOV69H,ACJNEA,#24H,JIAN1_71MOV65H,#00HMOV66H,#00HLCALLVIICWRITELJMPJIAN1_11JIAN1_71:MOVA,69HSWAPAANLA,#0FHMOV65H,AMOVA,69HANLA,#0FHMOV66H,ALCALLVIICWRITELJMPJIAN1_11JIAN1_8:MOVA,67H;写闹分SWAPAORLA,68HADDA,#01HDAAMOV69H,ACJNEA,#60H,JIAN1_81MOV67H,#00HMOV68H,#00HLCALLVIICWRITELJMPJIAN1_11JIAN1_81:MOVA,69HSWAPAANLA,#0FHMOV67H,AMOVA,69HANLA,#0FHMOV68H,ALCALLVIICWRITEJIAN1_11:MOVZIDI,BAOHUDI2MOVZIGAO,BAOHUGAO2;LCALLVIICWRITE;频率数据存入EEPROMSETBEAAJMPMNMNMN2:CLREAMOVBAOHUDI2,ZIDIMOVBAOHUGAO2,ZIGAOMOVA,5AH;看是否进入调整状态CJNEA,#00H,JIAN4_1CPL23HJIAN4_1:CLR22H;停止周期第三位闪烁CLRTR1CLRET1MOV59H,#00HMOV5AH,#00HMOVZIDI,BAOHUDI2MOVZIGAO,BAOHUGAO2SETBEAAJMPMNMN致谢首先我要感谢我的指导老师XX老师的大力帮助和支持。无论是在课题立项还是在课题的研究阶段X老师都给了我很大的帮助。在毕业设计的这段时间中,X老师不仅使我在学业上有了很大的提高,而且言传身教,使我学到了作为一名大学生所应具备的那种踏实勤恳、一丝不苟、认真求实的优良品质和学习作风。在我进行课题内容的研究中,从技术上给予了我极大的帮助和支持,而且在论文的最后评阅过程中,也给我提出了非常有价值的意见,使我获益极深。衷心地谢谢您,X老师!此外,我还要感谢X老师给予我的无私的帮助,他在程序编写和调试过程中给予了我莫大的帮助。在此,我真诚地感谢他们。最后,我要感谢我的母校XX学院,在校期间,这里给我留下了美好的回忆。特别是在我即将踏上工作岗位的同时,毕业设计整个过程给了我这样一个锻炼的机会,使我加深了对以前知识的理解和巩固,拓宽了知识面,也提高了我对所学知识的综合应用能力。我要对母校说:母校有我三五载,我爱母校一万年。祝愿母校的将来更加美好!PAGEPAGE17英文原文OverviewThe8051familyofmicrocontrollersisbasedonanarchitecturewhichishighlyoptimizedforembeddedcontrolsystems.ItisusedinawidevarietyofapplicationsfrommilitaryequipmenttoautomobilestothekeyboardonyourPC.SecondonlytotheMotorola68HC11ineightbitprocessorssales,the8051familyofmicrocontrollersisavailableinawidearrayofvariationsfrommanufacturerssuchasIntel,Philips,andSiemens.Thesemanufacturershaveaddednumerousfeaturesandperipheralstothe8051suchasI2Cinterfaces,analogtodigitalconverters,watchdogtimers,andpulsewidthmodulatedoutputs.Variationsofthe8051withclockspeedsupto40MHzandvoltagerequirementsdownto1.5voltsareavailable.Thiswiderangeofpartsbasedononecoremakesthe8051familyanexcellentchoiceasthebasearchitectureforacompany'sentirelineofproductssinceitcanperformmanyfunctionsanddeveloperswillonlyhavetolearnthisoneplatform.Thebasicarchitectureconsistsofthefollowingfeatures:1aneightbitALU232descreteI/Opins(4groupsof8)whichcanbeindividuallyaccessed3two16bittimer/counters4fullduplexUART56interruptsourceswith2prioritylevels6128bytesofonboardRAM7separate64KbyteaddressspacesforDATAandCODEmemoryOne8051processorcycleconsistsoftwelveoscillatorperiods.Eachofthetwelveoscillatorperiodsisusedforaspecialfunctionbythe8051coresuchasopcodefetchesandsamplesoftheinterruptdaisychainforpendinginterrupts.Thetimerequiredforany8051instructioncanbecomputedbydividingtheclockfrequencyby12,invertingthatresultandmultiplyingitbythenumberofprocessorcyclesrequiredbytheinstructioninquestion.Therefore,ifyouhaveasystemwhichisusingan11.059MHzclock,youcancomputethenumberofinstructionspersecondbydividingthisvalueby12.Thisgivesaninstructionfrequencyof921583instructionspersecond.Invertingthiswillprovidetheamountoftimetakenbyeachinstructioncycle(1.085microseconds).MemoryOrganizationThe8051architectureprovidestheuserwiththreephysicallydistinctmemoryspaceswhichcanbeseeninFigureA-1.Eachmemoryspaceconsistsofcontiguousaddressesfrom0tothemaximumsize,inbytes,ofthememoryspace.Addressoverlapsareresolvedbyutilizinginstructionswhichreferspecificallytoagivenaddressspace.Thethreememoryspacesfunctionasdescribedbelow.TheCODESpaceThefirstmemoryspaceistheCODEsegmentinwhichtheexecutableprogramresides.Thissegmentcanbeupto64K(sinceitisaddressedby16addresslines).TheprocessortreatsthissegmentasreadonlyandwillgeneratesignalsappropriatetoaccessamemorydevicesuchasanEPROM.However,thisdoesnotmeanthattheCODEsegmentmustbeimplementedusinganEPROM.ManyembeddedsystemsthesedaysareusingEEPROMwhichallowsthememorytobeoverwritteneitherbythe8051itselforbyanexternaldevice.ThismakesupgradestotheproducteasytodosincenewsoftwarecanbedownloadedintotheEEPROMratherthanhavingtodisassembleitandinstallanewEPROM.Additionally,batterybackedSRAMcanbeusedinplaceofanEPROM.ThismethodoffersthesamecapabilitytouploadnewsoftwaretotheunitasdoesanEEPROM,anddoesnothaveanysortofread/writecyclelimitationssuchasanEEPROMhas.However,whenthebatterysupplyingtheRAMeventuallydies,sodoesthesoftwareinit.UsinganSRAMinplaceofanEPROMindevelopmentsystemsallowsforrapiddownloadingofnewcodeintothetargetsystem.Whenthiscanbedone,ithelpsavoidthecycleofprogramming/testing/erasingwithEPROM,andcanalsohelpavoidhasslesoveranincircuitemulatorwhichisusuallyararecommodity.Inadditiontoexecutablecode,itiscommonpracticewiththe8051tostorefixedlookuptablesintheCODEsegment.Tofacilitatethis,the8051providesinstructionswhichallowrapidaccesstotablesviathedatapointer(DPTR)ortheprogramcounterwithanoffsetintothetableoptionallyprovidedbytheaccumulator.Thismeansthatoftentimes,atable'sbaseaddresscanbeloadedinDPTRandtheelementofthetabletoaccesscanbeheldintheaccumulator.Theadditionisperformedbythe8051duringtheexecutionoftheinstructionwhichcansavemanycyclesdependingonthesituation.Anexampleofthisisshownlaterinthischapterin.TheDATASpaceThesecondmemoryspaceisthe128bytesofinternalRAMonthe8051,orthefirst128bytesofinternalRAMonthe8052.ThissegmentistypicallyreferredtoastheDATAsegment.TheRAMlocationsinthissegmentareaccessedinoneortwocyclesdependingontheinstruction.ThisaccesstimeismuchquickerthanaccesstotheXDATAsegmentbecausememoryisaddresseddirectlyratherthanviaamemorypointersuchasDPTRwhichmustfirstbeinitialized.Therefore,frequentlyusedvariablesandtemporaryscratchvariablesareusuallyassignedtotheDATAsegment.Suchallocationmustbedonewithcare,however,duetothelimitedamountofmemoryinthissegment.VariablesstoredintheDATAsegmentcanalsobeaccessedindirectlyviaR0orR1.Theregisterbeingusedasthememorypointermustcontaintheaddressofthebytetoberetrievedoraltered.Theseinstructionscantakeoneortwoprocessorcyclesdependingonthesource/destinationdatabyte.TheDATAsegmentcontainstwosmallersegmentsofinterest.Thefirstsubsegmentconsistsofthefoursetsofregisterbankswhichcomposethefirst32bytesofRAM.The8051canuseanyofthesefourgroupsofeightbytesasitsdefaultregisterbank.TheselectionofregisterbanksischangeableatanytimeviatheRS1andtheRS0bitsintheProcessorStatusWord(PSW).Thesetwobitscombineintoanumberfrom0to3(withRS1beingthemostsignificantbit)whichindicatestheregisterbanktobeused.Registerbankswitchingallowsnotonlyforquickparameterpassing,butalsoopensthedoorforsimplifyingtaskswitchingonthe8051.Thesecondsub-segmentintheDATAspaceisabitaddressablesegmentinwhicheachbitcanbeindividuallyaccessed.ThissegmentisreferredtoastheBDATAsegment.Thebitaddressablesegmentconsistsof16bytes(128bits)abovethefourregisterbanksinmemory.The8051containsseveralsinglebitinstructionswhichareoftenveryusefulincontrolapplicationsandaidinreplacingexternalcombinatoriallogicwithsoftwareinthe8051thusreducingpartscountonthetargetsystem.Itshouldbenotedthatthese16bytescanalsobeaccessedona"byte-wide"basisjustlikeanyotherbyteintheDATAspace.SpecialFunctionRegistersControlregistersfortheinterruptsystemandtheperipheralsonthe8051arecontainedininternalRAMatlocations80hexandabove.TheseregistersarereferredtoasspecialfunctionRegisters(orSFRforshort).Manyofthemarebitaddressable.ThebitsinthebitaddressableSFRcaneitherbeaccessedbyname,indexorbitaddress.Thus,youcanrefertotheEAbitoftheInterruptEnableSFRasEA,IE.7,or0AFH.TheSFRcontrolthingssuchasthefunctionofthetimer/counters,theUART,andtheinterruptsourcesaswellastheirpriorities.TheseregistersareaccessedbythesamesetofinstructionsasthebytesandbitsintheDATAsegment.AmemorymapoftheSFRSindicatingtheregisterswhicharebitaddressableisshowninTableA-1.TheIDATASpaceCertain8051familymemberssuchasthe8052containanadditional128bytesofinternalRAMwhichresideatRAMlocations80hexandabove.ThissegmentofRAMistypicallyreferredtoastheIDATAsegment.BecausetheIDATAaddressesandtheSFRaddressesoverlap,addressconflictsbetweenIDATARAMandtheSFRsareresolvedbythetypeofmemoryaccessbeingperformed,sincetheIDATAsegmentcanonlybeaccessedviaindirectaddressingmodes.TheXDATASpace.Thefinal8051memoryspaceis64Kinlengthandisaddressedbythesame16addresslinesastheCODEsegment.Thisspaceistypicallyreferredtoastheexternaldatamemoryspace(ortheXDATAsegmentforshort).ThissegmentusuallyconsistsofsomesortofRAM(usuallyanSRAM)andtheI/Odevicesorexternalperipheralstowhichthe8051mustinterfaceviaitsbus.ReadorwriteoperationstothissegmenttakeaminimumoftwoprocessorcyclesandareperformedusingeitherDPTR,R0,orR1.InthecaseofDPTR,itusuallytakestwoprocessorcyclesormoretoloadthedesiredaddressinadditiontothetwocyclesrequiredtoperformthereadorwriteoperation.Similarly,loadingR0orR1willtakeminimumofonecycleinadditiontothetwocyclesimposedbythememoryaccessitself.Therefore,itiseasytoseethatatypicaloperationwiththeXDATAsegmentwill,ingeneral,takeaminimumofthreeprocessorcycles.Becauseofthis,theDATAsegmentisaveryattractiveplacetostoreanyfrequently.usedvariablesItispossibletofillthissegmententirelywith64KofRAMifthe8051doesnotneedtoperformanyI/OwithdevicesinitsbusorifthedesignerwishestocycletheRAMonandoffwhenI/Odevicesarebeingaccessedviathebus.Methodsforperformingthistechniquewillbediscussedinchapterslaterinthisbook.On-BoardTimer/CountersThestandard8051hastwotimer/counters(other8051familymembershavevaryingamounts),eachofwhichisafull16bits.Eachtimer/countercanbefunctionasafreerunningtimer(inwhichcasetheycountprocessorcycles)orcanbeusedtocountfallingedgesonthesignalappliedtotheirrespectiveI/Opin(eitherT0orT1).Whenusedasacounter,theinputsignalmusthaveafrequencyequaltoorlowerthantheinstructioncyclefrequencydividedby2(ie:theoscillatorfrequency/24)sincetheincomingsignalissampledeveryinstructioncycle,andthecounterisincrementedonlywhena1to0transitionisdetected(whichwillrequiretwosamples).Ifdesired,thetimer/counterscanforceasoftwareinterruptwhentheyoverflow.TheTCON(TimerControl)SFRisusedtostartorstopthetimersaswellasholdtheoverflowflagsofthetimers.TheTCONSFRisdetailedbelowinTableA-7.Thetimer/countersarestartedorstoppedbychangingthetimerrunbits(TR0andTR1)inTCON.ThesoftwarecanfreezetheoperationofeithertimeraswellasrestartthetimerssimplybychangingtheTrxbitintheTCONregister.TheTCONregisteralsocontainstheoverflowflagsforthetimers.Whenthetimersoverflow,theysettheirrespectiveflag(TF0orTF1)inthisregister.Whentheprocessordetectsa0to1transitionintheflag,aninterruptoccursifitisenabled.Itshouldbenotedthatthesoftwarecansetorclearthisflagatanytime.Therefore,aninterruptcanbepreventedaswellasforcedbythesoftware.MicrocomputerinterfaceAmicrocomputerinterfaceconvertsinformationbetweentwoforms.Outsidethemicrocomputertheinformationhandledbyanelectronicsystemexistsasaphysicalsignals,butwithintheprogram,itisrepresentednumerically.Thefunctionofanyinterfacecanbebrokendownintoanumberofoperationswhichmodifythedatainsomeway,sothantheprocessofconversionbetweentheexternalandinternalformsiscarriedoutinanumberorsteps.ThiscanbeillustratedbymeansofanexamplesuchasthanorFig18.1,whichshowsaninterfacebetweenamicrocomputerandatransducerproducingacontinuouslyvariableanalogsignal.transducersoftenproduceverysmalloutrequiringamplyfrication,ortheymaygeneratesignals.inaformthatneedstobeconvertedagainbeforebeinghandledbytherestofthesystem.Forexample,manytransducersthesevariableresistancewhichmustbeconvertedtoavoltagebyaspecialcircuit.Thisprocessofconvertingthetransduceroutputintoavoltage4signalwhichcanbeconnectedtotherestofthesystemiscalledsignalconditioning.IntheexampleofFigure18.1,thesigmaconditioningsectiontranslatestherangelfvoltageorcurrentsignalsfromthetransducertoonewhichcanbeconvertedtodigitalforumbyananalog-to-digitalconverter.TransducerADCSignalconditioningTransducerADCSignalconditioningI/OSectionI/OSectionFig10-1outputInterfaceAnalog-to-digital–digitalconverter(ADC)isusedtoconvertacontinuouslyvariablesignaltoacorrespondingdigitalforumwhichcantakeanyoneofafixednumberofpossiblebinaryvalues.Iftheoutputlfthetransducerdoesnotvarycontinuously,noADCisnecessary.Inthiscasethesignalconditioningsectionmustconverttheincomingsignaltoaformwhichcanbeconnecteddirectlytothenextpartoftheinterface,theinput/outputsectionlfthemicrocomputeritself.TheI/Osectionconvertsdigital“on/off”voltagesignalstoaformwhichcanbepresentedtotheprocessorviatheviathesystembuses.Herethestateofeachinputlinewhetheritis“on”or“off”,isindicatedbyacorresponding“1”or“0”.Inthelineinputswhichhavebeenconvertedtodigitalform,thepatternsofonesandzerosintheinternalrepresentationwillformbinarynumberscorrespondingtothequantitybeingconverted.The“raw”numbersfromtheinterfacearelimite
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 优化小区排水设施施工计划
- 餐饮租赁合同中对承租方有利的条款优化策略
- 出租车租赁与安全保障服务合同
- 金融软件采购合同中的交易数据保密协议
- 饭店消防评估方案
- 仓储租赁合同及仓储货物保险服务协议
- 水泥制品订做方案
- 卸装业务外包方案(3篇)
- 厂区改造厂房拆迁补偿协议及行政公文处理规范
- 汽车酒店资产重组与股权转让合同范本
- 陕西省专业技术人员继续教育2025公需课《党的二十届三中全会精神解读与高质量发展》20学时题库及答案
- 2024-2025学年人教版数学五年级下学期期末试卷(含答案)
- 气钉枪安全培训教材PPT学习教案
- 小学数学图形与几何知识点归纳汇总
- APQP培训教材PPT课件
- JC∕T 1083-2008 水泥与减水剂相容性试验方法
- IEC雷击风险评估软件EXCEL版
- 食品工程原理(李云飞)第二章ppt 传热
- 二氧化碳气体保护焊.ppt
- 仪表工程质量控制点等级划分表
- 广东某高层小区屋面飘板模板工程专项施工方案
评论
0/150
提交评论