![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Motion sensor program
README.md@2:a5a643b0eb25, 2019-09-18 (annotated)
- Committer:
- Niranjan_ravi
- Date:
- Wed Sep 18 00:38:49 2019 +0000
- Revision:
- 2:a5a643b0eb25
- Parent:
- 0:f665d23ec68a
I2C-Acc-Mag
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Niranjan_ravi | 0:f665d23ec68a | 1 | # Getting started example for Mbed OS |
Niranjan_ravi | 0:f665d23ec68a | 2 | |
Niranjan_ravi | 0:f665d23ec68a | 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).) |
Niranjan_ravi | 0:f665d23ec68a | 4 | |
Niranjan_ravi | 0:f665d23ec68a | 5 | Please install [Mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli). |
Niranjan_ravi | 0:f665d23ec68a | 6 | |
Niranjan_ravi | 0:f665d23ec68a | 7 | ## Import the example application |
Niranjan_ravi | 0:f665d23ec68a | 8 | |
Niranjan_ravi | 0:f665d23ec68a | 9 | From the command-line, import the example: |
Niranjan_ravi | 0:f665d23ec68a | 10 | |
Niranjan_ravi | 0:f665d23ec68a | 11 | ``` |
Niranjan_ravi | 0:f665d23ec68a | 12 | mbed import mbed-os-example-blinky |
Niranjan_ravi | 0:f665d23ec68a | 13 | cd mbed-os-example-blinky |
Niranjan_ravi | 0:f665d23ec68a | 14 | ``` |
Niranjan_ravi | 0:f665d23ec68a | 15 | |
Niranjan_ravi | 0:f665d23ec68a | 16 | ### Now compile |
Niranjan_ravi | 0:f665d23ec68a | 17 | |
Niranjan_ravi | 0:f665d23ec68a | 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: |
Niranjan_ravi | 0:f665d23ec68a | 19 | |
Niranjan_ravi | 0:f665d23ec68a | 20 | ``` |
Niranjan_ravi | 0:f665d23ec68a | 21 | mbed compile -m K64F -t ARM |
Niranjan_ravi | 0:f665d23ec68a | 22 | ``` |
Niranjan_ravi | 0:f665d23ec68a | 23 | |
Niranjan_ravi | 0:f665d23ec68a | 24 | Your PC may take a few minutes to compile your code. At the end, you see the following result: |
Niranjan_ravi | 0:f665d23ec68a | 25 | |
Niranjan_ravi | 0:f665d23ec68a | 26 | ``` |
Niranjan_ravi | 0:f665d23ec68a | 27 | [snip] |
Niranjan_ravi | 0:f665d23ec68a | 28 | |
Niranjan_ravi | 0:f665d23ec68a | 29 | Image: ./BUILD/K64F/GCC_ARM/mbed-os-example-blinky.bin |
Niranjan_ravi | 0:f665d23ec68a | 30 | ``` |
Niranjan_ravi | 0:f665d23ec68a | 31 | |
Niranjan_ravi | 0:f665d23ec68a | 32 | ### Program your board |
Niranjan_ravi | 0:f665d23ec68a | 33 | |
Niranjan_ravi | 0:f665d23ec68a | 34 | 1. Connect your Mbed device to the computer over USB. |
Niranjan_ravi | 0:f665d23ec68a | 35 | 1. Copy the binary file to the Mbed device. |
Niranjan_ravi | 0:f665d23ec68a | 36 | 1. Press the reset button to start the program. |
Niranjan_ravi | 0:f665d23ec68a | 37 | |
Niranjan_ravi | 0:f665d23ec68a | 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: |
Niranjan_ravi | 0:f665d23ec68a | 39 | |
Niranjan_ravi | 0:f665d23ec68a | 40 | * System Information: |
Niranjan_ravi | 0:f665d23ec68a | 41 | * Mbed OS Version: Will currently default to 999999 |
Niranjan_ravi | 0:f665d23ec68a | 42 | * Compiler ID |
Niranjan_ravi | 0:f665d23ec68a | 43 | * ARM = 1 |
Niranjan_ravi | 0:f665d23ec68a | 44 | * GCC_ARM = 2 |
Niranjan_ravi | 0:f665d23ec68a | 45 | * IAR = 3 |
Niranjan_ravi | 0:f665d23ec68a | 46 | * [CPUID Register Information](#cpuid-register-information) |
Niranjan_ravi | 0:f665d23ec68a | 47 | * [Compiler Version](#compiler-version) |
Niranjan_ravi | 0:f665d23ec68a | 48 | * CPU Statistics |
Niranjan_ravi | 0:f665d23ec68a | 49 | * Percentage of runtime that the device has spent awake versus in sleep |
Niranjan_ravi | 0:f665d23ec68a | 50 | * Heap Statistics |
Niranjan_ravi | 0:f665d23ec68a | 51 | * Current heap size |
Niranjan_ravi | 0:f665d23ec68a | 52 | * Max heap size which refers to the largest the heap has grown to |
Niranjan_ravi | 0:f665d23ec68a | 53 | * Thread Statistics |
Niranjan_ravi | 0:f665d23ec68a | 54 | * Provides information on all running threads in the OS including |
Niranjan_ravi | 0:f665d23ec68a | 55 | * Thread ID |
Niranjan_ravi | 0:f665d23ec68a | 56 | * Thread Name |
Niranjan_ravi | 0:f665d23ec68a | 57 | * Thread State |
Niranjan_ravi | 0:f665d23ec68a | 58 | * Thread Priority |
Niranjan_ravi | 0:f665d23ec68a | 59 | * Thread Stack Size |
Niranjan_ravi | 0:f665d23ec68a | 60 | * Thread Stack Space |
Niranjan_ravi | 0:f665d23ec68a | 61 | |
Niranjan_ravi | 0:f665d23ec68a | 62 | #### Compiler Version |
Niranjan_ravi | 0:f665d23ec68a | 63 | |
Niranjan_ravi | 0:f665d23ec68a | 64 | | Compiler | Version Layout | |
Niranjan_ravi | 0:f665d23ec68a | 65 | | -------- | -------------- | |
Niranjan_ravi | 0:f665d23ec68a | 66 | | ARM | PVVbbbb (P = Major; VV = Minor; bbbb = build number) | |
Niranjan_ravi | 0:f665d23ec68a | 67 | | GCC | VVRRPP (VV = Version; RR = Revision; PP = Patch) | |
Niranjan_ravi | 0:f665d23ec68a | 68 | | IAR | VRRRPPP (V = Version; RRR = Revision; PPP = Patch) | |
Niranjan_ravi | 0:f665d23ec68a | 69 | |
Niranjan_ravi | 0:f665d23ec68a | 70 | #### CPUID Register Information |
Niranjan_ravi | 0:f665d23ec68a | 71 | |
Niranjan_ravi | 0:f665d23ec68a | 72 | | Bit Field | Field Description | Values | |
Niranjan_ravi | 0:f665d23ec68a | 73 | | --------- | ----------------- | ------ | |
Niranjan_ravi | 0:f665d23ec68a | 74 | |[31:24] | Implementer | 0x41 = ARM | |
Niranjan_ravi | 0:f665d23ec68a | 75 | |[23:20] | Variant | Major revision 0x0 = Revision 0 | |
Niranjan_ravi | 0:f665d23ec68a | 76 | |[19:16] | Architecture | 0xC = Baseline Architecture | |
Niranjan_ravi | 0:f665d23ec68a | 77 | | | | 0xF = Constant (Mainline Architecture) | |
Niranjan_ravi | 0:f665d23ec68a | 78 | |[15:4] | Part Number | 0xC20 = Cortex-M0 | |
Niranjan_ravi | 0:f665d23ec68a | 79 | | | | 0xC60 = Cortex-M0+ | |
Niranjan_ravi | 0:f665d23ec68a | 80 | | | | 0xC23 = Cortex-M3 | |
Niranjan_ravi | 0:f665d23ec68a | 81 | | | | 0xC24 = Cortex-M4 | |
Niranjan_ravi | 0:f665d23ec68a | 82 | | | | 0xC27 = Cortex-M7 | |
Niranjan_ravi | 0:f665d23ec68a | 83 | | | | 0xD20 = Cortex-M23 | |
Niranjan_ravi | 0:f665d23ec68a | 84 | | | | 0xD21 = Cortex-M33 | |
Niranjan_ravi | 0:f665d23ec68a | 85 | |[3:0] | Revision | Minor revision: 0x1 = Patch 1 | |
Niranjan_ravi | 0:f665d23ec68a | 86 | |
Niranjan_ravi | 0:f665d23ec68a | 87 | |
Niranjan_ravi | 0:f665d23ec68a | 88 | |
Niranjan_ravi | 0:f665d23ec68a | 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). |
Niranjan_ravi | 0:f665d23ec68a | 90 | |
Niranjan_ravi | 0:f665d23ec68a | 91 | |
Niranjan_ravi | 0:f665d23ec68a | 92 | ### Output |
Niranjan_ravi | 0:f665d23ec68a | 93 | |
Niranjan_ravi | 0:f665d23ec68a | 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. |
Niranjan_ravi | 0:f665d23ec68a | 95 | |
Niranjan_ravi | 0:f665d23ec68a | 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). |
Niranjan_ravi | 0:f665d23ec68a | 97 | |
Niranjan_ravi | 0:f665d23ec68a | 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): |
Niranjan_ravi | 0:f665d23ec68a | 99 | |
Niranjan_ravi | 0:f665d23ec68a | 100 | ``` |
Niranjan_ravi | 0:f665d23ec68a | 101 | =============================== SYSTEM INFO ================================ |
Niranjan_ravi | 0:f665d23ec68a | 102 | Mbed OS Version: 999999 |
Niranjan_ravi | 0:f665d23ec68a | 103 | CPU ID: 0x410fc241 |
Niranjan_ravi | 0:f665d23ec68a | 104 | Compiler ID: 2 |
Niranjan_ravi | 0:f665d23ec68a | 105 | Compiler Version: 60300 |
Niranjan_ravi | 0:f665d23ec68a | 106 | RAM0: Start 0x20000000 Size: 0x30000 |
Niranjan_ravi | 0:f665d23ec68a | 107 | RAM1: Start 0x1fff0000 Size: 0x10000 |
Niranjan_ravi | 0:f665d23ec68a | 108 | ROM0: Start 0x0 Size: 0x100000 |
Niranjan_ravi | 0:f665d23ec68a | 109 | ================= CPU STATS ================= |
Niranjan_ravi | 0:f665d23ec68a | 110 | Idle: 98% Usage: 2% |
Niranjan_ravi | 0:f665d23ec68a | 111 | ================ HEAP STATS ================= |
Niranjan_ravi | 0:f665d23ec68a | 112 | Current heap: 1096 |
Niranjan_ravi | 0:f665d23ec68a | 113 | Max heap size: 1096 |
Niranjan_ravi | 0:f665d23ec68a | 114 | ================ THREAD STATS =============== |
Niranjan_ravi | 0:f665d23ec68a | 115 | ID: 0x20001eac |
Niranjan_ravi | 0:f665d23ec68a | 116 | Name: main_thread |
Niranjan_ravi | 0:f665d23ec68a | 117 | State: 2 |
Niranjan_ravi | 0:f665d23ec68a | 118 | Priority: 24 |
Niranjan_ravi | 0:f665d23ec68a | 119 | Stack Size: 4096 |
Niranjan_ravi | 0:f665d23ec68a | 120 | Stack Space: 3296 |
Niranjan_ravi | 0:f665d23ec68a | 121 | |
Niranjan_ravi | 0:f665d23ec68a | 122 | ID: 0x20000f5c |
Niranjan_ravi | 0:f665d23ec68a | 123 | Name: idle_thread |
Niranjan_ravi | 0:f665d23ec68a | 124 | State: 1 |
Niranjan_ravi | 0:f665d23ec68a | 125 | Priority: 1 |
Niranjan_ravi | 0:f665d23ec68a | 126 | Stack Size: 512 |
Niranjan_ravi | 0:f665d23ec68a | 127 | Stack Space: 352 |
Niranjan_ravi | 0:f665d23ec68a | 128 | |
Niranjan_ravi | 0:f665d23ec68a | 129 | ID: 0x20000f18 |
Niranjan_ravi | 0:f665d23ec68a | 130 | Name: timer_thread |
Niranjan_ravi | 0:f665d23ec68a | 131 | State: 3 |
Niranjan_ravi | 0:f665d23ec68a | 132 | Priority: 40 |
Niranjan_ravi | 0:f665d23ec68a | 133 | Stack Size: 768 |
Niranjan_ravi | 0:f665d23ec68a | 134 | Stack Space: 664 |
Niranjan_ravi | 0:f665d23ec68a | 135 | |
Niranjan_ravi | 0:f665d23ec68a | 136 | ``` |
Niranjan_ravi | 0:f665d23ec68a | 137 | |
Niranjan_ravi | 0:f665d23ec68a | 138 | ## Troubleshooting |
Niranjan_ravi | 0:f665d23ec68a | 139 | |
Niranjan_ravi | 0:f665d23ec68a | 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. |
Niranjan_ravi | 0:f665d23ec68a | 141 | |
Niranjan_ravi | 0:f665d23ec68a | 142 | ## Related Links |
Niranjan_ravi | 0:f665d23ec68a | 143 | |
Niranjan_ravi | 0:f665d23ec68a | 144 | * [Mbed OS Stats API](https://os.mbed.com/docs/latest/apis/mbed-statistics.html) |
Niranjan_ravi | 0:f665d23ec68a | 145 | * [Mbed OS Configuration](https://os.mbed.com/docs/latest/reference/configuration.html) |
Niranjan_ravi | 0:f665d23ec68a | 146 | * [Mbed OS Serial Communication](https://os.mbed.com/docs/latest/tutorials/serial-communication.html) |
Niranjan_ravi | 0:f665d23ec68a | 147 | |
Niranjan_ravi | 0:f665d23ec68a | 148 | ### License and contributions |
Niranjan_ravi | 0:f665d23ec68a | 149 | |
Niranjan_ravi | 0:f665d23ec68a | 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. |
Niranjan_ravi | 0:f665d23ec68a | 151 | |
Niranjan_ravi | 0:f665d23ec68a | 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. |