This tutorial introduces you to the IAR Embedded Workbench® IDE. The tutorial demonstrates the initial steps in a typical development cycle where you create a project in the IDE, add source files, and use the compiler and the linker to create a small application.Contains utility routines required by Fibonacci.c for the Fibonacci calculations.We recommend that you create a specific directory (with a subdirectory) where you can store all your tutorial files. In this tutorial we call the directory MyTutorials and the subdirectory GettingStarted. You can find all the files needed for the tutorials in the cpuname\tutorials directory (where cpuname reflects the microcontroller you are using) in your IAR Embedded Workbench installation. Copy the files listed above from the tutorials\GettingStarted directory to your MyTutorials\GettingStarted directory.For more information about the concepts related to project management, see the IDE Project Management and Building Guide.Before you can start creating a new project, you must first create a workspace (a workspace is where you collect your projects).
1
2 To create a new project, choose Project>Create New Project.The Create New Project dialog box appears.
3 From the Tool chain drop-down list, choose the toolchain you are using.
4 There are several ready-made project templates to choose from. For this tutorial, select the project template Empty project, which simply creates an empty project that uses default project settings.Click OK.
5 In the standard Save As dialog box that appears, specify where you want to place your project file, which typically would be in your newly created MyTutorials\GettingStarted directory. Specify MyFirstProject in the File name box, and click Save to create the new project.A project file—with the filename extension ewp—will be created in the MyTutorials\GettingStarted directory. This file contains information about your project-specific settings, such as build options.
6 The project appears in the Workspace window:By default, two build configurations are created—Debug and Release—which you view from the drop-down list at the top of the window. In this tutorial, Debug is used.
7 Before you add any files to your project, you should save the workspace. Choose File>Save Workspace and specify where you want to place your workspace file. For this tutorial, place the file in your newly created MyTutorials\GettingStarted directory.A workspace file—with the filename extension eww—has now been created in the MyTutorials\GettingStarted directory. Information about all projects will be stored in this file. Information related to the current session, such as the placement of windows and breakpoints, is located in the files created in the MyTutorials\GettingStarted\settings directory.
1
2 Choose Project>Add files to open a standard browse dialog box.Locate the files Fibonacci.c and Utilities.c and select them in the file selection list; click Open to add them to the MyFirstProject project.This tutorial only contains two source files. However, a real-life project probably contains many source files, maybe hundreds of files. To organize your files logically according to your project needs, you can organize them in hierarchies of groups. Organizing files in hierarchies of groups is useful for many reasons, you can:For more information about how to create advanced project structures, see the IDE Project Management and Building Guide.In the Workspace window, select MyFirstProject – Debug, right-click and choose Options from the context menu. The Target options page in the General Options category is displayed.
2 For this tutorial you can use the default settings. In addition to the default settings, click the List tab, and select the options Output list file and Assembler mnemonics. Click OK.
1 To compile the file Fibonacci.c, select it in the Workspace window, right-click and choose Compile from the context menu.The progress is displayed in the Build messages window.
2 Compile the file Utilities.c in the same manner.The IDE has now created new directories in your project directory. Because you are using the build configuration Debug, a Debug directory has been created that contains these subdirectories:
3 Click on the plus signs in the Workspace window to expand the view. As you can see, the IDE has also created an Output group that contains any generated output files. All included header files are displayed as well, showing the dependencies between the files:Now you will investigate how different optimization levels affect the generated code size. You will do this by changing the optimization level for just one of the files, Utilities.c, which means that you will override the project settings for that file.
1 In the Workspace window, double-click Utilities.lst to open the list file. Examine the list file, which contains this information:
2 Choose Tools>Options to open the IDE Options dialog box and click Editor in the left-side pane. Make sure the option Scan for changed files is selected.Click OK.
3 In the Workspace window, select Utilities.c, right-click and choose Options from the context menu. The compiler options are displayed in the Options dialog box. Select the C/C++ Compiler category.
4 Select the Override inherited settings option, click the Optimizations tab and choose High level of optimization.Click OK.This new setting will only affect Utilities.c. Notice how overriding the project options on file level is indicated with a black checkmark (✓) in the Workspace window.
5 Compile the file Utilities.c a second time. Now you will notice two things. First, note the automatic updating of the open list file due to the selected option Scan for changed files. Second, look at the end of the list file and notice the effect on the code size due to the increased optimization and how it differs from the first compilation.Select Utilities.c in the Workspace window, right-click, and choose Options from the context menu. Deselect Override inherited settings and click OK. Recompile the file Utilities.c.
1 In the Workspace window, select MyFirstProject – Debug, right-click and choose Options from the context menu.
2 In the Options dialog box, select the Linker category and inspect the settings. For this tutorial, pay attention to:Linker listings are created by default, but click the List tab, and make sure that the options Generate linker map file and Generate log file (and some log output suboptions) are selected.Program code and data are placed in memory according to the configuration specified in the linker configuration file (filename extension icf). It is important to be familiar with its syntax for how sections are placed in memory.Read more about the linker configuration file in the IAR C/C++ Development Guide.Click OK.
3 Choose Project>Make. The progress is as usual displayed in the Build messages window. The result of the linking is the code file MyFirstProject.out with debug information located in the Debug\Exe directory and a map file MyFirstProject.map located in the Debug\List directory.
1 Open the MyFirstProject.map file which you can find in the project’s Output group in the Workspace window. The map file typically contains:The MyFirstProject.out application is now ready to be executed in C-SPY.