July 30, 2013
The LPC1114FN28 is an exciting piece of hardware--a 32-bit ARM Cortex-M0 micro controller capable of 50MHz operation in a DIP-28 package. Unfortunately, getting your development environment set up on a Mac can be confusing.
You'll need the following:
- the GCC ARM Embedded toolchain
- lpc21isp to program the chip
- some sample code
- an FTDI USB-to-serial cable or equivalent. (Doesn't matter if you have a 5V or 3.3V model, the LPC1114's inputs are 5V-tolerant.)
So, let's get started.
-
Download the GCC ARM Embedded toolchain from https://launchpad.net/gcc-arm-embedded. You want to download the prebuilt Mac binaries: choose the download with
mac.tar.bz2
in the filename. (As of writing, the full link to the latest version is https://launchpad.net/gcc-arm-embedded/4.7/4.7-2013-q2-update/+download/gcc-arm-none-eabi-4_7-2013q2-20130614-mac.tar.bz2). -
Create a directory for your ARM toolchain binaries. I'd recommend against putting them directly in
/usr
. Instead, create a directory like/opt/local/arm
or~/arm
, whatever you prefer. -
Extract the toolchain tarball into the directory you just created. It should now contain these directories:
arm-none-eabi/
bin/
lib/
share/
-
Add the
bin/
directory to your$PATH
in your shell's rc file (.bashrc
,.zshrc
, etc.) Example:export PATH=$PATH:/opt/local/arm/bin
-
Download and extract the latest version of lpc21isp. You'll want at least version 1.92, which can be found here: https://github.com/capiman/lpc21isp
-
The Makefile needs to be modified. Remove
-static
from theCFLAGS
, or you'll get this error during compilation:ld: library not found for -lcrt0.o
-
Run
make
to build lpc21isp. Copy the resultinglpc21isp
binary to thearm
directory you added to your$PATH
in step 4. -
Set up your hardware on a breadboard. (diagram from Brad Luyster)
- Pin 22 (Vss) to ground
- Pin 21 (Vdd) to +3.3V
- Pin 23 (/RESET) to +3.3V via 4.7k pull-up resistor and to one end of a normally-open pushbutton. This is the reset button. The other end of the button should connect to ground, so pressing the button should drive pin 23 low.
- Pin 16 (TXD) to the YELLOW wire of the FTDI cable
- Pin 15 (RXD) to the ORANGE wire of the FTDI cable
- BLACK wire of the FTDI cable to ground
- Pin 24 (PIO0_1) to ground via 4.7k resistor. This places the chip in programming mode.
- Pin 17 (PIO1_8) to the anode of an LED for testing purposes. Connect the cathode of the LED to ground via a 220 ohm resistor.
-
Connect the FTDI cable to the circuit and to a USB port on your Mac.
-
If you don't know the device name of your FTDI cable, discover it by running the following command:
ls -l /dev/cu.usbserial*
It should be something like /dev/cu.usbserial-xxxxxxxx
, where the x's are random letters and numbers. Save it in an environment variable:
export FTDI_DEV=/dev/cu.usbserial-xxxxxxxx
-
Power on the circuit. (remember, 3.3V!)
-
Test communications with the LPC1114 by running the following command:
lpc21isp -detectonly $FTDI_DEV 115200 12000
If everything's successful, you'll see output ending with:
Read part ID: LPC1114FN.../102, 32 kiB ROM / 4 kiB SRAM (0x1A40902B)
-
Now it's time to run some code. Download Brad Luyster's blinking LED project from https://github.com/Zuph/lpc1114-blink.
-
Extract the archive,
cd
into it, and runmake
. If everything worked, you'll have a file calledlpc1114_blink_led.hex
in theout/
subdirectory. -
Power on the circuit again, and send the code to the LPC1114 using this command:
lpc21isp out/lpc1114_blink_led.hex $FTDI_DEV 115200 12000
If it worked, the output will end with:
Now launching the brand new code
(Note: the 115200
is the baud rate, and the 12000
is the chip's clock speed in kilohertz.)
- Remove the resistor connected to pin 24 to take the LPC1114 out of programming mode, and press the reset button. The LED on pin 17 should be blinking at a rate of 1Hz. And you're all set!