Mbed BK Ed2 CH 2
Mbed BK Ed2 CH 2
Mbed BK Ed2 CH 2
If you use or reference these slides or the associated textbook, please cite the original authors’ work as follows:
Toulson, R. & Wilmshurst, T. (2016). Fast and Effective Embedded Systems Design - Applying the ARM mbed
(2nd edition), Newnes, Oxford, ISBN: 978-0-08-100880-5.
www.embedded-knowhow.co.uk
Introducing the mbed LPC1768
The mbed takes a microcontroller, the LPC1768, and surrounds it with some
very useful support circuitry. It places this on a conveniently-sized little printed
circuit board (PCB), and supports it with an on-line compiler, program library and
handbook.
NXP LPC1768
Microcontroller
Introducing the mbed
The mbed takes the form of a 2 inch by 1 inch printed circuit board, with 40 pins
arranged in two rows of 20, with 0.1 inch spacing between the pins. There are
five LEDs on the board, one for status and four which are connected to four
microcontroller digital outputs. A reset switch is included, to force restart of the
current program.
The mbed Architecture
At the heart of the mbed is the LPC1768 microcontroller. The signal pins of the
mbed connect directly to the microcontroller. There is a second microcontroller
(the “interface microcontroller”) on the mbed, which interfaces with the USB.
This manages the
USB link, and acts
as a USB terminal
to the host
computer. It also
receives program
code files through
the USB, and
transfers them to a
16 Mbit memory,
the “USB Disk”.
The LPC1768 Microcontroller
The C++ compiler means that all files will carry the .cpp (C plus plus) extension.
C however is a subset of C++, and is simpler to learn and apply. This is because
it doesn’t use the more advanced “object-oriented” aspects of C++. In general, C
code will compile on a C++ compiler, but not the other way round.
C is usually the language of choice for any embedded program of low or medium
complexity, so will suit us well in this module. For simplicity therefore, we can use
only C in the programs we develop. We need to recognise however that the mbed
API is written in C++, and uses the features of that language to the full.
Getting Started with the mbed
Go to the mbed home page, connect your mbed, and follow the tutorial
instructions to complete these steps:
• Create an account,
• Open the compiler and create a program;
• Compile the program;
• Download to your mbed;
• Run the program!
The Opening Program
#include "mbed.h"
DigitalOut myled(LED1);
int main() {
while(1) {
myled = 1;
wait(0.2);
myled = 0;
wait(0.2);
}
}
The mbed Application Board
This board has a number of the most interesting peripheral devices that we might
want to connect to the mbed, like display, joystick, potentiometers, certain
sensors and connectors. The mbed plugs into the board, and a physical
connection with all the peripheral devices is then immediately made. The mbed
has to be programmed correctly before it can drive these external devices.