嵌入式mini stm32基于sim900a的温度实时报警系统_第1页
嵌入式mini stm32基于sim900a的温度实时报警系统_第2页
嵌入式mini stm32基于sim900a的温度实时报警系统_第3页
嵌入式mini stm32基于sim900a的温度实时报警系统_第4页
嵌入式mini stm32基于sim900a的温度实时报警系统_第5页
已阅读5页,还剩42页未读 继续免费阅读

下载本文档

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

文档简介

陕西理工学院毕业设计页共41页附录A外文翻译英文原文:8-bitMicrocontrollerwith4KBytesin-SystemProgrammableFlashFeatures:*CompatiblewithMCS-51Products*4KBytesofIn-SystemProgrammable(ISP)FlashMemory–Endurance:1000Write/EraseCycles*4.0Vto5.5VOperatingRange*FullyStaticOperation:0Hzto33MHz*Three-levelProgramMemoryLock*128x8-bitInternalRAM*32ProgrammableI/OLines*Two16-bitTimer/Counters*SixInterruptSources*FullDuplexUARTSerialChannel*Low-powerIdleandPower-downModes*InterruptRecoveryfromPower-downMode*WatchdogTimer*DualDataPointer*Power-offFlag*FastProgrammingTime*FlexibleISPProgramming(ByteandPageMode)Description:TheAT89S51isalow-power,high-performanceCMOS8-bitmicrocontrollerwith4Kbytesofin-systemprogrammableFlashmemory.ThedeviceismanufacturedusingAtmel’shigh-densitynonvolatilememorytechnologyandiscompatiblewiththeindustry-standard80C51instructionsetandpinout.Theon-chipFlashallowstheprogrammemorytobereprogrammedin-systemorbyaconventionalnonvolatilememoryprogrammer.Bycombiningaversatile8-bitCPUwithin-systemprogrammableFlashonamonolithicchip,theAtmelAT89S51isapowerfulmicrocontrollerwhichprovidesahighly-flexibleandcost-effectivesolutiontomanyembeddedcontrolapplications.TheAT89S51providesthefollowingstandardfeatures:4KbytesofFlash,128bytesofRAM,32I/Olines,Watchdogtimer,twodatapointers,two16-bittimer/counters,afive-vectortwo-levelinterruptarchitecture,afullduplexserialport,on-chiposcillator,andclockcircuitry.Inaddition,theAT89S51isdesignedwithstaticlogicforoperationdowntozerofrequencyandsupportstwosoftwareselectablepowersavingmodes.TheIdleModestopstheCPUwhileallowingtheRAM,timer/counters,serialport,andinterruptsystemtocontinuefunctioning.ThePower-downmodesavestheRAMcontentsbutfreezestheoscillator,disablingallotherchipfunctionsuntilthenextexternalinterruptorhardwarereset.PinDescriptionVCC:SupplyvoltageGND:GroundPort0:Port0isan8-bitopendrainbidirectionalI/Oport.Asanoutputport,eachpincansinkeightTTLinputs.When1sarewrittentoport0pins,thepinscanbeusedashigh-impedanceinputs.Port0canalsobeconfiguredtobethemultiplexedlow-orderaddress/databusduringaccessestoexternalprogramanddatamemory.Inthismode,POhasinternalpull-ups.Port0alsoreceivesthecodebytesduringFlashprogrammingandoutputsthcodebytesduringprogramverification.Externalpull-upsarerequireddurinprogramverification.Port1:Port1isan8-bitbidirectionalI/Oportwithinternalpull-ups.ThePort1outputbufferscansink/sourcefourTTLinputs.WhenisarewrittentoPort1pins,theyarepulledhighbytheinternalpull-upsandcanbeusedasinputs.Asinputs,Port1pinsthatareexternallybeingpulledlowwillsourcecurrent(lip)becauseoftheinternalpull-ups.Port1alsoreceivesthelow-orderaddressbytesduringFlashprogrammingandverificationPortPinAlternateFunctionsP1.5MOSI(usedforIn-SystemProgramming)P1.6MISO(usedforIn-SystemProgramming)P1.7SCK(usedforIn-SystemProgramming)Port2:Port2isan8-bitbidirectionalI/Oportwithinternalpull-ups.ThePort2outputbufferscansink/sourcefourTTLinputs.When1sarewrittentoPort2pins,theyarepulledhighbytheinternalpull-upsandcanbeusedasinputs.Asinputs,Port2pinsthatareexternallybeingpulledlowwillsourcecurrentbecauseoftheinternalpull-ups.Port2emitsthehigh-orderaddressbyteduringfetchesfromexternalprogrammemoryandduringaccessestoexternaldatamemorythatuse16-bitaddresses(MOVX@DPTR).Inthisapplication,Port2usesstronginternalpull-upsdatamemorythatuse8-bitaddresses(MOVX@RI)Port2emitsthecontentsoftheP2SpecialFunctionRegister。Port2alsoreceivesthehigh-orderaddressbits.somecontrolsignalsduringFlashpro-grammingandverification.Port3:Port3isan8-bitbidirectionalI/Oportwithinternalpull-ups.ThePort3outputbufferscansink/sourcefourTTLinputs.When1sarewrittentoPort3pins,theyarepulledhighbytheinternalpull-upsandcanbeusedasinputs.Asinputs,Port3pinsthatareexternallybeingpulledlowwillsourcecurrentbecauseofthepull-ups.Port3receivessomecontrolsignalsforFlashprogrammingverificationPort3alsoservesthefunctionsofvariousspecialfeaturesoftheAT89S51,asshowninthefollowingtable.RST:Resetinput.Ahighonthispinfortwomachinecycleswhiletheoscillatorisrunningresetsthedevice.ThispindrivesHighfor98oscillatorperiodsaftertheWatchdogtimesout.TheDISRTObitinSFRAUXR(address8EH)canbeusedtodisablethisfeature.InthedefaultstateofbitDISRTO,theRESETHIGHoutfeatureisenabled.ALE/PROG:AddressLatchEnable(ALE)isanoutputpulseforlatchingthelowbyteoftheaddressduringaccessestoexternalmemory.Thispinisalsotheprogrampulseinput(PROG)duringFlashprogramming.Innormaloperation,ALEisemittedataconstantrateof1/6theoscillatorfrequencyandmaybeusedforexternaltimingorclockingpurposes.Note,however,thatoneALEpulseisskippedduringeachaccesstoexternaldatamemory.Ifdesired,ALEoperationcanbedisabledbysettingbit0ofSFRlocation8EH.Withthebitset,ALEisactiveonlyduringaMOVXorMOVCinstruction.Otherwise,thepinisweaklypulledhigh.SettingtheALE-disablebithasnoeffectifthemicrocontrollerisinexternalexecution.PSEN:ProgramStoreEnable(PSEN)isthereadstrobetoexternalprogrammemory.WhentheAT89S51isexecutingcodefromexternalprogrammemory,PSENisactivatedtwiceeachmachinecycle,exceptthattwoPSENactivationsareskippedduringeachaccesstoexternaldatamemory.EA/VPP:ExternalAccessEnable.EAmustbestrappedtoGNDinordertoenablethedevicetofetchcodefromexternalprogrammemorylocationsstartingat0000HuptoFFFFH.Note,however,thatiflockbit1isprogrammed,EAwillbeinternallylatchedonreset.EAshouldbestrappedtoVCCforinternalprogramexecutions.Thispinalsoreceivesthe12-voltprogrammingenablevoltage(VPP)duringFlashprogramming.XTAL1:Inputtotheinvertingoscillatoramplifierandinputtotheinternalclockoperatingcircuit.XTAL2:Outputfromtheinvertingoscillatoramplifier.SpecialFunctionRegisters:Amapoftheon-chipmemoryareaiscalledtheSpecialFunctionRegister(SFR)Notethatnotalloftheaddressesareoccupied,andunoccupiedaddressesmaynotbeimple-mentedonthechip.Readaccessestotheseaddresseswillingeneralreturnrandomdata,andwriteaccesseswillhaveanindeterminateeffect.MemoryOrganization:MCS-51deviceshaveaseparateaddressspaceforProgramandDataMemory.Upto64KbyteseachofexternalProgramandDataMemorycanbeaddressed.ProgramMemoryIftheEApinisconnectedtoGND,allprogramfetchesaredirectedtoexternalmemory.OntheAT89S51,ifEAisconnectedtoVCC,programfetchestoaddresses0000HthroughFFFHaredirectedtointernalmemoryandfetchestoaddresses1000HthroughFFFFHaredirectedtoexternalmemory.DataMemory:TheAT89S51implements128bytesofon-chipRAM.The128bytesareaccessibleviadirectandindirectaddressingmodes.Stackoperationsareexamplesofindirectaddressing,sothe128bytesofdataRAMareavailableasstackspace.WatchdogTimer:TheWDTisintendedasarecoverymethodinsituationswheretheCPUmaybesubjectedtosoftwareupsets.TheWDTconsistsofa14-bitcounterandtheWatchdogTimerReset(WDTRST)SFR.TheWDTisdefaultedtodisablefromexitingreset.ToenabletheWDT,ausermustwrite01EHand0E1HinsequencetotheWDTRSTregister(SFRlocation0A6H).WhentheWDTisenabled,itwillincrementeverymachinecyclewhiletheoscillatorisrunning.TheWDTtimeoutperiodisdependentontheexternalclockfrequency.Thereisnowaytodis-abletheWDTexceptthroughreset(eitherhardwareresetorWDToverflowreset).WhenWDToverflows,itwilldriveanoutputRESETHIGHpulseattheRSTpin.带4K字节的可系统编程的Flash只读程序存储器的8位单片机主要性能参数:*MCS-51产品指令系统完全兼容*4k字节在系统编程(ISP)Flash闪速存储器*1000次擦写周期*4.0-5.5V的工作电压范围*全静态工作模式:0Hz-33MHz*三级程序加密锁*128*8字节内部RAM*32个可编程I/O口线*2个16位定时/计数器*6个中断源*全双工串行URAT通道*低功耗空闲和掉电模式*中断可从空闲模唤醒系统*看门狗(WDT)及双数据指针*掉电标识和快速编程特性*灵活的在系统编程(ISP-字节或页写模式)功能特性概述:AT89S51提供以下标准功能:4k字节Flash闪速存储器,128字节内部RAM,32个I/O口线,看门狗(WDT),两个数据指针,两个16位定时/计数器,一个5向量两级中断结构,一个全双工串行通信口,片内振荡器及时钟电路。同时,AT89S51可降至0Hz的静态逻辑操作,并支持两种软件可选的节电工作模式。空闲模式停止CPU的工作,但允许RAM,定时/计数器,串行通信口及中断系统继续工作。掉电模式保存RAM中的内容,但振荡器停止工作并禁止其它所有部件工作直到下一个硬件复位。引脚功能说明:*Vcc:电源电压*GND:地*P0口:P0口是一组8位漏极开路型双向I/0口,也即地址/数据总线复用口。作为输出口用时,每位能驱动8个TTL逻辑门电路,对端口写“1”可作为高阻抗输入端用。在访问外部数据存储器或程序存储器时,这组口线分时转换地址(低8位)和数据总线复用,在访问期间激活内部上拉电阻。在Flash编程时,P0口接收指令字节,而在程序校验时,输出指令字节校验时,要求外接上拉电阻。*Pl口:P1是一个带内部上拉电阻的8位双向I/O口,P1的输出缓冲级可驱动(吸收或输出电流)4个TTL逻辑门电路。对端口引脚通过内部的上拉电阻把端口拉到高电平,此时可作输入口。作输入口使用时,因为内部存在上拉电阻,某个引脚被外部信号拉低时会输出一个电流。Flash编程和程序校验期间,P1接收低8位地址。端口引脚第二功能P1.5MPSI(用于ISP编程)P1.6MISO(用于ISP编程)P1.7SCE(用于ISP编程)*P2口:P2是一个带有内部上拉电阻的8位双向I/O口,P2的输出缓冲级可驱动(吸收或输出电流)4个TTL逻辑门电路。对端口写“l”,通过内部的上拉电阻把端口拉到高电平,此时可作输入口,作输入口使用时,因为内部存在上拉电阻,某个引脚被外部信号拉低时会输出一个电流。在访问外翻环程序存储器或16位地址的外部数据存储器(例如执行MOVX@DPTR指令)时,P2口送出高8位地址数据。在访问8位地址的外部数据存储器(如执行MOVX@Ri指令)时,P2口线上的内容(也即特殊功能寄存器(SFR)区中P2寄存器的内容),在整个访问期间不改变。Flash编程或校验时,P2口亦接收高位地址和其它控制信号*P3口:P3口是一组带有内部上拉电阻的8位双向I/O口。P3口输出缓冲级可驱动(吸收或输出电流)4个TTL逻辑门电路。对P3口写入“1”时,它们被内部上拉电阻拉高并可作为输入端口。作输入端时,被外部拉低的P3口将用上拉电阻输出电流。P3口除了作为一般的I/0口线外,更重要的用途是它的第二功能,如下表所示:P3口还可用于Flash闪速存储器编程和程序校验的控制信号。端口引脚第二功能P3.0RXD(串行输入口)P3.1TXD(串行输出口)P3.2INT0(外中断0)P3.3INT1(外中断1)P3.4T0(定时/计数器0)P3.5T1(定时/计数器1)P3.6WR(外部数据存储器写选通)P3.7RD(外部数据存储器读选通)*RST:复位输入。当振荡器工作时,RST引脚出现两个机器周期以上高电平将使单片机复位。WDT溢出将使该引脚输出高电平,设置SFRAUXR的DISRTO位(地址8EH)打开或关闭该功能。DISRTO位缺省为RESET输出高电平打开状态。*ALE/PROG:当访问外翻环程序存储器或数据存储器时,ALE(地址锁存允许)输出脉冲用于锁存地址的低8位字节。即使不访问外部存储器,ALE仍以时钟振荡频率的1/6输出固定的正脉冲信号,因此它可对外输出时钟或用于定时目的。要注意的是:每当访问外部数据存储器时将跳过一个ALE脉冲。对Flash存储器编程期间,该引脚还用于输入编程脉冲(FROG)如有必要,可通过对特殊功能寄存器(SFR)区中的8EH单元的Do位置位,可禁ALE操作。该位置位后,只有一条MOVX和M0VC指令ALE才会被激活。此外,该引脚会被微弱拉高,单片机执行外部程序时,应设置ALE无效。*PSEN:程序储存允许(PSEN)输出是外部程序存储器的读选通信号。当AT89S51由外部程序存储器取指令(或数据)时,每个机器周期两次PSEN有效,即输出两个脉冲。当访问外部数据存储器,没有两次有效的PSEN信号。*EA/VPP:外部访问允许。欲使CPU仅访问外部程序存储器(地址为0000H-FFFFH),EA端必须保持低电平(接地)。需注意的是:如果加密位EB1被编程,复位时内部会锁存EA端状态。如EA端为高电平(接Vcc端),CPU则执行内部程序存储器中的指令。Flash存储器编程时,该引脚加上+12V的编程电压Vpp。*XTALl:振荡器反相放大器及内部时钟发生器的输入端。*XTAL2:振荡器反相放大器的输出端。*特殊功能寄存器:特殊功能寄存器的地址并没有全部占用,没有占用的地址亦不可使用,读这些地址将得到一个随意的数值。而写这些地址单元将能得到预期的结果。*电源空闲标志:电源空闲标志(POF)在特殊功能寄存器SFR中PCON的第4位(PCON.4),电源打开时POF置“1",它可由软件设置睡眠状态并不为复位所影响。*存储器结构:MCS-51单片机内核采用程序存储器和数据存储器空间分开的结构,均具有64KB外部程序和数据的寻址空间。*程序存储器:如果EA引脚接地(GND),全部程序均执行外部存储器。在AT89S51中EA接至Vcc(电源+),程序首先执行地址从0000H-0FFFH(60KB)的外部程序存储器。*数据存储器:AT89S51具有128字节的内部RAM,这128字节可利用直接或间接寻址方式访问,128字节均可设置为堆栈区空间。*看门狗定时器(WDT):WDT是为了解决CPU程序运行时可能进入混乱或死循环而设置,它由一个14bit计数器和看门狗复位SFR构成。外部复位时,WDT默认为关闭状态,要打开WDT,用户必须按顺序将01EFH写到WDTRST寄存器(SFR地址为0A6H),当启动了WDT,它会随晶体振荡器在每个机器周期计数,除硬件复位或WDT溢出复位外没有其它办法关闭WDT,当WDT溢出,将使RST引脚输出高电平的复位脉冲。*使用看门狗:打开WDT需按次序写01EFH和0E1FH到WDT寄存器(SFR的地址为0A6H),当WDT打开后,需在一定的时候写01EFH和01EFH到WDT寄存器以避免WDT计数溢出。14位WDT计数器计数达到16383(3FFFH),WDT将溢出并使器件复位。WDT打开时,它会随晶体振荡器在每个机器周期计数,这意味着用户必须在小于每个76383机器周期内复位WDT,也即写01EFH和01EFH到WDT寄存器,WDTRST为只写寄存器。WDT计数器既不可读也不可写,当WDT溢出时,通常将使RST引脚输出高电平的复位脉冲。复位脉冲持续时间为98xTOSC,而TOSC=1/FOSC(晶体振荡频率)为使WDT工作最优化,必须在合适的程序代码时间段周期地复位WDT防止WDT溢出。附录BDS18B20程序清单#include<intrins.h>#defineucharunsignedchar#defineuintunsignedintsbitDATA=P2^6;//DS18B20接入口sbitEN_1=P2^4; //使能端sbitRS_1=P2^2; //命令选择端sbitRW_1=P2^3;//数据选择端sbitLed=P1^0;//流水灯选择端ucharcodetable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};charcodezifu[]={"0123456789"};charcodenowt[]={"NowTemp:+"};charcodenow[]={"GSMTempBaojing"};/*********************延时*********************/voidDelay_1(uintnum){ while(num--);}/******************DS18b20设置************/intInit_DS18B20()//传感器初始化{ ucharx=0; DATA=1;//DQ复位 Delay_1(10);//稍做延时 DATA=0;//单片机将DQ拉低 Delay_1(80);//精确延时大于480us//450 DATA=1;//拉高总线 Delay_1(20); x=DATA;//稍做延时后如果x=0则初始化成功x=1则初始化失败 Delay_1(30); return(x);}//读一个字节int ReadOneChar(){ uchari=0; uchardat=0; for(i=8;i>0;i--) { DATA=0;//给脉冲信号 dat>>=1; DATA=1;//给脉冲信号 if(DATA) dat|=0x80; Delay_1(8); } return(dat);}//写一个字节void WriteOneChar(unsignedchardat){ uchari=0; for(i=8;i>0;i--) { DATA=0; DATA=dat&0x01; Delay_1(10); DATA=1; dat>>=1; } Delay_1(8);}//读取温度intReadTemperature(){ uchara=0; ucharb=0; intt=0; Init_DS18B20(); WriteOneChar(0xCC);//跳过读序号列号的操作 WriteOneChar(0x44);//启动温度转换 Init_DS18B20(); WriteOneChar(0xCC);//跳过读序号列号的操作 WriteOneChar(0xBE);//读取温度寄存器等(共可读9个寄存器)前两个就是温度 a=ReadOneChar();//低位 b=ReadOneChar();//高位 t=b; t<<=8; t=t|a; t=t*0.625+0.5; return(t);}附录C显示程序清单#include<intrins.h>#defineucharunsignedchar#defineuintunsignedintsbitDATA=P2^6;//DS18B20接入口sbitEN_1=P2^4; //使能端sbitRS_1=P2^2; //命令选择端sbitRW_1=P2^3;//数据选择端sbitLed=P1^0;//流水灯选择端ucharcodetable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};charcodezifu[]={"0123456789"};charcodenowt[]={"NowTemp:+"};charcodenow[]={"GSMTempBaojing"};/********************************************************************/voidDelay_1(uintnum){ while(num--);}/**************************1602设置*************

温馨提示

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

评论

0/150

提交评论