But first ... a bit of wiring is in order! You'll need to hookup a UART to USB adapter, a 3V3 voltage regulator, a couple caps, and a few wires to get everything wired up safely with the LPC810. Just follow the wiring diagram below and you should be good.
The UART cable colors on the right (four wires) match the colors of Adafruit's USB to TTL Serial Cable.
There are two main ways to take advantage of ISP mode to program your MCU:
- Use Flash Magic, a free GUI-based tool for Windows
- Use lpc2isp, an open source command-line tool that can be adapted to work on most operating systems, though you may need to build it yourself and add your MCU ID.
This tutorial will assume that you are using the PL2303-based USB to TTL Serial Cable included with the LPC810 Starter Kit.
- Insert the LPC810 into your breadboard as shown, along with the 3.3V voltage regulator, and two decoupling capacitors.
- Connect the white, green, red and black wires on the right-hand side of the diagram to the same colored cables on your USB to TTL serial adapter.
- Connect the ISP pin to GND (the cable shown in gray above), which will cause the chip to enter ISP mode when it comes out of reset
- Connect the other red and black cables on the breadboard which control the power supply to the MCU.
If you haven't already done so, download and install the latest version of the free Flash Magic tool.
The tool is relatively straight forward once you have used it once or twice, but this guide will show you everything you need to know to program the LPC810 using the Flash Magic GUI.
Flash magic uses Intel Hex files to program the MCUs.
The LPC810 CodeBase will produce a compatible .hex file from your own code, which we'll learn about later, but you can also find some sample .hex files at the bottom of this tutorial for convenience sake.
Before you can program your LPC810, you need to supply some basic information to Flash Magic:
- Set the device to 'LPC810M021FN8'
- Set the COM port to whatever COM port your USB to TTL cable is using (you can find this in the Device Manager on Windows, for example)
- Set the Baud Rate to '115200'
- Set the Oscillator to '12'
- Check the 'Erase blocks used by Hex File' checkbox
You can make sure that all of your settings are correct, and that everything is connected properly and that the chip is actually in ISP mode by selecting 'ISP > Read Device Signature ...' from the top menu bar:
After selecting your .hex file in the 'Hex File' textbox, you simply need to click the Start button, and Flash Magic should start programming your device.
You may wish to check the 'Verify After Programming' checkbox before doing this, but it isn't strictly necessary:
At this point, your device should be programmed. To test your firmware perform the following steps:
- Disconnect the ISP wire on your breadboard (the gray wire in the image above)
- Reset the device ... for example, disconnect then reconnect the red power cable on your USB to TTL adapter
- Once the board is powered up and if the ISP pin is not pulled low the chip will execute code normally
For convenience sake, you can find some pre-compiled sample .hex files for the LPC810 in the '/tools' folder of the LPC810 code base, available on github:
LPC810_Blinky_P0_2.hex - This hex file will cause an LED on P0.2 to blink at a regular rate. To use this firmware, connect the anode (the larger pin on your LED) to P0.2 on the LPC810, and the cathode (the shorter pin on the LED) to a 1K resistor and to GND, as seen in the following diagram: