Keil Get Started

Create a project

1. Project -> new uVision project

Pick a name and directory of the project

CPU: expand NXP(founded by Philips) -> choose LPC2194/01

Click yes to copy LPC2100 startup code to project folder

2. Rename target to "LPC2194/01"

Rename "Source Group 1" to "Startup Code and System Calls"

3. Copy Retarget.c from svn\Branches\uC modules to your project folder

4. Double click on "Startup Code and System Calls"

Add a Retarget.c from svn\Branches\uC modules

5. Right click on "LPC2194/01" and create a new group called "Source Code"

- This is where you add your own c file.

6. Open (file -> open) KEILsample.c from svn\Branches\uC modules and save it as "name_you_choose.c" in the same directory (or some other directory if the code will not be shared via subversion)

7. Double click on "Source Code"

Add "name_you_choose.c"

8. Copy "LPC2194_01.h" from svn\Branches\uC modules and paste it to C:\Keil\ARM\INC\Philips

- This is a specific header file for LPC2194/01

=> Now the local project you created will be modifying a shared c source file via subversion.

Settings

1. Click on "LPC2194/01" and go to project -> options for target LPC2194/01

2. Go to Debug tab

Choose "Use ULINK ARM Debugger"

3. Click on Settings

Select "Verify Code Download" and "Download to Flash" for Download Options

Click ok

4. Go to Utilities tab

Select "Use Target Driver for Flash Programming"

Choose "ULINK ARM Debugger"

5. Click on Settings

Select "Reset and Run" for Download Function

Make sure "Program" and "Verify" are also selected

6. Click Add for Programming Algorithm and choose "LPC2000 IAP 256kB Flash"

Click ok

=> Now you are ready to program a microcontroller.

Programming

Modify "name_you_choose.c" file

In order to program a microcontroller, you need to save changes, build, and load to flash.

KEILsample.c Description

When running KEILsample.c, a microcontroller will turn on and off pin 1.25 every second. Also, if connected to a serial port, it will print "Testing printf Function" on a computer screen.

This code has several examples of essential functions.

-  PLL settings (PLL user defined values, init_PLL) in general does not require any modification unless some change in CPU and/or peripheral clock speed is required.

-  Interrupt settings (init_timer0, time_counter) show how an interrupt can be set. This is one example of various kinds of interrupts. init_timer function is the interrupt handler which calls the interrupt function, time_counter. Note that time_counter function should include __irq before or after the declaration of the function.

-  If printf (print numbers and characters on a computer screen via serial port) function is in the code, UART settings (init_UART0, sendchar, getkey) should be included. In general, these functions do not need any change unless if UART1 is used instead of UART0. In that case, change the registers U0XXX (i.e. U0CLR, U0DLL, etc.) to U1XXX, and change PINSEL0 value to appropriate UART1 TXD and RXD. Since sendkey and getchar functions are called in Retarget.c file, do not change the name of them unless Retarget.c is modified.

-  Some extra settings include Memory Accelerator Module and Fast GPIO, which are included in main function. MAMCR register enables and disables the Memory Accelerator Module, and SCS register enables and disables Fast GPIO. If Fast GPIO is enabled, regular GPIO access cannot happen, and registers such as FIO0DIR should be used instead of IO0DIR.