• 沒有找到結果。

Step-by-Step

在文檔中 NUC1XX Quick Start Guide for Keil (頁 9-23)

2.   Quick Start

2.4.  Step-by-Step

This section details all of the materials necessary to download code to an ARM-based development board for debug in the KeilTM μVision4 IDE using the JTAG debug agent.

2.4.1. Starting the software

Double-click on the Keil uVision4 icon to start the user interface. The compiler, assembler, linker and Scope will be called from within Keil uVision4 in this tutorial. After you invoke Keil uVision4, the window shown as below appears. From this window, you can create projects, edit files, configure the tool, assemble, link, and invoke the debugger.

2.4.2. Creating a new project

Before writing any C-code, a project associated with our code needs to be created. This is done by first creating a new folder in the Keil directory in which your project will be saved. Next the Keil uV4 application can be launched and a new project is created. This is achieved by completing the following steps.

z Create a folder named “CodeTemplate” in your setting path z Launch the uV4 application. Start -> Programs -> Keil μVision4

z Create a new project. From the main window, choose the ‘Project’ menu and select New project . And then a new window appears as shown below

z Select the folder that you've created previously ( CodeTemplate ) and on the bottom of the window type the name of your new project, eg. CodeTemplate and press SAVE.

2.4.3. Device Support

A new window appears as shown below and you are now required to configure your setup to target the specific ARM device you wish to use (in this example we will be using the Cortex-M0) and the output file format generated after the compilation stage. This is achieved by completing the following steps.

z Open the ARM folder.

z Select the item on which you will be developing, in this tech note we will be using the Cortex-M0 as the target example.

2.4.4. Project Management

Keil uVision4 ensures easy and consistent Project Management. A single project file stores source file names and saves configuration information for Compiler, Assembler, Linker, Debugger, Flash Loader, and other utilities. The Project menu provides access to project files and dialogs for project management.

Select the icon to open Management Project Component Setting

A Project Component Setting window appears as shown below. According to your assignment, create new group and link your source code.

Finally, the project workspace will show as below:

2.4.5. Creating a C program

Now you also can write your C program. In the main window, choose the File pull-down menu and select New. A new window named <text1> will appear on the screen and you can write your code to

<text1>.

Once you've typed all the code, again choose the File pull-down menu and select Save. A new Save dialog window appears. Save your new file as “main.c” in the CodeTemplate folder you had created earlier. At this stage, before compiling the C-program, we need to include it in our project. To do this you must click with the right mouse button on ‘Source files ’and select Add Files to Group ‘Source Library’ as shown below. Select the file named “main.c“ that is in the CodeTemplate folder and click on Add and then on Close.

Target

Group

Source File

Include File

2.4.6. Compiling a C program

Select Rebuild all target files from the Project menu, or click on the Rebuild all button (icon).

All of the source files are compiled and linked. The activity can be seen in the Build window at the bottom of the μVision4 IDE. (In this example, the process completes with an application named CodeTemplate.axf and CodeTemplate.bin built with no errors and no warnings.)

2.4.7. Connecting and Configuring the Hardware

Step-by-step to finished the section.

1. Click on Project => Options for Target => your_target_name. Or click on the Options for Target button (icon).

2. On Target tab, allows you to specify CPU and memory options. These are used to configure basic

tool settings including those of the linker, debugger, and simulator.

3. The setting dialog show up in a window on the center. Click Debug tab and Select ULINK Cortex Debugger. You might need to select this from the drop-down menu if it is not already selected. If you want to load the application when starting debug mode, please enable the check box of Load Application at Startup.

2.4.8. Simulating your source code

Another powerful feature of the uVision4 IDE is that it allows you to run your code. To start a simulation session you simply click on the on Start/Stop Debug Session option available from the Debug pull-down menu. Alternatively you can press <Cntrl+F7> or the ‘Debug’ icon available in the

‘File’ toolbar as shown as below.

The IDE switches to debugging mode. The processor registers show up in a window on the left, the debugger command window is visible at the bottom, and the main window shows the source code being debugged.

Instruction

Disassembly Window Project

Workspace

C Source Code Tab Register Tab

From here, you can examine and modify memory, program variables, and processor registers, set breakpoints, single step, and all other typical debugging activities. To run the program, select Run from the Debug menu, or click on the Run button (icon).

2.4.9. Flash Tool

Keil tool chain supports to download image file to NUC1xx DEV Board through ICE interface. A specified flash tool file should be provided to let Keil flash download function work. For NUC1xx series IC, the flash tool is called NUC1XX_128kB.FLM NUC1XX_64kB.FLM

NUC1XX_328kB.FLM for different flash size and this file could be found at \FlashTool.

To install the NUC1xx_128kB.FLM, we need to copy it to the install directory of Keil, i.e.

C:\ARM\Flash. After copy NUC1xx_128kB.FLM to the specified directory, we can go back to the Keil IDE, open the Options for Targets dialog, select Utilities tab and open the Settings dialog.

After the Settings button has been pressed, the Flash Download Setup dialog would be opened. Then we can set the start address to be 0x20000000, size to be 0x4000 in RAM for Algorithm setting.

Finally, we press the Add button to add the flash tool. If the NUC1xx_128kB.FLM was copy to

\Keil\ARM\Flash, we should be able to find NUC1xx_128kB item in Add dialog:

After find the NUC1XX_128kB item, press Add button to add it to Flash Download Setup dialog.

Now, we can press ok to finish the setting.

Note: Due to the flash base address is 0x00000000, we should set the RO base of linker according to the flash base address.

2.4.10. Conclusion

You have now installed the KeilTM RealView® Microcontroller Development Kit, and used it to build, load, and run a demonstration application on your Nuvoton® Development Board. From here, you can experiment with the debugger or start creating your own application using the

CodeTemplate program as an example. If CodeTemplate project sample starts running, and you should see some text output to the hyper terminal display as shown as below:

在文檔中 NUC1XX Quick Start Guide for Keil (頁 9-23)

相關文件