Setting up a new project

Using the Provided Workspace

Projects in IAR are organized as follows:

  • Each project has corresponding  .ewd and .ewp project files associated with it.
  • .eww "workspace" file groups different projects together.
All projects of the On-Chip Software Development Kit are grouped in the 
all_projects.eww workspace.
Double-click on that file to open the workspace in IAR.

Create a New Project

All the projects shipped in the On-Chip Software Development Kit have been set up. We recommend you use those projects when exploring the different sample applications. You only need to follow the steps below when creating a project from scratch.

OCSDK revisions <= include IAR 6.x projects. Starting with OCSDK 1.2, it will included IAR 7.x project files, which are not compatible with a 6.x environment. If you are using a 6.x environment, you may need to set up project files manually, as described below.

Follows the steps below to create a new project:

We assume your project is entitled myProject.

  • Create the directory structure:
    • Create the following directories:
      • onchipsdk/src/
        app\myProject\ to hold the your project's source code
      • onchipsdk/projects/iar/
        myProject\ to hold the IAR project files
    • Place the source code of your project in 
      app\myProject\.  Typically, the source code consists of one of more C files, optionally header files, and the app_task_cfg.h header file.
  • Create the IAR project:
    • Open IAR
    • Select Project, Create New Project...
    • In the Create New Project dialog:
      • Tool Chain: ARM
      • Project templates: C >  main
      • Click OK
      • give your .ewp project file a name (e.g. myProject.ewp)
    • Remove the main.c file created by default:
      • In the right pane, right-click on the main.c tab and select Close.
      • In the project structure on the left, right-click on main.c and select Remove; click Yes to confirm.
      • In your project directory (e.g. 
        app\myProject\), delete the main.c file.
    • Right-click on the project and use the Add > Add Files... and Add > Add Group... entries to add and organize the source code files. Typically, the project contains:
      • In the app/myProject group, the source code of your application, taken from the 
        app\myProject\ directory.
      • In the app/common group, the source code of the helper modules, taken from the 
        app\common\ directory.
      • In the inc group, the header files associated with the library, taken from the 
        inc\ directory.
      • In the lib group, the pre-compiled libraries libip_stack.a and libucos_full.a, taken from the 
        lib\ directory.
      • In the modules group, the source code of the modules taken from the 
        modules\ directory.
      • The image below show the resulting structure of a typical project "02-gpio_net"
  • Configure the IAR project:
    • Select the new project in the Workspace view on the left by clicking on it. From the main menu select Project > Options...
    • In General Options
      • In the Target tab:
        • Core: Cortex-M3
      • In the Library Confrguration tab:
        • Set the Library low-level interface implementation to None.
    • In C/C++ Compiler:
      • Optimizations tab:
        • Set Level to High
        • Select Balanced
      • Preprocessor tab:
        • List the location of your header files in the Additional include directories text field, one per line. $PROJ_DIR$ is an IAR macro which corresponds to the directory containing the project's .ewp file. A typical configuration is (<your_app_dir> refers to the directory containing the source code of your application):

        • Preinclude file, enter:

      • Diagnostics tab:
        • If you encounter compilation errors related to data type conversion with older versions of the OCSDK, you may need to disable some diagnostics:
        • In the Suppress these diagnostics text field, enter:

      • Extra Options tab:
        • check Use command line options
        • In the Command line options text field, enter:

    • IOutput Converter:
      • Output tab:
        • check Generate additional output
        • output format: binary

This output converter configuration is no longer needed. It produced a binary (.bin) file that was compatible with loader It is replaced by the conversion of the .out file (as configured in the Linker output tab below) to a .bin file in the post-build step (as configured in the next step).  The new binary format requires loader or later.

    • In Build Actions:
      • In the Post-build command line field, enter:
      • C:\Python27\python.exe "$PROJ_DIR$\..\..\..\tools\dustElfToBin\" "$TARGET_PATH$"
    • In Linker:
      • Config tab:
        • check the Override default
        • In the browse field, if you are using version 7.3 or earlier enter:


          for version >= 7.4, the linker file is now bundled, so enter:

        • In the Configuration file symbol definitions text field, enter:

      • Library tab:
        • check Override default program entry
        • picEntry symbol and set to:

      • Output tab:
        • Change the Output filename field to a more descriptive filename, e.g. ocfdk_02_adc.out.
      • List tab:
        • Check Generate linker map file
    • In Debugger:
      • Setup tab:
        • Driver: J-Link/J-Trace
      • Download tab:
        • check User flash loader(s)
        • check Override default .board file
        • In the browse entry, if you are using version 7.3 or earlier enter:


          for version >= 7.4, the board file is now bundled, so enter:

      • Plugins tab:
        • check uC/OS-II in addition to any checked plugins
    • In J-Link/J-Trace:
      • Connection tab:
        • pick SWD

Using the i-jet debug probe

The IAR projects in the On-Chip Software Development Kit are set up to use the j-link debug probe. If you are using the i-jet, you need to change your project options as follows:

  1. right-click on your project and select options

  2. in the options, under Debugger, Setup, set Driver to I-jet.

  3. The first time run the project, you will see the following message. Click OK.

  4. In the Memory Configuration window, click OK.


Customizing an application

The contents of the

lib/, and
modules/ directories are tightly linked together. We highly discourage modifying those files. Doing so will complicate upgrading your applications to a newer version of the On-Chip Software Development Kit and may have unintended effects on other applications.  Future versions of the OCSDK will make it easier to customize the modules in one project without affecting the other samples. In the meantime, If you want to customize the behavior of the local or CLI module, we suggest creating a copy with a different name. For example, to customize the local module (assuming you will make changes to the following headers):

  • Copy dnm_local.h to private_dnm_local.h
  • Copy loc_task.h to private_local_task.h
  • Copy loc_task.c -> private_loc_task.c and replace the old #include references with the new ones.

You can now edit the local task without impacting other projects.