You are on page 1of 5

11/27/2015

HOME

BasicsofGPIOinLPC21xxARM7Tutorials|ELECTROONS.com

ARM7

WHATSNEW

AVR

8051

FREEPCB

PRAYOGWIKI

Enterkeyworks

SEARCH

August22,2014BreadboardPowerSuppliesReadbeforeyouBuyOne

HOME/ARMMICROCONTROLLER/ARM7/ELECTRONICS/GENERALKNOWHOW/INTERFACINGTUTORIAL/LPC21XX/NXP/PHYSICAL
COMPUTING/BASICSOFGPIOINLPC21XXARM7TUTORIALS

BasicsofGPIOinLPC21xxARM7Tutorials
January28,2013

Basic Registers
DownloadUserManualforLPC2148Chapter7,PAGE75

0
Share

PINSEL Registers
MostofthepinsonLPC2148aremultifunctional,everypincanbeusedtoperformoneoftheassignedfunctiontoitdependonthesettingof
PINSELregisterofthespecificporttowhichthatpinbelongs.

ForexampleintheLPC214Xpindiagramabove,pinnumber1islabeledasP0.21/PWM5/AD1.6/CAP1.3,itmeansthispincanfunctionin
4modes.Itcanbeeither
PORT0.21(GPIO)or
PWMOut5or
ADC1inputforchannel6thatisAD1.6or
CAP1.3TimerCapturePin
Outofthelisted4possiblefunctions,Pin1canfunctionasanyoneatonce.Currentfunctionofanypincanbe
configuredusingcorrespondingPINSELregisterinthiscasePINSEL0orPINSEL1(havetocheckindatasheet),for
everymultifunctionalpin,defaultfunctionalityisalwaysGPIOprovidedGPIOisoneofthefunctions.

forLPC2148thereare3PINSELregisters,PINSELx(x:0,1,2),refertodatasheetformoredetailschecktable60
onwards.

GPIO Registers

http://www.electroons.com/blog/2013/01/basicsofgpioinlpc21xxarm7tutorials/

1/5

11/27/2015

BasicsofGPIOinLPC21xxARM7Tutorials|ELECTROONS.com

Fast GPIO Registers

LikeusonFacebook!

Like

6k

ToenableFastInputOutput,SystemControlandStatusregister(SCS)shouldbegivenvalue3.
REFERtoUserManualformoredetailsonIODIR,IOSET,IOCLRcheckonPagenumber81onwards,itsChapter8

For writing C Code recipe


IO0DIR = 000000080 // Pin PORT0.7 configured as output
IO0SET = 000000080//Pin PORT0.7 goes HIGH
IO0CLR = 000000080//Pin PORT0.7 goes LOW
IO0SET = 000000080//Pin PORT0.7 goes HIGH
Difference between FAST & GP Input Output

http://www.electroons.com/blog/2013/01/basicsofgpioinlpc21xxarm7tutorials/

2/5

11/27/2015

BasicsofGPIOinLPC21xxARM7Tutorials|ELECTROONS.com

IhopeyoucanintuitivelydeducethedifferencebetweenFastGPIOandGenerelPurposeInputOutput.Fastinputoutputcontrollerblockis
connectedtotheARMlocalbuswhileGPIOblockisconnectedwithPeripheralBusofthecontrollersystem.

A note about usage of IOPIN register


WritetotheIOPINregisterenablesinstantaneousoutputofadesiredcontentontheparallelGPIO.BinarydatawrittenintotheIOPINregister
willaffectalloutputconfiguredpinsofthatparallelport:0sintheIOPINwillproducelowlevelpinoutputsand1sinIOPINwillproducehigh
levelpinoutputs.InordertochangeoutputofonlyagroupofPORTApins,applicationmustlogicallyANDreadoutfromtheIOPINwithmask
containing0sinbitscorrespondingtopinsthatwillbechanged,and1sforallothers.Finally,thisresulthastobelogicallyORredwiththe
desiredcontentandstoredbackintotheIOPINregister.
ForExample

IO0PIN=(IO0PIN&&0xFFFF00FF)|0x0000A500

PreviousArticle

HelloWorldLPC21xx/32bit
ProgrammingARM7

NextArticle

ADCInterfacingTutorialforLPC21xx
ARM7

ABOUTAUTHOR
IndianYouthful

LEAVEAREPLY
Youremailaddresswillnotbepublished.Requiredfieldsaremarked*

Name(required):

http://www.electroons.com/blog/2013/01/basicsofgpioinlpc21xxarm7tutorials/

3/5

11/27/2015

BasicsofGPIOinLPC21xxARM7Tutorials|ELECTROONS.com

Email(required):

Website

Yourcomment(required):

PostComment
Proveyouarehumanbyreadingthisresistor:

Matchtheslidersonthelefttoeachcolorbandontheresistor.

0+/5%

ClickHereforanewresistorimage.

Ifyou'dliketolearnmore,readaboutresistorcolorcodeshere.

10

20

http://www.electroons.com/blog/2013/01/basicsofgpioinlpc21xxarm7tutorials/

4/5

11/27/2015

BasicsofGPIOinLPC21xxARM7Tutorials|ELECTROONS.com

electroons.com
6,071likes

LikePage

Share

Bethefirstofyourfriendstolikethis

HOME

ARM7

AVR

8051

FREEPCB

PRAYOGWIKI

ContentatthissiteislicensedunderCCAttributionNoncommercialShareAlike3.0Unported

0
Share

http://www.electroons.com/blog/2013/01/basicsofgpioinlpc21xxarm7tutorials/

5/5

You might also like