NuMaker PWM0 play notes (to speaker)

Committer:
rkuo2000
Date:
Fri Oct 14 06:13:22 2016 +0000
Revision:
0:c3a30c36f19d
NuMaker-PFM-NUC472 : PWM output to play note (to a speaker)

Who changed what in which revision?

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