版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Chapter6BASICINPUTANDOUTPUTINTERFACE6.1Introduction6.2FunctionsofI/OInterface6.3BasicI/OInterfaceChips6.4BasicI/OPortOperation6.5DataTransferFormatsBetweenCPUandPeripherals6.6ApplicationsofBasicI/OInterfaceOBJECTIVES
Uponcompletionofthischapter,youwilllearnabout:
Theoperationofbufferedinputports
Theoperationoflatchedoutputports
I/Oaddressingspace
ThedesignoffullandpartialI/Oaddressdecoders
BasicI/Oinstruction
Basicdatatransfermode
6.1Introduction
Inchapter5,wesawhowthe8086/8088isconnectedtoitsmemorysystem.Weknewthatprogramdataandinstructionsarestoredinmemoryandaccessedoverasystembusconsistingofaddress,dataandcontrolsignals.
Manytimes,amicroprocessorisusedtocontrolaprocessthatrequiresanexchangeofdatabetweentheprocessorandtheperipheralsusedbytheprocessor.Forexample,an8086controllinganassemblylinemayreceiveinputdatafromswitchesorphotocellsthatgivethepositionofanassemblymakingitswaydowntheline.The8086willbeabletotestthestateofeachsensorbyreadingitsstatuswithaninputport.Indicatorlights,solenoids,andvideodisplayterminalsassociatedwiththeassemblylinemaybedrivenbyafewofthe8086’soutputports.
Asamatteroffact,theinput/outputunitprovidesthemicrocomputerwiththemeansforcommunicatingwiththeoutsideworld.Oftenyouhearthetermoutsideinterface.Whensomeonespeaksofthemicroprocessor’sinterface,theyaretalkinginabroadwayaboutallofthemicroprocessor’scircuitswhichareusedtoletthemicroprocessorcommunicatewithanexternaldevice.Themicroprocessor’sserialinterface,forexample,describesthemicroprocessor’sI/Oport,controllogic,dataformatconversionlogic,connector,andmaybeevencableswhichareusedtoallowthemicroprocessor-basedsystemtoconnecttoaprinter,modem,orothersimilarperipheral.
BeforewelearnaboutwhatisanI/Ointerfaceindeed,weshoulddiscusswhytheI/Ointerfaceisneeded.Themicroprocessorwouldbeabletocontroltheinput/outputdevicestostartorstop,understandthedevice’sworkingstateandthensendoutthecorrespondingcontrolsignals,whichmaketheseperipheralsactaccordinglytotherequirementsofcomputerinputoroutputdataandinformationinsequence.Inthischapter,wewilldiscussthebasicI/OandI/Ointerfaceformicroprocessor8086/8088.
6.2FunctionsofI/OInterface
6.2.1NecessityofI/OInterface
Theprocesstoexchangeinformationbetweenamicroprocessorandperipheralsisjustliketheprocesstoexchangeinformationbetweenamicroprocessorandmemory,whichisprocessedunderthecontrolofthecontrolsignalsthroughthedatabus.Butthelatteriseasierthantheformer.
Theproblemsofmessage’sswitchingbetweenmicroprocessorandperipheralsarelistedasbelow:
1) Datatransmissionspeed’sinconsistency
Usually,amicroprocessorhasamuchhigherworkingfrequencythanperipherals’,anddifferentperipheralshavedifferentworkingfrequencies.
2) Signallevel’smismatching
ThesignallevelsusedbythemicroprocessorareTTLelectrical
levels.Butmostly,theperipheralsarecomplexelectromechanicalequipmentandoftencannotbedrivenbyTTLelectricallevel.So,theperipheralsmusthavetheirownpowersystemandsignallevel.
3) Signalformats’mismatching
Thedatatransferredthroughthesystembusisusually8-bit,16-bit,or32-bitparalleldata.Butsundryperipheralsusesignalswithdifferentformats.Someuseanalogquantityandsomeuseswitchingvalue;someperipheralsareelectronicequipment,andsomeflowvoltagequantity;someadoptserialdatatransmissionmode,whileothersuseparallelmanner.
4) Timing’smismatching
Variousperipheralshaveinconsistenttimingandcontrollogiccomparedwiththemicroprocessor.
Duetothereasonsmentionedabove.TheremustbemediumcircuitstolinkperipheralsandCPU.ThecircuitiscalledI/Ointerfacecircuit,whichisbetweenthemicroprocessorandperipheralsandappliedtoassistantdatatransferandcontrollogicalcircuit.Programmableinterfacechip,I/ObusslotsinPCmainboardarebothinterfacecircuits.Withinterfacecircuits,themismatchingbetweenmicroprocessorsandperipheralscouldbesolved.Inotherwords,interfacecircuitsconnecttheperipheralstothemicroprocessorandmakethemworkinphase.6.2.2FunctionsofInterfaceCircuits
Usually,interfacecircuitshavethesebasicfunctionsasbelow:
(1) Settingdatabufferstosolvetheproblemofoutofcoordinationarousedbytheworkingfrequencyinconsistencybetweenperipheralsandmicroprocessors.
Theproblemofworkingspeed’sinconsistencycanbesolvedbysettingdatabuffer,thatis,preparesthedatathatwouldbetransferredinthebufferinadvanceandstartsthetransferwhenthetransferisneeded.Whatareusuallyusedtorealizethefunctionarebufferandlatchworkingtogetherwithproperhandshakingsignals.
Forinstance,whenthemicroprocessorworkinginhighfrequencysendsdatatoperipheralsworkinginlowfrequency,thedatacouldbesentintothelatchinadvance.Thentheperipheralreceivesthedataafteritisready.Conversely,ifthedatawouldbesenttotheprocessorfromexternaldevice,also,thedatacanbesentintoaninputregister(itisalsoakindoflatch),andthentheexternaldevicesendshandshakingsignaltoinformtheprocessortoaccessthedata.
Itisforbiddenthatsomeperipheralssenddataontothedatabusbecausethebuscouldberuinedbyacompetitionfortheuseofthedatabus.Therefore,theremustbeabufferbetweeninputregisteranddatabus.Onlywhenthechipselectsignalsentbytheprocessorarrivesatthebufferandthebufferisselectedthedatafromtheexternaldevicecouldbesentontothebus.
(2) Settingthesignalleveltransformationcircuit.
(3) Settingtheinformationconversionlogictomeettheirrequirementsofformat.
(4) SettingtimingcontrolcircuitforsynchronizingtheCPUandtheperipherals.
(5) Providingaddressdecodecircuit.
Furthermore,thereareotherfunctionsoftheinterfaces,suchasinput/outputcontrol,read/writecontrolandinterruptcontrolandsoon.Ofcourse,notalltheinterfaceshaveallthefunctionsabove.
6.3BasicI/OInterfaceChips
Themostcommonlyusedsimpleinput/outputinterfacechipsarebuffersandlatches,wewilldiscuss74LS244&74LS245ofBufferedInputPortand74LS373ofaLatchedOutputPortinthissection.
The74LS244octalbufferisatri-statedevice,meaningthatitsoutputsarecapableofgoingintoahigh-impedancestate,effectivelydisconnectingthe74LS244fromtheprocessor’sdatabus.Thehigh-impedancestatecanbethoughtofasanopenswitch.
Thisisthenormalstateofthe74LS244.Whenavalidportaddressappearsontheaddressbus,the74LS244willbeenabledbytheORgate,allowingitsoutputstoresemblethedigitaldatapresentontheeightinputs.Itisimportanttorememberthatthe74LS244isonlyenabledwhentheprocessorisreadingtheinputport!ThishappenswhentheinstructionINAL,9CHisexecuted.
A16-bitinputportrequiresanadditionoctalbufferandenablinglogic.Ifportaddress9CHistobeusedforthe16-bitinputport,thesecondbuffermustbeenabledwhenportaddress9DHisseenontheaddressbus.TheprocessorwilluseA0toenableeachhalfofthe16-bitport.
74LS245/74F245isalsoacommonlyusedbuffer.Figure6.3showsitsinternalfunctionlogicdiagram.Thedatabustransceiverblockofthebusinterfacecircuitcanbeimplementedwith74F245octalbustransceiverICs.Figure6.3(a)showsablockdiagramofthisdevice.Figure6.3(a)Blockdiagramofthe74F245octalbidirectionalbustransceiver;
(b)Circuitdiagramofthe74F245
Notethatitsbidirectionalinput/outputlinesarecalledA1throughA8andB1throughB8.LookingatthecircuitdiagraminFigure6.3(b),weseethattheGinputisusedtoenablethebufferforoperation.Ontheotherhand,thelogiclevelatthedirection(DIR)inputselectsthedirectioninwhichdataaretransferredthroughthedevice.Forinstance,logic0atthisinputsetsthetransceivertopassdatafromtheBlinestotheAlines.SwitchingDIRtologic1reversesthedirectionofdatatransfer.
Figure6.4showsacircuitthatcarriesoutthedatabustransceiverblockofthebusinterfacecircuitusingthe74F245.Forthe16-bitdatabusofthe8086microcomputer,twodevicesarerequired.HeretheDIRinputisdrivenbythesignaldatatransmit/receive(DT/R),andGissuppliedbydatabusenable(DEN).Thesesignalsareoutputsofthe8288buscontroller.Figure6.4Databustransceivercircuit
[ReadingMaterial]Anotherkeyfunctionofthedatabustransceivercircuitistobufferthedatabuslines.Thiscapabilityisdefinedbyhowmuchcurrentthedevicescansinkattheiroutputs.TheIOLratingofthe74F245is64mA.6.3.2LatchedOutputPort
Thereismoretoanoutputportthanasimplereversalofthedirectionthatdatatakesonthedatabus.Dataoutputtoaportcomesfromtheaccumulatorandisplacedontothedatabusonlyforashortperiodoftime.Wehaveonlyafewhundrednanosecondsatthemosttocapturetheoutputdatabeforeitisreplacedbyotherdata(aninstructionreadfrommemoryperhaps).3Itisnecessarytostoreacopyoftheoutputdatawhenitappears.Thisiswhyoutputportsmustcontainstorageelements.Theprocessor’scontrolsignalsareusedtotelltheoutputportcircuitrywhentostorewhatisonthedatabus.
Alatchisusedforthispurpose.The74LS373/74F373isanexampleofanoctallatchdevicethatcanbeusedtoimplementtheaddresslatchsectionofthe8086’smemoryinterfacecircuit.
AblockdiagramofthisdeviceisshowninFigure6.5(a)anditsinternalcircuitryisshowninFigure6.5(b).Notethatitacceptseightinputs:1Dthrough8D.Aslongastheclock(C)inputisatlogic1,theoutputsoftheD-byteflip-flopsfollowthelogiclevelofthedataappliedtotheircorrespondinginputs.
WhenCisswitchedtologic0,thecurrentcontentsoftheD-typeflip-floparelatched.Thelatchedinformationintheflip-flopisnotoutputatdataoutputs1Qthrough8Qunlesstheoutput-control(OC)inputofthebuffersthatfollowthelatchesisatlogic0.IfOCisatlogic1,theoutputsareinthehigh-impedancestate.Figure6.5(c)summarizesthisoperation.Figure6.5(a)BlockdiagramofanoctalD-typelatch;(b)Circuitdiagramofthe74F373(CourtesyofTexasInstrumentsIncorporated);(c)Operationofthe74F373(CourtesyofTexasInstrumentsIncorporated)
Inthe8086microcomputersystem,the20addresslines(AD0~AD15,A16~A19)andthebankhighenablesignalBHEarenormallylatchedintheaddressbuslatch.ThecircuitconfigurationshowninFigure6.6canbeusedtolatchthesesignals.FixingOCatthe0logiclevelpermanentlyenableslatchedoutputsA0LthroughA19LandBHEL.Moreover,theaddressinformationislatchedattheoutputsastheALEsignalfromthebuscontrollerreturnstologic0–thatis,whentheCLKinputofalldevicesisswitchedtologic0.
[ReadingMaterial]Ingeneral,itisimportanttominimizethepropagationdelayoftheaddresssignalsastheygothroughthebusinterfacecircuit.Theswitchingpropertyofthe74F373latchesthatdeterminethisdelayforthecircuitofFigure6.6iscalledenable-to-outputpropagationdelayandhasamaximumvalueof13ns.
Byselectingfastlatches — thatis,latcheswithashorterpropagationdelaytime — amaximumamountofthe8086’sbuscycletimeispreservedfortheaccesstimeofthememorydevices.Inthiswayslower,lowercostmemoryICscanbeused.Theselatchesalsoprovidebufferingforthe8086’saddresslines.Theoutputsofthelatchcansinkamaximumof24mA.Figure6.6Addresslatchcircuit.6.4BasicI/OPortOperation
6.4.1I/OPortAddressMode
Inadditiontothememoryspace,8086microprocessoralsohasI/Ospace.Thisallowsittoaccessports.PortsareusedeithertobringdataintoCPUfromanexternaldevicesuchasakeyboardortosenddatafromtheCPUtoanexternaldevicesuchasaprinter.
ThesimplestmicroprocessorsystemusuallyhasmorethanoneI/Oport.ThismeansthatthemicroprocessormusthaveawaytotellwhichI/Oportitistalkingto.ThemicroprocessordoesthisbyaddressingtheI/Oportinmuchthesamewaythatitaddressesamemorylocation.
4TherearetwowaystheI/Oportcanbeconnectedtothemicroprocessorsothatitcanbeaddressed.Itcanbememory-mappedorI/O-mapped.InthisSection,wewilllookatbothtypesofI/Oportaddressmodes.
IftheI/Oportismemory-mapped,theI/Oregistersactlikeread-writeRAMattheaddressedmemorylocation.Ofcourse,theI/Oportsareaddressed(mapped)atmemorylocationswhichdonotactuallyhaveanyRAM.
Somemicroprocessors,the6802(Motorola)forexample,onlyallowmemory-mappedI/O.Thatis,theonlywayanI/Oportcanbeaddressedbythemicroprocessoristoplaceitatamemoryaddress.However,allmicroprocessorscanusethisifthedesignerfeelsthatmemory-mappedI/OisthebestwaytoaddressI/Ointheparticularsystem.
Memory-mappedI/Ohassomeadvantagesanddisadvantages.Forexample,youwillfindthatitallowstheprogrammertousethewiderangeofinstructiontypesandmemoryaddressingmodesforI/Odatatransfers.Whenmemory-mappedI/Oisused,thereisnoprogrammingdifferencebetweenanI/Odatatransferandamemorydatatransfer.
Adisadvantage,however,isthatmemory-mappedI/Oreducesthenumberofmemorylocationsavailabletotheprogrammer.IfanI/Oporthasaninputregisterandanoutputregister,thenyoumustgiveupatleasttwomemorylocations.Inmanycases,alargeblockofmemorylocationsareassignedtoI/O.Whenthishappens,theentireblockofmemorylocationsisnotavailableforROMorRAM.
[ReadingMaterial]Normally,amemorylocation,oragroupoflocations,isusedtostoreprogramdataandotherimportantinformation.Dataiswrittenintoaparticularmemorylocationandreadlaterforuse.Throughaprocesscalledmemory-mappedI/O,weremovethestoragecapabilityofthememorylocationandinsteaduseittocommunicatewiththeoutsideworld.Imaginethatyouhaveakeyboardthatsuppliesan8-bitASCⅡcode(completewithparity)wheneveryoupressakey.
Yourjobistosomehowgetthisparallelinformationintoyourcomputer.Byusingmemory-mappedI/O,amemorylocationmaybesetasidethatwhenread,willcontainthe8-bitcodegeneratedbythekeyboard.Conversely,datamaybesenttotheoutsideworldbywritingtoamemory-mappedoutputlocation.The8088CPUiscapableofperformingmemory-mappedI/Oineitherbyteorwordlengths.Allthatisrequiredisamemoryaddressdecoder,coupledwiththeappropriatebuscircuitry.
Foramemory-mappedoutputlocation,thememoryaddressdecoderprovidesaclockpulsetoanoctalflip-flopcapableofstoringtheoutputdata.Amemory-mappedinputlocationwouldusethememoryaddressdecodertoenableatri-stateoctalbuffer,placingdatafromtheoutsideworldontotheCPU’sdatabuswhenactive.Figure6.7showsthecircuitryforan8-bitmemory-mappedI/Olocation,sometimesreferredtoasamemory-mappedI/Oport.Thememoryaddressdecodermaybeusedforbothinputandoutput.
SomemicroprocessorshaveaspecialaddressingmodecalledtheI/Omappedmode,orcalledI/Oisolated.WhentheprogrammerwantstomakeanI/Odatatransfer,adifferentsetofthemicroprocessor’scontrollinesisused.TheseI/Ocommands,likethememorycommands,usethemicroprocessor’saddressbusanddatabus,butthereisonedifference.ThesemicroprocessorshaveaspecialI/OcontrollineorsetofI/Ocontrollines.Figure6.7memory-mappedI/Ocircuitry
ControllinessignaltheexternalmicroprocessorsupportlogicthatthedatatransferistobewithmemoryorwithanI/Odevice.Usually,thereisonelinetotellthelogicthatthetransferisanI/Otransferandtheotherthattellsthelogicthatthetransferisamemorytransfer.Whenthecontrollinessignalamemorydatatransfer,theI/Osupportlogicisdisabled.Likewise,whenthecontrollinessignalanI/Otransfer,thememorysupportlogicisdisabled.
OftenthemicroprocessordoesnothaveasmanyI/Olocationsasithasmemorylocations.Forexample,onecommon8-bitmicroprocessorhas64K(65,536)memorylocations.However,itonlyhas256I/Olocations.WhenanI/Ooperationhappens,the8-bitmicroprocessorusesthelower8linesofthe16linesinitsaddressbus.DuringadatatransferwithanI/Olocation,thedataistransferredoverthe8-bitdatabusjustasitisduringadatatransferwithamemorylocation.Figure6.8showsthetwoformsthatmicroprocessorsusetocommunicatewithmemoryandI/O.6.4.2HandshakingSynchronizationofI/OInterface
Insomeapplications,themicrocomputermustsynchronizetheinputoroutputofinformationtoaperipheral.Twoexamplesofinterfacesthatmayrequireasynchronizeddatatransferareserialcommunicationsinterfaceandaparallelprinterinterface.
SometimesitisnecessaryaspartoftheI/OsynchronizationprocessfirsttopollaninputfromanI/Odeviceand,afterreceivingtheappropriatelevelatthepollinput,toacknowledgethisfacttothedevicewithanoutput.Thistypeofsynchronizationisachievedbyimplementingwhatisknownashandshakingaspartoftheinput/outputinterface.
Figure6.9(a)showsaconceptualviewoftheinterfacebetweentheprinterandaparallelprinterport.Therearethreegeneraltypesofsignalsattheprinterinterface:data,control,andstatus.Thedatalinesaretheparallelpathsusedtotransferdatatotheprinter.
Transfersofdataoverthisbusaresynchronizedwithanappropriatesequenceofcontrolsignals.However,datatransferscanonlytakeplaceiftheprinterisreadytoacceptdata.Printerreadinessisindicatedthroughtheparallelinterfacebyasetofsignalscalledstatuslines.ThisinterfacehandshakingsequenceissummarizedbytheflowchartshowninFigure6.9(b).
Theprinterisattachedtothemicrocomputersystemataconnectorknownastheparallelprinterport.OnaPC,a25-pinconnectorisusedtoattachtheprinter.Figure6.9(c)showstheactualsignalssuppliedatthepinsofthisconnector.Notethattherearefivestatussignalsavailableattheinterface,andtheyarecalledAck,Busy,PaperEmpty,Select,andError.Inaparticularimplementationonlysomeofthesesignalsmaybeused.Forinstance,tosendacharactertotheprinter,thesoftwaremaytestonlytheBusysignal.Ifitisinactive,itmaybeasufficientindicationtoproceedwiththetransfer.
Letusnowlookatthesequenceofeventsthattakeplaceattheparallelprinterinterfacewhendataareoutputtotheprinter.Figure6.10(c)isaflowchartofasubroutinethatperformsaparallelprinterinterfacecharacter-transferoperation.FirsttheBUSYinputoftheparallelprinterinterfaceistested.Notethatthisisdonewithapollingoperation.Thatis,theCPUteststhelogiclevelofBUSYrepeatedlyuntilitisfoundtobeatthenot-busylogiclevel.BUSYmeansthattheprinteriscurrentlyprintingacharacter.
Ontheotherhand,notbusysignalsthattheprinterisreadytoreceiveanothercharacterforprinting.Afterfindinganot-busycondition,acountofthenumberofcharacterintheprinterbuffer(microprocessormemory)isread;abyteofcharacterdataisreadfromtheprinterbuffer;thecharacterisoutputtotheparallelinterface;andthenapulseisproducedat
.
Thispulsetellstheprintertoreadthecharacteroffthedatabuslines.TheprinterisagainprintingacharacterandsignalsthisfactatBUSY.Thehandshakesequenceisnowcomplete.Nowthecountthatrepresentsthenumberofcharactersinthebufferisdecrementedandcheckedtoseeifthebufferisempty.Ifempty,theprintoperationiscomplete.Otherwise,thecharactertransfersequenceisrepeatedforthenextcharacter.6.4.3BasicI/OInstructions
Input/outputoperationsareperformedbythe8088and8086microprocessorsthatemployisolatedI/OusingspecialinputandoutputinstructionstogetherwiththeI/Omappedportaddressingmodes.Theseinstructions,in(IN)andout(OUT),arelistedinTable6.1.Theirmnemonicsandformatsareprovidedtogetherwithabriefdescriptionoftheiroperations.
NotethattherearetwodifferentformsofINandOUTinstructions:thedirectI/OinstructionsandvariableI/Oinstructions.Eitherofthesetwotypesininstructionscanbeusedtotransferabyteorwordofdata.AlldatatransferstakeplacebetweenanI/OdeviceandtheCPU’saccumulatorregister.Forthisreason,thismethodofperformingI/OisknownasaccumulatorI/O.BytetransfersinvolvetheALregister,andwordtransferstheAXregister.
Infact,specifyingALasthesourceordestinationregisterinanI/Oinstructionindicatesthatitcorrespondstoabytetransfer.Thatis,byte-wideorword-wideinput/outputisselectedbyspecifyingtheaccumulator(Acc)intheinstructionasALorAX,respectively.
Anexampleistheinstruction
INAL,0FEH
Executionofthisinstructioncausesthecontentsofthebyte-wideI/OportataddressFE16oftheI/OaddressspacetobeinputtotheALregister.Thisdatatransfertakesplaceinoneinputbuscycle.
5ThedifferencebetweenthedirectandvariableI/OinstructionsliesinthewayinwhichtheaddressoftheI/Oportisspecified.WejustsawthatfordirectI/Oinstructionsan8-bitaddressisspecifiedaspartoftheinstruction.Ontheotherhand,thevariableI/Oinstructionsusea16-bitaddressthatresidesintheDXregisterwithintheCPU.ThevalueinDXisnotanoffset.ItistheactualaddressthatistobeoutputonAD0throughAD7andA8throughA15duringtheI/Obuscycle.Sincethisaddressisafull16bitsinlength,variableI/Oinstructionscanaccessportslocatedanywhereinthe64K-byteI/Oaddressspace.
WhenusingeithertypeofI/Oinstruction,thedatamustbeloadedintoorremovedfromtheALorAXregisterbeforeanotherinputoroutputoperationcanbeperformed.InthecaseofvariableI/Oinstructions,theDXregistermustbeloadedwiththeaddress.Thisrequiresexecutionofadditionalinstructions.Forinstance,theinstructionsequence
MOV DX,0A000H
IN AL,DX
MOV BL,AL
meansthatinputsthecontentsofthebyte-wideinputportatA00016oftheI/OaddressspaceintoALandthensavesitinBL.
6.5DataTransferFormatsBetweenCPU
andPeripherals
Datatransfersbetweenthe8088/8086andI/Odevicesareperformedoverthedatabus.Datatransferringtobyte-wideI/Oportsalwaysrequireonebuscycle.BytedatatransferstoaportareperformedoverbuslinesD0throughD7.Wordtransfersalsotakeplaceoverthedatabus,D0throughD7.However,thistypeofoperationisperformedastwoconsecutivebyte-widedatatransfersandtakestwobuscycles.6.5.1PollingRoutineMode
Apollingroutineisverysimple.Themicroprocessor’ssoftwaresimplycheckseachoftheI/Odeviceseverysooften.Duringthischeck,themicroprocessorteststoseeifanydeviceneedsservicing.Forexample,aftercompletingabasiccalculationthemicroprocessorcallsthepollingsubroutine.ThepollingroutinemightlookliketheoneshowninFigure6.11.Figure6.11Apollingroutine(ThisprogramchecksthestatusregisterofeachI/Odeviceintheprogram’slist.IftheI/Odevice’sservicerequestbitisset,theprogramcallsaserviceroutineforthatdevice.)
ThisisasimpleprogramwhichservicesI/Oports01,02,and03.Onceweenterthepollingroutine,wetransferI/Oport01’sstatustotheaccumulator.TheI/Oport’sstatusisfoundinaspecialstatusregisterlocatedattheI/Oportwiththeinputandoutputdataregisters.DifferentbitsinthisregisteraresetorclearedtoshowthestatusoftheI/Oporthardware.Onebit,theservicerequestbit,issetwhentheI/Oportneedsservice.IntheI/Opollingroutine’sdecisionblock,wetestthisstatusregistertoseeiftheservicerequestbitisset.Ifitis,I/Oport01’sserviceroutineiscalled.WhenwereturnfromtheI/Oport’sserviceroutine,wereturntothepollingroutine.
Thepollingroutinemovesontotestport02afteroneoftwoactionsiscomplete:iftheport01servicerequestbitisnotset,orifthecalltotheI/Oserviceroutineiscomplete.Eitheractioncausesthemicroprocessortotestport02’sstatusregistertoseeifitsservicerequestbitisset.
ThistestandserviceprocedurecontinuesuntilalltheI/OportstatusregistersaretestedandalltheI/Oportsneedingserviceareserviced.Oncethisisdone,themicroprocessorcontinuestoexecutethenormalprograms.
ThepollingroutineassignsprioritiestothedifferentI/Odevices.Again,lookattheFigure6.13.Oncethepollingroutine
isstarted,theservicerequestbitatport01isalwayscheckedfirst.Onceport01ischecked,port02ischecked,andthenport03.However,theordercanbechangedbysimplychangingthepollingroutine.Tochangeit,youonlyneedtochangetheI/Oportnumbersinthegetstatusregisterinstructions.
ThepollingroutineisstartednotbytheI/Odevicebutbythesoftware.Whenthemainprogramreachesthepollingroutinesubroutinecall,thepollingbegins.PollingroutinescannotbeusedunlesstheI/Odevicescanwaitforservice.6.5.2InterruptMode
TheotherwaytostartanI/OdeviceservicedisforthisI/Odevicetoaskforservice.ItdoesthisbyusingaspecialmicroprocessorI/Oportcalledtheinterrupt.Theinterruptisaspecialinputtothemicroprocessor’scontrollogic.Interruptsindifferentmicroprocessorsoperateinslightlydifferentways.However,theyallhavethesameresult.
Whentheinterruptinputisasserted(asignalissenttotheinterruptinput),aspecialsequenceinthecontrollogicbegins.Itmakessuretha
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年飞行服务站接入民航空管运行体系流程
- 2026年适老化产品新增品种爆发式增长趋势分析
- 2026年燃料电池气水热电耦合特性耐久性技术路线
- 2026年绿色燃料生产储存运输加注全链条设施布局
- 2026年模型精度与推理性能的平衡:精度损失控制在0.3%以内的方案
- 2026年双鸭山地下人工硐室压缩空气储能助力双碳
- 2026年RSV预融合F蛋白DSCav1设计原理与稳定性改造
- 2026年量子通信芯片化规模化发展成本降低路径
- 2026陕西蒲城高新医院招聘25人备考题库(综合题)附答案详解
- 2026年卧室适老化照明与紧急呼叫系统设计
- 多品种小批量生产管理培训
- DL/T 5182-2021 火力发电厂仪表与控制就地设备安装、管路、电缆设计规程
- 新版GSP质量方针和目标展开图
- 2020年个人信用报告新版含水印
- 贵州三湘科技有限责任公司年处理100万吨电解锰渣资源化综合利用项目环评报告
- 2022年06月中央台办所属事业单位公开招聘人员笔试题库含答案解析
- 广东省五年一贯制考试英语真题
- 厂房钢结构吊装施工方案
- 绝缘铜管母线与封闭母线对照表
- GB/T 7584.3-2011声学护听器第3部分:使用专用声学测试装置测量耳罩式护听器的插入损失
- GB/T 5324-2009精梳涤棉混纺本色纱线
评论
0/150
提交评论