IIC总线主控的软件实现
Thisapplicationnotedescribesthesoftware
implementationofI
2
Cinterfaceroutinesforthe
PIC16CXXXfamilyofdevices.Onlythemastermodeof
I
2
Cinterfaceisimplementedinthisapplicationnote.
Thisimplementationisforasinglemastercommunica-
tiontomultipleslaveI
2
Cdevices.
SomePIC16CXXXdevices,suchasthePIC16C64and
PIC16C74,haveon-chiphardwarewhichimplements
theI
2
Cslaveinterface,whileotherPIC16CXXX
devices,suchasthePIC16C71andPIC16C84,donot
havethesameon-chiphardware.
ThisapplicationnotedoesnotdescribetheI
2
CBus
specificationsandtheuserisassumedtohavean
understandingoftheI
2
CBus.Fordetailedinformation
onthebus,theuserisadvisedtoreadtheI
2
CBus
SpecificationdocumentfromPhilips/Signetics(order
number98-8080-575).TheI
2
CBusisatwo-wireserial
buswithmultiplepossiblemastersandmultiplepossi-
bleslavesconnectedtoeachotherthroughtwowires.
Thetwowiresconsistsofaclockline(SCL)andadata
line(SDA)withbothlinesbeingbi-directional.Bi-direc-
tionalcommunicationisfacilitatedthroughtheuseof
wireandconnection(thelinesareeitheractive-lowor
passivehigh).TheI
2
CBusprotocolalsoallowscollision
detection,clocksynchronizationandhand-shakingfor
multi-mastersystems.Theclockisalwaysgeneratedby
themaster,buttheslavemayholditlowtogeneratea
waitstate.MSoftwareImplementationofI2CBusMasterAN554InmostsystemsthemicrocontrolleristhemasterandAuthor:AmarPalacherlatheexternalperipheraldevicesareslaves.IntheseMicrochipTechnologyInc.casesthisapplicationnotecanbeusedtoattachI2CslavestothePIC16CXXX(themaster)microcontroller.INTRODUCTIONThemulti-mastersystemisnotimplementedbecauseit