NTUES lab 2 BLE
Dependencies: mbed X_NUCLEO_IDB0XA1 BLE_API
README.md@0:088a3171bdab, 2019-05-14 (annotated)
- Committer:
- whz861025
- Date:
- Tue May 14 12:45:44 2019 +0000
- Revision:
- 0:088a3171bdab
heartRate ble done;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
whz861025 | 0:088a3171bdab | 1 | # Getting started example for Mbed OS |
whz861025 | 0:088a3171bdab | 2 | |
whz861025 | 0:088a3171bdab | 3 | This guide reviews the steps required to get Blinky with the addition of dynamic OS statistics working on an Mbed OS platform. (Note: To see a rendered example you can import into the Arm Online Compiler, please see our [quick start](https://os.mbed.com/docs/mbed-os/latest/quick-start/online-with-the-online-compiler.html#importing-the-code).) |
whz861025 | 0:088a3171bdab | 4 | |
whz861025 | 0:088a3171bdab | 5 | Please install [Mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli). |
whz861025 | 0:088a3171bdab | 6 | |
whz861025 | 0:088a3171bdab | 7 | ## Import the example application |
whz861025 | 0:088a3171bdab | 8 | |
whz861025 | 0:088a3171bdab | 9 | From the command-line, import the example: |
whz861025 | 0:088a3171bdab | 10 | |
whz861025 | 0:088a3171bdab | 11 | ``` |
whz861025 | 0:088a3171bdab | 12 | mbed import mbed-os-example-blinky |
whz861025 | 0:088a3171bdab | 13 | cd mbed-os-example-blinky |
whz861025 | 0:088a3171bdab | 14 | ``` |
whz861025 | 0:088a3171bdab | 15 | |
whz861025 | 0:088a3171bdab | 16 | ### Now compile |
whz861025 | 0:088a3171bdab | 17 | |
whz861025 | 0:088a3171bdab | 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: |
whz861025 | 0:088a3171bdab | 19 | |
whz861025 | 0:088a3171bdab | 20 | ``` |
whz861025 | 0:088a3171bdab | 21 | mbed compile -m K64F -t ARM |
whz861025 | 0:088a3171bdab | 22 | ``` |
whz861025 | 0:088a3171bdab | 23 | |
whz861025 | 0:088a3171bdab | 24 | Your PC may take a few minutes to compile your code. At the end, you see the following result: |
whz861025 | 0:088a3171bdab | 25 | |
whz861025 | 0:088a3171bdab | 26 | ``` |
whz861025 | 0:088a3171bdab | 27 | [snip] |
whz861025 | 0:088a3171bdab | 28 | |
whz861025 | 0:088a3171bdab | 29 | Image: ./BUILD/K64F/GCC_ARM/mbed-os-example-blinky.bin |
whz861025 | 0:088a3171bdab | 30 | ``` |
whz861025 | 0:088a3171bdab | 31 | |
whz861025 | 0:088a3171bdab | 32 | ### Program your board |
whz861025 | 0:088a3171bdab | 33 | |
whz861025 | 0:088a3171bdab | 34 | 1. Connect your Mbed device to the computer over USB. |
whz861025 | 0:088a3171bdab | 35 | 1. Copy the binary file to the Mbed device. |
whz861025 | 0:088a3171bdab | 36 | 1. Press the reset button to start the program. |
whz861025 | 0:088a3171bdab | 37 | |
whz861025 | 0:088a3171bdab | 38 | The LED on your platform turns on and off. The main thread will additionally take a snapshot of the device's runtime statistics and display it over serial to your PC. The snapshot includes: |
whz861025 | 0:088a3171bdab | 39 | |
whz861025 | 0:088a3171bdab | 40 | * System Information: |
whz861025 | 0:088a3171bdab | 41 | * Mbed OS Version: Will currently default to 999999 |
whz861025 | 0:088a3171bdab | 42 | * Compiler ID |
whz861025 | 0:088a3171bdab | 43 | * ARM = 1 |
whz861025 | 0:088a3171bdab | 44 | * GCC_ARM = 2 |
whz861025 | 0:088a3171bdab | 45 | * IAR = 3 |
whz861025 | 0:088a3171bdab | 46 | * [CPUID Register Information](#cpuid-register-information) |
whz861025 | 0:088a3171bdab | 47 | * [Compiler Version](#compiler-version) |
whz861025 | 0:088a3171bdab | 48 | * CPU Statistics |
whz861025 | 0:088a3171bdab | 49 | * Percentage of runtime that the device has spent awake versus in sleep |
whz861025 | 0:088a3171bdab | 50 | * Heap Statistics |
whz861025 | 0:088a3171bdab | 51 | * Current heap size |
whz861025 | 0:088a3171bdab | 52 | * Max heap size which refers to the largest the heap has grown to |
whz861025 | 0:088a3171bdab | 53 | * Thread Statistics |
whz861025 | 0:088a3171bdab | 54 | * Provides information on all running threads in the OS including |
whz861025 | 0:088a3171bdab | 55 | * Thread ID |
whz861025 | 0:088a3171bdab | 56 | * Thread Name |
whz861025 | 0:088a3171bdab | 57 | * Thread State |
whz861025 | 0:088a3171bdab | 58 | * Thread Priority |
whz861025 | 0:088a3171bdab | 59 | * Thread Stack Size |
whz861025 | 0:088a3171bdab | 60 | * Thread Stack Space |
whz861025 | 0:088a3171bdab | 61 | |
whz861025 | 0:088a3171bdab | 62 | #### Compiler Version |
whz861025 | 0:088a3171bdab | 63 | |
whz861025 | 0:088a3171bdab | 64 | | Compiler | Version Layout | |
whz861025 | 0:088a3171bdab | 65 | | -------- | -------------- | |
whz861025 | 0:088a3171bdab | 66 | | ARM | PVVbbbb (P = Major; VV = Minor; bbbb = build number) | |
whz861025 | 0:088a3171bdab | 67 | | GCC | VVRRPP (VV = Version; RR = Revision; PP = Patch) | |
whz861025 | 0:088a3171bdab | 68 | | IAR | VRRRPPP (V = Version; RRR = Revision; PPP = Patch) | |
whz861025 | 0:088a3171bdab | 69 | |
whz861025 | 0:088a3171bdab | 70 | #### CPUID Register Information |
whz861025 | 0:088a3171bdab | 71 | |
whz861025 | 0:088a3171bdab | 72 | | Bit Field | Field Description | Values | |
whz861025 | 0:088a3171bdab | 73 | | --------- | ----------------- | ------ | |
whz861025 | 0:088a3171bdab | 74 | |[31:24] | Implementer | 0x41 = ARM | |
whz861025 | 0:088a3171bdab | 75 | |[23:20] | Variant | Major revision 0x0 = Revision 0 | |
whz861025 | 0:088a3171bdab | 76 | |[19:16] | Architecture | 0xC = Baseline Architecture | |
whz861025 | 0:088a3171bdab | 77 | | | | 0xF = Constant (Mainline Architecture) | |
whz861025 | 0:088a3171bdab | 78 | |[15:4] | Part Number | 0xC20 = Cortex-M0 | |
whz861025 | 0:088a3171bdab | 79 | | | | 0xC60 = Cortex-M0+ | |
whz861025 | 0:088a3171bdab | 80 | | | | 0xC23 = Cortex-M3 | |
whz861025 | 0:088a3171bdab | 81 | | | | 0xC24 = Cortex-M4 | |
whz861025 | 0:088a3171bdab | 82 | | | | 0xC27 = Cortex-M7 | |
whz861025 | 0:088a3171bdab | 83 | | | | 0xD20 = Cortex-M23 | |
whz861025 | 0:088a3171bdab | 84 | | | | 0xD21 = Cortex-M33 | |
whz861025 | 0:088a3171bdab | 85 | |[3:0] | Revision | Minor revision: 0x1 = Patch 1 | |
whz861025 | 0:088a3171bdab | 86 | |
whz861025 | 0:088a3171bdab | 87 | |
whz861025 | 0:088a3171bdab | 88 | |
whz861025 | 0:088a3171bdab | 89 | You can view individual examples and additional API information of the statistics collection tools at the bottom of the page in the [related links section](#related-links). |
whz861025 | 0:088a3171bdab | 90 | |
whz861025 | 0:088a3171bdab | 91 | |
whz861025 | 0:088a3171bdab | 92 | ### Output |
whz861025 | 0:088a3171bdab | 93 | |
whz861025 | 0:088a3171bdab | 94 | To view the serial output you can use any terminal client of your choosing such as [PuTTY](http://www.putty.org/) or [CoolTerm](http://freeware.the-meiers.org/). Unless otherwise specified, printf defaults to a baud rate of 9600 on Mbed OS. |
whz861025 | 0:088a3171bdab | 95 | |
whz861025 | 0:088a3171bdab | 96 | You can find more information on the Mbed OS configuration tools and serial communication in Mbed OS in the related [related links section](#related-links). |
whz861025 | 0:088a3171bdab | 97 | |
whz861025 | 0:088a3171bdab | 98 | The output should contain the following block transmitted at the blinking LED frequency (actual values may vary depending on your target, build profile, and toolchain): |
whz861025 | 0:088a3171bdab | 99 | |
whz861025 | 0:088a3171bdab | 100 | ``` |
whz861025 | 0:088a3171bdab | 101 | =============================== SYSTEM INFO ================================ |
whz861025 | 0:088a3171bdab | 102 | Mbed OS Version: 999999 |
whz861025 | 0:088a3171bdab | 103 | CPU ID: 0x410fc241 |
whz861025 | 0:088a3171bdab | 104 | Compiler ID: 2 |
whz861025 | 0:088a3171bdab | 105 | Compiler Version: 60300 |
whz861025 | 0:088a3171bdab | 106 | RAM0: Start 0x20000000 Size: 0x30000 |
whz861025 | 0:088a3171bdab | 107 | RAM1: Start 0x1fff0000 Size: 0x10000 |
whz861025 | 0:088a3171bdab | 108 | ROM0: Start 0x0 Size: 0x100000 |
whz861025 | 0:088a3171bdab | 109 | ================= CPU STATS ================= |
whz861025 | 0:088a3171bdab | 110 | Idle: 98% Usage: 2% |
whz861025 | 0:088a3171bdab | 111 | ================ HEAP STATS ================= |
whz861025 | 0:088a3171bdab | 112 | Current heap: 1096 |
whz861025 | 0:088a3171bdab | 113 | Max heap size: 1096 |
whz861025 | 0:088a3171bdab | 114 | ================ THREAD STATS =============== |
whz861025 | 0:088a3171bdab | 115 | ID: 0x20001eac |
whz861025 | 0:088a3171bdab | 116 | Name: main_thread |
whz861025 | 0:088a3171bdab | 117 | State: 2 |
whz861025 | 0:088a3171bdab | 118 | Priority: 24 |
whz861025 | 0:088a3171bdab | 119 | Stack Size: 4096 |
whz861025 | 0:088a3171bdab | 120 | Stack Space: 3296 |
whz861025 | 0:088a3171bdab | 121 | |
whz861025 | 0:088a3171bdab | 122 | ID: 0x20000f5c |
whz861025 | 0:088a3171bdab | 123 | Name: idle_thread |
whz861025 | 0:088a3171bdab | 124 | State: 1 |
whz861025 | 0:088a3171bdab | 125 | Priority: 1 |
whz861025 | 0:088a3171bdab | 126 | Stack Size: 512 |
whz861025 | 0:088a3171bdab | 127 | Stack Space: 352 |
whz861025 | 0:088a3171bdab | 128 | |
whz861025 | 0:088a3171bdab | 129 | ID: 0x20000f18 |
whz861025 | 0:088a3171bdab | 130 | Name: timer_thread |
whz861025 | 0:088a3171bdab | 131 | State: 3 |
whz861025 | 0:088a3171bdab | 132 | Priority: 40 |
whz861025 | 0:088a3171bdab | 133 | Stack Size: 768 |
whz861025 | 0:088a3171bdab | 134 | Stack Space: 664 |
whz861025 | 0:088a3171bdab | 135 | |
whz861025 | 0:088a3171bdab | 136 | ``` |
whz861025 | 0:088a3171bdab | 137 | |
whz861025 | 0:088a3171bdab | 138 | ## Troubleshooting |
whz861025 | 0:088a3171bdab | 139 | |
whz861025 | 0:088a3171bdab | 140 | 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. |
whz861025 | 0:088a3171bdab | 141 | |
whz861025 | 0:088a3171bdab | 142 | ## Related Links |
whz861025 | 0:088a3171bdab | 143 | |
whz861025 | 0:088a3171bdab | 144 | * [Mbed OS Stats API](https://os.mbed.com/docs/latest/apis/mbed-statistics.html) |
whz861025 | 0:088a3171bdab | 145 | * [Mbed OS Configuration](https://os.mbed.com/docs/latest/reference/configuration.html) |
whz861025 | 0:088a3171bdab | 146 | * [Mbed OS Serial Communication](https://os.mbed.com/docs/latest/tutorials/serial-communication.html) |
whz861025 | 0:088a3171bdab | 147 | |
whz861025 | 0:088a3171bdab | 148 | ### License and contributions |
whz861025 | 0:088a3171bdab | 149 | |
whz861025 | 0:088a3171bdab | 150 | The software is provided under Apache-2.0 license. Contributions to this project are accepted under the same license. Please see contributing.md for more info. |
whz861025 | 0:088a3171bdab | 151 | |
whz861025 | 0:088a3171bdab | 152 | This project contains code from other projects. The original license text is included in those source files. They must comply with our license guide. |