Unit9MicrocomputerLesson25MCS-51《电子技术专业英语教程》冯新宇主编电子工业出版社《电子技术专业英语教程》2Lesson25MCS-51•Backgrounds•Texttour•Languageinuse–Vocabulary–Structure–Reading/writingtechniques2020/2/29《电子技术专业英语教程》3•Terminology–assemblylanguage汇编语言,装配语言–crystal晶振–oscillatoramplifier振荡放大器–specialfunctionregister特殊功能寄存器–statusregister状态寄存器–purposeregister目的寄存器–datapointer数据指针–movoperationsmov指令操作Backgrounds2020/2/29《电子技术专业英语教程》4Texttour•Outline-Introduction-BasicPins-Ports-DataandProgramMemory-ProgramStartAddress-DirectMemory-SpecialFunctionRegister-GeneralPurposeRegisters-AandBRegisters2020/2/29《电子技术专业英语教程》5Introduction•TheIntel8051microcontrollerisoneofthemostpopulargeneralpurposemicrocontrollersinusetoday.ThesuccessoftheIntel8051spawnedanumberofcloneswhicharecollectivelyreferredtoastheMCS-51familyofmicrocontrollers,whichincludeschipsfromvendorssuchasAtmel,Philips,Infineon,andTexasInstruments.2020/2/29《电子技术专业英语教程》6•Someofthefeaturesthathavemadethe8051popularare:•8-bitdatabus•16-bitaddressbus•32generalpurposesregistereachof8bits•16bittimers(usually2,butmayhavemore,orless).•3internaland2externalinterrupts.•BitaswellasbyteaddressableRAMareaof16bytes.•Four8-bitports,(shortmodelshavetwo8-bitports).•16-bitprogramcounteranddatapointer2020/2/29《电子技术专业英语教程》7BasicPins•PIN9:PIN9istheresetpinwhichisusedresetthemicrocontroller’sinternalregistersandportsuponstartingup.•PINS18and19:The8051hasabuilt-inoscillatoramplifierhenceweneedtoonlyconnectacrystalatthesepinstoprovideclockpulsestothecircuit.•PINS40and20:Pins40and20areVCCandgroundrespectively.The8051chipneeds+5V500mAtofunctionproperly,althoughtherearelowerpoweredversionsliketheAtmel2051whichisascaleddownversionofthe8051whichrunson+3V.2020/2/29《电子技术专业英语教程》8•PINS29,30and31:Asdescribedinthefeaturesofthe8051,thischipcontainsabuilt-inflashmemory.Inordertoprogramthisweneedtosupplyavoltageof+12Vatpin31.IfexternalmemoryisconnectedthenPIN31,alsocalledEA/VPP,shouldbeconnectedtogroundtoindicatethepresenceofexternalmemory.PIN30iscalledALE(addresslatchenable),whichisusedwhenmultiplememorychipsareconnectedtothecontrollerandonlyoneofthemneedstobeselected.PIN29iscalledPSEN.Thisisprogramselectenable.Inordertousetheexternalmemoryitisrequiredtoprovidethelowvoltage(0)onbothPSENandEApins.2020/2/29《电子技术专业英语教程》9Ports•PORTP1(Pins1to8):TheportP1isageneralpurposeinput/outputportwhichcanbeusedforavarietyofinterfacingtasks.TheotherportsP0,P2andP3havedualrolesoradditionalfunctionsassociatedwiththembaseduponthecontextoftheirusage.•PORTP3(Pins10to17):PORTP3actsasanormalIOport,butPortP3hasadditionalfunctionssuchas,serialtransmitandreceivepins,2externalinterruptpins,2externalcounterinputs,readandwritepinsformemoryaccess.2020/2/29《电子技术专业英语教程》10•PORTP2(pins21to28):PORTP2canalsobeusedasageneralpurpose8bitsportwhennoexternalmemoryispresent,butifexternalmemoryaccessisrequiredthenPORTP2willactasanaddressbusinconjunctionwithPORTP0toaccessexternalmemory.PORTP2actsasA8-A15,ascanbeseenfromFigure25-1.•PORTP0(pins32to39)PORTP0canbeusedasageneralpurpose8bitportwhennoexternalmemoryispresent,butifexternalmemoryaccessisrequiredthenPORTP0actsasamultiplexedaddressanddatabusthatcanbeusedtoaccessexternalmemoryinconjunctionwithPORTP2.P0actsasAD0-AD72020/2/29《电子技术专业英语教程》11DataandProgramMemory•The8051MicroprocessorcanbeprogrammedinPL/M,8051Assembly,Candanumberofotherhigh-levellanguages.ManycompilersevenhavesupportforcompilingC++foran8051.Programmemoryinthe8051isread-only,whilethedatamemoryisconsideredtoberead/writeaccessible.WhenstoredonEEPROMorFlash,theprogrammemorycanberewrittenwhenthemicrocontrollerisinthespecialprogrammercircuit.2020/2/29《电子技术专业英语教程》12ProgramStartAddress•The8051startsexecutingprograminstructionsfromaddress0x00intheprogram.2020/2/29《电子技术专业英语教程》13DirectMemory•The8051has256bytesofinternaladdressableRAM,althoughonlythefirst128bytesareavailableforgeneralusebytheprogrammer.Thefirst128bytesofRAM(from0x00to0x7F)arecalledtheDirectMemory,andcanbeusedtostoredata.2020/2/29《电子技术专业英语教程》14SpecialFunctionRegister•TheSpecialFunctionRegister(SFR)istheupperareaofaddressablememory,fromaddress0x80to0xFF.Thisareaofmemorycannotbeusedfordataorprogramstorage,butisinsteadaseriesofmemory-mappedportsandregisters.AllportinputandoutputcanthereforebeperformedbymemorymovoperationsonspecifiedaddressesintheSFR.Also,differentstatusregistersaremappedintotheSFR,foruseincheckingthestatusofthe8051,andchangingsomeoperationalparametersofthe8051.2020/2/29《电子技术专业英语教程》15GeneralPurposeRegisters•The8051has4selectablebanksof8addressable8-bitregisters,R0toR7.Thismeansthatthereareessentially32availablegeneralpurposeregisters,althoughonly8(onebank)canbedirectlyaccessedatatime.Toaccesstheotherbanks,weneedtochangethecurrentbanknumberintheflagstatusregister.2020/2/29《电子技术专业英语教程》16AandBRegisters•TheAregisterislocatedintheSFRatmemorylocation0xE0.TheAregisterworksinasimilarfashiontotheAXregisterofx86processors.TheAregisteriscalledtheaccumulator,andbydefaultitreceivestheresultofallarithmeticoperations.TheBregisterisusedinasimilarmanner,exceptthatitcanreceivetheext