My Colleagues Frank Duignan and Richard Hayes have been experimenting with an ARM 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 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!
Under Frank’s guidance, I’ve just implemented a simple flashing LED example for the ARM LPC1114. The following code is basically a stripped back version of the more complex example he sent me.
// // 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 SYSAHBCLKCTRL |= BIT6 + BIT13 + BIT16; GPIO0DIR = BIT8; // Make PIO0_8 an output GPIO0DATA = 0; // Turn off PIO0 outputs int n; while(1) { 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 (“build.bat”), courtesy of Frank Duignan.
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\GNU Tools ARM Embedded\4.7 2013q3\lib\gcc\arm-none-eabi\4.7.4\armv6-m" -lgcc -T linker_script.ld --cref -Map main.map -nostartfiles -o main.elf "C:\Program Files\GNU Tools ARM Embedded\4.7 2013q3\arm-none-eabi\bin\objcopy" -O ihex main.elf main.hex
I used the following ARM version of gcc to build the program:
I used Flash Magic to transfer the compiled code (main.hex) to the microcontroller:
http://www.flashmagictool.com/download.html&d=FlashMagic.exe
There are a couple of other bits and pieces that are required to build the program, namely a header file “lpc111x.h”, a linker script “linker_script.ld” and a C file with some init code “init.c”. Frank is planning to post those online over the weekend, so I’ll update this post with links once I have them.
