Thisapplicationnotedescribeshowtousea
PIC16F877AasanI
2
C™mastertocommunicatewith
theMicrochipMCP23016I
2
CI/OExpanderslave
device.
AnI/OExpanderdeviceisusedtoincreasetheI/O
capabilityofamicrocontroller(refertoFigure1).A
microcontroller’sI
2
Cportcanbeusedasacommuni-
cationchannelwithMCP23016(s)toexpandthemicro-
controller’sI/Ocount.ByusingtwoI
2
Cpins(andone
general-purposeI/Opin,ifusingtheinterruptcapability
oftheMCP23016),16to128general-purposeI/Oscan
begained.TheMCP23016hasthreeaddresspins
whichcanbeusedtoprovideuniqueaddressesforup
toeightdevices.
EachdeviceattachedtotheI
2
Cbusmustbeassigned
auniqueaddressunlessalldevices(withthesame
address)arereceivingthesamedataanddonottrans-
mitanydata.Whenthemasterinitiatesadatatransfer,
theaddressoftheslavedeviceistransmitted.Within
theaddress,theLSb(R/Wbit)specifieswhetherthe
masterreadsfrom,orwritesto,theslave.Forwrite
operations,aseriesofbyteswouldbetransmittedfrom
themaster.Forreadoperations,themasterwaitsfor
thebustobefree(i.e.,SCLlinenotpulledlow)and
thenclocksthedatatobereceivedfromtheslave.MAN245InterfacingTheMCP23016I/OExpanderWithThePIC16F877AWhatcanyoudowithanI/OExpander?Author:AbdelwahabFassi-FihriMicrochipTechnologyInc.AnI/OExpandercanalsobeusedtomonitorswitchesand/orsensors,driveLEDsand/orrelays,aswellasothergeneral-purposeI/Ofunctions.AnI/OExpanderINTRODUCTIONcanhaveseveralusesinavarietyofapplications.Typ-This
暂无评论