Application Tutorial. freescale ColdFire v6.0
বিজ্ঞাপন
বিজ্ঞাপন
CF.book Page 25 Friday, July 8, 2005 8:59 AM
3
Application Tutorial
This chapter takes you through the CodeWarrior™ IDE programming environment. This tutorial does not teach you programming. It instead teaches you how to use the
CodeWarrior IDE to write and debug applications for a target platform.
Before you start the tutorial, you must set up your target evaluation board (EVB).
Typically, this entails:
• Verifying all jumper-header and switch settings,
• Connecting a serial cable between the EVB and your computer, and
• Connecting EVB power.
NOTE
For complete setup instructions, see the EVB’s own documentation.
This chapter consists of these sections:
Create a Project
This section shows how to use stationery to create a new project for a ColdFire EVB, and how to set up the project to make a standalone application. Follow these steps:
ColdFire Architectures v6.0 - Targeting Manual 25
CF.book Page 26 Friday, July 8, 2005 8:59 AM
Application Tutorial
Create a Project
1. Select
Programs > Metrowerks CodeWarrior > CodeWarrior for ColdFire
V6.0 > CodeWarrior IDE. The CodeWarrior IDE starts and the main window
Figure 3.1 CodeWarrior IDE Main Window
26 ColdFire Architectures v6.0 - Targeting Manual
CF.book Page 27 Friday, July 8, 2005 8:59 AM
Application Tutorial
Create a Project
2. From the main menu bar, select
File > New. The New dialog box (Figure 3.2)
appears.
Figure 3.2 New Dialog Box
a. Select ColdFire Stationery.
b. In the Project name text box, type MyProj.
NOTE
The default project location is the CodeWarrior installation directory. For example, if the project name is abc and the installation directory is
CodeWarrior_Dir
, the default location is CodeWarrior_Dir\abc.
For a different location, click the Set button, then use the subsequent dialog box to specify the location. Clicking OK returns you to the New dialog box, which shows the specified location in the Location text box.
ColdFire Architectures v6.0 - Targeting Manual 27
CF.book Page 28 Friday, July 8, 2005 8:59 AM
Application Tutorial
Create a Project
c. Click OK. The New Project dialog box (Figure 3.3) appears.
Figure 3.3 New Project Dialog Box
3. Specify CF_M5213EVB C stationery.
a. Click the CF_M5213EVB expand control — the tree structure displays the subordinate option C.
b. Select C, as Figure 3.4 shows.
Figure 3.4 New Project Dialog Box: Selecting M5213 C Stationery
28
NOTE
Many possible ColdFire target processors have an external bus, so can use large external RAM devices for debugging applications during development.
But M521x processors do not have an external bus, so must accommodate applications in on-chip memory. Although this on-chip RAM accommodates
CodeWarrior stationery, it probably is too small for full development of your application. Accordingly, for an M521x processor, you should locate your
ColdFire Architectures v6.0 - Targeting Manual
CF.book Page 29 Friday, July 8, 2005 8:59 AM
Application Tutorial
Create a Project
applications in flash memory. (The Flash Programmer subsection explains how
to program a flash device.) c. Click OK. The CodeWarrior IDE creates a new project consisting of the folders and files (header, initialization, common, and so forth) that the M5213 C stationery
specifies. The project window (Figure 3.5) appears.
Figure 3.5 Project Window
4. Make sure that the target field (immediately under the project-window tab) specifies
M5213EVB Console Debug.
NOTE
Files in the project data folder include information about the project file, various target settings, and object code. Do not change the contents of this folder, or the CodeWarrior IDE could lose project settings.
5. This completes project creation. You are ready to build the project, per the procedure of the next section.
NOTE
While your source file (main.c) is open in the editor window, you can use all editor features to work with your code.
If you wish, you can use a third-party editor to create and edit your code, provided that this editor saves the file as plain text.
For information about the editor window, touching files, and file synchronization, and removing/adding text files, see IDE User’s Guide.
ColdFire Architectures v6.0 - Targeting Manual 29
CF.book Page 30 Friday, July 8, 2005 8:59 AM
Application Tutorial
Build the Project
Build the Project
This section shows how to select the linker, set up remote debugging, and build (compile and link) your project.
NOTE
The stationery for this project includes a default setup for the linker specific to the application’s target platform.
Follow these steps:
1. Select the appropriate linker.
a. Select Edit > Target Settings (where Target is the name of the current build
target). The Target Settings window (Figure 3.6) appears.
Figure 3.6 Target Settings Window: Target Settings Panel
30 b. From the Target Settings Panels list, select Target Settings. The Target Settings panel moves to the front of the window.
c. Use the Linker list box to specify the Embedded ColdFire Linker.
d. Click Apply. The IDE saves the new linker setting for the build target.
NOTE
This linker change applies only to the current build target. To use a different build target, you must specify its appropriate linker.
ColdFire Architectures v6.0 - Targeting Manual
CF.book Page 31 Friday, July 8, 2005 8:59 AM
Application Tutorial
Build the Project
For an actual target board, instead of the simulator, you would need to make board connections by this point.
2. Set Up Remote Debugging.
a. From the Target Settings Panels list, select Remote Debugging. The Remote
Debugging settings panel moves to the front of the Target Settings window, as
Figure 3.7 Target Settings Window: Remote Debugging Panel
b. Use the Connection list box to specify CCS-SIM.
c. Click OK. The IDE completes the remote debugging setup, and the Target
Settings window closes.
3. From the main menu bar, select
Project > Make
. The IDE updates all files, links code into the finished application, and displays any error messages or warnings in the
Errors & Warnings window.
NOTE
The Make command applies to all source files: the IDE opens them all, the compiler generates object code, then the linker creates an executable file.
(The Compile command applies only to selected files. The Bring Up To Date command compiles all changed files, without linking.)
The Project window lets you view compiler progress, or stop the build.
ColdFire Architectures v6.0 - Targeting Manual 31
CF.book Page 32 Friday, July 8, 2005 8:59 AM
Application Tutorial
Debug the Application
4. This completes building your project. You are ready for the debugging procedure of the next section.
Debug the Application
This section explains you how to test whether your application runs as you expect. Topics include starting the debugger, setting a breakpoint, and viewing registers. Follow these steps:
1. Set debugger preferences.
a. Select Edit > Target Settings, (where Target is the name of the current build target). The Target Settings window appears.
b. From the Target Settings Panels list, select CF Debugger Settings. The CF
Debugger Settings panel moves to the front of the window, as Figure 3.8 shows.
Figure 3.8 The CF Debugger Settings Panel
32 c. Make sure that the Target Processor list box specifies 521x.
d. Make sure that the Target OS list box specifies BareBoard.
e. Click OK. The IDE saves the debugger settings, and the Target Settings window closes.
ColdFire Architectures v6.0 - Targeting Manual
CF.book Page 33 Friday, July 8, 2005 8:59 AM
Application Tutorial
Debug the Application
NOTE
The default target initialization and memory configuration files are in subdirectory \E68K_Support\Initialization_Files, of the
CodeWarrior installation directory.
2. From the IDE main menu, select Project > Debug. A progress bar appears as the system downloads the output file to the target. The debugger starts; the Debugger
NOTE
For a ROM build target, you must load the application to Flash memory before you can perform Step 2.
Figure 3.9 Debugger Window
a. Note the toolbar at the top of the window; it includes command buttons Run, Stop,
Kill, Step Over, Step Into, and Step Out.
b. Note the Stack pane, at the upper left. This pane shows the function calling stack.
c. Note the Variables pane, at the upper right. This pane lists the names and values of any local variables.
d. Note the Source pane, the largest pane of the window. This pane displays source code or assembly code.
ColdFire Architectures v6.0 - Targeting Manual 33
CF.book Page 34 Friday, July 8, 2005 8:59 AM
Application Tutorial
Debug the Application
3. Set a breakpoint.
a. In the Source pane, find the line containing the open brace ( { ) character.
b. In the far left-hand column of this line, click the grey dash. A red circle replaces the
dash, indicating that the debugger set a breakpoint at the location. Figure 3.10
shows the red-circle indicator.
Figure 3.10 Setting a breakpoint
34
Breakpoint
4. View registers.
a. From the main menu bar, select View > Registers. The Registers window
b. Use the expand controls to drill down through register categories to individual registers — when you reach individual registers, their values appear at the right side of the window.
c. You may edit register values directly in the Registers window.
d. Close the Registers window.
ColdFire Architectures v6.0 - Targeting Manual
CF.book Page 35 Friday, July 8, 2005 8:59 AM
Figure 3.11 Registers Window
Application Tutorial
Debug the Application
5. View memory.
a. In the Source pane of the Debugger window, right-click on main. The view-
memory context menu (Figure 3.12) appears.
Figure 3.12 View Memory Context Menu
ColdFire Architectures v6.0 - Targeting Manual 35
CF.book Page 36 Friday, July 8, 2005 8:59 AM
Application Tutorial
Debug the Application
b. From this context menu, select View Memory. The View Memory window Figure
Figure 3.13 View Memory Window
c. Note that the View Memory window displays hexadecimal and ascii values for several addresses, starting at the address of main.
d. In the Display text box, type a valid address in RAM or ROM.
e. Press the Enter key. Window contents change, to display memory values starting at the address you entered.
NOTE
You can edit the contents of the View Memory window. This window also lets you disassemble a random part of memory.
f. Close the View Memory window.
36 ColdFire Architectures v6.0 - Targeting Manual
CF.book Page 37 Friday, July 8, 2005 8:59 AM
Application Tutorial
Debug the Application
6. Run the application.
a. From the main menu bar, select Project > Run, or click the Run button of
the Debugger window. A console window (Figure 3.14) appears, displaying the
Hello-World-message result of the application.
Figure 3.14 Console Window
b. Click the Kill button of the Debugger window. The debugger stops the application, the IDE stops the debugger, and the Debugger widow closes.
c. This completes the procedure — you have created and debugged a simple application. You may close any open windows.
ColdFire Architectures v6.0 - Targeting Manual 37
CF.book Page 38 Friday, July 8, 2005 8:59 AM
Application Tutorial
Debug the Application
38 ColdFire Architectures v6.0 - Targeting Manual
ডাউনলোড
বিজ্ঞাপন