1of26032703INTRODUCTIONThe1-WirecommunicationprotocolcanbegeneratedwithanIOpinonamicroprocessor;however,caremustbetakentoprovidethecorrecttimingandproperslewratestocreateareliable1-Wirenetwork.
Impropertimingsentbythe1-Wiremastermaycausecommunicationwith1-Wireslavedevicestobeintermittentorfailaltogether.
Uncontrolledslewratescanseverelylimitthelengthofanetworkandcreatesporadicbehavior.
IfaserialcommunicationUARTisavailable,usingaserial-to-1-Wirebridge(DS2480B)willeliminatetheseproblems.
TheDS2480Bisaserialbridgetothe1-Wirenetworkprotocol.
ThisbridgeallowsanyhostwithaverymodestserialcommunicationUARTtogenerateproperlytimedandslewcontrolled1-Wirewaveforms.
TheDS2480Breceivesescapedcommandsanddata,performs1-Wireoperations,andreturnstheresultbacktothehost.
SeeFigure1forasimplifieddiagramoftheDS2480Bconfiguration.
ImplementationofthisprotocolandnavigatingtheavailableDS2480Bcommandscanbetimeconsumingandconfusing.
Thisguideidentifiescommon1-WireoperationsandexplainstheconstructionofinputserialpacketsandinterpretationofoutputserialpacketsfortheDS2480B.
ThisdocumentisdesignedtocomplementtheDS2480Bdatasheet,butnotreplaceit.
Thedatasheetcanbefoundonhttp://www.
maxim-ic.
com/quick_view2.
cfm/qv_pk/2923.
DS2480BUSAGE(SIMPLIFIED)Figure1TheminimumhostUARTthatwillworkwiththisbridgemustsupport8-bit,non-parity,9600baud(bitspersecond)communication.
Fasterdataratesupto115200baudcanbenegotiatedbutthebridgestartsat9600baudwhenpoweringup.
ElectricalconsiderationssuchasRS232areaddressedinDS2480Bdatasheet.
THE1-WIREINTERFACETheDS2480Bisonlyusefulifallofitscommandsandmodescanbetranslatedintoa1-Wirecommunicationinterfacethatapplicationscanuseandbuildupon.
Thereareafewbasic1-Wirefunctionsthatanapplicationmusthaveinordertodoany1-Wireoperation.
Thisfirstoperationresetsallofthe1-Wireslavesonthebusreadyingthemforacommandfromthe1-Wiremaster.
Thesecondwritesabitfromthe1-Wiremastertotheslavesandthethirdreadsabitfromthe1-Wireslaves.
Sincethe1-Wiremastermuststartall1-Wirebitcommunication,a'read'istechnicallya'write'ofaonebitwiththeresultsampled.
Almostallother1-Wireoperationscanbeconstructedfromthesethreeoperations.
Forexample,abytewrittentothe1-Wirebusisjusteightsinglebitwrites.
The1-WireSearchAlgorithm(SeeApplicationNote187athttp://www.
maxim-ic.
com/appnotes.
cfm/an_pk/187)canalsobeconstructedusingtheseprimitives.
Thisisnotnecessarilythemostefficientimplementationmethod,however.
TheDS2480BincorporatesasearchacceleratormodethatgreatlyreducestheserialApplicationNote192UsingtheDS2480BSerial1-WireLineDriver1-WiremasterDS2480B(serialbridge)1-WirebusRXDHOSTUART(morPC)TXD1-Wireslave1-Wireslave1-WireisaregisteredtrademarkofDallasSemiconductor.
AN1922of26communicationrequiredtodoasearch.
Itisalsomoreefficienttobundlegroupsofbitcommunicationintobytesandevenblocksofbytes.
Wheneverpossible,anapplicationshouldusethelargestgroupingofcommands(biggestpackets)formaximumefficiency.
Table1isaminimalinterfaceofefficient1-Wirefunctions.
Theoperationnameisprovidedasalabeltotheparticularoperationandwillbeusedthroughtheremainderofthisdocument.
BASIC1-WIREOPERATIONSTable1OperationDescriptionOWResetSendthe1-Wireresetstimulusandcheckfor1-Wireslavedevicepresencepulses.
OWWriteBit/OWReadBitSendorreceiveasinglebitofdatatothe1-Wirebus.
OWWriteByte/OWReadByteSendorreceiveasinglebyteofdatatothe1-Wirebus.
OWBlockSendandreceivemultiplebytesofdatatoandfromthe1-Wirebus.
OWSearchPerformthe1-WireSearchAlgorithm(seeApplicationNote187).
Therearealsoextended1-Wirefunctionsthatarenotcoveredinthebasicoperations.
Some1-Wireslavedevicescanoperateattwodifferentcommunicationspeeds:standardandoverdrive.
Alldevicesatleastsupportstandard.
Overdriveisapproximately10timesfasterthanstandard.
TheDS2480Bsupportsboth1-Wirespeeds.
1-Wiredevicesnormallyderivesomeoralloftheiroperatingenergyfromthe1-Wirebus.
Howeversomedevicesrequireadditionalpowerdeliveryataparticularplaceintheprotocol.
Forexample,adevicemayneedtodoatemperatureconversionorcomputeanSHA-1hash.
Thispowerissuppliedbyenablingastrongerpulluponthe1-Wirebus.
Normalcommunicationcannottakeplaceduringthispowerdelivery.
TheDS2480Bhasseveraladvancedfeaturestoprovidepowerdelivery.
EPROM(one-time-programmable)1-Wirememorydevicesrequireaspecial12Vpulsewhenwriting.
IftheDS2480Bhas12Vavailablethenitcanbetoldtodeliverapulseontothe1-WirebusforEPROMprogramming.
Table2liststheextended1-Wireoperationsfor1-Wirespeed,powerdelivery,andprogrammingpulse.
EXTENDED1-WIREOPERATIONSTable2OperationDescriptionOWSpeedSetthe1-Wirecommunicationspeed.
Thechoiceisstandardoroverdrivespeed.
Notethatthisonlychangesthecommunicationspeedofthe1-Wiremaster;the1-Wireslavedevicemustbeinstructedtomaketheswitchwhengoingfromnormaltooverdrive.
The1-Wireslavewillalwaysreverttostandardspeedwhenitencountersastandardspeed1-Wirereset.
OWLevelSetthe1-Wirepowerlevel(normalorpowerdelivery).
OWProgramPulseSendsatimed12VprogrammingpulseforEPROM1-Wiredevicewriting.
OWReadBitPowerReadasinglebitofdatafromthe1-Wirebusandoptionallyapplypower-deliveryimmediatelyafterthebitiscomplete.
OWWriteBytePowerSendasinglebyteofdatatothe1-Wirebusandapplypower-deliveryimmediatelyafterthebyteiscomplete.
AN1923of26Thisdocumentpresentsanefficientimplementationofthebasicandextended1-WireoperationsusingtheDS2480B.
Theseoperationsprovideacompletefoundationtoperformallfunctionsforcurrentandfuture1-Wiredevices.
Abstractingthe1-Wireoperationsinthisfashionleadsto1-Wireapplicationsthatareindependentofthe1-Wiremastertype(seeExample1).
NotethatthisimplementationisnottheonlyonepossibleanddoesnotnecessarilyutilizealloftheDS2480B'sfeatures.
More1-Wireusageexamplesarepresentedattheendofthisdocument.
READMEMORYPSEUDOCODEExample1trans_block–temporarytransmitbuffer,valuesexpressedinhexadecimalnotation//resetthe1-WirebusIfOWReset=TRUE//senttheMATCHROMsequenceforthedevicetoread,ROMisR0.
.
.
R7trans_block=55,R0,R1,R2,R3,R4,R5,R6,R7OWBlock(trans_block)//sendtheReadMemorycommand,address(0),//and32readbytesforthepageofdatatrans_block=F0,00,00,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FFOWBlock(tran_block)//page0dataisnowinlast32bytesoftrans_block.
.
.
Else//nodevicepresent.
.
.
EndIFHOSTCONFIGURATIONThehostoftheDS2480BmusthaveaUARTthatcanatleastsupport8-bit,non-parity,9600baudcommunication.
ConfigurationofthehostUARTisplatformspecificsoisnotcoveredbythisdocument.
Itmust,however,providestandardinterfaceoperationsincludedreadingandwriting,flushinganypendingreads/writes,issuingabreak,andoptionallychangingthebaudrate.
Table3providesalistofoperationtermstodescribeaninterfacetoagenerichostUART.
ThesetermswillbeusedtodescribeoperationsdonetotheUART.
REQUIREDHOSTUARTOPERATIONSTable3OperationDescriptionBreakSendsaBREAKonthecommunicationportforatleast2ms.
FlushAllowsanypendingwriteoperationstocompleteandclearinput(read)buffer.
ReadReadaspecifiednumberofbytesfromtheserialport.
Provideasufficientlylongtimeouttoensurethatallbytesarereceivedundernormalconditions.
WriteWriteaspecifiednumberofbytestotheserialport.
Returnafterallofthebyteshavebeenwritten.
SetBaudChangestheserialBAUDratetotheratespecified.
(Optionalifoverdriveneeded.
)DelayDelaysatleastthespecifiednumberofmilliseconds.
AN1924of26A'C'codeimplementationofthisapplicationnoteusingtheMicrosoftWindows32-bitoperatingsystemRS232serialportwithaDS9097Uadapterasthehostcanbedownloadedfromthefollowinglink:http://files.
maxim-ic.
com/sia_bu/public/an192.
zip.
This'C'codeimplementationisasimplifiedversionoftheoneprovidedinthe1-WirePublicDomainkit.
The1-WirePublicDomainkitalsocontainsdevicespecificmodulesandexamplesandcanbefoundatthefollowinglink:http://www.
maxim-ic.
com/products/ibutton/software/tmex/.
DS2480BCONFIGURATIONBeforeany1-Wireoperationscanbeattempted,thehostmustsetupandsynchronizewiththeDS2480BSerial1-Wirelinedriver.
Thissetupandsynchronizationprocedureisalsodoneifacommunicationproblemiseverdetectedbetweenthehostandthebridge.
TheDS2480Brequires9600baudduringsetup.
Aftersetupthebaudratecanbenegotiatedupto115200baud.
Caremustbetaken,however,sincetheDS2480Bonlyhasaonebyteinputbuffer.
Theprovided1-Wirecommandmustbeabletocompletebeforethenextcommandisshiftedin.
SeeTable7intheDS2480Bdatasheettoseewhatcommandswillworkatwhatbaudrates.
DS2480B_DetectSincetheDS2480Bdoesnothaveacrystalitmusttuneitstime-basebysamplingtheserialcommunicationsentbythehost.
ThissetupsequenceisinitiatedbyresettingtheDS2480Bandthensendingapredefinedtimingbyte.
Resettingthedevicewillresultinallofthe1-Wireconfigurationparametersbeingresettotheirdefaultstate.
Forgoodperformanceonsmalltomediumlength1-Wirenetworks,itisrecommendedthattheDS2480Bbeusedin'flex'modewhendoingstandardspeedcommunication.
The1-Wireconfigurationparametersareusedtoshapethe1-Wiresignalinflexmode.
Consequently,whenevertheDS2480Bisreset,theconfigurationparametersneedtobereloaded.
ThedesiredflexsettingsarePDSRC=1.
37V/ms,W1LD=10ms,DSO/W0RT=8ms.
ThisresetandconfigurationsequenceiscombinedintoonoperationcalledDS2480B_Detect.
TheDS2480Bisresetifitdetectsaspaceinthestop-bitposition.
Theeasiestwaytogeneratethisiswithaserialbreaklongerthana9600baud8-bitword.
IfbreakisnotavailableonthehostUARTthenswitchingtoaslowerbaudrateandsendingazerobytecansimulateabreak.
Switchingtospaceparityorchangingtoa9-bitwordlengthwithazerointhemostsignificantbitcanalsosimulateabreak.
Someofthedelayvaluesintheconfigurationsequence(seeFigure2)arearbitrarilylargetoaccommodatemostUARTS.
Thesevaluescanbereduced.
Thereadbaudrateregisterandwrite1-WirebitattheendofthesetupsequenceisdesignedtomeasurethecorrectfunctioningoftheDS2480Bsetup.
Ifeitheroneofthoseoperationsreturnsaninvalidresponsethenthesetupisdeemedunsuccessful.
NotethatthisimplementationdoesnotcheckfortheunsolicitedpresencepulsenotificationbytefromtheDS2480B.
Thismaycauseanyofthe1-WireoperationstogetanimproperlyformattedresponsebyteleadingtothecalltotheDS2480B_Detectfunction.
Sinceany1-Wireapplicationthatisusedinanintermittentcontactenvironmentthatwouldproducetheseunsolicitedpresencepulsenotificationsmustalreadyincorporateretries,thisdoesnotpresentaproblem.
AN1925of26DS2480B_DETECTFLOWFigure2Setbaudto9600Sendbreak(2ms)Delay(2ms)FlushWritetimingbyte(C1hex)Delay(2ms)ConstructPacket:SetPDSRC=1.
37V/msSetW1LD=10msSetDSO/W0RT=8msReadBaud(RBR)Senda1-WirebitWritethepacketandreceivethe5-byteresponseFlushPacketreceivedandvalidYesNoDS2480BPresentDS2480BNOTPresentOutboundPacket(toDS2480B)setPDSRCsetW1LDsetDSO/W0RTreadRBR1-WireBit17(hex)455B0F91ResponsePacket(fromDS2480B)responsePDSRCresponseW1LDresponseDSO/W0RTreadRBRresponse1-WireBitresult16445A0093StartAN1926of26DS2480B_ChangeBaudTochangethecommunicationspeedbetweentheHOSTandtheDS2480B,theRBR(RS232BaudRate)registermustbewritten.
TheDS2480BimmediatelyrespondswiththesetbaudrateresponseatthenewbaudratebutitislikelytobemissedbytheHOST.
Consequently,therecommendedflowasseeninFigure3hastheresponsebyteflushedandignored.
AfterboththehostandtheDS2480Bhaveswitchedbaudrates,thebaudrateregisterisreadbacktoverifycompletion.
IftheDS2480Bisnotatthecorrectbaudrate,thereadbackwillfailandthesetupinitializationsequenceDS2480B_Detectiscalled.
TheDS2480Bcanoperateonfourdifferentbaudrates:9600,19200,57600,and115200.
SincetheDS2480Bhasonlyaone-bytebuffer,thecommandsentmustbecompletebeforethenextcommandarrives.
Figure7inthedatasheetshowswhatoperationscanbeperformedatwhatbaudrateswithoutdangerofoverwritingcommands.
Itisrecommendedthatthe1-Wireresetresultshouldalwaysbereceivedbeforeproceedingtothenextcommandsodonotincludeitinacontinuousbytestream.
Thisimplementationsplitsthe1-WireresetoffintoitsownoperationOWResetsothisisnotanissue.
Similarly,thesinglebitandsinglebyteoperationsarealsosplitintotheirownoperations:OWReadBit,OWWriteBit,OWReadByte,andOWWriteByte.
Sincetheyarenotstreamedwithothercommands,themaximumbaudratecanbeused.
Alsonotethatthisimplementationonlyusesflexmodewithextendedbittimingwhendoingstandardspeed1-Wirecommunicationwhichaffectstheallowedbaudrates.
SeeTable4forthebaudraterecommendations.
Forsimplicity,thisimplementationwilluseonlytwobaudrates:9600baudforstandardspeed(flex)operationsand115200baudfornon-searchoverdriveoperations.
MAXIMUMSTREAMINGBAUDRATESTable4FunctionStandard(Flex)OverdriveSearch(OWSearch)9600(baud)57600Command(allnon1-Wireoperations)115200115200Data(OWBlock)9600115200AN1927of26DS2480B_CHANGEBAUDFLOWFigure3AddsetbaudrateRBRtooutboundpacketSetBaudtonewbaudDelay(5ms)FlushWritereadbaudratecommandRBR(0Fhex)andget1byteresponseDS2480BMode=commandYesNoAddcommandselecttooutboundpacket,E3hexWritethepacketandignoreanyresponseDelay(5ms)FlushReadRBRreceivedandvalidYesNoDS2480BatnewbaudFailtogetDS2480BtonewbaudOutboundPacket(toDS2480B)Commandmode(optional)setbaudrateRBRE3(hex)0111bbb1(binary)ResponsePacket(fromDS2480B)(ignored)bbbbaud00096000011920001057600011115200OutboundPacket(toDS2480B)ReadbaudrateRBR0F(hex)ResponsePacket(fromDS2480B)RBRregisterresult0000bbb0(binary)bbbbaud00096000011920001057600011115200StartDS2480B_DetectAN1928of261-WIREOPERATIONSThebasicandextended1-Wireoperationscreateacommon1-Wireinterfacethatfacilitatesanyoperationonany1-Wiredevice.
Theimplementationforeachofthese1-Wireoperationshassomecommonfeatures.
ThecommandsanddataaregroupedtogetherwheneverpossibletoreducethenumberofpacketsexchangedwiththeDS2480B.
ThecurrentmodeoftheDS2480Biskeptasstatesoapacketmaystartwithamodechangingcommand.
Iftheresponsepacketisnotthecorrectlengthorisinanimproperformat,theDS2480B_Detectsequenceiscalled.
TheonlychangeintheserialcommunicationratebetweenthehostandtheDS2480BisdoneinOWSpeedwhenchangingthe1-Wirecommunicationspeed.
Asitisimplemented,OWSearchcannotberuninoverdrivemode.
Asimplecheckcouldbeaddedtoreducethebaudrateto57600baudwhendoingasearchatthefastercommunicationrate.
Every1-Wireoperationshouldfirstmakesurethatthecurrentlevelpullupisnormal.
SoeachflowstartswithanimplicitcalltoOWLevel(normal).
OWResetTheOWResetoperationinstructstheDS2480Btosendaresetpulsetothe1-Wireandsampletodetectthepresencepulsesfrom1-Wireslavesonthebus.
Whiletheprimarypurposeofthisinstructionistoperformthisresetoperation,italsoreturnsotherusefulinformation.
Italsoprovidesathree-bitfieldthatindicatestheversionofthechip.
TheversionfieldwillbeconstantwithallDS2480Bs,howeveritcanbeusedtodetectthepredecessortothisbridge,theDS2480.
ThisimplementationiscompatiblewiththeDS2480.
Also,maskingoffthisfieldwillmakethehostsoftwareorfirmwareatleastpartiallycompatibletofuturebridgeversions.
The1-Wireresetcommandoperationtakesinthecommunicationspeed.
Notethatwhencommunicatinginstandard1-Wirespeed,theDS2480Bflexmodeisusedinthisimplementation.
Thetimethatthisoperationtakestocompletedependsonwhetherthereisanalarmpresence.
Thisisthemainreasonwhythisoperationisnotgroupedinpacketswithother1-Wireoperations.
Notetheextra5msdelayandflushifaDS1994*orDS2404*devicecouldbeonthe1-Wirebus.
TheDS2480Bdoesnothandleallofthe1-Wireresetalarmtypesfromthesedevicesandcommunicationmustbedelayeduntiltheyarecomplete.
SeeFigure4fortheflowofthisoperation.
*TheDS1994andDS2404arenolongerrecommendedfornewdesigns.
AN1929of26OWRESETFLOWFigure4ResetresponsevalidYesNoStandardspeedandDS1994NoYesAddflexoroverdrive1-WireresettopacketFlushDS2480BMode=commandYesNoAddcommandselecttooutboundpacket,E3hexOutboundPacket(toDS2480B)Commandmode(optional)1-WireresetcommandE3(hex)1100ss01(binary)ResponsePacket(fromDS2480B)1-Wireresetresult11xvvvrr(binary)ssSpeed01standard(flex)10overdriverrResetresult001-Wireshorted01presence10alarmpresence11nopresenceWritethepacketandreceivethe1-byteresponseReturnresetresultReturn1-WireresetfailurexUndefinedbitvvvDS2480version010DS2480011DS2480B100(future)Delay(5ms)FlushDS2480B_DetectStartReturn1-WireresetpresentAN19210of26OWWriteBit/OWReadBitPerformingasinglebitoperationonthe1-Wireisunusualbutisincludedhereforcompleteness.
Whentheprotocolindicatesawritebitthenthevalueisjustwrittentothe1-WireasseeninFigure5.
Ifareadisrequiredthenawrite-oneisdoneandtheresultsampledisthereadresult.
OWWRITEBIT/OWREADBITFLOWFigure51-WirebitresponsevalidYesNoAddbitcommandtopacketFlushDS2480BMode=commandYesNoAddcommandselecttooutboundpacket,E3hexOutboundPacket(toDS2480B)Commandmode(optional)send1-WirebitE3(hex)100dss01(binary)ResponsePacket(fromDS2480B)1-Wirebitresult100dssrr(binary)ssSpeed01standard(flex)10overdriverrbitresult000readback111readbackWritethepacketandreceivethe1-byteresponseReturn1-WirebitresultdDatatosend0write0bit1write1orreadbitReturn1-WirebitfailureDS2480B_DetectStartAN19211of26OWWriteByte/OWReadByte/OWBlockThesingleandmultiplebyteoperationsareverysimilar.
TheDS2480Bmustfirstbeputintodatamode.
Likethesinglebitcommands,whentheprotocolindicatesawritebytethenthedataisjustwritten.
AreadbyteisdonebywritingaFFhex(allones)andthenthesampleddataisthereadresult.
Ablockoperationisagroupofsinglebyteoperationsthatmaybeamixtureofreadsandwrites.
Thereadpositionsmustbepre-filledwithFF'shex.
Caremustbetakentoalwaysduplicatedatabytesthatarethesameastheswitchtocommandmodecommand(E3hex).
ThisinstructstheDS2480Btotreatitasdataandnottheswitchtocommandmode.
OWWRITEBYTE/OWREADBYTE/OWBLOCKFLOWFigure6ResponselengthvalidYesNoAdddatabyte(s)topacket,duplicateE3'sFlushDS2480BModeDataYesNoAdddatamodeselecttooutboundpacket,E1hexOutboundPacket(toDS2480B)Datamode(optional)1-Wiredatabyte1-WiredatabyteE1(hex)(databyte1)(databyteN)ResponsePacket(fromDS2480B)1-Wiredatabytereturn1-Wiredatabytereturn(databyte1)(databyteN)WritethepacketandreceivetheresponseReturn1-WiredataresponseReturnfailure1-WiredatafailureDS2480B_DetectStartAN19212of26OWSearchThesearchalgorithmisabinarytreesearchwherebranchesarefolloweduntiladeviceROMnumber,orleaf,isfound.
Subsequentsearchesthentaketheotherbranchpathsuntilalloftheleavespresentarediscovered.
Thesearchalgorithmbeginswiththedevicesonthe1-Wirebeingresetusingtheresetandpresencepulsesequence(seeOWReset).
Ifthisissuccessfulthenthe1-bytesearchcommandissent(normalF0hexoralarmEChex).
Thesearchcommandreadiesthe1-Wiredevicestobeginthesearch.
Followingthesearchcommand,theactualsearchbeginswithalloftheparticipatingdevicessimultaneouslysendingthefirstbit(leastsignificant)intheirROMnumber(alsocalledregistrationnumber).
Aswithall1-Wirecommunication,the1-Wiremasterstartseverybitwhetheritisdatatobereadorwrittentotheslavedevices.
Whenalldevicesrespondatthesametime,theresultwillbealogicalANDofthebitssent.
AfterthedevicessendthefirstbitoftheirROMnumber,themasterinitiatesthenextbitandthedevicesthensendthecomplementofthefirstbit.
Ifbothbitsarezerothenthereareboth1sand0sinthatbitposition.
Thisiscalledadiscrepancyandisabranchpointinthesearch.
The1-Wiremasterthenwritesasearchdirectionbit.
Ifthedevicehasthatbitvalueitwillcontinueparticipatinginthesearch,allotherdevicesgointoawaitstate.
This'readtwobits'and'writeonebit'patternisthenrepeatedfortheremaining63bitsoftheROMnumber.
SeeApplicationNote187,1-WireSearchAlgorithm,athttp://www.
maxim-ic.
com/appnotes.
cfm/an_pk/187fordetailsontheoperationofthe1-Wiresearchandselectivesearchoptions.
Thebasicsearchoperationsincludefindingalldevicesonthe1-Wirenetwork.
Theselectivesearchoperationsallowsearchesthatfindonlyaparticularfamilyof1-Wiredevices.
Alargepartofthe1-WiresearchisperformedbytheDS2480B.
TheflowofthesearchsequencecanbeseeninFigure7.
Theoutboundsearchdataisconstructedbasedonthelastsearch(seeFigures8and9),thesearchisperformed,andthenthesearchresponsedataisparsed(seeFigures10and11).
CaremustbetakentonotrunOWSearchinoverdriveusingthisimplementationofOWSpeedsinceituses115200baud,whichwilloverflowtheDS2480Binputbuffer.
Thiscouldbeeasilymodifiedtoreducethebaudrateto57200whendoingoverdrivesearches.
AN19213of26OWSEARCHFLOWFigure7OWReset,devicefoundYesNoReturnnodevicesfoundDevicefoundfromsearchYesNoAdddatamodeandsearchcommandF0(orEC)hextooutboundpacket.
Alsoadd'searchaccelerator'datasequence.
(seeFigures8and9)OutboundPacket(toDS2480B)DatamodeSearchcmdCmdmodeSearchAcceleratoronE1(hex)F0E31011ss01(binary)Datamode1-Wiresearchdatabyte1-WiresearchdatabyteCmdmodeSearchAcceleratoroffE1(hex)(databyte0)(databyte15)E31010ss01(binary)ResponsePacket(fromDS2480B)Echoofsearchcmd1-Wiresearchdatabytereturn1-WiresearchdatabytereturnF0(databyte0)(databyte15)Writethe22bytepacketandreceivethe17byteresponsessSpeed01standard(flex)10overdriveFlushExtracttheROMandsearchinformationfromresponsepacket(seeFigures10and11)ReturnnodevicesfoundReturndevicefoundStartResponselength+formatvalidYesNoDS2480B_DetectAN19214of26Thestateofthe1-Wiresearchmustbemaintainedbetweensearchestofindsubsequentdevices.
ThetermsrepresentingthesearchstatearepresentedinTable5andcoincidewiththetermsusedinApplicationNote187,The1-WireSearchAlgorithm.
SEARCHSTATETable5TermDescriptionid_bit_numberTheROMbitnumber1to64currentlybeingsearched.
LastDeviceFlagFlagtoindicateprevioussearchwasthelastdevice.
LastDiscrepancyBitindexthatidentifiesfromwhichbitthe(next)searchdiscrepancycheckshouldstart.
LastFamilyDiscrepancyBitindexthatidentifiestheLastDiscrepancywithinthefirst8-bitfamilycodeofROMnumber.
ROM_NO8-bytebufferthatcontainsthecurrentROMregistrationnumberdiscovered.
search_directionBitvalueindicatingthedirectionofthesearch.
Alldeviceswiththisbitstayinthesearchandtherestgointoawaitstatefora1-Wirereset.
1-WireSearchDataConstructionThe16bytesof1-Wiresearchdatainputcanbeconsidered128bitsofdata.
Thedataisgroupedinto642-bitpairs.
Thefirstbitisnotusedandshouldbe0.
Thesecondbitisthesearchdirectionusedifadiscrepancyisdetected.
IfadiscrepancyisnotdetectedthentheDS2480Bwillautomaticallyproceedwiththeonlyavailablepath.
Whenconstructingtheoutbounddata,setthesearchdirectionbitstotheROM_IDbitsfromtheprevioussearchupuntilthelastdiscrepancybitposition.
Atthatpoint,setthesearchdirectiontooneandthereaftersetthemalltozero.
SeeFigure8forthedataformatandFigure9fortheconstructionflow.
OUTBOUNDSEARCHDATAFigure8302r1*104r2L-10L**112701280*ROM_IDbitscorrespondingtotheid_bit_numberfromaprevioussearch**LastDiscrepancybitpositionAN19215of26OWSEARCH:OUTBOUNDSEARCHDATACONSTRUCTIONFigure9Clearthe128-bits(16-bytes)ofsearchdata.
Setid_bit_numberto1.
Startid_bit_number64NoYes1-WireSearchDatacompleteAN19216of261-WireSearchDataParsingThedataresultingfromthe1-WiresearchfromtheDS2480Bareagain16bytesofdatarepresenting64two-bitpairs.
Thefirstbitineachpairisaflagindicatingifthisbitpositionencounteradiscrepancyrequiringtheuseofthesearchdirectionbitprovided.
ThesecondbitineachpairisthesearchdirectiontakenwhichisabitoftheresultingROMnumberofthedevicefoundinthesearch.
TheformatcanbeseeninFigure10.
ThediscrepancyflagsandthesearchdirectiontakenisparsedtosetthesearchstateasseeninFigure11.
SEARCHDATARESPONSEFigure103d22r1*1d1**4r2127d64128r64*newROM_IDbitscorrespondingtotheid_bit_numberfromthissearch**1ifdiscrepancyoccurredinthisbitposition,thehighestzeropositionisthenewLastDiscrepancyAN19217of26OWSEARCH:RESPONSESEARCHDATAPARSINGFigure11Retrieve(16-bytes)ofsearchdata.
Setid_bit_numberto1.
Startdiscrepancy=1andROM_ID=0NoYesSetLastDescrepancytotheid_bit_numberIncrementid_bit_numberid_bit_number64NoYesSetLastFamily-Discrepancytoid_bit_numberRetrievethenewROM_IDbitLastDiscrepancyLastFamilyDiscrepancyequalYesNoResetSearchLastDiscrepancy=0LastFamilyDiscrepancy=0LastDeviceFlag=0CRCofROM_IDvalidYesNoSetLastFamily-Discrepancyto0Last-Discrepancy=0NoYesSetLastDeviceFlagtotrueParsecompletedeviceNOTfoundAN19218of26OWSpeedTotakeadvantageofhigherthroughputofoverdrive1-Wirespeed,thebaudrateoftheserialcommunicationbetweenthehostandtheDS2480Bisincreased.
Thisimplementationusesonlytwobaudrates:9600forstandardspeedand115200foroverdrivespeednon-searchoperations.
AsearchacceleratoroffoperationisdonetosettheDS2480Btothenew1-Wirespeed.
Thisisincludedsothatevenifthenext1-Wireoperationistocommunicatebytesindatamode,thecorrectspeedwillbeused.
Seethe1-WirespeedflowinFigure12.
OWLevelTheprimarypurposeoftheOWLeveloperationistodisablethepreviouslyenabledstrongpulluppowerdeliverythatwasinitiatedfromacalltoOWReadBitPowerorOWWriteBytePower.
Thesecondarypurposeistomanuallyturnonstrongpulluppowerdeliverywithoutthearmfeature,althoughthisisnotusedoften.
TheallowedcallstothisoperationareOWLevel(normal)andOWLevel(power).
NotethatacalltoOWLevel(normal)isassumedtobeatthebeginningofall1-Wireoperationstoensurethatthe1-Wirepullupisinthenormalstate.
Todisableanarmedandcurrentinfinitepulseitisnecessarytoterminatethepulse,startanewpulsewithoutarmenabledandthenterminatethatpulse.
TheOWLevel(power)operationbeginsanewnon-armedinfinitepulse.
SeeFigure13fortheflowofthesetwooperations.
OWProgramPulseTheOWProgramPulseoperationdeliversa12-Voltprogrammingpulsetothe1-Wire.
Thisoperationisusedtoprogram1-WireEPROM(One-Time-Programmable)memorydevices.
Itcheckstoseewhethertheprogrammingvoltageisavailablebasedontheinformationderivedfromthelast1-WireresetoperationOWReset.
SeeFigure14fortheflowofthisoperation.
AN19219of26OWSPEEDFLOWFigure12DS2480B_ChangeBaudto115200(ormax)AddSearchAcceleratorOffwithnewspeedtooutboundpacketNewSpeedisoverdriveYesNoDS2480B_ChangeBaudto9600OutboundPacket(toDS2480B)Commandmode(optional)SearchAcceleratoroffE3(hex)1010ss01(binary)ResponsePacket(fromDS2480B)(none)Writethepacket,noresponseReturnsuccessStartChangeinSpeedYesNoDoneDS2480BMode=commandYesNoAddcommandselecttooutboundpacket,E3hexFlushssSpeed01standard(flex)10overdriveAN19220of26OWLEVELFLOWFigure13ResponsevalidYesNoAddtooutboundpacket:Setpullupdurationtoinfinite(3Fhex)andStartpulse(EDhex)NewLevelisNormalNoYesAddtooutboundpacket:pulseterminationcommand,startnewpulsewithoutprimeandthenterminatepulseagainWritethepacketandreceivetheresponseReturnsuccessReturnfailuretochangelevelDS2480B_DetectStartDS2480BMode=commandYesNoAddcommandselecttooutboundpacket,E3hexFlushOutboundPacket(toDS2480B)Commandmode(optional)PulseTerminationE3(hex)F1Startpulse(pullup,noprime)PulseTerminationEDF1ResponsePacket(fromDS2480B)Pulseterminationresponse(xxundefined)Pulseterminationresponse(xxundefined)111011xx(binary)111011xx(binary)WritethepacketandreceivetheresponseFlushOutboundPacket(toDS2480B)Commandmode(optional)SetstrongpullupdurationtoinfiniteStartpulse(pullup)commandE3(hex)3FEDResponsePacket(fromDS2480B)Setpullupdurationresponsebyte3E(hex)AN19221of26OWPROGRAMPULSEFLOWFigure14ResponsevalidYesNoAddtooutboundpacket:Setprogrampulsedurationto512ms(29hex)andStartpulse(FDhex)FlushDS2480BMode=commandYesNoAddcommandselecttooutboundpacket,E3hexOutboundPacket(toDS2480B)Commandmode(optional)Setpulsedurationto512msStartpulse(program)commandE3(hex)29FDResponsePacket(fromDS2480B)SetprogrampulsedurationresponsebytePulseterminationresponse(xxundefined)28(hex)111011xx(binary)WritethepacketandreceivetheresponseReturnsuccessReturnprogrampulsefailureDS2480B_DetectStartProgramVoltageavailableYesNoReturnprogrampulsefailureAN19222of26OWReadBitPowerTheOWReadBitPoweroperationisusedexclusivelywiththeJava-powerediButton.
ThisiButtonhasareleasesequencethatmustapplypowerimmediatelyafteraconfirmationbit.
Iftheconfirmationbitisthewrongvaluethenthepoweristurnedbackoffandtheoperationfails.
IftheJava-powerediButtonisnotgoingtobeusedthenthisoperationneednotbeimplemented.
Toterminatethepowerdeliveryafterthisoperation,callOWLevel(normal).
SeeFigure15fortheflowofthisoperation.
OWREADBITPOWERFLOWFigure151-WirebitresultvaluecorrectYesNoAddtooutboundpacket:Setpullupdurationtoinfinite(3Fhex)and1-WirebitwithpulluparmedFlushDS2480BMode=commandYesNoAddcommandselecttooutboundpacket,E3hexOutboundPacket(toDS2480B)Commandmode(optional)Setstrongpullupdurationtoinfinite1-Wirebitcommand(withpulluparm)E3(hex)3F100dss11(binary)ResponsePacket(fromDS2480B)Setpullupdurationresponsebyte1-Wirebitresult3E(hex)100dssrr(binary)WritethepacketandreceivetheresponseReturnsuccessReturnbitpowerfailureOWLevel(normal)StartssSpeed01standard(flex)10overdrivedDatatosend0write0bit1write1orreadbitrrbitresult000readback111readbackResponsepacketvalidYesNoDS2480B_DetectiButtonisaregisteredtrademarkofDallasSemiconductor.
AN19223of26OWWriteBytePowerTheOWWriteBytePoweroperationappliesstrongpulluppowerdeliveryimmediatelyafterawrite1-Wirebyte.
Thisisthetypicalformofpowerdelivery.
Forexample,theDS1920temperatureiButtonhasasinglebyteconverttemperaturecommandthatrequirespowerafterthecommandiscomplete.
Toterminatethepowerdeliveryafterthisoperation,callOWLevel(normal).
SeeFigure16fortheflowofthisoperation.
Notethatthebytetowriteisconvertedtoeightsinglebitoperationswiththelastbitarmingthepowerdelivery.
ThiscouldhavebeenaccomplishedwithasinglebytesequencebutthiswasdonesothattheoperationisverysimilartotheOWReadBitPoweroperationandcouldpotentiallybecombined.
OWWRITEBYTEPOWERFLOWFigure16Addtooutboundpacket:Setpullupdurationtoinfinite(3Fhex)andeight1-WirebitcommandswiththelastarmingpullupFlushDS2480BMode=commandYesNoAddcommandselecttooutboundpacket,E3hexOutboundPacket(toDS2480B)Commandmode(optional)Setstrongpullupdurationtoinfinite1-Wirebitcommand(bit0ofbytetowrite)1-Wirebitcommand(bit7ofbytetowrite+pullup)E3(hex)3F100dss01(binary)100dss11(binary)ResponsePacket(fromDS2480B)Setpullupdurationresponsebyte1-Wirebitresult(bit0ofbyte)1-Wirebitresult(bit7ofbytetowrite)3E(hex)100dssrr(binary)100dssrr(binary)Writethepacketandreceivethe9-byteresponsepacketReturnsuccessReturnbytepowerfailureStartssSpeed01standard(flex)10overdrivedDatatosend0write0bit1write1orreadbitrrbitresult000readback111readbackResponsepacketvalidYesNoDS2480B_DetectAN19224of26EXAMPLESThissectionhasseveral1-Wirecommunicationexamplesusingthebasicandextended1-Wireoperations.
TheoverdrivematchsequenceasseeninExample2isusedtotakeanoverdrivecapable1-Wiredevicetooverdrivespeed.
AfterthissequencehasbeensuccessfullycompletedboththeDS2480Bandthe1-Wiredeviceareoperatingatoverdrivespeedandany1-WireoperationexceptOWSearchcanbeperformed.
OVERDRIVEMATCHPSEUDOCODEExample2trans_block–temporarytransmitbuffer,valuesexpressedinhexadecimalnotation//putat1-WirespeedtonormalOWSpeed(normal)//resetthe1-Wirebus(atnormalspeed)IfOWReset=TRUE//overdrivematchcommandOWWriteByte(69hex)//change1-WirespeedtooverdriveOWSpeed(overdrive)//sendthe1-WiredeviceROMnumbertocompleteMATCH,ROMisR0.
.
.
R7trans_block=R0,R1,R2,R3,R4,R5,R6,R7OWBlock(trans_block)//Success.
.
.
Else//nodevicepresent.
.
.
EndIfTheDS1920iButtonisatemperaturereadingsensorthatperformsatemperatureconversionwheninstructed.
Whileatemperatureconversionistakingplacethe1-Wiremastermustsupplystrongpulluppowerdelivery.
Example3showstheconverttemperaturesequenceusingtheextended1-Wirepowerdeliveryoperations.
DS1920TEMPERATURECONVERTPSEUDOCODEExample3trans_block–temporarytransmitbuffer,valuesexpressedinhexadecimalnotation//resetthe1-WirebusIfOWReset=TRUEIfOWReset=TRUE//senttheMATCHROMsequenceforthedevicetoread,ROMisR0.
.
.
R7trans_block=55,R0,R1,R2,R3,R4,R5,R6,R7OWBlock(trans_block)//convertcommandandapplypowerOWWriteBytePower(44hex)//delaytoallowconverttocompeteDelay(1000ms)//disablethepowerdeliveryOWLevel(normal)AN19225of26//verifyconvertcompletedIfOWReadByte==FFhex//Success.
.
.
Else//convertnotcomplete,fail.
.
.
EndIfElse//nodevicepresent.
.
.
EndIfOne-time-programmable(OTP)EPROM1-WirememorydevicesarewrittenonebyteatatimeusingthesequenceasseeninExample4.
TheDS2480Bmustbesuppliedwitha12Vsupplyforthisoperationtocomplete.
TheavailabilityofthesupplyissensedoneachcalledtoOWReset.
DS1986EPROMPROGRAMMINGPSEUDOCODEExample4trans_block–temporarytransmitbuffer,valuesexpressedinhexadecimalnotation//resetthe1-WirebusIfOWReset=TRUE//senttheMATCHROMsequenceforthedevicetowrite,ROMisR0.
.
.
R7//withwritememorycommand0F,andaddress0000,anddata66,andreadCRC16.
trans_block=55,R0,R1,R2,R3,R4,R5,R6,R7,0F,00,00,66,FF,FFOWBlock(trans_block)//computeCRC16overlast6bytesinblocktoverifydata/addresssetcorrectlyIfCRC16correct//sendtheprogrampulseIfNotOWProgramPulse//Programvoltagenotavailable.
.
.
EndIf//readbackthedataforverificationIfOWReadByte!
=66//Success.
.
.
Else//failedtoprogram,pagelocked,bytealreadyprogrammed.
.
.
EndIfElse//errorintransmittingaddressanddata.
.
.
EndIfElse//nodevicepresent.
.
.
EndIfAN19226of26Example5showsawritescratchpadsequencefortheDS1996.
Notethattheentireoperationexcepttheresetitlumpedtogetherinsingleblock.
Thisisdesirableforoptimaloperationwherethereisanoverheadforeachpacketsentandreceivedfromaserialport.
DS1996WRITESCRATCHPADPSEUDOCODEExample5trans_block–temporarytransmitbuffer,valuesexpressedinhexadecimalnotation//resetthe1-WirebusIfOWReset=TRUE//senttheMATCHROMsequenceforthedevicetowrite,ROMisR0.
.
.
R7,//thewritescratchpadcommand0F,targetaddress0000,//andthedata(all66h'sforthisexample)trans_block=55,R0,R1,R2,R3,R4,R5,R6,R7,0F,00,00,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66OWBlock(trans_block)Else//nodevicepresent.
.
.
EndIfCONCLUSIONTheDS2480Bhassuccessfullybeenutilizedinthefollowingserialto1-WirebridgeadaptersforPCsandworkstations:DS9097U-009,DS9097U-S09,DS9097U-E25,DS1411-000,andDS1411-S09.
ThedatasheetsfortheseadapterscanbefoundontheDallasSemiconductor/Maximwebsiteatthefollowinglink:http://www.
maxim-ic.
comTheDS2480BhasalsobeenusedinembeddedapplicationslikeTINI.
DetailsonTINIembeddedplatformcanbefoundatthefollowinglink:http://www.
maxim-ic.
com/products/ibutton/Thisdocumenthaspresentedacomplete1-WireinterfacesolutionusingtheDS2480BSerial1-WireLineDriver.
Theprovidedflowchartsareeasilyimplementedonanyhostsystemwithaminimalserialcommunicationsport.
Acomplete'C'implementationisalsoavailablefordownloadfromthefollowinglink:http://files.
maxim-ic.
com/sia_bu/public/an192.
zipRevisionHistory03/05/02Version1.
0—Initialrelease03/27/03Version1.
1—Corrections:SearchROMcommandscorrectedtoF0hex.
(Figure4)ChangedVPPdetectionbitinthe1-Wireresetresponsebytetoundefined,ignoreresponsewhenaDS1994/DS2404isbeingread,andcorrect1-Wireresetcommand.
CorrectFigure9.
TINIisaregisteredtrademarkofDallasSemiconductor.
热网互联怎么样?热网互联(hotiis)是随客云计算(Suike.Cloud)成立于2009年,增值电信业务经营许可证:B1-20203716)旗下平台。热网互联云主机是CN2高速回国线路,香港/日本/洛杉矶/韩国CN2高速线路云主机,最低33元/月;热网互联国内BGP高防服务器,香港服务器,日本服务器全线活动中,大量七五折来袭!点击进入:热网互联官方网站地址热网互联香港/日本/洛杉矶/韩国cn2...
目前,我们都在用哪个FTP软件?喜欢用的是WinSCP,是一款免费的FTP/SFTP软件。今天在帮助一个网友远程解决问题的时候看到他用的是FlashFXP FTP工具,这个工具以前我也用过,不过正版是需要付费的,但是网上有很多的绿色版本和破解版本。考虑到安全的问题,个人不建议选择破解版。但是这款软件还是比较好用的。今天主要是遇到他的虚拟主机无法通过FTP连接主机,这里我就帮忙看看到底是什么问题。一...
zji怎么样?zji最近新上韩国BGP+CN2线路服务器,国内三网访问速度优秀,适用8折优惠码zji,优惠后韩国服务器最低每月440元起。zji主机支持安装Linux或者Windows操作系统,会员中心集成电源管理功能,8折优惠码为终身折扣,续费同价,全场适用。ZJI是原Wordpress圈知名主机商:维翔主机,成立于2011年,2018年9月启用新域名ZJI,提供中国香港、台湾、日本、美国独立服...
response.flush为你推荐
FUSIONENTERTAINMENT.COM桥面163我的"点绛唇"支持ipadoutput_buffering飞飞的官方网站是啥css3圆角用CSS3怎么实现圆角边框?重庆宽带测速重庆云阳电信宽带测速网址谁知道,帮个忙?勒索病毒win7补丁由于电脑没连接网络,所以成功躲过了勒索病毒,但最近要联网,要提前装什么补丁吗?我电脑断网好久了用itunes备份如何使用itunes完整备份iPhone资料重庆电信宽带管家中国电信电脑管家是什么?怎么样?
新网域名 私人服务器 主机屋免费空间 商家促销 qingyun 七夕快乐英文 新家坡 shopex主机 空间首页登陆 便宜空间 smtp服务器地址 服务器论坛 镇江高防 攻击服务器 广东服务器托管 reboot dbank 西安电信测速网 qq空间技术网 服务器监测软件 更多