This is a very simple guide, reviewing the steps required to get Blinky working on an Mbed OS platform.
Mbed OS Blinky
This example shows the use of a DigitalOut object to represent an LED and use of the nonblocking Thread::wait()
call. Using nonblocking calls is good practice because Mbed OS can schedule and run other threads while the first thread is waiting.
Building this example
Building with Arm Mbed CLI
To use Mbed CLI to build this example, follow the instructions in the documentation. The instructions here relate to using the Arm Online Compiler.
To use the Online Compiler, import this code into the Online Compiler, and select your platform from the top right. Compile the code using the compile button, load it onto your board and press the reset button on the board. The code will run on the board, and you will see the LED blink.
You can find more instructions for using the Mbed Online Compiler in the documentation.
README.md@59:4c739d732e0d, 2018-02-13 (annotated)
- Committer:
- mbed_official
- Date:
- Tue Feb 13 17:00:02 2018 +0000
- Revision:
- 59:4c739d732e0d
- Parent:
- 57:98afe5d5ae5c
- Child:
- 82:abf1b1785bd7
Merge pull request #113 from adbridge/master
Updating mbed-os to mbed-os-5.7.5
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-blinky
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jonathan Austin |
0:2757d7abb7d9 | 1 | # Getting started with Blinky on mbed OS |
Jonathan Austin |
0:2757d7abb7d9 | 2 | |
mbed_official | 27:e64a31d541da | 3 | This guide reviews the steps required to get Blinky working on an mbed OS platform. |
Jonathan Austin |
0:2757d7abb7d9 | 4 | |
Jonathan Austin |
0:2757d7abb7d9 | 5 | Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli). |
Jonathan Austin |
0:2757d7abb7d9 | 6 | |
mbed_official | 27:e64a31d541da | 7 | ## Import the example application |
Jonathan Austin |
0:2757d7abb7d9 | 8 | |
mbed_official | 27:e64a31d541da | 9 | From the command-line, import the example: |
Jonathan Austin |
0:2757d7abb7d9 | 10 | |
Jonathan Austin |
0:2757d7abb7d9 | 11 | ``` |
Jonathan Austin |
0:2757d7abb7d9 | 12 | mbed import mbed-os-example-blinky |
Jonathan Austin |
0:2757d7abb7d9 | 13 | cd mbed-os-example-blinky |
Jonathan Austin |
0:2757d7abb7d9 | 14 | ``` |
Jonathan Austin |
0:2757d7abb7d9 | 15 | |
Jonathan Austin |
0:2757d7abb7d9 | 16 | ### Now compile |
Jonathan Austin |
0:2757d7abb7d9 | 17 | |
mbed_official | 27:e64a31d541da | 18 | Invoke `mbed compile`, and specify the name of your platform and your favorite toolchain (`GCC_ARM`, `ARM`, `IAR`). For example, for the ARM Compiler 5: |
Jonathan Austin |
0:2757d7abb7d9 | 19 | |
Jonathan Austin |
0:2757d7abb7d9 | 20 | ``` |
Jonathan Austin |
0:2757d7abb7d9 | 21 | mbed compile -m K64F -t ARM |
Jonathan Austin |
0:2757d7abb7d9 | 22 | ``` |
Jonathan Austin |
0:2757d7abb7d9 | 23 | |
mbed_official | 27:e64a31d541da | 24 | Your PC may take a few minutes to compile your code. At the end, you see the following result: |
Jonathan Austin |
0:2757d7abb7d9 | 25 | |
Jonathan Austin |
0:2757d7abb7d9 | 26 | ``` |
Jonathan Austin |
0:2757d7abb7d9 | 27 | [snip] |
Jonathan Austin |
0:2757d7abb7d9 | 28 | +----------------------------+-------+-------+------+ |
Jonathan Austin |
0:2757d7abb7d9 | 29 | | Module | .text | .data | .bss | |
Jonathan Austin |
0:2757d7abb7d9 | 30 | +----------------------------+-------+-------+------+ |
Jonathan Austin |
0:2757d7abb7d9 | 31 | | Misc | 13939 | 24 | 1372 | |
Jonathan Austin |
0:2757d7abb7d9 | 32 | | core/hal | 16993 | 96 | 296 | |
Jonathan Austin |
0:2757d7abb7d9 | 33 | | core/rtos | 7384 | 92 | 4204 | |
Jonathan Austin |
0:2757d7abb7d9 | 34 | | features/FEATURE_IPV4 | 80 | 0 | 176 | |
Jonathan Austin |
0:2757d7abb7d9 | 35 | | frameworks/greentea-client | 1830 | 60 | 44 | |
Jonathan Austin |
0:2757d7abb7d9 | 36 | | frameworks/utest | 2392 | 512 | 292 | |
Jonathan Austin |
0:2757d7abb7d9 | 37 | | Subtotals | 42618 | 784 | 6384 | |
Jonathan Austin |
0:2757d7abb7d9 | 38 | +----------------------------+-------+-------+------+ |
Jonathan Austin |
0:2757d7abb7d9 | 39 | Allocated Heap: unknown |
Jonathan Austin |
0:2757d7abb7d9 | 40 | Allocated Stack: unknown |
Jonathan Austin |
0:2757d7abb7d9 | 41 | Total Static RAM memory (data + bss): 7168 bytes |
Jonathan Austin |
0:2757d7abb7d9 | 42 | Total RAM memory (data + bss + heap + stack): 7168 bytes |
Jonathan Austin |
0:2757d7abb7d9 | 43 | Total Flash memory (text + data + misc): 43402 bytes |
Jonathan Austin |
1:846c97078558 | 44 | Image: .\.build\K64F\ARM\mbed-os-example-blinky.bin |
Jonathan Austin |
0:2757d7abb7d9 | 45 | ``` |
Jonathan Austin |
0:2757d7abb7d9 | 46 | |
Jonathan Austin |
0:2757d7abb7d9 | 47 | ### Program your board |
Jonathan Austin |
0:2757d7abb7d9 | 48 | |
Jonathan Austin |
0:2757d7abb7d9 | 49 | 1. Connect your mbed device to the computer over USB. |
mbed_official | 27:e64a31d541da | 50 | 1. Copy the binary file to the mbed device. |
Jonathan Austin |
0:2757d7abb7d9 | 51 | 1. Press the reset button to start the program. |
Jonathan Austin |
0:2757d7abb7d9 | 52 | |
mbed_official | 27:e64a31d541da | 53 | The LED on your platform turns on and off. |
Jonathan Austin |
0:2757d7abb7d9 | 54 | |
Jonathan Austin |
0:2757d7abb7d9 | 55 | ## Troubleshooting |
Jonathan Austin |
0:2757d7abb7d9 | 56 | |
mbed_official | 54:64a293b4da54 | 57 | If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it. |