As I mentioned in my previous post in this series, I have been planning for a long time to make my own ARM Cortex development board from scratch. After a lot of mulling around, and a bit of a false start with the LPC1114 chip, I discovered JeeLabs, a comprehensive web site, blog and upcoming book all about this sort of stuff run by Jean-Claude Wippler. A lot of the older material is based around Atmel AVR chips. Starting in November last year, however, Jean-Claude has been exploring the world of 32-bit ARM, beginning with the cute little LPC810, in a breadboard-friendly eight-pin Dual-in-Line package.
This chip is small in both size and features compared to most ARMs, but still packs a surprising amount of punch. It has a Cortex M0+ core running at 25MHz, 4K of flash, 1K of RAM, six GPIO pins, two UARTs, SPI, I2C, several timers and an analogue comparator. All of this is a bit much to squeeze into only eight pins, especially when you consider that two of them are earmarked for power and ground! The way NXP get around this is by providing a built-in switch matrix which can route (almost) any chip feature to any pin. This gives a surprising amount of flexibility for simple applications.
Although the point of this exercise is to build my own development boards, sometimes its comforting to have something to fall back on to test things out. NXP originally produced a nice simple development board for this chip, but sadly it seems that this board is no longer available, so if I am to do anything with this device I will have to make my own.
The first step is to find out a minimum circuit. Luckily, JeeLabs has this covered
Image thanks to jeelabs.org
There are some interesting things about this circuit. The first is the very small number of components There’s the microcontroller itself, a smoothing capacitor for the power pins and an LED. The second interesting thing is the LED. It is mainly used as a rough and ready regulator to drop 5V, provided by a serial adapter board, to 3.3V for the device. For a purely 3.3V circuit, even that would not be necessary! The simplicity of this circuit made me very happy. Surely even I can’t get this wrong! I still have niggling worries about the lack of any pull-up or pull-down resistors on any of the communication pins, but Jean-Claude has obviously made it work. I quickly assembled the specified circuit on a small breadboard, following the JeeLabs instructions.
Next came the challenge of programming the LP810. There are so few pins that it does not make sense to permanently dedicate several of them to functions such as RESET and the SWD programming protocol, and not everyone has a SWD debug probe. To help get round this, the LPC810 comes with a built-in bootloader which looks for a particular pattern of highs and lows on some of the pins and switches into a serial programming mode.
If The ISP pin (pin 5) is low when the chip powers up or comes out of reset, it will enter programming mode and expect commands and data over a serial port on pins 2 and 8. While serial port adapters are cheap and plentiful (even though they don’t often have an output which does exactly the right thing for the ISP pin) this approach does mean that some special software is needed which speaks the correct protocol over the serial port. JeeLabs recommends some software called lpc21isp which it recommends installing in a Linux virtual machine. I tried this approach and spent several days messing with software and modified serial adapter boards. All with no success.
In my case it seems that code in a Linux VM was either unable to write to the USB serial port, or suffered timing problems which prevented it form working. Whatever versions I could find for Windows were not quite the same and didn’t work either. Eventually I gave up on the modified serial board approach, and fitted a manual ISP button (initially it was just a jumper cable). This allowed me to, eventually, get some JeeLabs example code onto the chip so I could see it blink an LED. The process still seemed pretty hit or miss, though. A large proportion of the time the software download would fail, with no obvious reason why, and messing with a manual ISP switch became very tedious. I also faced the problem that I was not set up to develop code in the same way as Jean-Claude at JeeLabs, so I was mostly limited to the supplied examples. I even tried connecting my Keil ULink 2 debug proble to the SWD pins, in an attempt to use Keil uVision to write code for this chip. Again without success. Adafruit recommends the LPCXpresso IDE, so I also installed that. Although I could use it to program other NXP chips on pre-made development boards, I still had no real success with programming the LPC810.
The LP810 is very sweet, but the small number of available pins does limit its usefulness. After some examples with this little chip, JeeLabs moved on to cover the very similar LPC812, which mainly differs in having a smaller (TSSOP) package with 20 pins. With a bit of care I was able to solder this chip onto a DIP adapter. The extra pins are nice, but I still faced the same issues with programming. I decided that however neat the idea of the ISP pin and serial bootloader seems on the surface, it is just too fiddly for sensible software development.
Next time I’ll step into the confusing world of SWD, but this time I’ll try with a microcontroller where I am already comfortable with the development software.