IAR Embedded Workbench

IAR EW is the recommended environment by Texas Instrument for developing CC2530 applications. It natively supports hardware debugging of CC chipset family. IAR EW is a commercial software; different licenses are available and may be purchased from IAR website. Additionally, two types of evaluation versions exist, which can be used free of charge:

  • 30-day time-limited evaluation version
  • Size-limited KickStarter version: The code size limit for 8051 programming is currently 4kb.

We recommend using IAR-EW ver. 8.10, since it includes all the required libraries for complete support of CC2530 chipset. Previous versions such as IAR-EW Ver. 7.51A or 7.6 require a patch update (IAR-EW ver. 7.51M and 7.6.6) to enable hardware debugging of CC2530. To download the patch, you need to create an account in IAR Service Center page, then go to “My Pages” section. In case you are using evaluation versions, download relevant patches from following links:

Note that IAR-EW is Windows-only.

Setting up the environment

  1. Download and Install IAR-EW. To avoid any problem, completely remove any previous installation from your operating system.
  2. You may use TI CC2530 Development Kit Software Examples as the skeleton for your project.
  3. Follow these steps to program the Programming Board:
    1. Download and Install SmartRF Flash Programmer from TI website
    2. Install SmartRF Studio, which will set up all the driver environment for your windows system. Otherwise, your OS may have trouble recognizing the Programming Board when you plug in the USB.
    3. Download and install Silicon Labs IDE from here. To make sure the JTAG programmer itself has the correct firmware:
      • Open the Silicon Labs IDE
      • From the Options menu, choose Connection Options
      • Set “COMPORT” to the serial port with the JTAG adapter, and set “Debug Interface” to C2
      • Press OK, and select Connect from the Debug menu to test the adapter
      • If necessary, press Yes or OK to update the adapter’s firmware
      • When done, select Disconnect from the Debug menu
    4. Write bootloader to Programming Board:
      • Open SmartRF Flash Programmer
      • Go to tab “EB bootloader”
      • Choose file srf04eb_bootloader.hex, fill out the device ID field, and write bootloader to Programming Board. At this step, the bootloader is written to page 0-3 and 30.
      • NOTE: The JTAG programmer may be recognized as some COM port with large port number, say 17. However, Smart RF Flash Programmer can ONLY talk to the COM ports from 1 to 8. In this case, you need to manually re-assign the port number for JTAG device in “system properties / hardware / device manager”
    5. Write firmware to the Programming Board:
      • In Flash Programmer, go to tab “EB App(serial)”
      • Choose file “srf04eb_fwid0400.hex” (Note: the file name may be fwid0400.hex in some versions)
      • Write the firmware to the Programming Board. The firmware will be written to page 4-29.
    6. Go to tab “EB App(USB)”. Now the Programming Board should be recognized as a USB device with the ID you set at step 4.
  4. Now that Programming Board is programmed:
    1. Connect it to a USB port
    2. Connect debugging pins (DD, DC, and RST) on your CC2530 module to corresponding ports on the Programming Board.
    3. Open SmartRF Flash Programmer and push the RESET button on the Programming board. The module should be recognized with chipset type of cc2530. Now we are ready to program the module.
  5. No let’s configure IAR as following. In IAR, open a sample project.
    1. Go to Project –> Options
    2. In General Options – Target tab, make sure cc2530 is selected in the Device field. If not, browse through device configuration files and select cc2530.i51. Select code and data model according to your project. Banked data model is necessary to access the entire flash  on cc2530f128 and cc2530f256.
    3. In Linker – Config tab, check override default and make sure that you browse and select the appropriate linker file (most common file is named lnk51ew _cc2530.xcl. Note that correct linker file for banked memory model ends with a “b”. 
    4. In Debugger – Setup tab, make sure Texas Instrument is selected as the Driver. Note for 7.51M and 7.6.6: If Texas Instrument is not listed, your IAR/patch installation is corrupted and should be reinstalled.
  6. IAR environment is ready now. To write your own code:
    1. Open a sample project that has already imported necessary libraries. Note: If your project was done in an older version, IAR will ask to upgrade the project structure. This is a necessary and harmless step. Click OK and proceed. IAR will create and keep a legacy format of the project to use with older versions.
    2. Create a new file in the project and save it as “FILE_NAME.c”. Make sure file includes the following line near the top:
      #include "iocc2530.h"
    3. “Project –> Make” to spot any errors/warnings in your code.
    4. “Project –> Debug and Download” to write your code into the module and start the debugger.
    5. If multiple Programming Boards are connected, a target selection dialog will pop up; choose the proper target.

Open Source Toolchain (Code::Blocks/SDCC)

As an alternative to IAR Embedded Workbench, an open-source toolchain can be installed in Windows to get around issues with the code-size-limited or time-limited free versions of IAR. The IDE and compiler used here will also work in Mac OS or Linux, but the TI programming software is Windows-only.


  1. Install the latest snapshot of the SDCC compiler from
  2. Install the Code::Blocks IDE from When Code::Blocks is run for the first time, it will show a list of compilers automatically detected on the system. Make sure that SDCC is shown in this list with “Detected” next to it.
  3. Select “SDCC” in this list and press the “Set as Default” button, then continue installation.
  4. If Code::Blocks hangs after this point, kill the program and start it again/repeat step 3 if necessary.
  5. Now that the development environment is set up, install the TI SmartRF Flash Programmer from here. so that code can be flashed to the chips.
  6. In Code::Blocks, open the “Tools” menu and select “Configure Tools…”.
  7. Press the “Add” button and fill in the following fields:

Name: Program SoC
Executable: C:\Program Files\Texas Instruments\SmartRF Tools\Flash Programmer\bin\SmartRFProgConsole.exe
Working Directory: C:\Program Files\Texas Instruments\SmartRF Tools\Flash Programmer\bin
Launching Options: Launch tool in a new console window and wait for a keypress when done

Warning: make sure that you enter normal double quotation marks (not typewriter version “)when you directly copy parameters from above list.

This assumes that you installed the SmartRF Flash Programmer in the default directory of C:\Program Files\Texas Instruments\SmartRF Tools\Flash Programmer. Press the “OK” button to confirm. You will now be able to select “Program SoC” on the “Tools” menu to automatically flash an attached CC2530 with the current project’s code.

Creating a project

  1. Select “File”→“New”→“Project”.
  2. Pick “Empty project” from the list and press “Go”.
  3. Now enter a name for your project and pick a directory to create it in.
  4. On the next page, make sure that SDCC is already selected as the compiler to use.
  5. When it’s done creating the project, Code::Blocks will show a few messages such as “CodeBlocks doesn’t know how to…”. Ignore these.
  6. Select “Project”→“Properties…”, “Build Targets”. Select the Release and Debug targets, and for each one:
    1. Change “Type” to Native.
    2. Uncheck “Auto-generate filename extension”.
    3. Change the extension on the output filename from ”.sys” to ”.hex”.
  7. Select “Project”→“Build options…”. Select the Release and Debug targets, and for each one:
    1. Check the ”[MCS51] Large model programs (default is Small) [–model-large]” checkbox.
    2. In the “Other options” tab, type this: –iram-size 256 –xram-size 7936 –code-size 65536
  8. Download this version of the TI CC2530 code library adapted for SDCC, unzip it in your project directory, and use “Project”, “Add files…” to add all the files to your project. NOTE: If you won’t be using the functions in the “basic_rf.c” file, make sure you don’t select it when adding files to your project.
  9. You can now create a new file by selecting “File”, “New”, “Empty file…” and start coding. The main file must have

    #include "cc2530/cc2530.h"

    near the top.

Porting code written for the IAR Compiler to SDCC

There are some differences between SDCC and the standard IAR compiler to keep in mind when coding:

  • “data” is a reserved keyword and can’t be used for variable or function names.
  • Order of evaluation when ”==” or ”!=” operators are involved is sometimes not obvious. For example, DON’T do something like this:

    if (response[4] & 0x0F == 0x0C) ...

    Instead, you should do this:

    if ((response[4] & 0x0F) == 0x0C) ...

    It never hurts to use more parentheses than necessary.

  • When checking the contents of an XDATA register (the registers in ioCC2530.h with “XREG(…)” by their names), you cannot use “if (!REG)” or “while (!REG)” to check that the register contents are 0. You must use “if (REG == 0)” or “while (REG == 0)” instead (this is an SDCC compiler bug that should be fixed in the next release after 3.0.0).
  • Functions that are not used in the program will still be included in the output file and will take up code space, so if you don’t need the functions in certain library files, these files can be either removed from the project, or you can right-click on the file in the “Projects” pane (on the left-hand side), select “Properties…”, go to the “Build” tab, and uncheck the “Link” checkbox.