Developing with IAR

Installing IAR

The IAR toolchain contains many features beyond the scope of this document. More information and documentation can be found at IAR.com.

Check the BLE-Stack 3.01.01.00 release notes to see which IAR version to use and any required workarounds. Object code produced by IAR may differ in size and performance as compared to CCS produced object code.

The following procedure describes installing and configuring the correct version of IAR and the necessary tools.

  1. Install IAR Embedded Workbench for ARM

    Download and install IAR EW ARM

    To get IAR, choose one of the following methods:

    • Download the IAR Embedded Workbench 30-Day Evaluation Edition – This version of IAR is free, has full functionality, and includes all of the standard features. The size-limited Kickstart evaluation option is not compatible with this SDK.
    • Purchase the full-featured version of IAR Embedded Workbench – For complete BLE application development using the CC2640R2F, TI recommends purchasing the complete version of IAR without any restrictions. You can find the information on purchasing the complete version of IAR.

    Attention

    The version required is stated in the release notes. Opening IAR project files with a previous version of IAR may cause project file corruption.

  2. Show Build Messages

    TI recommends showing all the build output messages for full verbosity during building. To do this, go to Tools -> Options and set Show Build Messages to All (see Figure 16.)

    ../_images/image15.png

    Figure 16. Show All Build Messages in IAR

Opening BLE-Stack IAR Projects

This section describes how to open and build an existing project and references the simple_peripheral project. All of the BLE-Stack projects included in the development kit have a similar structure.

Error

If you have imported the global <SDK_INSTALL_DIR>/tools/iar/SIMPLELINK_CC13XX_CC26XX_SDK.custom_argvars as described in Importing TI Drivers IAR Projects, then BLE-Stack examples will fail to build. For BLE-Stack examples, you must remove this custom_argvars file from your IAR global custom arguments.

  1. Open the IAR Embedded Workbench IDE from the Start Menu.

  2. Open an IAR workspace project: File -> Open -> Workspace...

    • For this example, select <SDK_INSTALL_DIR>\examples\rtos\CC2640R2_LAUNCHXL\ble5stack\simple_peripheral\tirtos\iar\ble5_simple_peripheral.eww

This workspace file is for the simple_peripheral project. When selected, the files associated with the workspace become visible in the Workspace pane on the left side of the screen. See Figure 17.

Select either project as the active project by clicking the respective tab at the bottom of the workspace pane. In Figure 17., the Overview tab is selected. This tab displays the file structure for both projects simultaneously. In this case, use the drop-down menu at the top of the workspace pane to select the active project. Each of these projects produces a separate downloadable object. The simple_peripheral sample project is the primary reference target for the description of a generic application in this guide. The simple_peripheral project implements a basic BLE-Stack peripheral device including a GATT server with GATT services. This project can be a framework for developing peripheral-role applications.

BLE-Stack IAR project build configurations

This and all BLE-Stack project workspaces contain various projects and build configurations as shown in Table 7. *_StackLibrary build configurations build the stack as a library as described in Stack Library Configuration (_stack_library).

Table 7. Available IAR project build configurations
Project type Project’s build configuration Compatible project complement
Application FlashROM Stack - FlashROM
FlashROM_StackLibrary Stack - FlashROM_StackLibrary
FlashROM_StackLibrary_RCOSC Stack - FlashROM_StackLibrary
FlashROM_OAD_ImgB Stack - FlashROM
FlashROM_OAD_Offchip Stack - FlashROM
Stack FlashROM_Library Application - FlashROM_Library
FlashROM Application - FlashROM

Compile and Download

For all build configurations, the stack project should always be built before the application project.

For projects where the stack is built as a library:

  1. Build the stack library project.

    • Select the stack project.
    • Select Project -> Make to build the stack.
  2. Build the application project.

    • Select the application project.
    • Select Project -> Make to build the application.
  3. Load the whole application

    • To download and debug: Select Project -> Download and Debug
    • To download without debugging: Select Project -> Download -> Download Active Application

Note

Application project that consume the stack in a library form will not have hard defined image boundaries.

After the initial build, if the stack project is not modified, only the application project needs to be rebuilt.

For projects where the stack and application are split images (not a library):

  1. Build the stack project.

    • Select the stack project.
    • Select Project -> Make to build the stack.
  2. Build the application project.

    • Select the application project.
    • Select Project -> Make to build the application.
  3. Load the stack project.

    • Select Project -> Download -> Download Active Application to download the stack project.
  4. Load the application project.

    • To download and debug: Select Project -> Download and Debug
    • To download without debugging: Select Project -> Download -> Download Active Application

Note

The stack project defines the flash and RAM boundary parameters used by the application project. Any modifications to the stack project require a rebuild of the stack project, followed by a rebuild of the application project to use the new boundary settings. See Frontier Tool.

After the initial build, if the stack project is not modified, only the application project needs to be rebuilt.

When the application is downloaded (that is, flash memory programmed), you can debug without reflashing the device. Go to Project -> Debug without Downloading.

Caution

Do not modify the CPU Variant in the project settings. All sample projects are configured with a CPU type, and changing this setting (that is, from CC2640R2F) may result in build errors.

Sample applications that implement the Over the Air Download (OAD) firmware update capability require the Boot Image Manager (BIM) project to be built. Refer to the Over the Air Download (OAD) section for more details.

Importing TI Drivers IAR Projects

Unlike the IAR projects for the BLE-Stack, IAR projects for TI Drivers must be imported rather than opened. All TI Drivers project are created from the original sources in <SDK_INSTALL_DIR>/source/ti/drivers. Because of this difference, you must not open TI Drivers .eww IAR projects directly from within the SDK.

Here are the steps on how to import a TI Drivers project.

Error

Do NOT try to open the .eww projects in <SDK_INSTALL_DIR>/source/ti/drivers directly in IAR!

Doing so will cause IAR to generate project files directly in the example you opened. The result of this is a project that does not open the correct source files and if you try to import the project afterwards with the import procedures listed below, not all source files will be imported into the project!

  1. Open the version of IAR that is stated in the release notes.

  2. Globally import the .custom_argvars file provided by the SimpleLink CC2640R2 SDK:

    1. Select Tools -> Configure Custom Argument Variables

      ../_images/iar_global_custom_vars.png

      Figure 18. Configuring Custom Argument Variables

    2. Select the Global Tab and click on the Import button

      ../_images/iar_global_imports.png

      Figure 19. Global Custom Variable Imports

    3. Select <SDK_INSTALL_DIR>/tools/iar/SIMPLELINK_CC13XX_CC26XX_SDK.custom_argvars

  3. Now you can import TI Drivers examples

    1. Open Help -> Information Center, and click on Integrates solutions.

    2. Go into the Texas Instruments Example projects.

      ../_images/iar_ti_import_examples.png

      Figure 20. Texas Instruments Example projects

    3. Click on example applications

      ../_images/iar_ti_list_examples.png

      Figure 21. To go to the list of available TI Drivers examples

    4. Click on the TI-RTOS link for the TI Drivers example you want to import.

      ../_images/iar_ti_import_project.png

      Figure 22. Select the project you want to import and specify where you want to save it.

  4. At this stage, you have imported a new TI Drivers project.

Accessing Preprocessor Symbols

Various C preprocessor symbols may need to be set or adjusted at the project level. The following procedure describes how to access and modify preprocessor symbols.

  1. Open the Project’s Options and select the C/C++ Compiler Category.
  2. Open the Preprocessor tab.
  3. View the Defined symbols box (see Figure 23.).
  4. Add or edit the preprocessor symbols.
../_images/image38.jpeg

Figure 23. IAR Defined Symbols Box

Accessing Linker Symbols

Linker symbols may need to be set or adjusted at the project level in order to control the memory layout of the generated image. The following procedure describes how to access and modify linker symbols.

  1. Open the Project’s Options and select the Linker Category.
  2. Open the Config tab.
  3. View the Configuration File symbol definitions box (see Figure 24.).
  4. Add or edit the preprocessor symbols.
../_images/iar_linker_opts.png

Figure 24. IAR Defined Symbols Box

Resetting the CC2640R2F in IAR

Select the Board Reset option from the following Reset (back arrow) Debug Menu drop-down box.

../_images/image182.jpeg

Figure 25. IAR Board Reset