ST2205U
7. GPIO
TheꢀST2205Uꢀconsistsꢀofꢀ48ꢀgeneralꢁpurposeꢀI/Oꢀ(GPIO)ꢀwhichꢀ
areꢀdividedꢀintoꢀsixꢀI/Oꢀports:ꢀPortꢁA/B/C/D/EꢀandꢀPortꢁL.ꢀ ꢀ
ꢀ
Eachꢀsingleꢀpinꢀcanꢀbeꢀprogrammedꢀtoꢀbeꢀinputꢀorꢀoutput.ꢀThisꢀ
isꢀcontrolledꢀbyꢀportꢀdirectionꢀcontrolꢀregistersꢀPCx.ꢀSettingꢀbitꢀ
ofꢀPCxꢀmakesꢀrespectiveꢀpinꢀtoꢀoutput,ꢀandꢀclearingꢀthisꢀbitꢀforꢀ
input.ꢀThereꢀareꢀtwoꢀoptions:ꢀpullꢁup/downꢀforꢀinputsꢀofꢀPortꢁCꢀ
butꢀonlyꢀpullꢁupꢀforꢀinputsꢀofꢀtheꢀotherꢀports.ꢀInꢀcaseꢀofꢀoutput,ꢀ
thereꢀareꢀopenꢁdrain/CMOSꢀoptionsꢀforꢀoutputsꢀofꢀPortCꢀbutꢀ
ꢀ
onlyꢀCMOSꢀforꢀtheꢀotherꢀports.ꢀReferꢀtoꢀTABLEꢀ7ꢁ1.ꢀ
ꢀ
TABLE 7-1 I/O Types Of GPIO Ports
I/O Types
I/O Mode
Port-A/B/D/E/L
Pullꢁup/Pureꢀ
CMOSꢀ
Port-C
Pullꢁup/Pullꢁdown/Pureꢀ
Openꢁdrain/CMOSꢀ
Input
Output
ꢀ
ꢀ
ꢀ
Input Mode
ꢀ
Output Mode
Inꢀcaseꢀofꢀinputꢀfunction,ꢀportꢀdataꢀregistersꢀPxꢀreflectꢀtheꢀ
valuesꢀonꢀassociatedꢀpins.ꢀBesidesꢀreadꢀinstructionꢀforꢀdataꢀofꢀ
signalsꢀinput,ꢀwritingꢀtoꢀregisterꢀPxꢀselectsꢀI/Oꢀtypesꢀofꢀpins,ꢀ
pullꢁupꢀorꢀpullꢁdown.ꢀSettingꢀbitsꢀofꢀallꢀportꢀdataꢀregisterꢀPxꢀtoꢀ
selectꢀpullꢁupꢀtype.ꢀClearingꢀbitsꢀofꢀonlyꢀPCꢀtoꢀselectꢀpullꢁdownꢀ
typeꢀforꢀpinsꢀofꢀPortꢁC.ꢀThereꢀareꢀnoꢀpullꢁdownꢀresistorsꢀforꢀ
PortꢁA/B/D/EꢀandꢀPortꢁL,ꢀtherebyꢀnoꢀpullꢁdownꢀresistorsꢀwillꢀbeꢀ
enabledꢀifꢀclearingꢀbitsꢀofꢀPA,ꢀPB,ꢀPD,ꢀPEꢀandꢀPL.ꢀPullꢁupꢀ
resistorsꢀofꢀPortꢁA/B/D/E/LꢀareꢀalsoꢀcontrolledꢀbyꢀPULLꢀbitꢀ(bit7ꢀ
ofꢀportꢀmiscellaneousꢀregisterꢀPMCR),ꢀ“0”ꢀisꢀtoꢀdisable,ꢀwhileꢀ
“1”ꢀisꢀtoꢀenableꢀthem.ꢀTheꢀpullꢁup/pullꢁdownꢀresistorsꢀofꢀPortꢁCꢀ
areꢀfurtherꢀcontrolledꢀbyꢀbitsꢀofꢀportꢀtypeꢀselectꢀregistersꢀPSC.ꢀ
TheyꢀworkꢀinꢀtheꢀsameꢀwayꢀwithꢀPULLꢀbitꢀofꢀPMCRꢀbutꢀonlyꢀonꢀ
singleꢀpin,ꢀ“0”ꢀisꢀtoꢀdisable,ꢀwhileꢀ“1”ꢀisꢀtoꢀenable.ꢀ
Inꢀcaseꢀofꢀoutputꢀfunction,ꢀWriteꢀtoꢀportꢀdataꢀregistersꢀPxꢀ
makesꢀpinsꢀtoꢀoutputꢀdesiredꢀvalue.ꢀThisꢀvalueꢀcanꢀalsoꢀbeꢀ
readꢀbackꢀbyꢀreadꢀinstruction.ꢀBesidesꢀPortꢁC,ꢀtheꢀoutputꢀpinsꢀ
areꢀCMOSꢀtype.ꢀPortꢁCꢀhaveꢀtwoꢀoptionsꢀofꢀoutputꢀtypes:ꢀ
openꢁdrainꢀandꢀCMOS,ꢀandꢀisꢀcontrolledꢀbyꢀportꢀtypeꢀselectꢀ
registersꢀPSC.ꢀClearingꢀbitsꢀofꢀregistersꢀPSCꢀisꢀforꢀthatꢀdisableꢀ
PMOSꢀofꢀoutputꢀstageꢀandꢀleftꢀonlyꢀNMOS,ꢀwhileꢀsettingꢀbitsꢀisꢀ
forꢀCMOS.ꢀ
ꢀ
PortꢁAꢀisꢀdesignedꢀforꢀkeyboardꢀscanꢀwithꢀdeꢁbounceꢀandꢀ
transitionꢀtriggeredꢀinterrupt,ꢀwhileꢀPortꢁC/D/Eꢀareꢀmultiplexedꢀ
withꢀotherꢀsystemꢀfunctions,ꢀandꢀareꢀcontrolledꢀbyꢀPFC,ꢀPFD,ꢀ
andꢀPMCR[2:0].ꢀPortꢁLꢀisꢀsharedꢀwithꢀLCDꢀspecificꢀsignalsꢀofꢀ
LCDC.ꢀTurningꢀoffꢀLCDCꢀbyꢀsettingꢀLPWRꢀ(LCTR[7])ꢀreservesꢀ
PortꢁLꢀforꢀGPIO.ꢀ
ꢀ
ꢀ
VCC
SelectingꢀrespectiveꢀpinsꢀtoꢀbeꢀGPIOꢀorꢀsignalsꢀofꢀsystemꢀ
functionꢀwillꢀnotꢀaffectꢀoriginalꢀsettingsꢀofꢀI/Oꢀdirectionsꢀandꢀ
types.ꢀThisꢀentendsꢀtheꢀflexibilityꢀofꢀtheꢀusageꢀofꢀfunctionꢀ
signals.ꢀ
PULLꢁUP
PMOS
PULLꢁUP
PORT
CONTROL
REGISTER
(ꢀPCRꢀ)
ꢀ
PORT
DATA
REGISTER
(ꢀPDRꢀ)
Note:ꢀAllꢀtheꢀpropertiesꢀofꢀpinsꢀareꢀstillꢀprogrammableꢀ
andꢀmustꢀbeꢀascertainedꢀbeforeꢀtheyꢀareꢀ
assignedꢀtoꢀsystemꢀfunctions,ꢀespeciallyꢀtheꢀ
directionꢀofꢀpins.ꢀ
DATAꢀINPUT
ꢀ
RD_INPUT
ꢀ
FIGURE 7-1 Configuration Of Port-A/B/D/E/L
ꢀ
ꢀ
FIGURE 7-2 Configuration Of Port-C
ꢀ
Versionꢀ1.0ꢀ
9/32ꢀ
ꢀ ꢀ 6/13/2007ꢀ