Sunteți pe pagina 1din 1

Serialisanumbrellawordforallthatis"TimeDivisionMultiplexed",touseanexpensiveterm.

It
meansthatthedataissentspreadovertime,mostoftenonesinglebitafteranother.Alltheprotocols
you'renamingareserialprotocols.
UART,forUniversalAsynchronousReceiverTransmitter,isoneofthemostusedserialprotocols.It's
almostasoldasIam,andverysimple.MostcontrollershaveahardwareUARTonboard.Itusesa
singledatalinefortransmittingandoneforreceivingdata.Mostoften8bitdataistransferred,as
follows:1startbit(lowlevel),8databitsand1stopbit(highlevel).Thelowlevelstartbitandhigh
levelstopbitmeanthatthere'salwaysahightolowtransitiontostartthecommunication.That'swhat
describesUART.Novoltagelevel,soyoucanhaveitat3.3Vor5V,whicheveryourmicrocontroller
uses.NotethatthemicrocontrollerswhichwanttocommunicateviaUARThavetoagreeonthe
transmissionspeed,thebitrate,astheyonlyhavethestartbit'sfallingedgetosynchronize.That's
calledasynchronouscommunication.
Forlongdistancecommunication(Thatdoesn'thavetobehundredsofmeters)the5VUARTisnot
veryreliable,that'swhyit'sconvertedtoahighervoltage,typically+12Vfora"0"and12Vfora"1".
Thedataformatremainsthesame.ThenyouhaveRS232(whichyouactuallyshouldcallEIA232,
butnobodydoes.)
ThetimingdependencyisoneofthebigdrawbacksofUART,andthesolutionisUSART,forUniversal
Synchronous/AsynchronousReceiverTransmitter.ThiscandoUART,butalsoasynchronousprotocol.In
synchronousthere'snotonlydata,butalsoaclocktransmitted.Witheachbitaclockpulsetellsthe
receiveritshouldlatchthatbit.Synchronousprotocolseitherneedahigherbandwidth,likeinthecase
ofManchesterencoding,oranextrawirefortheclock,likeSPIandI2C.
SPI(SerialPeripheralInterface)isanotherverysimpleserialprotocol.Amastersendsaclocksignal,
anduponeachclockpulseitshiftsonebitouttotheslave,andonebitin,comingfromtheslave.Signal
namesarethereforeSCKforclock,MOSIforMasterOutSlaveIn,andMISOforMasterInSlaveOut.By
usingSS(SlaveSelect)signalsthemastercancontrolmorethan1slaveonthebus.Therearetwo
waystoconnectmultipleslavedevicestoonemaster,oneismentionedabovei.e.usingslaveselect,
andotherisdaisychaining,ituseslesshardwarepins(selectlines),butsoftwaregetscomplicated.
I2C(InterIntegratedCircuit,pronounced"IsquaredC")isalsoasynchronousprotocol,andit'sthe
firstweseewhichhassome"intelligence"inittheotheronesdumblyshiftedbitsinandout,andthat
wasthat.I2Cusesonly2wires,onefortheclock(SCL)andoneforthedata(SDA).Thatmeansthat
masterandslavesenddataoverthesamewire,againcontrolledbythemasterwhocreatestheclock
signal.I2Cdoesn'tuseseparateSlaveSelectstoselectaparticulardevice,buthasaddressing.Thefirst
bytesentbythemasterholdsa7bitaddress(sothatyoucanuse127devicesonthebus)anda
read/writebit,indicatingwhetherthenextbyte(s)willalsocomefromthemasterofshouldcomefrom
theslave.Aftereachbytereceivermustsenda"0"toacknowledgethereceptionofthebyte,whichthe
masterlatcheswitha9thclockpulse.Ifthemasterwantstowriteabytethesameprocessrepeats:
themasterputsbitafterbitonthebusandeachtimegivesaclockpulsetosignalthatthedatais
readytoberead.Ifthemasterwantstoreceivedataitonlygeneratestheclockpulses.Theslavehas
totakecarethatthenextbitisreadywhentheclockpulseisgiven.Thisprotocolispatentedby
NXP(formerlyPhillips),tosavelicensingcost,AtmelusingthewordTWI(2wireinterface)whichexactly
sameasI2C,soanyAVRdevicewillnothaveI2CbutitwillhaveTWI.
Twoormoresignalsonthesamewiremaycauseconflicts,andyouwouldhaveaproblemifonedevice
sendsa"1"whiletheothersendsa"0".ThereforethebusiswiredOR'd:tworesistorspullthebustoa
highlevel,andthedevicesonlysendlowlevels.Iftheywanttosendahighleveltheysimplyrelease
thebus.
TTL(TransistorTransistorLogic)isnotaprotocol.It'sanoldertechnologyfordigitallogic,butthename
isoftenusedtorefertothe5Vsupplyvoltage,oftenincorrectlyreferringtowhatshouldbecalled
UART.

S-ar putea să vă placă și