Basics of ARM7 Microcontroller(LPC2124) Programming

ARM7 Microcontroller

ARM ( Advanced Risc Machine ) a Microcontroller which took us to the next step in to the world of Automation. There are plenty of devices and gadgets running with the help of these Controllers. In fact 90% of smartphones, Cameras, Cars, Laptops etc uses ARM controllers. Its fair to say that the usage of these Controllers crosses the horizon since it was used in space too. Let’s step in to the basics of ARM7 microcontroller.

What makes this controller so special? how it fits in all kind of applications? To answer this, we can point out its Robust Architecture and high computing power. Aside from that here are some features which makes it really unique.

  • 16/32 bit ARM7TDMI Architecture 
  • Memory Accelerator Module to increase CPU performance
  • Programmable PLL.
  • Peripherals such as UART, Timer, ADC, PWM, RTC,PWM, Capture, Compare and much more.
  • Protocols I2C, SPI, CAN and USB.
  • Dual Power supply 1.65 to 1.95 for CPU and 3.0 to 3.6V for I/O.

I definitely need 10 or more articles to discuss about the highlights of ARM 7 Microcontrollers. So i suggest you to download the Manual provided in the below link as it does a better job in describing the features than i do.


So Let me come straight to the point, How to program a ARM Microcontroller? Programming ARM Microcontroller will be a piece of cake if you are familiar with AVR Programming if you are not then getting a clear idea about Bit masking and Bit wise operation, it will give you a edge in learning programming this Controller.

This tutorial deals with the ARM7 Microcontroller LPC2124 ( 64 Pin package)by Philips.  It consists of totally two 32 bit Birdirectional I/O ports Port 0 and Port 1. Each Pins in the port Carries four functions which is separated by slashes ‘/’ in the below pin diagram. The pins 2 to 15 in the Port 1 is not available for the user.


Pin Diagram of LPC 2124

When coming to ARM7 Programming there are 5 things you need to be get familiarize with. They are



A 32 bit register which is used to select the function of the pins in which the user needs it to operate. As i said there are four functions for each pins of the controller, in which the first function one was GPIO ( General Purpose Input Output ). It means that the pin can either act as a Input or Output with no specific functions. 

There are totally three PINSEL register in LPC2124 Controller in order to control the functions of the Pins in the respective ports. The classification is given below

PINSEL0 – Controls functions of Port0.0 – Port0.15

PINSEL1 – Controls functions of Port0.16-Port0.31

PINSEL2 – Controls functions of Port1.16-Port1.31

Now you know that these registers are used to assign functions for all the Pins in the controller. Now let me tell how to configure this register to force the pin to perform a specific task. A table illustrates the value to load in the PINSEL for specific functions.


So the above table will give you the values you need to load to make the pin to perform your desired function. So if you want to make the whole port to function as GPIO you can simply do it by 

“PINSEL0=0” or you can ignore mentioning it because 0 in the register always make the pin to work as GPIO. But always mention it for good programming practice.

If you need to use specific pin P0.0 as TXD then you can do it by


If you need to make the same pin P0.0 as PWM1 then you should load the value as 


Can you feel the difference between these two, writing 1 to the 0th position make it work as TXD and to the 1st position make it work as PWM1 as shown in the above table.

Consider the Pin P0.3 and for making it work as EINT1 that is the fourth function then you need to configure it as


Kindly refer the manual for function tables of PINSEL1 and PINSEL2. I hope now you are clear with choosing the functions using the PINSEL register. 


Like DDR in AVR and TRIS in PIC, ARM uses IODIR register to specify the direction which in which we are going to use the pins. Two 32 bit registers IODIR0 for Port0(P0.0 – P0.31) and IODIR1 for Port1(P1.16- P1.31). Kindly note that loading values in IODIR, it will take effect only if the Pins are used as GPIO and the directions are controlled automatically if it was specified with any special functions.

So for making as Pin as output you have to load “1” to it and “0” for output. You can do it by following two methods. For example if you need to specify P0.0 as output then you can do it as

IODIR0=0x00000001 or IODIR0|=(1<<0). 

You may use it as input by loading 0 


This Register is meant to set the pins in the Ports where writing 1 to it will set the respective pin while 0 will have no effect. There are two registers dedicated for both the ports IOSET0 -P0.0 – P0.31 and IOSET1 for P1.16 – P1.31

 For example if you need to set P0.12 then you can do it by

IOSET0|=(1<<12) or IOSET0=0x00001000


This Register is meant to clear the pins in the Ports where writing 1 will clear the respective pin while 0 will have no effect in the Ports. There are two registers dedicated for both the ports IOCLR0 -P0.0 – P0.31 and IOCLR1 for P1.16 – P1.31


For example if you need to Clear P0.12 then you can do it by 

IOCLR0|=(1<<12) or IOCLR0=0x00001000


This is used only when we assign certain pins as Input in the IODIR register. There are two registers dedicated for both the ports IOPIN0 -P0.0 – P0.31 and IOPIN1 for P1.16 – P1.31. For example you have connected a switch as input to the Pin P0.0 then you can read it as  

if((IOPIN0&(1<<0))) // seeing if P0.0 ==1

if(!(IOPIN0&(1<<0))) //Check if P0.0 ==0

So that’s it you are now familiar with all the basic programming procedures of ARM7 Microcontrollers. Now let’s take a first step by writing simple LED toggle program in this ARM7 Microcontroller.


Consider 16 LED’s are connected to the Port 0 form (P0.0-P0.15) of the LPC2124 Microcontroller. Lets see how to write a simple code for toggling the LED’s with equal time delays. This code was built using Keil uvision 4 Software.

void delay(void);
int main(void)
     PINSEL0=0;                      //Use all pins as GPIO
     IODIR0=0x0000ffff;          //Setting directions of P0.0-P0.15 as output
             IOSET0=0x0000ffff;          //Setting pins P0.0-P0.15
             IOCLR0=0x0000ffff;         //Clearing pins P0.0-P0.15
      return 0;

void delay(void)
    unsigned int i;
The following two tabs change content below.
Frank Donald

Frank Donald

Junior Network Engineer at Tata Communications
Frank Donald is an Electronics and Communication Engineer who loves building stuff in his free time. Video games, blogging and programming are the things he loves most

Ask your query

12 Comments on "Basics of ARM7 Microcontroller(LPC2124) Programming"

Notify of
Sort by:   newest | oldest | most voted

i m beginner to is very useful and understandable..thank you..and put more projects


Get an editor. This article has so mangled the English language it’s painful to read.

Frank Donald

Sorry for the inconvenience

>> So for making as Pin as output you have to load “1” to it and “0” for output. ^ is this input?Thanks, good tutorial
Frank Donald

Its ok, i figured it was a typo. I hope you understand it well, feel free to ask if you have any queries


Sorry it was my fault when I posted the comment. I just wanted indicate that in the sentence the second “output” probably had have to be “input” instead.

Frank Donald

I cant understand you, I guess the article is clear enough for explaining basics. As i said before go through the bit wise operations in C language then this will be a piece of cake.


Love it i always thought of learning ARM and this tutorial made ma first step towards it. i would love to see more ARM based interfacing and conceptual tutorial.good work mate

Frank Donald

Sure will post in the future, Keep visiting …Cheers

Bob Afwata

Hello I am bob and i love your tutorial please help me get started very well like how to build a simple circuit using the chip and how to configure the software(I KNOW OF KEIL) but how to i put up a simple circuit together,crystal ,capacitors etc and what programmer do i need.I would appreciate if you provide a bare minimal sample blink led circuit with all components and programmer connected.If any driver is also needed