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;

     for(i=0; i<100000; i++);
     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;

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?

  • 1
    \$\begingroup\$ I must assume there is an 'include' somewhere otherwise neither of the codes should work. \$\endgroup\$
    – Oldfart
    Mar 7, 2018 at 16:54
  • \$\begingroup\$ #include <LPC17xx.H>, edited \$\endgroup\$
    – Athul
    Mar 7, 2018 at 17:01
  • \$\begingroup\$ 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. \$\endgroup\$ Mar 7, 2018 at 17:08
  • \$\begingroup\$ 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. \$\endgroup\$
    – user103380
    Mar 7, 2018 at 17:21
  • \$\begingroup\$ link found this in keil site. At the end, it provides peripheral declarations. \$\endgroup\$
    – Athul
    Mar 7, 2018 at 17:23

2 Answers 2


My experience is that a lot of manufacturers have bad or no manuals for their include files. They often have a plethora of example programs which use those structures.

Modern GUI's have support to pop-up a list of all the substructures. Below an example screenshot.

enter image description here

But that does not help unless you know the 'magic start runes' (PIOA in this case). Even then you might not know what "PIO_ABCDSR" does. (See my remark about data sheets further) Lately I have been looking more and more at the includes files. In the beginning it is a bit of work to locate the appropriate files but I found that in the end it is faster then looking on the internet, the example programs or the manuals.

I do have the datasheet next to my keyboard as the register and field names in there often (but not always!) correspond with the names used in the header files.


The relevant documentation for this convention is the Arm CMSIS-Core documentation, Specifically Peripheral Access, you might also want to refer to Device Header File. I feel these are a bit more aimed at device vendors than end users though.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.