Simple ARM example for LPC1114

My colleagues Frank Duignan and Richard Hayes have been experimenting with an ARM Cortex M0 microcontroller in a dual inline package (DIP) which can be plugged straight into a breadboard. The chip they’re using is LPC1114FN28/102, which is made by NXP and is available for less than €2. Frank spent a bit of time working out how to program the chip using a low-cost USB-to-serial converter, so the whole thing provides a micrcontroller programming setup that’s incredibly inexpensive, but quite powerful!

Following Frank’s instructions, I’ve just got my first simple flashing LED example working on the ARM LPC1114. Here’s a couple of snaps of my breadboard circuit:

ARM LPC1114 simple breadboard circuit

ARM LPC1114 simple breadboard circuit

The following code (filename “main.c”) is really just a stripped back version of a more extensive example Frank sent me, so I must emphasise that all credit here goes to him.

// main.c - Blinking LED example for ARM LPC1114
// Written by Ted Burke (based on code by Frank Duignan)
// Last updated 29-11-2013

#include "lpc111x.h"

int main()
    // Turn on clock for GPIO, IOCON and ADC
    GPIO0DIR = BIT8; // Make PIO0_8 an output
    GPIO0DATA = 0;   // Turn off PIO0 outputs
    int n;
        GPIO0DATA = BIT8; // Turn on PIO0_8
        n=1000000; while(--n);
        GPIO0DATA = 0;    // Turn on PIO0_8
        n=1000000; while(--n);

I’m using the following build script (filename “build.bat”), also courtesy of Frank Duignan. Note the full path included in the linker command on line 3. If your installation directory is different from mine, you will need to modify line 3 to match your own installation folder. Note that the default installation folder may be different on other versions of Windows (note that my installation folder is under “C:\Program Files (x86)\”).

arm-none-eabi-gcc -mcpu=cortex-m0 -mthumb -g -c init.c -o init.o
arm-none-eabi-gcc -mcpu=cortex-m0 -mthumb -g -c main.c -o main.o
arm-none-eabi-ld init.o main.o -L "C:\Program Files (x86)\GNU Tools ARM Embedded\4.7 2013q3\lib\gcc\arm-none-eabi\4.7.4\armv6-m" -lgcc -T linker_script.ld --cref -Map -nostartfiles -o main.elf
objcopy -O ihex main.elf main.hex

I built my program using the gcc compiler from the GNU Tools for ARM Embedded Processors. This was the version I installed (4.7 2013q3):

During the installation, the following dialog box appears. I suggest ticking the check box to “Add path to environment variable”.

Dialog box during installation of GNU Tools for ARM Embedded Processors

I used Flash Magic to transfer the compiled program (main.hex) to the microcontroller:

To compile the example code above, three more files are required: a header file “lpc111x.h”, a linker script “linker_script.ld”, and a C file called “init.c” which contains initialisation code for the ARM. All three files can be downloaded (along with lots of other useful info) from Frank’s web page. Alternatively, a quick way to get all three is to download this zip file (I just zipped the three files with Frank’s permission – thanks Frank!).

So, before building the program, my project folder contained the following five files:

ARM blinking LED project folder screenshot

Then I built the program by running the batch file build.bat.

Building a simple example program for the ARM LPC1114  - console screenshot

After building, the project folder contained the following files:

ARM blinking LED project folder screenshot

Finally, I transferred the compiled program (“main.hex”) to the LPC1114 using FlashMagic.

This entry was posted in Uncategorized and tagged , , , , , , , , , , , . Bookmark the permalink.

16 Responses to Simple ARM example for LPC1114

  1. Dsoberoi says:

    Good, to begin with.


  2. Dsoberoi says:

    Will ping u for some issue. I am trying to introduce same o my students.

  3. Dsoberoi says:

    I had gone through that.
    I had received samples from NXP India and want same to be used by students now. Ur article has been a good help. Could not find “lpc111x.h”, a linker script “linker_script.ld”, and a C file called “init.c” in a Zipped file, in the link as indicated above. Pls. check the link.

    • batchloaf says:

      Hi Dsoberoi,

      Ok sorry, I see the problem now! The link Frank sent me for the zip file only works when I’m logged into my gmail. I’ve just checked with Frank if I could upload a new zip file containing those three files and he said that’s fine (thanks Frank!), so here’s the link:

      ARM LPC111 development files from Frank Duignan (lpc111x.h, linker_script.ld, init.c)

      Sorry about the confusion. I’ll update the post now with the new link.


  4. Dsoberoi says:

    Will start work, after my winter vacations. Let us see how my experiments goes ahead.

  5. Dsoberoi says:

    Thanks. Best wishes.

  6. Kiran Manju says:

    Hi…I am having LPC2148 development board. I wanted to use Eclipse IDE with GCC compiler. So I using Eclipse IDE with the Sourcery CodeBench Lite (Bare Metal) . I started off with led_blinky. The build is successful with an warning:cannot find entry symbol _start. How do I solve this. The code did not blink any led.

    • batchloaf says:

      Hi Kiran,

      Sorry, but I’m not sure what the problem is there. You’re using a different ARM chip and development environment, so I don’t think I can offer much useful advice.


  7. cthomasbrittain says:

    Being the hobbyist I am, couldn’t figure out what I was missing.

    It’s the binutils I didn’t have on my windows machine, so during the translation from .elf to .hex I was getting a file not found error. Anyway, thought I’d share incase someone was as dumb as me.

    Here’s a link to binutils pre-compiled for Windows.

  8. Pingback: ARM-Cortex M0 programming with lpc1114FN28 – an overview | LE Xuan Sang – personal page

  9. I wrote a makefile and built a better toolchain for it.
    Also I ported the NXP’s header library and made it standalone and I built my own easy compiler macros for all the builtin functions.
    Thanks for sharing your infos in the first place.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s