Tuesday, October 12, 2010

Hello World from LPC1768

Finally, the blueboard LPC1768-H arrived. Have a look.


Unfortunately, it did not have accessories like JTAG cable or mini-USB cable. So, a quick visit to the local electronics store was needed. Once the mini-USB cable was plugged into the blueboard, the LED started blinking. Apparently NGX had pre-loaded the board with a test program. Now I had to say "hello world" through the board.

Initially, the plan was to use NXP's on-chip permanent UART bootloader. However, the USB->UART board( FT232R based) had not yet arrived. This meant that 3 options were left out.

1. Use parallel port and program using JTAG.
2. Build the USB->UART converter on a prototyping board.
3. Use the RS232 port and convert signals to TTL using a level converter.

I really wanted to avoid using the JTAG because of the ill-fame openOCD carries with it. Using the bootloader seemed so much more easier. Furthermore, the goal of the first experiment was to just get the LED blinking program to download to the chip and run. This hardly calls for a debugger. Also, while using the AVR atmega's , I had never done an on-chip debug before. So, at first, using JTAG was not the course of choice.

Building the USB-> UART bridge on a protoboard would consume a lot of time. I had an RS232 port on my PC. But not the required MAX3223. Although MAX232 was in the drawer, it needs a 5v supply which would require a bit of circus on my part as the blueboard gives out only 3.3v.

Running out of options, I ended looking up on JTAG. The wiggler clone based on the parallel port is extremely simple to build. Here's the circuit.


About a year ago, I'd built an LPT AVR programmer. In that I'd ignored the recommendation of using a buffer like HC244 but it had worked quite well even with my 3 meter long DB25 cable. So, I threw caution to the winds and connected the LPT pins to the JTAG pins via a 100 ohm resistor without a buffer. This is the circuit.


This design is far from perfect and has many flaws. The advantage of simplicity lured me into it. In any case, I dont plan on using this for long. Once a USB boot loader is ready, this wiggler clone wont be used unless absolutely needed.

With CodeSourcery g++ Lite as the compiler, Eclipse as the editor and H-JTAG as the debugger, it was a piece of cake to get code onto the chip. The debugger instantly recognized the chip and within a minute, I had my code on the chip with the LED now blinking. And viola ! Hello World project successful.

All together, building the Wiggler Clone and getting the LED blinking took about one and a half hour. About the same time I had taken on my Atmega "Hello World". Perhaps I could have gotten it to work faster if fantastic tutorials like that for AVR on AVRFreaks were available for ARM Cortex M3. Sadly, there are few. I seek to remedy this by writing up all that I do.

Once I get some time, I'll add some more pics and write up a tutorial on how to start from the scratch like I did.


  1. I just started with this but i dont understand many of the steps (I wont say which). Please meke it more detailed for newers like me.

  2. This post is not a tutorial per se. More of a record of my doings.

    As for setting up the software tools on the PC, you can see

    If you're interested in JTAG, this one is pictorial and takes you step-by-step.

    If you are more specific about what you are trying to do and where you are having trouble, I can offer directed suggestions.

  3. Thanks for answering.
    The other 2 links were very useful for me.
    I got a LPC1768H (blueboard) and a openOCD-USB dongle. I did not know what to install or hot to set them up.
    I could flash my hello world, But it is amazing how difficult is to set all together!!! (windows)

    What I did was:
    - connect the dongle and the blueboard to the dongle.
    - get the drivers for that (2 usbtoRS232 drivers very very difficult to get)
    - Install codesourcery G++ lite. Add ARM software (add new software option in help menu).
    -create a new C project, add the Startup code for ARM.
    -download and run openocd for windows. (dificult to find, difficult to run). I ran it like this: openocd -f /interface/openocd-usb.cfg -f /target/lpc1768.cfg
    -telnet to localhost:4444, then run the flash commands to run the .hex and .bin that I got building my project in G++.

    "With CodeSourcery g++ Lite as the compiler, Eclipse as the editor and H-JTAG as the debugger, it was a piece of cake to get code onto the chip. The debugger instantly recognized the chip and within a minute, I had my code on the chip with the LED now blinking. And viola ! Hello World project successful."

    Wow. I would like you to explain all these steps. It is not peace of cake for me.

    What I am now desperately searching on the internet:

    - H-JTAG does not recognise my lpc1768. No idea why.
    - Can G++ lite do realtime debug on chip? No idea, nobody says how.
    - Should I create a empty C project or should I reate an ARM project (LPC1768 is not in the available boards and setting cortexM3,it does not compile)

    Thanks for any help.


  4. Sorry about the late reply. Your comment was erroneously detected as spam.

    I'd used the good old parallel port with H-JTAG. Maybe openOCD USB JTAG dongle isn't compatible with H-JTAG out of the box.

    Here is a step by step tutorial on how to use H-JTAG.

    g++ IDE can probably debug lpc1768 but g++ Lite is just a compiler and not an IDE. So you'll need an external debugger like openOCD.

    Create a C/C++ makefile project. Yeah, empty as you put it and import all the files from the codebase. ( Import file system )