还剩11页未读,继续阅读
本资源只提供10页预览,全部文档请下载后查看!喜欢就下载吧,查找使用更方便
文本内容:
原文:The Introductionof AT89C51DescriptionThe AT89C51is alow-power,high-performance CMOS8-bit microcomputerwith4K bytesof Flash programmableand erasableread onlymemory PEROM.The deviceis manufacturedusingAtmeFs high-density nonvolatilememory technologyand iscompatible with theindustry-standard MCS-51instruction setand pinout.The on-chip Flashallows the programmemory to be reprogrammedin-system or by aconventional nonvolatilememory programmer.By combininga versatile8-bit CPUwith Flashon amonolithic chip,the AtmelAT89C51is apowerfulmicrocomputer whichprovides ahighly-flexible andcost-effective solutionto manyembeddedcontrol applications.Function characteristicTheAT89C51provides thefollowing standardfeatures:4K bytesofFlash,128bytes ofRAM,32I/O lines,two16-bit timer/counters,a fivevector two-level interruptarchitecture,a fullduplexserial port,on-chip oscillatorand clockcircuitry.In addition,the AT89C51is designedwithstatic logicfor operationdown tozero frequencyand supportstwo softwareselectable powersavingmodes.The IdleMode stopsthe CPUwhile allowingthe RAM,timer/counters,serial portandinterrupt systemto continuefunctioning.The Power-down Modesaves theRAM contentsbutfreezes the oscillator disablingall otherchip functionsuntil thenext hardware reset.P
3.6WRP
3.7RD□还接收一些用于闪烁存储器编程和程序校验的控制信号P3RST复位输入当震荡器工作时,引脚出现两个机器周期以上的高电平将使单片机RET复位ALE/PROG当访问外部程序存储器或数据存储器时,输出脉冲用于锁存地址的低位字节ALE8即使不访问外部存储器,以时钟震荡频率的输出固定的正脉冲信号,因此它可ALE1/16对输出时钟或用于定时目的要注意的是每当访问外部数据存储器时将跳过一个ALE脉冲时,闪烁存储器编程时,这个引脚还用于输入编程脉冲如果必要,可对特殊寄存器区中的单元的位置禁止操作这个位置后只有一条和指令8EH DOALE MOVXMOVC才会被应用此外,这个引脚会微弱拉高,单片机执行外部程序时,应设置无ALE ALE效PSEN程序储存允许输出是外部程序存储器的读选通信号,当由外部程序存储器AT89c51读取指令时,每个机器周期两次有效,即输出两个脉冲在此期间,当访问外部数PSEN据存储器时,这两次有效的信号不出现PSENEA/VPP外部访问允许欲使中央处理器仅访问外部程序存储器,端必须保持低电平需EA要注意的是如果加密位被编程,复位时内部会锁存端状态如端为高电平,LBI EAEA则执行内部程序存储器中的指令闪烁存储器编程时,该引脚加上的编程允许CPU+12V电压当然这必须是该器件是使用编程电压VPP,12V VPP震荡器反相放大器及内部时钟发生器的输入端XTAL1震荡器反相放大器的输出端XTAL2时钟震荡器中有一个用于构成内部震荡器的高增益反相放大器,引脚和AT89C51XTAL1XTAL2分别是该放大器的输入端和输出端这个放大器与作为反馈元件的片外石英晶体或陶瓷谐振器一起构成自然震荡器外接石英晶体及电容接在放大器的反馈回路中构成并联Cl,C2震荡电路对外接电容虽然没有十分严格的要求,但电容容量的大小会轻微影响震Cl,C2荡频率的高低、震荡器工作的稳定性、起振的难易程序及温度稳定性如果使用石英晶体,我们推荐电容使用而如果使用陶瓷振荡器建议选择用户也可以采30PF+10PF,40PF±10PFo用外部时钟采用外部时钟的电路如图示这种情况下,外部时钟脉冲接到端,XTAL1即内部时钟发生器的输入端,则悬空由于外部时钟信号是通过一个分频触发XTAL22器后作为内部时钟信号的,所以对外部时钟信号的占空比没有特殊要求,但最小高电平持续时间和最大的低电平持续时间应符合产品技术条件的要求C2XIAL2□T01ilL X7AL1GND内部振荡电路NC X7AL2EXTERNALXTAL1OSCILLATORSIGNALGND外部振荡电路闲散节电模式有两种可用软件编程的省电模式,它们是闲散模式和掉电工作模式这两AT89C51种方式是控制专用寄存器中的和位来实现的是掉电模式,当PCON PD IDL PDPD=1时,激活掉电工作模式,单片机进入掉电工作状态是闲散等待方式,当激活闲散JDL IDL=1,工作状态,单片机进入睡眠状态如需要同时进入两种工作模式,即和同时为PDIDL1,则先激活掉电模式在闲散工作模式状态,中央处理器保持睡眠状态,而所有片内CPU的外设仍保持激活状态,这种方式由软件产生此时,片内随机存取数据存储器和所有特殊功能寄存器的内容保持不变闲散模式可由任何允许的中断请求或硬件复位终止终止闲散工作模式的方法有两种,一是任何一条被允许中断的事件被激活,被硬件清除,IDL即刻终止闲散工作模式程序会首先影响中断,进入中断服务程序,执行完中断服务程序,并紧随指令后,下一条要执行的指令就是使单片机进入闲散工作模式,那条指令后RETI面的一条指令二是通过硬件复位也可将闲散工作模式终止需要注意的是当由硬件复位来终止闲散工作模式时,中央处理器通常是从激活空闲模式那条指令的下一条开CPU始继续执行程序的,要完成内部复位操作,硬件复位脉冲要保持两个机器周期有效,在这种情况下,内部禁止中央处理器访问片内而允许访问其他端口,为了避免可能CPU RAM,对端口产生的意外写入激活闲散模式的那条指令后面的一条指令不应是一条对端口或外部存储器的写入指令掉电模式在掉电模式下,振荡器停止工作,进入掉电模式的指令是最后一条被执行的指令,片内和特殊功能寄存器的内容在中指掉电模式前被冻结退出掉电模式的唯一方法是RAM硬件复位,复位后将从新定义全部特殊功能寄存器但不改变中的内容,在恢复RAM VCC到正常工作电平前,复位应无效切必须保持一定时间以使振荡器从新启动并稳定工作闲散和掉电模式外部引脚状态模式程序存储器ALE PSENP0P1P2P3闲散模式内部数据数据数据数据11闲散模式内部浮空数据地址数据11掉电模式外部数据数据00掉电模式外部数据数据数据数据00程序存储器的加密可使用对芯片上的三个加密位进行编程()或不编程()AT89c51LB1,LB2,LB3P U得到如下表所示的功能程序加密位保护类型没有程序保护功能1U U U禁止从外部程序存储器中执行指令读取内部程序存储器MOVC2P UU的内容除上表功能外,还禁止程序校验3P P U除以上功能外,同时禁止外部执行4P P P当被编程时,在复位期间,端的电平被锁存,如果单片机上电后一直没有复LB1EA位,锁存起来的初始值是一个不确定数,这个不确定数会一直保存到真正复位位置为了使单片机正常工作,被锁存的电平与这个引脚当前辑电平一致机密位只能通过整片EA擦除的方法清除Pin DescriptionVCC Supplyvoltage.GND Ground.Port0Port0is an8-bit open-drain bi-directional I/O port.As anoutput port,each pincan sinkeightTTL inputs.When Isare writtento port0pins,the pinscan be used ashighimpedance inputs.Port0may alsobe configuredtobethe multiplexedloworder address/data busduring accesses toexternal programand data memory.In this mode POhas internalpullups.Port0also receivesthecode bytes during Flash programming,and outputsthe codebytesduring programverification.External pullupsare requiredduringprogramverification.Port1Port1is an8-bit bi-directional I/O portwith internalpullups.The Port1output bufferscansink/source fourTTL inputs.When Isare writtento Port1pins theyare pulled high bythe internalpullupsand can be usedas inputs.As inputs,Port1pins thatare externallybeing pulledlow willsourcecurrent IILbecause of the internalpullups.Port1also receivesthe low-order addressbytesduring Flash programming and verification.Port2Port2is an8-bit bi-directional I/O portwith internalpullups.The Port2output bufferscansink/source fourTTL inputs.When Isare writtento Port2pins theyare pulledhigh bythe internalpullupsand can be usedas inputs.As inputs,Port2pins thatare externallybeing pulledlow willsourcecurrent,because of the internalpullups.Port2emits the high-order addressbyte duringfetchesfrom external program memoryand duringaccessestoexternal data memory thatuse16-bit addresses.In thisapplication,it usesstrong internalpullupswhen emittingIs.Duringaccesses toexternal datamemory thatuse8-bit addresses,Port2emits thecontents of the P2Special FunctionRegister.Port2also receivesthehigh-orderaddress bitsand some control signalsduring Flashprogramming andverification.Port3Port3is an8-bit bi-directional I/O portwith internalpullups.The Port3output bufferscansink/source fourTTL inputs.When Isare writtento Port3pins theyare pulledhigh bythe internalpullupsand canbe usedas inputs.As inputs,Port3pins thatare externallybeing pulledlow willsourcecurrent IILbecause ofthe pullups.Port3also servesthe functionsof variousspecialfeatures ofthe AT89C51as listedbelow:Port PinAlternate FunctionsP
3.0RXD serialinput portP
3.1TXD serialoutput portP
3.2INTO external interrupt0P
3.3INT1externalinterrupt1P
3.4TO timer0external inputP
3.5T1timer1external inputP
3.6WR external datamemorywrite strobeP
3.7RD externaldatamemoryread strobePort3also receivessomecontrolsignals forFlashprogrammingandverification.RSTReset input.A highon thispin fortwo machinecycles whilethe oscillatoris runningresets thedevice.ALE/PROGAddress LatchEnable outputpulse forlatching thelow byteoftheaddress duringaccesses toexternalmemory.This pin is alsotheprogrampulse inputPROG duringFlashprogramming.In normaloperationALE isemitted ata constantrate of1/6the oscillatorfrequency,and may beusedfor externaltimingor clockingpurposes.Note,however,that oneALE pulseis skippedduring eachaccess toexternalData Memory.If desired,ALE operationcanbedisabled bysetting bit0of SFRlocation8EH.With thebit set,ALE isactiveonly duringa MOVXor MOVCinstruction.Otherwise,the pinis weaklypulledhigh.Setting theALE-disable bithas noeffect ifthe microcontrolleris inexternal executionmode.PSENProgram StoreEnable isthe readstrobe toexternalprogram memory.When theAT89C51isexecuting codefrom externalprogram memory,PSEN isactivated twiceeach machinecycle,except thattwoPSEN activationsare skippedduring eachaccess toexternaldatamemory.EA/VPPExternal AccessEnable.EA must be strappedto GNDin orderto enablethe deviceto fetchcodefrom externalprogram memorylocations startingat0000H up to FFFFH.Note,however,that iflock bit1is programmed,EA willbe internallylatched onreset.EA should be strappedto VCCfor internalprogramexecutions.This pinalso receivesthe12-volt programmingenable voltageVPPduring Flashprogramming,for partsthat require12-volt VPP.XTAL1Input to the invertingoscillator amplifierand input to the internal clockoperating circuit.XTAL2Output fromthe invertingoscillator amplifier.Oscillator CharacteristicsXTAL1and XTAL2are theinput andoutput,respectively,of aninverting amplifierwhich canbeconfigured foruse asan on-chip oscillator,as shownin Figure
1.Either aquartz crystalor ceramicresonatormaybeused.To drivethe devicefrom anexternal clocksource,XTAL2shouldbeleftunconnected whileXTAL1is drivenas shownin Figure
2.There areno requirementson theduty cycleofthe externalclock signal,since theinputtothe internalclocking circuitryis througha divide-by-twoflip-flop,but minimumand maximumvoltage highand lowtime specificationsmustbeobserved.NC X7AL2X1AL2EXTERNALOSCILLATOR XTAL1X1AL1SIGNALGNDGNDFigure
1.Oscillator ConnectionsFigure
2.External ClockDriveConfigurationIdle ModeInidle mode,the CPUputs itselfto sleepwhile allthe onchipperipherals remainactive.The modeisinvoked bysoftware.The contentoftheon-chip RAMand allthe specialfunctions registersremainunchanged duringthismode.The idlemode canbe terminated by anyenabled interruptorbya hardwarereset.lt shouldbe notedthat whenidle is terminatedbya hardwarereset,the devicenormally resumesprogramexecution,from whereit leftoff,uptotwo machinecycles beforetheinternalreset algorithmtakescontrol.On-chip hardwareinhibits accessto internalRAM inthis event,but accesstotheport pinsisnot inhibited.To eliminatethe possibilityof anunexpected writeto aport pinwhen Idleis terminatedbyreset,the instructionfollowing theone thatinvokes Idleshould notbe onethat writesto aport pinorto externalmemory.Power-down ModeInthe power-down mode,theoscillatoris stopped,and theinstruction thatinvokes power-down isthelast instructionexecuted.The on-chip RAMand SpecialFunction Registersretain theirvalues untilthepower-down modeisterminated.The onlyexit frompower-down isa hardwarereset.Reset redefinestheSFRs butdoes notchange theon-chipRAM.The resetshould notbe activatedbefore VCCis restoredto itsnormal operatinglevel andmust beheldactive longenough toallow theoscillator torestart andstabilize.Status ofExternal PinsDuring Idleand Power-down ModesModeProgram MemoryALE PSENPORTO PORT1PORT2PORT3Idle Internal11Data Data Data DataIdleExternal11Fbat DataAddress DataPower-down Internal00DataDataData DataPower-down External00Fbat DataData DataProgramMemory Lock BitsOn thechip arethree lockbits whichcanbeleft unprogrammedU orcan beprogrammedP toobtain theadditional featureslisted inthe tablebelow.LockBitProtection ModesProgramLock BitsLB1LB2LB3Protection Type1UUU Noprogram lockfeatures2PUU MOVCinstructions executedfro,n Gxternalprogrammemoryare disabledfrom fetchingcodebytes frominternal memory,EA issampled andlatched onreset,and furtherprogrammingoftheFlash is disabled3P PU Sameas mode
2.also verifyisdisabled4PPP Sameas mode
3.also externalexecution isdisabledWhen lockbit1is programmed,the logiclevel atthe EApinissampled andlatched duringreset.Ifthe deviceis poweredup withouta reset,the latchinitializes toa randomvalue,and holdsthat valueuntilreset isactivated.It isnecessary thatthe latchedvalue ofEA bein agreementwiththecurrent logiclevelat thatpin inorder forthe deviceto functionproperly.译文:的介绍AT89C51描述是一个低电压,高性能位单片机带有字节的可反复擦写的程序存储AT89c51CMOS84K器这种器件采用公司的高密度、不容易丢失存储技术生产,并且能够与PENROM ATMELo系列的单片机兼容片内含有位中央处理器和闪烁存储单元,有较强的功能的MCS-518AT89c51单片机能够被应用到控制领域中功能特性提供以下的功能标准字节闪烁存储器,字节随机存取数据存储器,AT89c514K12832个口,个位定时/计数器,个向量两级中断结构,个串行通信口,片内震荡器和I/O216151时钟电路另外,还可以进行的静态逻辑操作,并支持两种软件的节电模式闲AT89c510HZ散方式停止中央处理器的工作,能够允许随机存取数据存储器、定时/计数器、串行通信口及中断系统继续工作掉电方式保存随机存取数据存储器中的内容,但震荡器停止工作并禁止其它所有部件的工作直到下一个复位引脚描述电源电压VCC地GND口P0口是一组位漏极开路双向口,即地址/数据总线复用口作为输出口时,每一个管P08I/O脚都能够驱动个电路当被写入口时,每个管脚都能够作为高阻抗输入端口8TTL“1”P0P0还能够在访问外部数据存储器或程序存储器时,转换地址和数据总线复用,并在这时激活内部的上拉电阻口在闪烁编程时,口接收指令,在程序校验时,输出指令,需要接电阻P0P0口Pl口一个带内部上拉电阻的位双向口,的输出缓冲级可驱动个电路对端Pl8I/O P14TTL口写,通过内部的电阻把端口拉到高电平,此时可作为输入口因为内部有电阻,某个引脚“1”被外部信号拉低时输出一个电流闪烁编程时和程序校验时,口接收低位地址P18口P2口是一个内部带有上拉电阻的位双向口,的输出缓冲级可驱动个电路P28I/O P24TTL对端口写,通过内部的电阻把端口拉到高电平,此时,可作为输入口因为内部有电阻,某“1”个引脚被外部信号拉低时会输出一个电流在访问外部程序存储器或位地址的外部数据存储16器时,口送出高位地址数据在访问位地址的外部数据存储器时,口线上的内容在P288P2整个运行期间不变闪烁编程或校验时,□接收高位地址和其它控制信号P2口P3□是一组带有内部电阻的位双向口,口输出缓冲故可驱动个电路对P38I/O P34TTL口写如时,它们被内部电阻拉到高电平并可作为输入端时,被外部拉低的口将用电阻P3“1”P3输出电流□除了作为一般的□外,更重要的用途是它的第二功能,如下表所示P3I/O端口引脚第二功能P
3.0RXDP
3.1TXDP
3.2INTOP
3.3INTIP
3.4TOP
3.5T1。
个人认证
优秀文档
获得点赞 0