TUKS MCU Introductory course / TUKS-COURSE-THERMOMETER

Fork of TUKS-COURSE-TIMER by TUKS MCU Introductory course

Committer:
elmot
Date:
Fri Feb 24 21:06:51 2017 +0000
Revision:
0:a9bbfbd216e8
Two-Leds-Example

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elmot 0:a9bbfbd216e8 1 # Getting started with Blinky on mbed OS
elmot 0:a9bbfbd216e8 2
elmot 0:a9bbfbd216e8 3 This is a very simple guide, reviewing the steps required to get Blinky working on an mbed OS platform.
elmot 0:a9bbfbd216e8 4
elmot 0:a9bbfbd216e8 5 Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli).
elmot 0:a9bbfbd216e8 6
elmot 0:a9bbfbd216e8 7 ## Get the example application!
elmot 0:a9bbfbd216e8 8
elmot 0:a9bbfbd216e8 9 From the command line, import the example:
elmot 0:a9bbfbd216e8 10
elmot 0:a9bbfbd216e8 11 ```
elmot 0:a9bbfbd216e8 12 mbed import mbed-os-example-blinky
elmot 0:a9bbfbd216e8 13 cd mbed-os-example-blinky
elmot 0:a9bbfbd216e8 14 ```
elmot 0:a9bbfbd216e8 15
elmot 0:a9bbfbd216e8 16 ### Now compile
elmot 0:a9bbfbd216e8 17
elmot 0:a9bbfbd216e8 18 Invoke `mbed compile` specifying the name of your platform and your favorite toolchain (`GCC_ARM`, `ARM`, `IAR`). For example, for the ARM Compiler 5:
elmot 0:a9bbfbd216e8 19
elmot 0:a9bbfbd216e8 20 ```
elmot 0:a9bbfbd216e8 21 mbed compile -m K64F -t ARM
elmot 0:a9bbfbd216e8 22 ```
elmot 0:a9bbfbd216e8 23
elmot 0:a9bbfbd216e8 24 Your PC may take a few minutes to compile your code. At the end you should get the following result:
elmot 0:a9bbfbd216e8 25
elmot 0:a9bbfbd216e8 26 ```
elmot 0:a9bbfbd216e8 27 [snip]
elmot 0:a9bbfbd216e8 28 +----------------------------+-------+-------+------+
elmot 0:a9bbfbd216e8 29 | Module | .text | .data | .bss |
elmot 0:a9bbfbd216e8 30 +----------------------------+-------+-------+------+
elmot 0:a9bbfbd216e8 31 | Misc | 13939 | 24 | 1372 |
elmot 0:a9bbfbd216e8 32 | core/hal | 16993 | 96 | 296 |
elmot 0:a9bbfbd216e8 33 | core/rtos | 7384 | 92 | 4204 |
elmot 0:a9bbfbd216e8 34 | features/FEATURE_IPV4 | 80 | 0 | 176 |
elmot 0:a9bbfbd216e8 35 | frameworks/greentea-client | 1830 | 60 | 44 |
elmot 0:a9bbfbd216e8 36 | frameworks/utest | 2392 | 512 | 292 |
elmot 0:a9bbfbd216e8 37 | Subtotals | 42618 | 784 | 6384 |
elmot 0:a9bbfbd216e8 38 +----------------------------+-------+-------+------+
elmot 0:a9bbfbd216e8 39 Allocated Heap: unknown
elmot 0:a9bbfbd216e8 40 Allocated Stack: unknown
elmot 0:a9bbfbd216e8 41 Total Static RAM memory (data + bss): 7168 bytes
elmot 0:a9bbfbd216e8 42 Total RAM memory (data + bss + heap + stack): 7168 bytes
elmot 0:a9bbfbd216e8 43 Total Flash memory (text + data + misc): 43402 bytes
elmot 0:a9bbfbd216e8 44 Image: .\.build\K64F\ARM\mbed-os-example-blinky.bin
elmot 0:a9bbfbd216e8 45 ```
elmot 0:a9bbfbd216e8 46
elmot 0:a9bbfbd216e8 47 ### Program your board
elmot 0:a9bbfbd216e8 48
elmot 0:a9bbfbd216e8 49 1. Connect your mbed device to the computer over USB.
elmot 0:a9bbfbd216e8 50 1. Copy the binary file to the mbed device .
elmot 0:a9bbfbd216e8 51 1. Press the reset button to start the program.
elmot 0:a9bbfbd216e8 52
elmot 0:a9bbfbd216e8 53 You should see the LED of your platform turning on and off.
elmot 0:a9bbfbd216e8 54
elmot 0:a9bbfbd216e8 55 Congratulations if you managed to complete this test!
elmot 0:a9bbfbd216e8 56
elmot 0:a9bbfbd216e8 57 ## Export the project to Keil MDK and debug your application
elmot 0:a9bbfbd216e8 58
elmot 0:a9bbfbd216e8 59 From the command line, run the following command:
elmot 0:a9bbfbd216e8 60
elmot 0:a9bbfbd216e8 61 ```
elmot 0:a9bbfbd216e8 62 mbed export -m K64F -i uvision
elmot 0:a9bbfbd216e8 63 ```
elmot 0:a9bbfbd216e8 64
elmot 0:a9bbfbd216e8 65 To debug the application:
elmot 0:a9bbfbd216e8 66
elmot 0:a9bbfbd216e8 67 1. Start uVision.
elmot 0:a9bbfbd216e8 68 1. Import the uVision project generated earlier.
elmot 0:a9bbfbd216e8 69 1. Compile your application and generate an `.axf` file.
elmot 0:a9bbfbd216e8 70 1. Make sure uVision is configured to debug over CMSIS-DAP (From the Project menu > Options for Target '...' > Debug tab > Use CMSIS-DAP Debugger).
elmot 0:a9bbfbd216e8 71 1. Set breakpoints and start a debug session.
elmot 0:a9bbfbd216e8 72
elmot 0:a9bbfbd216e8 73 ![Image of uVision](img/uvision.png)
elmot 0:a9bbfbd216e8 74
elmot 0:a9bbfbd216e8 75 ## Troubleshooting
elmot 0:a9bbfbd216e8 76
elmot 0:a9bbfbd216e8 77 1. Make sure `mbed-cli` is working correctly and its version is `>1.0.0`
elmot 0:a9bbfbd216e8 78
elmot 0:a9bbfbd216e8 79 ```
elmot 0:a9bbfbd216e8 80 mbed --version
elmot 0:a9bbfbd216e8 81 ```
elmot 0:a9bbfbd216e8 82
elmot 0:a9bbfbd216e8 83 If not, you can update it easily:
elmot 0:a9bbfbd216e8 84
elmot 0:a9bbfbd216e8 85 ```
elmot 0:a9bbfbd216e8 86 pip install mbed-cli --upgrade
elmot 0:a9bbfbd216e8 87 ```
elmot 0:a9bbfbd216e8 88
elmot 0:a9bbfbd216e8 89 2. If using Keil MDK, make sure you have a license installed. [MDK-Lite](http://www.keil.com/arm/mdk.asp) has a 32KB restriction on code size.