Atfirstglance,Microchip’ssimplifiedschematicoftheI/Opinsmayseemconfusing.Chapter3ofthe
16F87xReference,forexample,requirestenfigurestoillustratetheinternalsofI/Opinconstruction.Atthe
beginningandintermediatestagesofprogrammingwithMBasicandconcentratingonlyontheoutputmode,
though,wecansimplifythingsfurther,reducingtheessentialstothoseofFigure3-2.Inthe16F87xseries,
andinothermid-rangePICs,wheninoutputmode,pinsareconnectedtoaclassicalcomplementarymetal
oxidesemiconductor(CMOS)configuration.Insomecases,suchasforRA0…RA3,Microchip’sdocuments
showtheCMOStransistorsdirectly;inothers,suchasRB0…RB3,theyarenotshownbutareimbeddedin
alogicgatesymbol.
Formanypurposes,wecanregardthePMOSandNMOStransistorsofFigure3-2assimplyswitched
resistors;theyareeitherveryhighresistances,amountingtoalmostopencircuits,oralowvalueresistor,as
illustratedinFigure3-3.Whentheoutputislow,thepinappearstobealowvalueresistor,approximately25
ohms.Whentheoutputishigh,thepinappearstobetheVDDsourceconnectedthroughresistorofabout85
ohms,aslongasthesourcedcurrentdoesn’texceed15mAorso.
V
R Current I
Figure3-1:Conventional
CurrentFlow
WhenusingBasicMicro’sdevelopmentorprototypeboards,the74HC4053
multiplexerneededtopermitin-circuitprogrammingaddsapproximately
50–100ohmsseriesresistancetopinsRB4,RB6andRB7.Inmanycases
thisadditionalresistancecanbeignored.
Onepin,RA4,isdifferent;itisconfiguredasanopendrainMOSFET.
Whensettolow,itperformsidenticallywiththeotherpinarchitectures.
However,whensettohigh,thereisnointernalconnectionwithVDDand
henceitwillnotdirectlysourcevoltage.Ifit’snecessarytouseRA4asa
sourcingoutputpin,youcanaddanexternal“pull-up”resistor,typicallyin
therangeof470ohms–4.7Kohms.Thesourcedcurrentthencomesfrom
thepull-upresistor.UnlikeallotherpinsthatcannotexceedVDD,RA4’s
opendrainisratedto12volts.
Wheneithersourcingorsinkingcurrent,thesafeoperatinglimitsofthePIC
mustbeobserved.Thefollowingmaximumsafeparametersapplytothe
16F87xseries,andtheElectricalCharacteristicssectionofMicrochip’sdata
sheetforyourtargetPICshouldbeconsulted.Exceedingtheselimitsmay
causedamagetothedevice,orreduceitsreliability.
AbsoluteMaximumRatingsfor16F87XPICs
Symbol Characteristic MaximumValue Units Conditions
VOD Opendrainhighvoltage 14 V AppliestopinRA4only
Voltageonanypinwithrespect
toVss
-0.3Vto
VDD+0.3V
V TotalchipsupplycurrentintoVDD
supplypin
250 mA
TotalchipcurrentoutofVSSpin 300 mA IOK Outputclampcurrent(Vf<0or
Vf>VDD) ±
20 mA
Maximumoutputcurrentsunkby
anyI/Opin
25 mA
PMOS
NMOS NMOS
External Pull Up
I/O_Pin Vdd
I/O_Pin Vdd
PIC Internal Driver Circuitry
Simplified PIC Output
PIC Internal Driver Circuitry
Simplified PIC Output Pin RA4-T0CKI Pin Only
External Pull-up Resistor Required if Logic High to be Outputted
Figure3-2:Simplified
outputpin.
85
25 Vdd
PIN
Simple Model of PIC's I/O Pins When Set to Output
When Pin=High When Pin=Low
Figure3-3:Formanyanalyses,
theoutputpinsappeartobe
simpleresistors.
AbsoluteMaximumRatingsfor16F87XPICs
Symbol Characteristic MaximumValue Units Conditions
Maximumoutputcurrentsourced
byanyI/Opin
25 mA
MaximumcurrentsunkbyPortA,
PortBandPortE,combined
200 mA PortDandPortEarenot
implementedon16F873/876
devices Maximumcurrentsourcedby
PortA,PortBandPortE,combined
200 mA PortDandPortEarenot
implementedon16F873/876
devices MaximumcurrentsunkbyPortC
andPortD,combined
200 mA PortDandPortEarenot
implementedon16F873/876
devices MaximumcurrentsourcedbyPortC
andPortD,combined
200 mA PortDandPortEarenot
implementedon16F873/876
devices
Beforestartingourcircuitdiscussion,let’sreviewthesemaximumratings.
Opendrainhighvoltage—RA4isuniqueandomitstheinternalPMOStransistorconnectiontoVDD.VODis
maximumsafevoltagethatmaybeappliedtoRA4.
VoltageonanypinwithrespecttoVss—Inthenormalcircuit,VSSwillbeatgroundpotential.Yourcircuit
shouldbedesignedsothatwheninoutputmode,pinswillnotbetakenmorethan0.3Vnegativewith
respecttogroundnormorethan0.3VabovethePIC’spositivesupplyvoltage,VDD.Shouldthesevoltages
besignificantlyexceeded,theprotectivediodesshowninFigure3-2willstarttoconduct,potentiallycaus-ingthepinorchipmaximumcurrentlimittobeexceeded,unlessotherwisecurrentlimited.
TotalchipsupplycurrentintoVDDsupplypin—Inadditiontosourcingcurrentlimitsonindividualpins,this
parameterestablishesaglobalmaximumavailablecurrentfortheentirePIC.Itis,withnegligibleerror,
thesumofallpinsourcingcurrents.
TotalchipcurrentoutofVSSpin—Inadditiontosinkingcurrentlimitsonindividualpins,thisparameter
establishesaglobalmaximumfortheentirePIC.Itis,withnegligibleerror,thesumofallpinsinking
currents.
Outputclampcurrent(Vf<0orVf>VDD)—IfapinistakenaboveVDDorbelowground,itmustbecurrent
limited,commonlywithaseriesresistor,sothattheoutputclampcurrentisnotexceeded.
MaximumoutputcurrentsunkbyanyI/Opin—Themaximumsafesinkingcurrentwhenapinislow.
Sinkingcurrentisnotinternallylimitedandisgovernedbytheexternalcircuitparameters.
MaximumoutputcurrentsourcedbyanyI/Opin—Themaximumcurrentthatmaybesafelysourcedbya
highpin.Internalcircuitrylimitssourcingcurrenttoapproximately25-30mAsoitissafe,butnotgood
designpractice,tooperateanoutputpinintoashortcircuit.
MaximumcurrentsunkbyPortA,PortBandPortE,combined—Anothercompositelimit,applyingtosink-ingcurrentbyallPortsA,BandEpinscombined.
MaximumcurrentsourcedbyPortA,PortBandPortE,combined—Anothercompositelimit,applyingto
sourcingcurrentbyallPortsA,BandEpinscombined.
MaximumcurrentsunkbyPortCandPortD,combined—Anothercompositelimit,applyingtosinking
currentbyallPortsCandDpinscombined.
MaximumcurrentsourcedbyPortCandPortD,combined—Anothercompositelimit,applyingtosourc-ingcurrentbyallPortsCandDpinscombined.
Ahighoutputwillsourcebetween25and30mAintoashortcircuitindefinitely,butwhensinkingcur-rent,themaximumsafecurrentratingmustbeobserved.Figures3-4and3-5illustratethetypicalvoltage
0 5 10 15 20 25 30 0
200 400 600 800 1000
Typical E vs. I PIC Sinking Current
Voltage Developed on Pin (mV)
Current into PIC Pin (mA)
0 5 10 15 20 25 30
5 Typical E vs. I PIC Sourcing Current
Voltage Available at PIC Pin (V)
Current out of PIC pin (mA)
Figures3-4:TypicalEvs.Iforsinkingcurrent. Figures3-5:TypicalEvs.Iforsourcingcurrent.
versuscurrentrelationshipfor
bothsourcingandsinkingcurrent.
Alsorememberthatwhenusing
BasicMicro’s2840Development
Board,pinsRB4,RB6andRB7are
switchedthroughthe74HC4053
multiplexerwhichhasa25mA
maximumcurrentlimit.
Onefinalbitofterminologyand
we’llbeontocircuitry.Figure3-6
showsthreepossibleswitchingcon-figurations.Forclarity,thedrawing
showsamechanicalswitch.We,of
course,willuseavarietyofelectronicsubstitutes.
Lowsideswitching—Theswitchisbetweentheloadandground.Whenclosed,bothsidesoftheswitchare
atgroundpotential.
Highsideswitching—Theswitchisbetweenthevoltagebeingswitchedandtheload.Whenclosed,both
sidesoftheswitchareattheswitchingvoltage.
Isolatedswitching—Thereisnocommonconnectionbetweenthecircuitbeingswitchedandthecontrolling
PIC.Manydevicessuitableforisolatedswitchingalso
workforlowsideorhighsideswitching.