NuMaker PWM1 drive +5V DC servo motor

Committer:
shliu1
Date:
Tue Dec 13 13:39:14 2016 +0800
Revision:
2:ec4920016fea
Child:
3:59536611f5af
Add README.md and sync mbed-os library to mbed-os 5.2.3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shliu1 2:ec4920016fea 1
shliu1 2:ec4920016fea 2 # Getting started with NuMaker-mbed-PWM1_DCservo on mbed OS
shliu1 2:ec4920016fea 3
shliu1 2:ec4920016fea 4 The code works on an mbed OS platform. The code is that PWM1 outputs to drive DC servo motor.
shliu1 2:ec4920016fea 5
shliu1 2:ec4920016fea 6 Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli).
shliu1 2:ec4920016fea 7
shliu1 2:ec4920016fea 8 ## Get the example application!
shliu1 2:ec4920016fea 9
shliu1 2:ec4920016fea 10 Obtain the mbed-OS library from Windows command prompt
shliu1 2:ec4920016fea 11
shliu1 2:ec4920016fea 12 git clone https://github.com/ARMmbed/mbed-os
shliu1 2:ec4920016fea 13
shliu1 2:ec4920016fea 14
shliu1 2:ec4920016fea 15 From the command line of Git Bash, for example:
shliu1 2:ec4920016fea 16
shliu1 2:ec4920016fea 17 ```
shliu1 2:ec4920016fea 18 hg clone https://developer.mbed.org/teams/Nuvoton/code/NuMaker-mbed-PWM1_DCservo/
shliu1 2:ec4920016fea 19 cd NuMaker-mbed-PWM1_DCservo
shliu1 2:ec4920016fea 20
shliu1 2:ec4920016fea 21 ```
shliu1 2:ec4920016fea 22
shliu1 2:ec4920016fea 23 Make shortcut for mbed-os library within the folder NuMaker-mbed-PWM1_DCservo
shliu1 2:ec4920016fea 24
shliu1 2:ec4920016fea 25 ### Now compile
shliu1 2:ec4920016fea 26
shliu1 2:ec4920016fea 27 Invoke `mbed compile` specifying the name of your platform and your favorite toolchain (`GCC_ARM`, `ARM`, `IAR`). For example, for the ARM Compiler 5:
shliu1 2:ec4920016fea 28
shliu1 2:ec4920016fea 29 ```
shliu1 2:ec4920016fea 30 mbed compile -m NUMAKER_PFM_NUC472 -t ARM
shliu1 2:ec4920016fea 31 ```
shliu1 2:ec4920016fea 32
shliu1 2:ec4920016fea 33 Your PC may take a few minutes to compile your code. At the end you should get the following result:
shliu1 2:ec4920016fea 34
shliu1 2:ec4920016fea 35 ```
shliu1 2:ec4920016fea 36 +------------------------+-------+-------+---------+
shliu1 2:ec4920016fea 37 | Module | .text | .data | .bss |
shliu1 2:ec4920016fea 38 +------------------------+-------+-------+---------+
shliu1 2:ec4920016fea 39 | Misc | 12547 | 16 | 1051616 |
shliu1 2:ec4920016fea 40 | drivers | 444 | 4 | 28 |
shliu1 2:ec4920016fea 41 | features/FEATURE_LWIP | 162 | 16 | 16 |
shliu1 2:ec4920016fea 42 | hal | 358 | 8 | 0 |
shliu1 2:ec4920016fea 43 | platform | 1565 | 16 | 92 |
shliu1 2:ec4920016fea 44 | rtos | 130 | 8 | 0 |
shliu1 2:ec4920016fea 45 | rtos/rtx | 6702 | 100 | 8396 |
shliu1 2:ec4920016fea 46 | targets/TARGET_NUVOTON | 8100 | 276 | 104 |
shliu1 2:ec4920016fea 47 | Subtotals | 30008 | 444 | 1060252 |
shliu1 2:ec4920016fea 48 +------------------------+-------+-------+---------+
shliu1 2:ec4920016fea 49 Allocated Heap: unknown
shliu1 2:ec4920016fea 50 Allocated Stack: unknown
shliu1 2:ec4920016fea 51 Total Static RAM memory (data + bss): 1060696 bytes
shliu1 2:ec4920016fea 52 Total RAM memory (data + bss + heap + stack): 1060696 bytes
shliu1 2:ec4920016fea 53 Total Flash memory (text + data + misc): 30452 bytes
shliu1 2:ec4920016fea 54 ```
shliu1 2:ec4920016fea 55
shliu1 2:ec4920016fea 56 ### Program your board
shliu1 2:ec4920016fea 57
shliu1 2:ec4920016fea 58 1. Connect your mbed device to the computer over USB.
shliu1 2:ec4920016fea 59 1. Copy the binary file to the mbed device .
shliu1 2:ec4920016fea 60 1. Press the reset button to start the program.
shliu1 2:ec4920016fea 61
shliu1 2:ec4920016fea 62 Please refer to the documents at the path https://github.com/OpenNuvoton/NuMaker_NuWicam_Samples/
shliu1 2:ec4920016fea 63
shliu1 2:ec4920016fea 64 ## Export the project to Keil MDK and debug your application
shliu1 2:ec4920016fea 65
shliu1 2:ec4920016fea 66 From the command line, run the following command:
shliu1 2:ec4920016fea 67
shliu1 2:ec4920016fea 68 ```
shliu1 2:ec4920016fea 69 mbed export -m NUMAKER_PFM_NUC472 -i uvision
shliu1 2:ec4920016fea 70 ```
shliu1 2:ec4920016fea 71
shliu1 2:ec4920016fea 72 To debug the application:
shliu1 2:ec4920016fea 73
shliu1 2:ec4920016fea 74 1. Start uVision.
shliu1 2:ec4920016fea 75 1. Import the uVision project generated earlier.
shliu1 2:ec4920016fea 76 1. Compile your application and generate an `.axf` file.
shliu1 2:ec4920016fea 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).
shliu1 2:ec4920016fea 78 1. Set breakpoints and start a debug session.
shliu1 2:ec4920016fea 79
shliu1 2:ec4920016fea 80 ![Image of uVision](img/uvision.png)
shliu1 2:ec4920016fea 81
shliu1 2:ec4920016fea 82 ## Troubleshooting
shliu1 2:ec4920016fea 83
shliu1 2:ec4920016fea 84 1. Make sure `mbed-cli` is working correctly and its version is greater than `0.8.9`
shliu1 2:ec4920016fea 85
shliu1 2:ec4920016fea 86 ```
shliu1 2:ec4920016fea 87 mbed --version
shliu1 2:ec4920016fea 88 ```
shliu1 2:ec4920016fea 89
shliu1 2:ec4920016fea 90 If not, you can update it easily:
shliu1 2:ec4920016fea 91
shliu1 2:ec4920016fea 92 ```
shliu1 2:ec4920016fea 93 pip install mbed-cli --upgrade
shliu1 2:ec4920016fea 94 ```
shliu1 2:ec4920016fea 95
shliu1 2:ec4920016fea 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.
shliu1 2:ec4920016fea 97
shliu1 2:ec4920016fea 98