Compiling the code
Get the code
From your command-line, import the example:
$ mbed import https://github.com/ARMmbed/mbed-os-example-blinky $ cd mbed-os-example-blinky
Compile and program your board:
mbed compile, and specify the name of your platform and your installed toolchain (
IAR). For example, for the K64F platform and Arm Compiler 5 toolchain:
$ mbed compile --target K64F --toolchain ARM --flash
--flashargument automatically flashes the compiled program onto your board if it is connected to your computer.
Tip: You can get the name of the board plugged into your computer by running
mbed detect, and you can get a full list of supported toolchains and targets by running the
mbed compile --supportedcommand.
Press the board's reset button. The LED blinks.
The quick start example blinks the LED on your board on and off. The main thread also takes a snapshot of the device's runtime statistics and displays them over a serial connection to your PC.
Viewing the output
The default baud rate, or speed, for this application is set to
9600. You can modify it in the
mbed_app.json file. To configure your terminal client to this baud rate, change the speed option when selecting the port.
Tip: You can find more information on the Mbed OS configuration tools and serial communication in Mbed OS in the related links section.
The output transmits the following block at the blinking LED frequency (actual values may vary depending on your target, build profile and toolchain):
=============================== SYSTEM INFO ================================ Mbed OS Version: 999999 CPU ID: 0x410fc241 Compiler ID: 2 Compiler Version: 60300 RAM0: Start 0x20000000 Size: 0x30000 RAM1: Start 0x1fff0000 Size: 0x10000 ROM0: Start 0x0 Size: 0x100000 ================= CPU STATS ================= Idle: 98% Usage: 2% ================ HEAP STATS ================= Current heap: 1096 Max heap size: 1096 ================ THREAD STATS =============== ID: 0x20001eac Name: main_thread State: 2 Priority: 24 Stack Size: 4096 Stack Space: 3296 ID: 0x20000f5c Name: idle_thread State: 1 Priority: 1 Stack Size: 512 Stack Space: 352 ID: 0x20000f18 Name: timer_thread State: 3 Priority: 40 Stack Size: 768 Stack Space: 664
Understanding the output
Mbed OS version: Tip of master is represented by 999999. If you are using a tagged release of Mbed OS, the version will be configured by the OS. For custom releases, you can modify the version manually in
CPUID register information:
|Bit Field||Field Description||Values|
|[31:24]||Implementer||0x41 = ARM|
|[23:20]||Variant||Major revision 0x0 = Revision 0|
|[19:16]||Architecture||0xC = Baseline Architecture|
|0xF = Constant (Mainline Architecture)|
|[15:4]||Part Number||0xC20 = Cortex-M0|
|0xC60 = Cortex-M0+|
|0xC23 = Cortex-M3|
|0xC24 = Cortex-M4|
|0xC27 = Cortex-M7|
|0xD20 = Cortex-M23|
|0xD21 = Cortex-M33|
|[3:0]||Revision||Minor revision: 0x1 = Patch 1|
Compiler ID and version:
|Compiler||Version tag||Version layout|
|ARM||1||PVVbbbb (P = Major; VV = Minor; bbbb = build number)|
|GCC_ARM||2||VVRRPP (VV = Version; RR = Revision; PP = Patch)|
|IAR||3||VRRRPPP (V = Version; RRR = Revision; PPP = Patch)|
Percentage of runtime the device has spent awake.
- Current heap size.
- Maximum size the heap has ever reached (not the maximum size it can reach).
Provides information on all running threads in the OS:
- Stack size.
- Stack space.