NuMaker GPIO button with LED and buzzer

Committer:
rkuo2000
Date:
Thu Oct 13 10:39:25 2016 +0000
Revision:
0:f700c61f47e5
GPIO : SW1 & SW2 input to control LED, RGBLED, Buzzer output

Who changed what in which revision?

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