The easiest way to dive in to ARM programming

[Brad] has been very excited about an ARM Cortex-M0 chip released by NXP; it’s a fully featured ARM microcontroller, and is, quite amazingly, stuffed into a hobbyist and breadboard-friendly DIP-28 package. After finding a supplier for this chip, [Brad] dove in and put together a great tutorial for programming an ARM on the breadboard using open source tools.

The chip in question is NXP’s LPC1114FN28, a 28-pin breadboard friendly chip we’ve posted about before. After finding a single supplier for this microcontroller (only $1.26 for one chip!), [Brad] pulled out his breadboard and started wiring things up.

Because this microcontroller has an on-board oscillator, wiring up a breadboard and putting in a breakout for an FTDI cable was a snap. After configuring a toolchain and writing a bit of code, the only issue was uploading the code to the chip. This was handled by the lpc21isp programming tool, slightly modified and configured by [Brad] to support his favorite microcontroller.

The LPC1114FN28 is an impressive bit of kit, and with free tools to program the damn thing, we can’t wait for a homebrew ARM dev board to show up.

44 thoughts on “The easiest way to dive in to ARM programming

  1. 32k flash, 4k of RAM, SPI, Serial, ADC, and I2C? Only $1.50? I’m not so updated but for this price, I only know the PIC12F683 (2kW flash, 128 B ram, 256 B E²PROM, ADC, PWM and only 6 I/O!). Which is the best PIC model near this price (with ADC). I Have PIC16F628A with plenty of legs but with the painfull lack oof ADC.

  2. Loved the price, and yes, those chip are great, too bad they are a pain to program, so I will check those tutorials up and see if it helps things out. I also got the FEZ Panda and turned it into an ARM dev. board, by removing C#. hehehe, it works, as its also a NXP chip inside the FEZ Panda.

    Now, if only eBay would sell those chips…

      1. I asked to carry those, maybe if more people ask? ;-) I use them to ship things here in Brazil, cheaper shipping, and they also send as replacement parts, which is nice. If you haven’t used yet, check it out, its a nice alternative for buying stuff from Brazil. Most stuff is a bit more expensive, so if its not on eBay, its there, but with a higher price. But still cheaper than buying on other sites like AVNET.

      2. Any hackerspaces in Brazil? Selling electronic components could be a fundraising opportunity for a hackerspace or any other tech orientated group. I’m not going to say it would be simple matter devoid of effort, but it should be worthy of investigation.

    1. I try to avoid buying anything in small quantities from Avnet, and I’m a domestic customer. They generally have better pricing than their big competitors [Mouser, Arrow, Newark, Digikey, etc], but their shipping costs are high and their packaging practices laughable. They have, on multiple occasions, sent me *really big* boxes to ship maybe 2 QFN chips. They charge the appropriate amount for a box that big. But a $0.45US stamp would have covered it. All of the big distributors do it, but Avnet and Arrow are the absolute worst in my experience.

    2. Its actually soccer, and oil is expensive here, and I hate samba. ;-)

      Ok, as for shipping, I can’t just order more to accommodate shipping, as stupid local laws don’t allow me to order anything that is price+shipping > $ 50 USD without having to pay 90% of extra custom taxes and some other fees.

      Resuming, anything above 50 bucks will get you nearly 3 times the price in fees. :-(

      Its a stupid country, really lame laws…

      1. that problem exists in other countries too – for example in Romania i can only purchase goods worth of 10$ anything more and i have to pay duty taxes – good thing the ladies from the postal office have no idea what electronics components are worth

        as for shipping from USA – ive found someone on arduino forum who was willing to buy from mouser/digikey and ship to romania for as low as 10-15$ (that was the total cost shipping from vendor to him and from him to me)

  3. I wonder…. wouldn’t it be easier to dive into ARM programming using qemu? That way, you wouldn’t be required to get hold of the hardware first. Of course, it is more fun to play with the hardware and see an actual LED blink (for instance). But diving in using qemu does eliminate the issue of having to produce the hardware before getting started.

    1. I’m not sure why you have to get into “ARM” coding.. if anything you need to learn the peripheral set your selected chip has and not specifically “ARM”. Once you have GCC and Newlib running most of the time the instruction set is interchangeable. For example I have code that runs on ARM7, H8 and m68k without any changes .. and most of the time the code I write is no different to that I would write if I was targeting Linux.

  4. I got 5 free samples of the LPC1114FN28 months ago directly from NXPs through their university program. After reading this I ask myself “why?”. All this code modification and rigging can be avoided. I use LPCXpresso for my ARM programming and you can get a cheap lpc-link devboard from them that is explicitly designed for you to be able to cut off the JTAG programmer from the rest of the PCB and use it as a standalone JTAG for this and any other NXP ARM processor.

    1. But can you use the JTAG programmer on the lpc-link devboard with open source toolchain, or any other development environment? I was under the impression that lpc-link devboard tied you to the lpcxpresso IDE. (Not that that’s a bad thing)

    2. Some of us prefer open source toolchains, rather than relying on proprietary hardware and software from the manufacturer.

      That said, NXP’s Linux support is better than others, and if you want to use the NXP approved flash magic tool, it works well in wine.

    1. Galago might be easier for some (most?) things, but sometimes you just want to dive in, and breadboard something together. Plus, at $1.27 a pop, I can burn through a lot of Cortex-M0s for the price of your board!

      That said, I backed your project before I submitted this to Hack-a-day, and I look forward to playing around with your board. The kickstarter mentions that the project is open hardware, do you have the design files/software libraries posted anywhere yet?

  5. I designed a product using the Code Red tools (Ecclipse and GCC-based) for a LPC1111 some time ago. It is really powerful compared to 8bit controllers, and the timers are good. The code red tools worked well too, and I used the expresso without problems. The drawbacks are high power consumption. When running 48MHz I used 17mA (which is OK) and something like 8-11mA when in sleep (which is hardly worth the effort). Output drivers as not fast, and I needed to add some tinylogic to drive a MOSFET for switch mode conversion. Back then there were no EEPROM, but I can see, it has been added since. I would love to use one again.

  6. Been playing with this chip for the past few weeks and I have to say it’s pretty awesome. I’m using it to control everything (drive motors, steppers, sensors, path finding logic) for a small robot project. And it’s so inexpensive that if more processing power is needed you can just throw another uProc into the mix. I am a big fan of opensource (and I appreciate the folks who make it happen), however for $38 you can get the Olimex ARM-JTAG-COOCOX programmer for Serial Wire Debug that enables on chip debugging and flashing. Combine that with the free version of Keil MDK-ARM (install the MDK driver from and you have a very nice workflow with minimal setup. The free version of Keil MDK is limited to 32K flash… but that happens to be the size of the flash on these devices.

    There are some comments about ARM being notoriously difficult to program. With more capability there is usually more complexity. But with the right abstraction layer(s) in place, this complexity can be mitigated. For example, most of the examples I’ve come across use standard bit shifting and masking to set the registers. This makes the code very hard to read and also error prone. My preference is to use C++ and overlay the uint32_t register with a structure containing named bitfields. The bitfields are written to look like the LPC11xx User Manual, so there is less room for error. For example:

    // LPC_IOCON->PIO0_8
    // I/O configuration for pin PIO0_8/MISO0/CT16B0_MAT0 (R/W)
    struct _PIO0_8
    uint32_t FUNC : 3; // pin function
    uint32_t MODE : 2; // pull up/down resistor mode
    uint32_t HYS : 1; // Hysteresis.
    uint32_t reserved0 : 4;
    uint32_t OD : 1; // Selects pseudo open-drain mode
    uint32_t reserved1 : 21;

    I then use inline functions to cast the ptr to register to the structure and then set/get the bit field values.

    #define PIO0_8_FUNC_GPIO 0x0
    #define PIO0_8_FUNC_MISO 0x1
    #define PIO0_8_FUNC_TIMER 0x2
    inline void IOCON_PIO0_8_FUNC(uint32_t val)
    ((_PIO0_8*)&LPC_IOCON->PIO0_8)->FUNC = val;

    The end result is code that reads like the LPC11xx User Manual and is just as efficient as C implementations because of the inlines. And best of all I let the compiler figure out all of the masks and bit shifts for me. Here is what programming the 16-bit timer for PWM looks like with these inline functions:

    void SetupPWM()
    // Enables clock for 16-bit counter/timer 0
    // setup pin 1 for PWM output
    // disable pullup resistor pin 1
    // set timer prescaler
    TMR16B0_PR_Set(SystemFrequency/10000); // TC = 10Khz
    // set match register 3 to reset TC
    // set PWM duty cycle
    TMR16B0_MR3_Set(100); // 100Hz
    // set pulse width
    TMR16B0_MR0_Set(0); // 0%
    // enable PWM mode on match register 0 (MR0)
    // enable counter
    // reset timers

    Of course this function could be wrapped in another abstraction, but at least the code is easy to read (imo). For anyone interested, I keep my code at If you want to help build out the abstraction for all functions on the chip please let me know. Hope this helps some folks getting started.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s