The mbed hardware takes a different approach for a development
kit. The kit's module acts like a standard USB drive. So, the Setup Guide lists
only two steps: First, connect the mbed module to a PC and second, click on the
mbed.htm icon that appears on the screen for the mbed "drive." The
second step opens a browser window so you can sign up for an mbed
"account" and get started. (Yes, mbed is all lower-case letters.)
And unlike most development kits, the mbed kit doesn't include a
compiler or integrated development environment (IDE) that reside in a PC.
Instead, developers use an online C/C++ compiler and mbed libraries. That
approach gives them the flexibility to move from computer to computer and still
have tools available. Remember, the compiler and documents exist on the mbed website.
I liked working with the mbed module and found information from the community
of developers very helpful.
The mbed.org website guided me to a short Getting Started
tutorial that explained how to start the compiler and begin a new project. The
project automatically included a simple LED-Flash program that I compiled. The
compiler produced a standard binary file and then a File Download window asked
me if I wanted to Open, Save, or Cancel the file from the compiler. To transfer
the file to the mbed MCU, I clicked on Save and selected the mbed
"drive" as the destination. After that, a press of the reset button
on the mbed module started the program and the LED flashed. The module and
software were easy to use and I recommend the kit as a way to quickly get code
A second MCU on the board handles the USB interface and properly
loads the binary code into the ARM MCU's Flash memory. Each new binary file
overwrites the previous one and the new code runs upon reset of the MCU.
The online compiler lists the libraries on the left side of the
display under the "My Project" folder. Click on the Serial library,
for example, and you get the serial-port information, a list of the functions,
and a description of each.† The online
Handbook also provides information about library functions. The mbed people
have done an excellent job with documentation for the libraries. Within a few
minutes I had figured out how to change the simple program to turn other LEDs
on or off. The Handbook's section, "Programming the mbed Microcontroller,"
also provides some short LED-Flash programs.
The board lacks a JTAG connector and the compiler does not
include any debug capabilities, so you must fall back on techniques such as
flashing LEDs when errors occur or using printf(), error(), or putc() to
transmit information back to a host PC and a terminal emulator such as
HyperTerm via the USB cable and a virtual serial port. The mbed MCU provides three serial ports, so
you also could transmit debug information to a small external printer or LCD. You
cannot trace programs, set breakpoints, or watch variables with the compiler. I'll
discuss debugging again below.
Because the mbed software is still fairly new, the source code
for the libraries will likely change. So as of March 2010 it's not available
for those of us who would like to delve into and peruse the source. The mbed
folks don't want to have us modify open-source code right now, which could lead
to many "forks" in library developments. Of course, developers can
jump into the LPC1768 at the chip level and write their own code to control,
say, one of the chip's I2C or PWM devices. Find documentation for the LPC1768
MCU on the NXP website. The LPC17xx User Manual (UM10360), Rev. 01, runs to
over 800 pages. (Keep in mind that neither mbed nor NXP "support" the
libraries with technical assistance.)
Next I decided to set up a serial output port to communicate with
a 4-line alphanumeric LCD. The mbed libraries simplify identifying one of the
ports, setting the baud rate, and sending a character at a time ‚ÄĒ or a string ‚ÄĒ to the LCD. The LCD requires an "inverted" serial stream with a
logic-1 start bit, so I had to breadboard an inverter for the serial output to
the display. After that, my 10-line C++ program continuously sent printing
ASCII information to the display.
The mbed board supplies 40 square pins, with 20 down each long
side of the module and a 0.9-inch space between rows. You can plug the module
into a solderless breadboard and have one solderless connection per module pin.
Getting a module out of a solderless breadboard can get a bit tricky, though,
due to the force exerted on all 40 square pins. The pins also work well for
wire-wrap connections.† If you want
better access to the I/O pins, you can build a breakout board, find someone who
has already created such a board, or buy something like the LPCXpresso Base
Board from Embedded Artists. This board has many
capabilities and I/O devices you can use. Price: about 90 Euros.
The mbed hardware has spawned an active user community that
exchanges information on the mbed.org site via a forum and a blog. After you
register at mbed.org you can post your own comments and queries.
"Notebooks" on the website let people post code, circuits and other
information to help others. So, when you need more information about how to use
the Ethernet port, for example, you can find it here.
Now you might wonder how you go from an mbed board to your own
prototype. The online C/C++ compiler creates a standard binary file, so you can
continue to use it to write programs for the NXP LPC1768 ARM chip, or for other
NXP ARM MCUs. Chris Styles, a member of the mbed staff, has posted,
"Prototype to hardware" on the site to explain how he used the MCU's
built-in boot loader for in-system-programming (ISP) of an LPC2368. (He thought
he had soldered an LPC1768 in a breadboard, but he had picked up a different
MCU. No problem, though. The process worked just fine.)
You can read about Chris' experience and how he went from the
mbed to his prototype, and you
can download his code. Also, see Chapter 32 in the User Manual noted earlier.
Although the NXP ARM chips can provide both standard JTAG and ARM
Serial Wire Debug modes, Chris' technique does not use them. Instead, the ISP
technique uses two pins for serial I/O. The lack of a JTAG port on the mbed
module limits debugging to the basic techniques noted previously. On your
prototype, though, you could route the signals for the JTAG pins to a header
and use a commercial JTAG pod such as the IAR J-Trace for ARM Cortex-M3.
If you want to use a virtual serial port to let an mbed module
communicate with a PC's terminal emulator, you must install the mbed USB
driver. Go to the online mbed Handbook and locate the section "USB
Serial" on the opening page.† Click
on "Windows Driver" to go to the page that explains how to download
and install the mbed-USB driver.† Connect
your mbed board to your PC. Find
HyperTerminal at:† Programs-->Accessories-->Communications
After you install the Windows serial driver, you should find a
new serial port in the Device Manager.†
Now, when you use HyperTerminal, set it to use this port number, COM(number)
as the serial port. Set the bit rate to 9,600 bits/sec, 8 data bits, no parity,
one stop bit.
Your mbed code must open the USB-serial communications channel: Serial pc(USBTX, USBRX); and then the code can transmit to and receive from the host PC.
The mbed defaults to 9600 bits/sec, 8N1, so you don't have to explicitly
establish these parameters. Then you can use a command such as: pc.putc(data_to_send);
in your code.
A sample program on the mbed site includes the use of a
USB-serial port and an X-CTU program from Digi International (the supplier of
the XBee modules). I posted more details about the setup and use of this code
in a Notebook page for "XBee Communications."† The code worked fine, once I
"uncovered" some of the missing details.