groep 16 / Mbed OS MoveMotors

Dependencies:   QEI MODSERIAL

Committer:
JonaVonk
Date:
Fri Oct 04 08:25:00 2019 +0000
Revision:
0:6986a58c4515
commit

Who changed what in which revision?

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