# Configuring Registers in ARM Cortex M3

I've been learning to program LPC2148(ARM7) microcontroller, and today I got hold of an LPC1768(Cortex M3) board. By referring it's manual, I tried to make a LED blink program and did it as follows, following the same methods as LPC2148(configuring pin connection block and GPIO registers)

#include <LPC17xx.H>
int main()
{
int i;
PINSEL0 = 0;
FIO0DIR = 0XFFFFFFFF;

while(1)
{
FIO0SET = 0XFFFFFFFF;
for(i=0; i<100000; i++);
FIO0CLR = 0XFFFFFFFF;
for(i=0; i<100000; i++);
}
}


But got error as PINSEL, FI0SET ... as undefined.

after referring some example codes, I have to use

LPC_PINCON->PINSEL0 = 0X00000000;
LPC_GPIO0->FIODIR


Where does this LPC_GPIO & LPC_PINCON come from? As per one online tutorial

As per the CMSIS convention, the registers that we saw are grouped into structures. LPC_GPIOx is defined as a pointer to this structure in LPC17xx.h header. These registers are defined as members of this structure. Hence to use any register, for e.g. FIODIR, we must use the arrow “->” operator to de-reference members of structure (since the structure itself is a pointer) to access the register as follows : LPC_GPIO0->FIODIR = some value.

I couldn't find any reference to this in manual.

Is there any documentation available?

• I must assume there is an 'include' somewhere otherwise neither of the codes should work. Mar 7, 2018 at 16:54
• #include <LPC17xx.H>, edited Mar 7, 2018 at 17:01
• There are two distinct things here: the peripherals of the chip, and the base software sources which do things like define registers. Using the latter is optional - if you are going to use it, you need to find the manual for the software (or read the header files and examples), as well as the manual for the chip. Mar 7, 2018 at 17:08
• I found the GitHub link if anyone was interested in looking at the LPC17xx.h library. Please tell me if this is the correct author of the library.
– user103380
Mar 7, 2018 at 17:21
• link found this in keil site. At the end, it provides peripheral declarations. Mar 7, 2018 at 17:23