Вы находитесь на странице: 1из 12

IAR Tutorial

In this step-by-step tutorial Ill show how to make a simple project for LPC43xx series microcontroller using IAR Embedded Workbench IDE. It is primary intended for beginners, but it may also be useful for developers with some experience in other development environments (like KEIL, LPCXpresso, etc.). Hardware and software I use in this step by step tutorial: 1. 2. 3. 4. IAR Embedded Workbench for ARM, version 6.40. For our purpose 32KB Kickstart (freely available at IAR web site) is more than enough. IAR In-circuit Debugging Probe for ARM I-jet Diolan LPC4350-DB1 development board. Diolan LPC4357-DB1 Development Board.

Following this tutorial you will learn how to: 1. Configure IAR Embedded Workbench for LPC43xx microcontroller. 2. Use LPC43xx CMSIS-Compliant Standard Peripheral Firmware Driver Library. 3. Initialize and use the LPC43xx GPIO peripheral.

4. 5. 6. 7.

Run code from the LPC43xx internal RAM and external Flash. Start Cortex M0 core to run the program on both LPC43xx cores. Implement simple inter-process communication. Simultaneously debug the application on both LPC43xx cores.

First IAR Project

Add new comment To create a new IAR project, go to the "Project -> Create New Project" menu.

In the dialog box that appears select "ARM" tool chain, and "C -> main" project template. After you click the "OK" button, IAR will prompt you to specify the project name in the "Save As" dialog. I use "first" both for the project and workspace names:

IAR has generated a very simple main function for our project:

But how do we get this project to run at our LPC4300 development board? IAR knows nothing about our project yet. We need to specify the processor type and the way to upload the compiled binaries to this processor. Let's visit our project options (menu Project -> Options). There is one detail about IAR GUI to know at this step. When you go to the Project -> Options menu, IAR shows options for the entity that is currently selected in the Workspace window. If you select the main.c row, you will see the options for this file. So pay attention that the root entity (the project name) is selected. Another possibility to get to the project options is to right click the project name in the Workspace window and select Options from the context menu:

We can specify the device type at the General Options category. Select the "Device" option in the "Processor variant" options group and click the small button after the edit field. Now we have a long way through the pull-down menus

It seems that we can simply specify the device type in the edit field, but not this is another strange behavior of the IAR GUI. You can place the cursor in this edit field, you can even select the part of the text, but when you press any button nothing happens. IAR compiler is very good, but its GUI is sometimes unpredictable.

I have selected the NXP LPC4350_M4. Depending on your exact demoboard type you can also select the LPC4357_M4 or LPC1850 device type. There is also the option for another core (LPC4350_M0), but this is not for us just now. The main reason is that the Cortex-M0 core cant start without the CortexM4 core. The Cortex-M4 core is responsible to load and start the Cortex-M0 core. Now we can build the project specifically for our processor, but how will we

load it? I use the IAR I-jet probe, so lets configure it.

As you can guess, the debugger is set in the Debugger category. Just select the I-jet option. Now our project is configured, so click the OK button to close the dialog. One more note: when you open the project options dialog, you see the options for currently selected configuration. If you change the configuration (select Release

instead of Debug in the combo box at the top of the Workspace window), you will see that all our changes have gone. This is because they are set for the "Debug" configuration and not for the "Release". Lets set the breakpoint inside our main function (you can use the F9 button) and run our application (menu Project -> Download and Debug).

Great! Now our project is compiled and we can run it. Tags:


LPC43xx Standard Driver Library

Add new comment In the previous article I have shown you how to set up the IAR Embedded Workbench project. At the end we got the project that can be compiled for LPC43xx Cortex-M4 core and loaded into the LPC43xx internal RAM. Now we need to initialize the LPC43xx clocks and peripheral. We dont want to bother with all the initialization from scratch when NXP provides us with handy highlevel functions to do this. These functions are parts of the LPC43xx CMSIS-Compliant Standard Peripheral Firmware Driver Library. For a moment I wrote this article I have found no official way to download the LPC43xx CMSIS-Compliant Standard Peripheral Firmware Driver Library from the NXP web site (while you can easily find the similar library for LPC17xx). Probably the library for LCP43xx is not finally released yet. I have found the most recent version of the library at the LPCware web site. It appears under the list of files for LPC43xx microcontrollers - http://www.lpcware.com/file_filter/nxpf/lpc43xx. The direct link to the LPC43xx CMSIS-Compliant is http://www.lpcware.com/sites/default/files/lpc43xx.zip. The library structure is perfectly explained at the Diolan web site (in the LPC4300 open source code section), so I will not cover it here. Ill only write my opinion on project files placements. Both NXP and Diolan place their project files in the Examples folder. It may be good for examples (as they contain project files for different build environments), but I dont like this approach for my own projects. I prefer to have the library in its own folder and to put my projects in separate folders. This way I can easily replace the library with the new version when it is available. In the following screenshot I created the folder first for our example source code. All library files are located in the lpc43xx folder.

In the next article we will use the LPC43xx CMSISCompliant Standard Peripheral Firmware Driver Library to initialize LPC43xx clocks and interrupt vector table.