iar tutorial for lpc4357 (beginning)

12
IAR Tutorial In this step-by-step tutorial I’ll 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. IAR Embedded Workbench for ARM, version 6.40. For our purpose 32KB Kickstart (freely available at IAR web site ) is more than enough. 2. IAR In-circuit Debugging Probe for ARM I-jet™ 3. Diolan LPC4350-DB1 development board . 4. 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.

Upload: dmitrydiolan

Post on 28-Apr-2015

278 views

Category:

Documents


12 download

DESCRIPTION

The first part of tutorial for using IAR with LPC4300 microcontrollers

TRANSCRIPT

Page 1: iar tutorial for lpc4357 (beginning)

IAR Tutorial

In this step-by-step tutorial I’ll 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. IAR Embedded Workbench for ARM, version 6.40. For our purpose 32KB Kickstart (freely available at IAR web site) is more than enough.

2. IAR In-circuit Debugging Probe for ARM I-jet™

3. Diolan LPC4350-DB1 development board.4. 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.

Page 2: iar tutorial for lpc4357 (beginning)

4. Run code from the LPC43xx internal RAM and external Flash.5. Start Cortex M0 core – to run the program on both LPC43xx cores.

6. Implement simple inter-process communication.7. 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:

Page 3: iar tutorial for lpc4357 (beginning)

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

Page 4: iar tutorial for lpc4357 (beginning)

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 theway 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:

Page 5: iar tutorial for lpc4357 (beginning)

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 afterthe edit field. Now we have a long way through the pull-down menus…

Page 6: iar tutorial for lpc4357 (beginning)
Page 7: iar tutorial for lpc4357 (beginning)

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 editfield, 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 can’t start without the Cortex-M4 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

Page 8: iar tutorial for lpc4357 (beginning)

load it? I use the IAR I-jet probe, so let’s 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”

Page 9: iar tutorial for lpc4357 (beginning)

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".

Let’s set the breakpoint inside our main function (you can use the F9 button) and run our application (menu “Project -> Download and Debug”).

Page 10: iar tutorial for lpc4357 (beginning)

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

Tags:

Page 11: iar tutorial for lpc4357 (beginning)

IAR

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 LPC43xxCortex-M4 core and loaded into the LPC43xx internal RAM.

Now we need to initialize the LPC43xx clocks and peripheral. We don’t want to bother with all the initialization from scratch when NXP provides us with handy high-level 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 theNXP 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 recentversion 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. I’ll only write my opinion onproject 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 differentbuild environments), but I don’t 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. Thisway 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.

Page 12: iar tutorial for lpc4357 (beginning)

In the next article we will use the “LPC43xx CMSIS-Compliant Standard Peripheral Firmware Driver Library” to initialize LPC43xx clocks and interrupt vector table.