Written By: SweePoh, Quek (Kevin)
Testech Electronics Pte Ltd. Blk 118, #05-118, Aljunied Ave 2, Singapore 380118
Tel: (+65)-67492162 Fax:
(+65)-67494246. Email:
sales@testech-elect.com Web:
www.testech-elect.com
Requirements:
1. IAR EWARM 4.31A
2. Phytec LPC2294 Rapid Development Kit with Debug Core Modules (JTAG + ETM Connectors)
Procedures:
1. Connect the Phytec Debug Core Board between the Base Development carrier Board, and the LPC2294 Core Module.
2. Connect the IAR Jlink to the Debug Core Board 20pin JTAG connector. If you do not have the debug core, connect the 20pins JTAG to the 50mils JTAG connector on the Phycore LPC2294 Module.
3. Install IAR EWARM 4.31A either using the QuickStart Key or request for 30 days evaluation key from Web.
Loading the IAR EWARM WorkSpace for LPC2292/LPC2294
1. Run the IAR Embedded WorkBench EWARM.
2. Select File -> OPen -> WorkBench. Browse to the \program files\iar systems\embedded workbench 4.0\arm\src\examples directory. All IAR sample projects, flash loader, sample project setup and plenty of samples code, interrupt driven examples, ADC/DAC, SPI samples are in this examples

Select the Philips Subdirectory. There are many board support sample that are already ported to IAR Kickstart Kit and will run on many third party boards with minor change of debug scripts. Select the LPC22xx directory.

Select the phytec_pcm023.eww IAR embedded WorkBench Project. You will notice that when you create any new projects within IAR WOrkBench, IAR workbench can contains multiple projects. Each Project will have its own subdirectory that contains the object code, listing and executbale for both debug, release or any other variant of the project setup settings. The flash loader has also been created for LPC229x for both internal and external flash and this can be modify to suit customer choice should they chose a different external flash or bus width.

Once the workspace is loaded, you will see that the workspace contains of blinky and hello for BOTH internal and external flash release version and debug version., as well as internal RAM or external RAM debug version. The flash project (either internal flash or external flash) can also be debug version (with low optimisation) or FULL production Release (High Optimisation, no debug). You can therefore debug your code in flash as well, although the hardware breakpoint in this case shall be limited by the ARM OnChip Debug number of breakpoint.

Setting IAR EWARM Project Setting Gernal Project Options and Library Use
On the left workspace pane, right click on the blinky project, and select Options. This will bringup the project compilation and debug options. This is where you select the CPU, output, compilation and assembly as well as debug or simulatio options. On the button besides the devices make sure the device is selected as Philips LPC2292 or LPC2294. By default the project generate interwork code and little endian that is suitable for this projects.Therefore it is very easy to setup the IAR workspace by simply selecting the CPU type and all options has been selected for you.
![]() |
![]() |
Click on the output tab. You can specifiy a different directory for the generated exe or object code listing.

Click on the Library Options. For project that uses sprintf or printf you can specify the most suitable format to suit your memory footpint of your projects.

Click on the MISRA C Tab. IAR EWARM support MISRA C Compiler Code Checking for safety critical coding if you are writing code that needs stringent static code analysis and confirm to ISO 9899 standard.

Setting IAR EWARM Project Setting Compiler Language, Output and Optimization
Select the C/C++ Compiler Category to set compiler options. This is where you
fine tune compiler settings suitbale for your projects. As this project is
written in ANSI C, we select the language as C. IAR EWARM supports project
written in embedded C++, Extended Embeddedd C++. Also note you can specify
default definition of char as either signed or unsigned. Also noted that you can
specify the compiler to requires all function to be prototype.

Select the Optimization. For best use low optimization or none. Also you can
chose to compile optimized for speed or optimize for size. in addition to
allowing you to manually select each optimization scheme.

Select the output tab. For debugging in RAM (or in flash) you have to turn on the Generate Debug Information. For release version (in flash) production, you willl turn this debug information off, in the flash project.

Select the list tab. You can request the compiler to generate output listing file, as well as generate assembler file (for example code that are to be written in assembly that is callable from C, you can generate the skeleton Assembly code and then modify it and saving you the trouble of figuring out which register or memory is being use pass and return variables.

Select the preprocessor tab. Note that you specify any compile time flag here
(that is your code has selectable compile using #ifdef xxxxx #endif)

Setting IAR EWARM Project Setting Linker Options
On the left Option Category select the Link Options. As we are going to use
IAR CSPY Debugger to debug the target board using JLink or IAR JTRACE (ETM
Hardware Trace Support), select the format as Debug information for C-SPY.
If you are using other third party debugger that requires ELF output, select
other format and select ELF/DWARF output with option -yas (ARM). For example
Nohau EMUL-ARM-STD and EMUL-ARM-PRO with seehau debugger requires debug format
in ELF output. (www.testech-elect.com/nohau/index.htm)
If you are using Ashling Pahtfinder Debugger, select hte format as "ashling".
The IAR Linker is a powerful multi-format linker to support all available output
such as simple binary (requires for flash programming), hex, S Record, Tektronix
Hex etc.

select the tab List. Turn on the module summary and segment map. IAR linker generate a linker output summary that allows you to see your code size, RAM size requirement as well as how those code and data variables etc are linked and resides in the final physical memory.

Select the config tab. This is a very important setting, you have to get a suitable linker config file that setup the correct settings. As you can see, the various possible options for setting the linker segment arrangement and physical memory assignment is listed in this file. Preconfigure linker setting has been created for internal ram, external ram, internal flash or external flash. These file as ascii text file and is very easy to modify to suit the customer final target if their memory map is different (for example different size of external SRAM or external Flash)

Setting Up IAR EWARM Project Setting Debug Options
On the left option pane, select the debugger category option. On the Debugger select IAR Jlink/JTrace Options. As you can see various debugging options is possible such as using RDI (using ARM MULTICE or RealView JTAG, using third party RDI Driver such as Ashling RDI driver). Some target board already has Debug ROM Monitor (such as ARM Angel Monitor) or IAR ROM monitor. ROM Monitor allows the target board to be debug via serial link (RS232C) for example some customer may chose to incorporate ROM Monitor in the target final version even in production board for field debug, for example if the production release board did not have JTAG connection.
Also note that we selected the checkbox "Run To" so that after CSPY Debugger download the code to the target board, it will immediately run the startup code and break at the main() entry. If you are debugging the startup code, uncheck this box. In addition, notice the device description file has been prese to LPC2294.ddf this allows the CSPY Debugger to set the correct debugger options, as well as allows user to see Peripheral registers on the CSPY Debugger windows.

Select the Download Tab.
By default the Verify download is turn off to speed up download.If you suspect
the target board has problem setup or faulty external SRAM, be sure to turn this
option on, so that if the code download has failed, you will be inform of any
error during download. Also notice the suppress download, for debugging flash
code, you may choose to only load the source code for debugging as the code may
have already existed on the board and you do not wish to download the code to
the flash (and RAM). Attached to Program allows you to debug a RUNNINg target
without stopping it.
The "Use Flash Loader" option is use the IAR Flash Loader to download and
program the code into the target internal or external flash. So when you select
download code, it is actually being flash into the target.

Select the tab Plugins.
CMX CSPY Debugger has powerful option and valuable plugin such as Code
Coverage and profiling that allows you to do software quality analysis by doign
a code coverage (check which line of the code has been executed at least once),
Profiling (check how the code are using the CPU time). Stack windows is a very
nice window option that allows you to have window to view the Stack content (yes
no more memory dump!!)
In addition, CSPY Has built in Kernel Aware for CMX RTOS, CMX Tiny RTOS, UCOS-II
RTOS. These Kernel windows allows you to debug a Multi-Tasking Code much more
effectively by showing you all the Kernel Objects (Task, Seamaphore, Event,
Message Box, Queue, Signals, kernel Timer etc). These Plugin are
already bundle with IAR EWARM environment.

Setting the Jlink Options
Select the J-Link/J-Trace Category options on the left pane. Notice that you can chose to reset the target when download using the #TRESET Pin signal (if it is routed on the target board) or software (that is set the program counter) or choose to run the target for a while and then asser the hardware reset (for board has has bootcode in ROM). THe JTAG speed can be setup for Auto speed (for example wait for target board PLL to run to full speed) or use adaptive Clock with CPU that has RTCLK signal being routed on the target board..

Building the Code
Return to the IAR embedded workbench, on the left pane workspace, right click on the blinky project and select either "Rebuilt All" or "Make". The project will be check for file dependencies, compile, linked and if there is no error, the output will be generated.

If your code has an error (for example we create a bug by adding a code line that will generate compile time error). The bottom pane (Messages) will shows Error{xxx}: <error message>. If you click on this tools message windows on the error line, it will bring up the source code and position the cursor on the line that generate the error.

Downloading Code and Debugging on the target Board
When there is no make or built error, select "Project" -> Debug or simply
click on the CSPY Debug icon
.
The code will be downloaded to the target ram and then stop at the main() as
shown below.

Now go to the source code LPC2294SystemInit() and right click, set a breakpoint at the code cursor line by selecting "Toggle BreakPoint (Code)". Note that in this option you can run to any code cursor line, change the program counter at the cursor line etc.

Select the View -> Memory window.
You can type a symbolic address into the memory address location. We like to see
the memory at ms_ctr, type this into the memory address.

Right click on the memory window. you can view the memory. as 8 bit,
16bit or 32 bit, in little endian or in big endian. You can even fill memory
region or upload the entire memory or a region o the memory for analysis.

Click on the view menu and select the register window. The IAR CSPY Debugger
support microcontroller or user specify peripheral register windows. If you
select a peripheral register (for example UART0), the register name, address,
value, content, details of the register setting even down to bit value are being
displayed. You can directly modify the value during debugging to aid in
debugging and different options.
![]() |
![]() |
![]() |
In the view menu, selet the Watch and Locals windows. Locals windows will automatically display all local variable during debugging. Watch windows allows you to watch selected variables, global variables, registers content etc. From the source code, highlight the ms_ctr variable in the timer function and drag it into the watch windows. Drag and drop operation ease your debug since you do not need to manually type variable names in the watch window.

In the view menu, select Disassembly window. you will see a disassembled code windows.

Click on the debug Menu. Note that you can step in, step out, step over and auto step, or run a macro in debug mode to setup a series of variables values etc to automate your code testing.

Return to IAR Tutorial Menu
Back to IAR Home Page Back to Testech Home Page Compiler RTOS Emulator/Debugging