NuMaker Modbus-RS485

Dependencies:   Modbus nvt_rs485

Fork of modbus-over-rs485-sample by Wayne Lin

Committer:
shliu1
Date:
Tue Dec 13 11:13:47 2016 +0800
Revision:
2:ea05f8a719a9
Child:
3:6087ac36c45f
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:ea05f8a719a9 1
shliu1 2:ea05f8a719a9 2 # Getting started with NuMaker-mbed-modbus-sample on mbed OS
shliu1 2:ea05f8a719a9 3
shliu1 2:ea05f8a719a9 4 The code works on an mbed OS platform. It needs run with some NuMaker-PFM-NUC472 boards, it includes the application of Modbus protocol and RS485 port.
shliu1 2:ea05f8a719a9 5 Please refer to the documents on the website https://github.com/OpenNuvoton/NuMaker_NuWicam_Samples/ for more details
shliu1 2:ea05f8a719a9 6
shliu1 2:ea05f8a719a9 7 Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli).
shliu1 2:ea05f8a719a9 8
shliu1 2:ea05f8a719a9 9 ## Get the example application!
shliu1 2:ea05f8a719a9 10
shliu1 2:ea05f8a719a9 11 Ontain the mbed-OS library from Windows command prompt
shliu1 2:ea05f8a719a9 12
shliu1 2:ea05f8a719a9 13 git clone https://github.com/ARMmbed/mbed-os
shliu1 2:ea05f8a719a9 14
shliu1 2:ea05f8a719a9 15
shliu1 2:ea05f8a719a9 16 From the command line of Git Bash, for example:
shliu1 2:ea05f8a719a9 17
shliu1 2:ea05f8a719a9 18 ```
shliu1 2:ea05f8a719a9 19 hg clone https://developer.mbed.org/teams/Nuvoton/code/NuMaker-mbed-modbus-sample/
shliu1 2:ea05f8a719a9 20 cd NuMaker-mbed-modbus-sample
shliu1 2:ea05f8a719a9 21
shliu1 2:ea05f8a719a9 22 ```
shliu1 2:ea05f8a719a9 23
shliu1 2:ea05f8a719a9 24 Make shortcut for mbed-os, modbus and nvt_rs485 libraries within the folder NuMaker-mbed-modbus-sample
shliu1 2:ea05f8a719a9 25
shliu1 2:ea05f8a719a9 26 ### Now compile
shliu1 2:ea05f8a719a9 27
shliu1 2:ea05f8a719a9 28 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:ea05f8a719a9 29
shliu1 2:ea05f8a719a9 30 ```
shliu1 2:ea05f8a719a9 31 mbed compile -m NUMAKER_PFM_NUC472 -t ARM
shliu1 2:ea05f8a719a9 32 ```
shliu1 2:ea05f8a719a9 33
shliu1 2:ea05f8a719a9 34 Your PC may take a few minutes to compile your code. At the end you should get the following result:
shliu1 2:ea05f8a719a9 35
shliu1 2:ea05f8a719a9 36 ```
shliu1 2:ea05f8a719a9 37 +------------------------+-------+-------+---------+
shliu1 2:ea05f8a719a9 38 | Module | .text | .data | .bss |
shliu1 2:ea05f8a719a9 39 +------------------------+-------+-------+---------+
shliu1 2:ea05f8a719a9 40 | Misc | 18452 | 238 | 1052256 |
shliu1 2:ea05f8a719a9 41 | drivers | 2357 | 4 | 28 |
shliu1 2:ea05f8a719a9 42 | features/FEATURE_LWIP | 162 | 16 | 16 |
shliu1 2:ea05f8a719a9 43 | hal | 842 | 8 | 0 |
shliu1 2:ea05f8a719a9 44 | platform | 1919 | 16 | 92 |
shliu1 2:ea05f8a719a9 45 | rtos | 144 | 8 | 0 |
shliu1 2:ea05f8a719a9 46 | rtos/rtx | 6946 | 100 | 8396 |
shliu1 2:ea05f8a719a9 47 | targets/TARGET_NUVOTON | 9538 | 272 | 312 |
shliu1 2:ea05f8a719a9 48 | Subtotals | 40360 | 662 | 1061100 |
shliu1 2:ea05f8a719a9 49 +------------------------+-------+-------+---------+
shliu1 2:ea05f8a719a9 50 Allocated Heap: unknown
shliu1 2:ea05f8a719a9 51 Allocated Stack: unknown
shliu1 2:ea05f8a719a9 52 Total Static RAM memory (data + bss): 1061762 bytes
shliu1 2:ea05f8a719a9 53 Total RAM memory (data + bss + heap + stack): 1061762 bytes
shliu1 2:ea05f8a719a9 54 Total Flash memory (text + data + misc): 41022 bytes
shliu1 2:ea05f8a719a9 55 ```
shliu1 2:ea05f8a719a9 56
shliu1 2:ea05f8a719a9 57 ### Program your board
shliu1 2:ea05f8a719a9 58
shliu1 2:ea05f8a719a9 59 1. Connect your mbed device to the computer over USB.
shliu1 2:ea05f8a719a9 60 1. Copy the binary file to the mbed device .
shliu1 2:ea05f8a719a9 61 1. Press the reset button to start the program.
shliu1 2:ea05f8a719a9 62
shliu1 2:ea05f8a719a9 63 Please refer to the documents at the path https://github.com/OpenNuvoton/NuMaker_NuWicam_Samples/
shliu1 2:ea05f8a719a9 64
shliu1 2:ea05f8a719a9 65 ## Export the project to Keil MDK and debug your application
shliu1 2:ea05f8a719a9 66
shliu1 2:ea05f8a719a9 67 From the command line, run the following command:
shliu1 2:ea05f8a719a9 68
shliu1 2:ea05f8a719a9 69 ```
shliu1 2:ea05f8a719a9 70 mbed export -m NUMAKER_PFM_NUC472 -i uvision
shliu1 2:ea05f8a719a9 71 ```
shliu1 2:ea05f8a719a9 72
shliu1 2:ea05f8a719a9 73 To debug the application:
shliu1 2:ea05f8a719a9 74
shliu1 2:ea05f8a719a9 75 1. Start uVision.
shliu1 2:ea05f8a719a9 76 1. Import the uVision project generated earlier.
shliu1 2:ea05f8a719a9 77 1. Compile your application and generate an `.axf` file.
shliu1 2:ea05f8a719a9 78 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:ea05f8a719a9 79 1. Set breakpoints and start a debug session.
shliu1 2:ea05f8a719a9 80
shliu1 2:ea05f8a719a9 81 ![Image of uVision](img/uvision.png)
shliu1 2:ea05f8a719a9 82
shliu1 2:ea05f8a719a9 83 ## Troubleshooting
shliu1 2:ea05f8a719a9 84
shliu1 2:ea05f8a719a9 85 1. Make sure `mbed-cli` is working correctly and its version is greater than `0.8.9`
shliu1 2:ea05f8a719a9 86
shliu1 2:ea05f8a719a9 87 ```
shliu1 2:ea05f8a719a9 88 mbed --version
shliu1 2:ea05f8a719a9 89 ```
shliu1 2:ea05f8a719a9 90
shliu1 2:ea05f8a719a9 91 If not, you can update it easily:
shliu1 2:ea05f8a719a9 92
shliu1 2:ea05f8a719a9 93 ```
shliu1 2:ea05f8a719a9 94 pip install mbed-cli --upgrade
shliu1 2:ea05f8a719a9 95 ```
shliu1 2:ea05f8a719a9 96
shliu1 2:ea05f8a719a9 97 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:ea05f8a719a9 98
shliu1 2:ea05f8a719a9 99