home index sites engineering software hardware email

ARM7 NXP (formerly a division of Philips) LPC Microcontroller


ARM7TDMI == low power and low cost 16/32 bit microcontroller

NXP LPC == ARM7TDMI at its best!

With the ingenious 16/32 'Thumb' instruction set, ARM provides the code density of a 16-bit CPU with the processing power of 32-bit CPU in their ARM7TDMI core.

I have worked with many ARM7TDMI variants including products from Cirrus Logic, Netsilicon and Atmel, however my favorite ARM7TDMI product line is the NXP LPC ARM7TDMI family.

The LPC combines the code/power efficient ARM7TDMI with plenty of peripherals, including '550 compatible (16 character FIFO) UARTs, SPIs, I2Cs, timers, PWMs, ADCs, a DAC, and even an RTC. The LPC also provides field upgradeable Flash and plenty of SRAM (64 kB on the LPC2106).

A very important feature of the LPC ARM7TDMI is the embedded boot-loader that allows firwmware upgrading over UART0. This boot-loader also provides an interface for running firmware to upgrade the Flash in-service.

Unlike many other ARM7TDMI processors, the LPC utilizes a PLL that can interface to a cheap crystal.

The LPC2104/5/6 also provide a powerful debug feature; the ability to re-map the JTAG pins under firmware control. The five 'main' JTAG control pins (NTRST, TMS, TDI, TDO and TCK) are normally enabled via DBGSEL on reset. However DBGSEL also enables the embedded trace macrocell taking up an additional 10 pins, for a total of 15 pins lost (on the 48 pin LPC2104/5/6 this is devastating). The bright engineers at NXP solved this problem by remapping access (under firmware control) to the five main JTAG signals on alternate pins, thus saving 10 pins when debugging.

For more information on the LPC ARM7TDMI visit the NXP LPC2K site or the Yahoo! LPC2000 Group.

ARM7TDMI GNU development tools under Linux

As expected, ARM7TDMI is well supported with the GNU tools. Below you will find the build script that I created to compile and install the GNU binutils and GCC C compiler for ARM (arm-elf) under Linux (windows users should look at GNUARM or Yagarto, Linux users interested in C++ or newlib should look here). I am using Ubuntu Linux, however this script should work for almost any Linux, or UNIX system for that matter.

To start developing C code with ARM7TDMI under Linux simply download the following files, then run the build script buildarm.sh.

Of course, actually writing code for ARM7TDMI is a completely different matter! If you are new to ARM7TDMI, or GCC in general then you should consult one of the following guides:

Programming ARM7TDMI

As mentioned, the LPC ARM7TDMI contains a boot-loader capable of upgrading the Flash. This boot-loader is programmed by NXP at the factory, so only a low-voltage (TTL/CMOS) UART is needed to program a fresh LPC ARM7TDMI part.

Under Linux I currently use a tool called 'lpc21isp' to program LPC devices (it also works under windows). NXP provides a windows tool (a link is available on the LPC product page).

Don't worry about erasing or over-writing the NXP boot-loader; you can't!

Debugging ARM7TDMI

The LPC, and most ARM7TDMI devices contain the ARM 'EmbeddedICE' logic which allows debugging via the JTAG port. All you need is a JTAG interface device (with drivers for your PC) and GDB/Insight to debug ARM7TDMI. Under Linux, and windows you can use Macraigor's 'OCDLibRemote', which interfaces with their hardware products (and then you run GDB/Insight and connect to it via TCP/IP). I have used the Wiggler, Raven and the mpDemon, all which work very reliably (except the Wiggler, which is not supported under Linux). See the the Macraigor FAQ for more information on using their software and hardware with GDB/Insight.

One thing that is not documented very well when using Insight/GDB with the Macraigor tools is setting hardware breakpoints (which are required for debugging firmware running out of Flash). Insight/GDB is not able to directly set the hardware breakpoints, however with the 'monitor' command you can get access to the low-level registers and extra commands that Insight/GDB do not (currently) support.

For example to set a hardware break point at 0x12345678 type in the following in the Insight/GDB console:

monitor set hbreak 0x12345678

To get access to both of the hardware breakpoints in the ARM7TDMI you will need to access the EmbeddedICE logic registers directly. To set a hardware breakpoint at 0x12345678 and 0xDEADBEEF type in the following in the Insight/GDB console (note that by using this technique you will not be able to set software breakpoints):

monitor reg w0av = 0x12345678
monitor reg w0am = 1
monitor reg w0dv = 0
monitor reg w0dm = 0xFFFFFFFF
monitor reg w0cv = 0x100
monitor reg w0cm = 0xFFFFFEF7

monitor reg w1av = 0xDEADBEEF
monitor reg w1am = 1
monitor reg w1dv = 0
monitor reg w1dm = 0xFFFFFFFF
monitor reg w1cv = 0x100
monitor reg w1cm = 0xFFFFFEF7

I created a small GDB script that when sourced (simply type in "source ib.gdb" in the GDB console) provides a user defined command 'ib' to simplify setting the hardware breakpoints on the ARM7TDMI. Type 'help ib' for more info. I also have a similar script for data breakpoints. If you want to have these scripts sourced automatically create a file with the name ".gdbinit" in the directory where you run Insight/GDB with "source path/to/your/script", one line per script.