Example of using the mq2 library

Dependencies:   MQ2

Committer:
azazeal88
Date:
Fri Oct 06 09:36:16 2017 +0000
Revision:
2:3a61e56476bc
Parent:
0:1e2a25e50796
RC1

Who changed what in which revision?

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