MicroController Pros Home Page My Account  Cart Contents  Checkout  
  Store » EEDT6.0 Tutorial 1 My Account  |  Cart Contents  |  Checkout   
Quick Find
Enter keywords to find the product you are looking for in the Quick Find field above

or use
Advanced Search
Accessory Boards->
ADI Blackfin
Atmel AVR->
Cypress PSoC
Microchip PIC->
Silicon Labs
ST Microelectronics->
Texas Instruments->
Embedded Ethernet->
Embedded Software->
I/O Modules->
Parts & Components->
Pick & Place Tools
Programmable Logic (PLD)
Prototype PCBs->
ROM/Flash Emulators
Test & Measurement->
Tutorial Software
Universal Programmers->
Intro to Embedded Tools
Embedded News Digest
Useful Resources
Shipping & Returns
Warranty & Liability
Privacy Notice
Conditions of Use
Contact Us
Installing Keil and creating first project for LPC2138

This is a tutorial for owners of the EEDT6.0 development board.

This tutorial demonstrates the procedure to install and use Keil IDE for ARM processors.

The Evaluation version of Keil for ARM is available for download at http://www.keil.com

Once downloaded, follow these steps:

1. Run the setup file MDK-ARM V4.xx.exe (double-click the file icon). The Setup Window should appear:

2. Click Next.

3. Click the checkbox for the License Agreement in order to proceed, then click Next.

4. In the folder selection window, select a suitable directory for the installation and click Next. (The default directory should work fine.)

5. Fill out the Customer Information form (with your own data, of course) and click Next.

6. The setup should begin. The Setup Status window will show installation of different files. Wait until everything is installed completely.

7. Once the installation has been completed successfully, the following message should appear. Click Next without making any changes.

8. The next message will confirm "Keil ÁVision 4 Setup completed". Click Finish.

9. It will take you to the webpage of Keil Development Suite for ARM. This will provide you with release notes for the Keil Development Kit. That document gives you a brief idea of which microcontrollers are being added in the Keil ÁVision 4. Now, run Keil ÁVision 4 by double-clicking the Keil ÁVision 4 icon from your Windows desktop or Start menu. The Keil work environment now should be ready to use.

Working in Keil ÁVision 4

This is an evaluation version. Let's start with a new project. This tutorial demonstrates an LED blinking program for the LPC2138 microcontroller. Do the following steps:

1. Click Project from menu bar and select New ÁVision Project.

2. Under the Create New Project window, select the project folder in Save in and name the project under File name.

3. Click Save.

4. It will create a new project with a new work environment. This will give you a new window. As this tutorial is based on EEDT6.0 hardware, which has an LPC2138 mounted on it, expand NXP (founded by Philips), then select LPC2138 and click OK.

5. It will ask you to confirm whether to add startup code to your project. Click Yes.

6. Now you are ready to start programming. As a demonstration, an LED blinking program is provided below for reference. Under the File menu, select New. A new file will open where you can create your LPC2138 program.

7. Write your code in there and save it with a ".c" extension in the same project folder (e.g. LED1.c).

8. The window on the left side of the screen is the Project Window. The Project window gives you the hierarchy of the Target folder and Source group folder. Right-click on the Source Code" and select Add files to Source Code. In the screenshot below, it is seen as Source Group 1.

9. Locate the LED1.c file by browsing the window to include it to the group folder.

10. Click the Project menu then select Build Target. The Build Output window should show that the program is getting compiled and linked.

11. When you get a message of 0 Errors and 0 Warnings, your program is ready to run without any queries. Click the Debug menu and select Start/Stop debug session. The following window will appear. Click OK.

This will give you another window where you can see the simulation of the program.

12. This window provides information regarding the LPC2138's registers with which we are working. There are some supportive windows where you can see the different changes during simulation. Click the Debug menu and select Run. The code simulation will begin.

13. Before going to the actual hardware, we can see if the program really works as per our requirements. In the sample program, the Port 1 block is used for interfacing. Go to the Peripherals menu and select GPIO followed by Port 1. Now you will get the following window where you can see that your LEDs are blinking from Pin 16 through Pin 23 of Port 1. This is a standard method to check how the program is working.

14. When you are done with the project, you can stop it from the Debug menu by clicking Start/stop the Debug session. This will take you to the original window.

15. Now, in order load the code into the hardware, we need to make a hex file of the source code. Click the Flash menu and select Configure Flash Tools.

16. Go to the Output menu and select Create HEX File and enter a Name of Executable for the file, e.g. "LED".

17. Again go to the Project menu and select Build Target. This will create the hex file.

Sample Program

#include <lpc21xx.h>

void wait (void) { /* wait function */
long d;
for (d = 0; d < 10000; d++); /* only to delay for LED flashes */
int main (void)
unsigned int i; /* LED var */
IODIR1 = 0x00FF0000; /* P1.16..23 defined as Outputs */
while (1)
{ /* Loop forever */
for (i = 1<<16; i < 1<<23; i <<= 1) { /* Blink LED 0,1,2,3,4,5,6 */
IOSET1 = i; /* Turn on LED */
wait (); /* call wait function */
IOCLR1 = i; /* Turn off LED */
for (i = 1<<23; i > 1<<16; i >>=1 ) { /* Blink LED 7,6,5,4,3,2,1 */
IOSET1 = i; /* Turn on LED */
wait (); /* call wait function */
IOCLR1 = i; /* Turn off LED */

Downloading Program to LPC2138 using Flash Magic

Flash Magic is a utility to download the hex file to the LPC2138 processor. Download Flash Magic from http://www.flashmagictool.com and install it.

You will need a hardware programming interface to download the program from PC to the LPC2138 processor. You may use the included EM-P-NXP for this purpose. Before programming, remember to connect eight LEDs to P1.16 through P1.23 on the EEDT6.0 kit using the single-pin connectors provided.

In Flash Magic, follow these steps, which correspond with the Step sections on the software dialog:

Step 1. Select LPC2138 as the device. Then select the COM Port to which the programmer is connected (check your Device Manager). Keep the baud rate at 2400.

Step 2. Check the box to Erase all Flash + Code RD Prot.

Step 3. Browse to and select your Hex File from the Keil project folder.

Step 4. Check the Verify after programming box (optional).

Step 5. Click Start to download the program. Once finished, the LPC2138 mounted on the EEDT6.0 kit should go back to Application mode and will start the application code.

Shopping Cart more
0 items
What's New? more
J-Link ULTRA+, High-Speed USB JTAG Debugger with Software
J-Link ULTRA+, High-Speed USB JTAG Debugger with Software
Specials more
XBee ZigBee Module, 50mW, Series 2.5, RPSMA Antenna Connector
XBee ZigBee Module, 50mW, Series 2.5, RPSMA Antenna Connector
01. LCD 4-mux, 7 digits x 14 segments, progress bar, arrows
02. LCD 4-mux, 7.1 digits x 7 segments, progress bar, arrows
03. PIC16F628A-I/P Microcontroller, 18 DIP, 20 MHz
04. Atmel ATtiny2313-20PU AVR Microcontroller, 20 DIP, 20 MHz
05. USB-to-Serial Cable: 3.3V TTL, Audio Plug Type, Reverse RX/TX
06. 2x5 (10-pin) 0.05" pitch IDC Connector Flat Ribbon Cable, 12cm
07. 2x10 (20-pin) 0.1" pitch IDC Connector Flat Ribbon Cable, 15cm
08. USB Universal In-Circuit Programmer PIC AVR ARM MSP 8051 EEPROM
09. ARM JTAG Debugger & Programmer, parallel port
10. Power Supply 3-12V DC, U.S. plug, 6 connection tips
Reviews more
Solar Module DC Power Source
This module is a great concept and ordering it from uCPros h ..
1 of 5 Stars!
  Friday 22 February, 2019   List of all our Products

Copyright © 2003-2017 MicroController Pros LLC
Powered by osCommerce