Sunteți pe pagina 1din 5

KEIL IDE

DEVELOPMENT
TOOL FOR ARM
Introduction
ABSTRACT
This is an introduction to the KEIL development tool
for ARM. This document is brief tutorial of how to
use KEIL to write ARM based ALP
Anupama KR & Meetha.V.Shenoy
Embedded System Design

Keil IDE Development Tool for ARM
You will be using ARM based LPC 2378 as the development platform for this lab exercise. You will to
read the manual for Keil 8051 to understand the development environment before you start with
using LPC2378.
The User Interface of the Keil IDE simulator and debugger for LPC2378 Microcontroller is same as
8051microcontroller. Apart from the generic features that it has for 8051 microcontroller, the
interface also has menus to configure the additional hardware of the LPC2378 system like Ethernet,
CAN etc In this exercise you just need to concentrate on the ARM7TDMI core around which LPC 2378
is built
The steps to simulate and download the code to the kit are similar to 8051 and are given below:
1. Create a new vision project
2. Choose LPC2378 microcontroller under NXP (founded by Philips) menu in Select Device
for Target window.
3. Pop-up will appear to ask whether you want to add startup-code startup.s.
4. Click YES in the pop-up window if the programming language is C/C++ and NO if
it is assembly language.
5. Disable Use memory layout from Target Dialog in Linker tab of the Options for
target window
6. Clear any file path if mentioned in the scatter file textbox.
7. Select appropriate option that is Use simulator in the debug tab in the target window
according to the requirements. (Refer Figure1)

Figure 1: Debug options

Examples:
Write an assembly language program for LPC23xx microcontroller to implement the following
pseudo code
If (a < b) {
x = 5;
y = c + d;
}
Else y = c - d;

Program 1
AREA RESET, CODE, READONLY
ENTRY
START
; define code area
adr r4,a ;address of data a is transferred to R4
ldr r5,=dst ;result address stored in r5
bl sub1 ; call subprogram sub 1
b lst
STOP
sub1
ldr r0,[r4],#4
ldr r1,[r4],#4
cmp r0,r1 ; check if a
ldrlt r0,[r4],#4 ; all the following Instructions are executed conditionally(LT)
ldrlt r1,[r4],#4
addlt r0,r1,r0
movlt r2,#5
strlt r0,[r5],#4 ; if less than y = c-d
strlt r2,[r5] ; x =5
fb1
ldrge r0,[r4],#4 ; all the following instructions are executed conditionally (GE)
ldrge r1,[r4]
subge r0,r0,r1
strge r0,[r5,#4] ; if greater than or equal to y = c+d
aft mov pc,lr ;return

a DCD 0x50,0x40,0x30,0x10 ;source data a, b, c & d

AREA RES, DATA, READWRIT
dst DCD 0,0 ;destination data y and x
END

Program 2:
AREA RESET ,CODE, READONLY
ENTRY
START
; define code area
adr r4,a
ldr r5,=dst
bl sub1
lst b lst
STOP
sub1
ldr r0,[r4],#4
ldr r1,[r4],#4
cmp r0,r1
bge fb1
ldr r0,[r4],#4
ldr r1,[r4],#4
add r0,r1,r0
mov r2,#5
str r0,[r5],#4
str r2,[r5]
b aft
fb1
ldr r0,[r4],#4
ldr r1,[r4]
sub r0,r0,r1
str r0,[r5,#4]
aft mov pc,lr

a dcd 0x50,0x40,0x30,0x10

AREA RES,DATA,READWRITE
dst dcd 0,0
END


Note:
Labels are not followed by :
Assembler directives such as AREA, END, ENTRY etc. should not be written in the first column
Directive AREA is used to define a memory area
Format is AREA NAME, TYPE (CODE/DATA), Characteristic (READONLY/READWRITE) - usual
directive ORG is not used here
START defines start of execution
STOP end of main execution area
END end of assembly
Source data usually specified in ROM or you have to write source data into RAM area every
time you run the program
Destination data usually defined in RAM as you need Read/ Write Capacity
DCD Define Constant double word equivalent to DD Directive
ROM starts at 0X00000000 (00 00 00 00H)
RAM starts at 0X40000000 (40 00 00 00H)

S-ar putea să vă placă și