TRUEresponse.flush

response.flush  时间:2021-05-18  阅读:()
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.

BlueHost主机商年中618活动全场低至五折

BlueHost 主机商在以前做外贸网站的时候还是经常会用到的,想必那时候有做外贸网站或者是选择海外主机的时候还是较多会用BlueHost主机商的。只不过这些年云服务器流行且性价比较高,于是大家可选择商家变多,但是BlueHost在外贸主机用户群中可选的还是比较多的。这次年中618活动大促来袭,毕竟BLUEHOST商家目前中文公司设立在上海,等后面有机会也过去看看。他们也会根据我们的国内年中促销发...

享有云:美国BGP云服务器低至20元/月起,首月打折;香港2核2G2M仅50元/月起

享有云怎么样?享有云是一家新的国内云服务器商家,目前提供国内、香港及海外地区的云服务器,拥有多线路如:BGP线路、CN2线路、高防等云服务器,并且提供稳定、安全、弹性、高性能的云端计算服务,实时满足您的多样性业务需求。目前,美国bgp云服务器,5M带宽,低至20元/月起,270元/年起,首月打折;香港2核2G2M仅50元/月起,450元/年起!点击进入:享有云官方网站地址享有云优惠活动:一、美国B...

白丝云-美国圣何塞4837/德国4837大带宽/美西9929,26元/月起

官方网站:点击访问白丝云官网活动方案:一、KVM虚拟化套餐A1核心 512MB内存 10G SSD硬盘 800G流量 2560Mbps带宽159.99一年 26一月套餐B1核心 512MB内存 10G SSD硬盘 2000G流量 2560Mbps带宽299.99一年 52一月套餐...

response.flush为你推荐
Intentsandroid支持ipad支持ipadiexplore.exe应用程序错误iexplore.exe应用程序错误x-routerx-arcsinx的等价无穷小是什么?ms17-010win10蒙林北冬虫夏草酒·10年原浆1*6 500ml 176,176是一瓶的价格还是一箱的价格联通iphone4联通iphone4怎么样,好不好用?迅雷快鸟用迅雷快鸟提示:您所在的网络暂不支持迅雷快鸟电信版iphone4s电信版iphone4s是买16gb的好还是32gb的好?杀毒软件免费下载2013排行榜用什么免费杀毒软件最好
美国主机空间 解析域名 视频空间租用 域名备案中心 互联网域名管理办法 bluevm linode uk2 idc评测网 12306抢票攻略 patcha debian源 华为4核 域名和空间 isp服务商 福建铁通 空间技术网 512mb 河南移动梦网 浙江服务器 更多