Sei sulla pagina 1di 3

7/7/2017 electroons.

comARM7TutorialsBasicRegistersPINSEL,IOSET,IODIR,IOPIN,IOCLR

ARM7 @ electroons.com
HOME8051AVRARMBUYCDsQUERIESC2051

Basic Registers
DownloadUserManualforLPC2148Chapter7,PAGE75

PINSEL Registers
MostofthepinsonLPC2148aremultifunctional,everypincanbeusedtoperformoneoftheassigned
functiontoitdependonthesettingofPINSELregisterofthespecificporttowhichthatpinbelongs.

ForexampleintheLPC214Xpindiagramabove,pinnumber1islabeledas"P0.21/PWM5/AD1.6/CAP1.3",itmeans
thispincanfunctionin4modes.Itcanbeeither...
PORT0.21(GPIO)or
PWMOut5or
ADC1inputforchannel6thatisAD1.6or
CAP1.3TimerCapturepin
Outofthelisted4possiblefunctionalityPin1canfunctionasanyoneatonce.Currentfunctionofanypin
canbeconfiguredusingcorrespondingPINSELregisterinthiscasePINSEL0orPINSEL1(havetocheckin
datasheet),foreverymultifunctionalpindefaultfunctionalityisalwaysGPIOprovidedGPIOisoneofthe
functions.
forLPC2148thereare3PINSELregisters,PINSELx(x:0,1,2),refertodatasheetformoredetailscheck
table60onwards.

GPIO Registers

http://www.electroons.com/ARM/basic_registers.html 1/3
7/7/2017 electroons.comARM7TutorialsBasicRegistersPINSEL,IOSET,IODIR,IOPIN,IOCLR

Fast GPIO Registers

ToenableFastInputOutput,SystemControlandStatusregister(SCS)shouldbegivenvalue3.

REFERtoUserManualformoredetailsonIODIR,IOSET,IOCLRcheckonPagenumber81onwards,itsChapter8

For writing C Code recipe...

http://www.electroons.com/ARM/basic_registers.html 2/3
7/7/2017 electroons.comARM7TutorialsBasicRegistersPINSEL,IOSET,IODIR,IOPIN,IOCLR

IO0DIR = 0x00000080 // Pin PORT0.7 configured as output

IO0SET = 0x00000080//Pin PORT0.7 goes HIGH

IO0CLR = 0x00000080//Pin PORT0.7 goes LOW

IO0SET = 0x00000080//Pin PORT0.7 goes HIGH

Difference between FAST & GP Input Output

IhopeyoucanintuitivelydeducethedifferencebetweenFastGPIOandGenerelPurposeInputOutput.Fast
inputoutputcontrollerblockisconnectedtotheARMlocalbuswhileGPIOblockisconnectedwithPeripheral
Busofthecontrollersystem.

A note about usage of IOPIN register...


WritetotheIOPINregisterenablesinstantaneousoutputofadesiredcontentontheparallelGPIO.Binary
datawrittenintotheIOPINregisterwillaffectalloutputconfiguredpinsofthatparallelport:0sinthe
IOPINwillproducelowlevelpinoutputsand1sinIOPINwillproducehighlevelpinoutputs.Inorderto
changeoutputofonlyagroupofportspins,applicationmustlogicallyANDreadoutfromtheIOPIN
withmaskcontaining0sinbitscorrespondingtopinsthatwillbechanged,and1sforallothers.Finally,
thisresulthastobelogicallyORredwiththedesiredcontentandstoredbackintotheIOPINregister.
ForExample
IO0PIN=(IO0PIN&&0xFFFF00FF)|0x0000A500

askaQuestion

NOcopyrights!Share,Copy,Modifyasmuchasyoucan.DigiTallyYourshttp://www.electroons.com

http://www.electroons.com/ARM/basic_registers.html 3/3

Potrebbero piacerti anche