Top Banner
ARM7‐ LPC2148 Developme nt board User Manual No.56, Venkatesan Chowdry Street, West Tambaram, Chennai - 600045 Ph: 044-43159192/22266935 Cell: 98411 33919. Email: [email protected]
91
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: lpc2148

ARM7‐ LPC2148 Development board User Manual

No.56, Venkatesan Chowdry

Street,

West Tambaram,

Chennai - 600045

Ph: 044-43159192/22266935

Cell: 98411 33919. Email: [email protected]

Page 2: lpc2148

LPC2148 ‐ User Manual 

Revision 1.0 Author: Rajasekaran K

SM MICRRO SYSTEM provides the enclosed product(s) under the following conditions:

This evaluation board/kit is intended for use for ENGINEERING DEVELOPMENT,

DEMONSTRATION, EDUCATION OR EVALUATION PURPOSES ONLY and is not considered by SM

MICRRO SYSTEM to be a finished end-product fit for general consumer use. Persons handling

the

product(s) must have electronics training and observe good engineering practice standards.

As

such, the goods being provided are not intended to be complete in terms of required

design-,

marketing-, and/or manufacturing-related protective considerations, including product safety

and

environmental measures typically found in end products that incorporate such

semiconductor

components or circuit boards. This evaluation board/kit does not fall within the scope of

the

European Union directives regarding electromagnetic compatibility, restricted substances

(RoHS), recycling (WEEE), FCC, CE or UL, and therefore may not meet the technical

requirements of these directives or other related directives.

The user assumes all responsibility and liability for proper and safe handling of the

goods.

Further, the user indemnifies SM MICRRO SYSTEM from all claims arising from the handling

or

use of the goods. Due to the open construction of the product, it is the user’s responsibility

to

take any and all appropriate precautions with regard to electrostatic discharge. EXCEPT TO

THE

EXTENT OF THE INDEMNITY SET FORTH ABOVE, NEITHER PARTY SHALL BE LIABLE TO THE

OTHER FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES.

SM MICRRO SYSTEM currently deals with a variety of customers for products,

and therefore our arrangement with the user is not exclusive. SM MICRRO SYSTEM

assumes no liability for applications assistance, customer product design, software

performance, or infringement of patents or services described herein. Please read the

User’s Guide and, specifically, the Warnings and Restrictions notice in the User’s Guide

prior to handling the product. This notice contains important safety information about

temperatures and voltages. No license is granted under any patent right or other

Page 3: lpc2148

intellectual property right of SM MICRRO SYSTEM covering or relating to any machine,

process, or combination in which such SM MICRRO SYSTEM products or services might be or are

used.

Mailing Address:

#56, Venkatesan Chowdry Street, West Tambaram, Chennai - 600045, Tamilnadu, India - 560040

Revision 1.0 1

Page 4: lpc2148

LPC2148 ‐ User Manual 

Table of Contents:

1. Introduction………………………………………………………………..…………….4

2. Get going……………………………………………………………………..…………...5

2.1 System Requirements………………………………..……………..……………....... 5

2.2 Starting off…………………………………………………………..…………… ..…..5

3. Programming LPC2148 board …………………...……………..………………...5

4. LPC2148 board Hardware …..……………………………………..……………….7

4.1 Functional overview …………………………………………………..………. .…….7

4.2 Hardware Configurations …………………………………………..………………...7

5. Testing the development board ………………………………..……… ………..9

6. Installing Keil MicroVision4 ……..……… ……………………..………..... …..16

7. Setting up GCC Compiler ………………………………………..………17

8. Installing FlashMagic …………………………………………………...… ….…….19

9. Creating New project in KeiluV4 …………………………………… …….…….20

10. Editing existing Example projects ………………………..….…………….... 34

11.LPC2148 Development board schematics ……………….…..… …………35

12. Working with RTOS………………………………………………….………………..36

12.1 Keil Settings to integrate GCC …………………………….……………. .……. .37

12.2 Compiling existing example project …………………………….…………...…..39

Revision 1.0 2

Page 5: lpc2148

LPC2148 ‐ User Manual 

12.3 Creating new RTOS project ……………………………………………………...... 41

APPENDIX- I : Component List………………………………………………………… 47

APPENDIX-II : Connectors & Connection Details …..…..………………...…………48

APPENDIX-III : LPC2148 Specification…………………….. ……………………. ……50

APPENDIX- IV : LPC2148 Add-On card Projects Source code……………………...54

Revision 1.0 3

Page 6: lpc2148

LPC2148 ‐ User Manual 

1. INTRODUCTION:

SM Micrro’s LPC2148 is a evaluation board for LPC2148 ARM7TDMI based microcontroller. The LPC2148 microcontroller has 512KB of internal flash and 32+8K RAM. Following are the salient features of the board.

• Dimensions: 18x15 cm • Two layer PCB • Power:

Power supply: AC 220V - 240, 6Amps, 50Hz • Connectors:

RS232 connectors (2)

26 pin FRC for user I/O interface

20 pin JTAG interface

6 pin RMC for ADC interface

3pin RMC for PWM

3 pin RMC for DAC

PS2 connector for Keyboard interface

16 pin RMC for LCD module interface

• Other peripherals:

126KB I2C based EEPROM

2 line x 16 character LCD

Temperature sensor

Revision 1.0 4

Page 7: lpc2148

LPC2148 ‐ User Manual 

Configurable for manual and automatic program download(ISP) via

serial

port

2. Get going:

2.1 System Requirements:

• Windows XP • Serial or parallel port

2.2 Starting Off:

Connecting the hardware:

• Connect the power cable to the power-input port provided at the rear side of the

development kit. • Switch ON the power supply to board using the power-switch(Red color)

provided at the rear side of the kit.

3. Programming LPC2148 board:

The LPC2148 board can be programmed using built in JTAG-ICE. To download program using JTAG wiggler via parallel port a 20 pin FRC connector(CON2) is provided in the development board(programming via JTAG would be added in next revision).

The other option for downloading programs is via ISP using serial port. In this section we have discussed about only programming the microcontroller using serial port ISP. The ‘Flash magic’ software tool is used at PC side to communicate and download the program via ISP to the microcontroller.

Before start downloading the program, make sure you have made all the configurations in the Flash magic tool as shown in figure 3.1. The hardware configurations to be done are given below.

1. Set the Jumper J1 in J1-2 position(drives max 232 with 5v supply)

Page 8: lpc2148

2. Set the 3x2 way switch S2 in P1 position(as shown in figure 4.2 in page7) 3. Connect the serial cable from the PC to the DB9 connector CON3 in the

development board 4. Reset the board using the Reset-Switch S1. 5. Now click “Start” button in the ‘Flash magic’ programming software tool.

Revision 1.0 5

Page 9: lpc2148

LPC2148 ‐ User Manual 

Figure 3.1

Note:

In COM port option of step1 given in the Flash magic tool select the appropriate port you are using.

Revision 1.0 6

Page 10: lpc2148

LPC2148 ‐ User Manual 

4. LPC2148 Board Hardware:

4.1 Functional Overview:

16 pin RMC connector for  LCD interface

PS2connector  

forKeyboard

26 pin FRCmale ARM7TDMI

connector LPC2148for user I/O Microcontroller

LM35Temperature  sensor and  amplification

circuitry

RMC connectors  for PWM, DAC

and ADC  interface

Revision 1.0

DB9female

connector  for UART0

DB9female

connector  for UART1

20   pin FRC  male

connector  for JTAG

Page 11: lpc2148

LPC2148 ‐ User Manual 

4.2 Hardware Configurations:

Jumper J1:

The Jumper J1 should always be in J1-2 position for correct operation of the development board.

1 2 3

J1

1 2 3

J1

3x2 way Switch S2:

Jumper J1 is in J1 2‐  position (Top view)

Figure: 4.1

Jumper J1 is in J2 3 position (Top‐  view) 

To download the program into the microcontroller, the 3x2 way switch S2 must be in position P1 and it should be in the position P2 to run the program downloaded into the microcontroller.

Switch S2 in position P1

Switch S2 in position P2

Revision 1.0

Figure: 4.2

Page 12: lpc2148

LPC2148 ‐ User Manual 

5. Testing the Development Board:

The user can test the development board to check whether all the peripherals are working correctly using the example programs in the SMM_LPC2148 utilities CD.

The examples are located inside the folder ‘SM_ARMboard_Examples’. This folder contains example projects to test the peripherals listed below

1. LEDs L2 and L3 which is on development board itself 2. UART0 and UART1 3. LCD Display 4. ADC 5. I/O via 26pin FRC using matrix keyboard.

The sub folders inside this folder demonstrate each peripheral. Each subfolder contains a HEX file which is to be downloaded into the microcontroller to test the respective peripheral.

1. Example program to switch ON the onboard LEDs:

Make all the hardware configurations and Flash magic software configurations as given in the topic “Programming LPC2148” in step3.

1. Under step3 in Flash magic, click the browse button and locate the hex file

Test_led_onBoard.hex as shown in figure 5.1 and figure 5.2

Page 13: lpc2148

Revision 1.0 9

Page 14: lpc2148

LPC2148 ‐ User Manual 

Figure 5.1

Figure5.2

2. The Test_led_onBoard.hex file is in the location usr_drive:\...\ SM_ARMboard_Examples\ Led_onBoard\Test_led_onBoard.hex

3. Make the 3x2 way switch S2 in position P1. 4. Reset the development board using the Reset switch S1. 5. Make sure the serial cable is properly connected with development board. 6. Click ‘start’ button in the Flash magic. 7. Wait for ‘Finished’ message at the bottom of the Flash magic tool. 8. Make the 3x2 way switch S2 in position P1. 9. Reset the development board using the Reset switch S1

Revision 1.0 10

Page 15: lpc2148

LPC2148 ‐ User Manual 

10. Now you can see the LEDs L2 and L3 on board glows.

2. Example program to blink onboard LEDs:

The ‘Led_onBoard_Blink’ folder contains example project to demonstrate blink LED on development board. Use the same procedure as discussed in LED example project to download the hex file into microcontroller.

The ‘Test_Led_onBoard_Blink.hex’ file is in the location usr_drive:\...\ SM_ARMboard_Examples\ Led_onBoard\ Test_Led_onBoard_Blink.hex

3. Example program to Test UART0 functionality:

The ‘uart0_Test’ folder contains example project to demonstrate

working of UART0 via RS232 interface on development board. Use the

same procedure to as discussed in LED example project to download the hex

file into microcontroller.

1. The ‘uart_test.hex’ file is in the location usr_drive:\...\ SM_ARMboard_Examples\ uart0_Test\ uart_test.hex

2. The data sent by UART0 can be verified using Communication Hyper terminal in

your PC. To open Hyper terminal go to Start ProgramsAccessoriesCommunications Hyper terminal. You can view the window asshown below.

Page 16: lpc2148

Revision 1.0 11

Page 17: lpc2148

LPC2148 ‐ User Manual 

Figure 5.3

3. Give some name in the Name field and click ok. 4. Then select appropriate com port from the “connect using” field as shown below

and click ‘OK’

Figure 5.4

Revision 1.0 12

Page 18: lpc2148

LPC2148 ‐ User Manual 

5. Next, select the options as shown below and click ‘OK’.

Figure 5.5

6. Press Reset button. Now, in the hyper terminal window you can view the data

sent from microcontroller.

Revision 1.0 13

Page 19: lpc2148

LPC2148 ‐ User Manual 

Figure 5.6

Note: Before opening the hyper terminal, close the flash magic tool.

Similarly, while using the flash magic tool close the hyper terminal. You would receive error messages if above given criteria are not satisfied.

4. Example program to Test UART1 functionality:

Using the uart_test.hex file inside the ‘uart1_Test’ folder you can test UART1’s functionality. Follow the same procedure as discussed for UART0 except connect the serial cable to DB9 connector CON4 on the development board. The uart_test.hex file is in the location, usr_drive:\...\ SM_ARMboard_Examples\ uart1_Test\ uart_test.hex

5. Example program to Test ADC :

Revision 1.0 14

Page 20: lpc2148

LPC2148 ‐ User Manual 

This program displays the atmospheric temperature in the LCD. The

analog value

from onboard temperature sensor is sampled by ADC and temperature is

displayed in

LCD.

1. The procedure to download the hex file is same as discussed in

previous

example projects.

2. The hex file to test ADC is in location

usr_drive:\...\ SM_ARMboard_Examples\ ADC_Test\ ADC_Test.hex

6. Example program to Test DAC :

This program generates analog voltage output of 2V from the DAC

port of LPC2148 microcontroller.

1. The procedure to download the hex file is same as discussed in

previous

example projects.

2. The hex file to test DAC is in location

usr_drive:\...\ SM_ARMboard_Examples\ DAC_Test\ DAC_Test.hex

7. Example program to Test I2C & EEPROM:

This example project demonstrates the use of I2C and external EEPROM.

In this example data write and read using I2C to EEPROM is

demonstrated. You can see the display message of read success and

the written value followed by write success in LCD.

1. The procedure to download the hex file is same as discussed in

previous

example projects.

2. The hex file to test I2C is in location

usr_drive:\...\ SM_ARMboard_Examples\ I2C_Test\ I2C_Test.hex

Page 21: lpc2148

Revision 1.0 15

Page 22: lpc2148

LPC2148 ‐ User Manual 

8. Example program to Test I/O using Matrix keyboard:

In this example project the general purpose input port is tested using a

matrix

keyboard. When the key is pressed the corresponding key value is

displayed in

the LCD.

1. The procedure to download the hex file is same as discussed in

previous

example projects.

2. The hex file to test general purpose input is in location

usr_drive:\...\ SM_ARMboard_Examples\ IN_Test\ IN_Test.hex

9. Example program to Test Output using external LED module:

In this example project the general purpose output port is tested using

external

switch & LED board. When the switch is ON the corresponding LED is

made ON.

1. The procedure to download the hex file is same as discussed in

previous

example projects.

2. The hex file to test general purpose output is in location

usr_drive:\...\ SM_ARMboard_Examples\ OUT_Test\ OUT_Test.hex

10. Example program to Test PWM output:

In this example project the PWM wave form is generated and it can be

viewed using a oscilloscope.

1. The procedure to download the hex file is same as discussed in

previous

example projects.

2. The hex file to test PWM output is in location

usr_drive:\...\ SM_ARMboard_Examples\ PWM_Test\ PWM_Test.hex

Page 23: lpc2148

Revision 1.0 16

Page 24: lpc2148

LPC2148 ‐ User Manual 

11. Example program to Test RTC:

In this example project the RTC is activated and time can be viewed in LCD.

1. The procedure to download the hex file is same as discussed in

previous

example projects.

2. The hex file to test RTC output is in location

usr_drive:\...\ SM_ARMboard_Examples\ RTC_Test\RTC_Test.hex

6. Installing keiluV4:

The keiluv4 IDE and compiler provided with the CD is code limited demo

version

and it can compile only less than 32K of code size. If the validity of the

software is

completed or if you want latest software updates, kindly verify the

website

www.keil.com

1. In the ‘utilities’ CD provided to you, open the

location

usr_drive:\...\ Softwares\ Keiluv4.

2. Double click the setup file‘mdk402.exe’ and follow the instructions while

installation.

Page 25: lpc2148

Revision 1.0 17

Page 26: lpc2148

LPC2148 ‐ User Manual 

7.Setting up Gcc compiler:

Gcc compiler is a open source C cross compiler. Here we are using

Cygnus’s GCC compiler containing µclibc library to compile programs written for

ARM. The setup file to install GCC compiler is in the location

usr drive:\...\Softwares\Keil UV4\Keil ARM compiler\gccarm331.exe

If you want to use RTOS in Arm follow the instructions given

below otherwise skip those and directly go to unit 8.

To compile RTOS, we need to add the GCC compiler with keil UV4. So in keilUV4,

1. Select “File extensions, books and environment” button (Refer Figure7.1).

Figure 7.1

2. Select “Folders/Extension” tab in the newly opened window. (refer figure 7.2).

Revision 1.0 18

Page 27: lpc2148

LPC2148 ‐ User Manual 

Figure 7.2

3. After selecting the Folders/Extension, we have to select GNU compiler.

After that

select YES in newly opened dialog box(refer figure 7.3).

Figure 7.3

4. We have to type GCC compiler’s Folder path and Prefix as given below.

Revision 1.0 19

Page 28: lpc2148

LPC2148 ‐ User Manual 

GNU-Tool-Prefix : arm-uclibc-

GNU-Tool Folder : c:\Cygnus

Figure7.4

5. Then click OK.

8. Installing Flash magic tool:

This Flash Magic tool is used to download the hex file to the

microcontroller. The setup file to install FlashMagic is in the location

usr_drive:\...\ Softwares\ FlashMagic.

Double click the setup file ‘FlashMagic.exe’ and follow the instructions while installation.

9. Creating New Project in Keiluv4:

Revision 1.0 20

Page 29: lpc2148

LPC2148 ‐ User Manual 

The steps to be followed to create new project is given below

1. Go to startprogramsKeiluVision4.

Figure 9.1

2. A blank IDE will be opened now as shown below,

Revision 1.0 21

Page 30: lpc2148

LPC2148 ‐ User Manual 

3. Open Project NewuVisionProject.., as shown below

4. In the ‘Create New Project’ window, select the location where you want

to save

your project folder using the “Save In” filed at the top. Then create a new

folder

to store your project files. In the below example, we have selected the

location

C:\KeiluV4\ARM\Examples. Create separate folder for our project and

name it as

“LED proj”.

Page 31: lpc2148

Revision 1.0 22

Page 32: lpc2148

LPC2148 ‐ User Manual 

5. Name the project as LED_TestProj and click save, as show below

Revision 1.0 23

Page 33: lpc2148

LPC2148 ‐ User Manual 

6. Next, in the “Select Device for Target” window, Select LPC2148 under

“NXP(founded by Philips)” in the ‘Database’ Filed. Its is shown below

7. Select LPC2148 and click ‘OK’ as shown below

Revision 1.0 24

Page 34: lpc2148

LPC2148 ‐ User Manual 

8. Next a message window opens, asking for startup file to be added or not. Press

‘yes’ to finish creation of project.

9. Create new file to write your C code by selecting FileNew. A new text file will

be opened. Type the below given code in the text file.

#include <LPC214x.H>

int main (void) {

IODIR0 = 0x80000200; IOCLR0 =

0x80000200; while (1)

{ }

}

/* LPC214x definitions */

/* P0.13 and P0.31 defined as Outputs */

/*Active Low outputs makes the LEDs ON*/

/* Loop forever */

10. Save the file as LED_testproj.c by selecting FileSave

Page 35: lpc2148

Revision 1.0 25

Page 36: lpc2148

LPC2148 ‐ User Manual 

11. Add the saved “LED_testproj.c” file to your project using the ‘Project window’ at

the left side. Expand the Target folder by clicking on the + symbol. Right click on

the ‘source group1’ and select the ‘Add files to group source group1’

Revision 1.0 26

Page 37: lpc2148

LPC2148 ‐ User Manual 

Then click the ‘close’ button.

Revision 1.0 27

Page 38: lpc2148

LPC2148 ‐ User Manual 

12. Now select the ‘Target options’ button from the tool bars, as shown below

13. In the ‘Options for Taget Target1’ window, choose all the options as shown

below one by one.

Revision 1.0 28

Page 39: lpc2148

LPC2148 ‐ User Manual 

Revision 1.0 29

Page 40: lpc2148

LPC2148 ‐ User Manual 

Revision 1.0 30

Page 41: lpc2148

LPC2148 ‐ User Manual 

Revision 1.0 31

Page 42: lpc2148

LPC2148 ‐ User Manual 

14. Next step is to compile and build the project. To compile the project select

projectTranslate C:\Keiluv4\ARM\Examples\LED Proj\Led_testproj from the

menu bar.

Revision 1.0 32

Page 43: lpc2148

LPC2148 ‐ User Manual 

15. You must get ‘0 Errors’ message at the Output window, as shown below

Revision 1.0 33

Page 44: lpc2148

LPC2148 ‐ User Manual 

16. To build the project press F7 or select ProjectBuild from the menu bar. After

completion of build process, you would expect messages at the output window

as shown below.

17. Now download the created hex file using FlashMagic. Follow the procedure to

download the hex file as we discussed in the topic “Programming LPC2148

board”.

Note:

Before start editing the existing example projects, copy the file lcd.c from the utilities CD to the location C:\Keil\ARM\INC\philips

Page 45: lpc2148

Revision 1.0 34

Page 46: lpc2148

LPC2148 ‐ User Manual 

10. Editing existing example projects:

In this section we discuss about creating your own application or editing the existing example projects. Copy the ‘SM_ARMboard_Examples’ folder from CD to your PC.

To open the example project in the folder “ADC_Test”, we can use to methods

1. First method: Double click on the ‘ADC_Test’ uvision project file in the folder. 2. Second method: Open the Keil IDE and select ProjectOpen project..

Then, using the ‘Select Project’ window locate the project file you wish to open and click ‘Open’.

3. Now all the files related to the project will be shown in the ‘project’ window at

the left side. Double click on the file you wish to edit and start developing your

application.

Page 47: lpc2148

Revision 1.0 35

Page 48: lpc2148

LPC2148 ‐ User Manual 

11. LPC2148 Development board schematics:

Revision 1.0 36

Page 49: lpc2148

LPC2148 ‐ User Manual 

12. Working with RTOS:

In this section we are about to discuss procedures to be followed to compile and port UCOS-II Real Time Operating System. The associated files and their respective group is tabulated below for your ease of understanding.

S.NO FILE GROUP FILES1 OS related files 1.os_core.c 15.os_cfg.h

2.os_debug_r.c 16.ucos_ii.h3.os_flag.c 4.os_mbox.c 5.os_mem.c 6.os_mutex.c 7.os_q.c 8.os_sem.c 9.os_task.c 10.os_time.c 11.os_tmr.c 12.ucos_ii.c 13.app_cfg.h 14.includes.h

2 Processor(port) 1.os_cpu_c.crelated files 2.os_cpu_a.s

3.start.s4.os_cpu.h5.LPC214X.h

3 Board Support 1.bsp.cPackage related files2.bsp.h

4 Driver files (depends1.lcd.con application) 2.uart0_driver.c

3.lcd.h4.uart0.h

5 Compiler related 1.ROM.ld (linker script files)files(here GCCcompiler is used)

Table 10.1In the example RTOS project given to you, all the above mentioned files are kept

in single folder and project is created in keil IDE. The projects are compiled using GCCcompiler.

Revision 1.0 37

Page 50: lpc2148

LPC2148 ‐ User Manual 

12.1Keil settings to integrate GCC: 1. Install Cygus gcc compiler given with Keiluv4 IDE inside the location

Userdrive…/LPC2148 utilities CD/Keil UV4/Keil ARM Compiler/gccarm331.exe 2. After installation you can see a folder named Cygnus in the C:\ drive. 3. In the menu bar click “File Extension, books and Environment..” button as shown

below

4. In the pop up window opened, choose ‘Folders/Extension tab’ 5. Choos use GNU compiler and set GNU-Tool prefix as “arm-uclibc-” and GNU Tool

folder “c:\cygnus\” as shown in the figure below.

6. Then click the ‘option for Target’ button as shown below

7. A window named ‘option for target Target1’ will be opened and choose “Linker”

tab in that window . There in the ‘Linker script file’ option locate the ROM.ld file

Page 51: lpc2148

given to you with LPC2148 utilities CD. Its shown below for your reference.

Revision 1.0 38

Page 52: lpc2148

LPC2148 ‐ User Manual 

8. Then in the ‘output’ tab choose ‘create HEX file’ option as shown below

9. Finally click OK button and now the set up is ready to use GCC compiler to

compile RTOS.

Revision 1.0 39

Page 53: lpc2148

LPC2148 ‐ User Manual 

12.2 Compiling existing example projects: In this section let us discuss how to compile the example projects given

to you. Here we discuss about compiling uart project under the folder ‘ucos_arm_uart’

1. Open the folder ‘user drive…/LPC2148 utilities CD/RTOS_Example/ucos_arm_uart’

2. Double click the project file ‘ucos-keil.uvproj’ 3. The window as shown below will be opened.

4. Click the “Rebuild” button at the menu bar to build all the files included in the

project. 5. Once the build was successful you can see the below messages from the ‘output’

window as shown below. 6. This project displays three different messages from three different tasks using

semaphore. It is self explanatory from the output about the messages and

respective tasks.

Page 54: lpc2148

Revision 1.0 40

Page 55: lpc2148

LPC2148 ‐ User Manual 

7. Now you can use the hex file generated to download into the microcontroller. 8. After downloading the hex file, reset the LPC2148 board. You can view the

output in the hyper terminal window as shown below at 9600 baud rate.

Revision 1.0 41

Page 56: lpc2148

LPC2148 ‐ User Manual 

12.3 Creating new RTOS project: In this section let us discuss how to create a new RTOS project. Here we are

about to discuss a project with LCD application. This application uses mutex semaphore to display two messages in LCD display. The first message “Task 1” is sent by task1 at first line and second message “Task 2” is sent by task2 at second line. The procedure to create new RTOS project is as follows

1. Create new folder named “ucos_uart_arm”

Revision 1.0 42

Page 57: lpc2148

LPC2148 ‐ User Manual 

2. Copy all the files listed in the Table10.1 from the folder ‘ucos files’ into this

folder. Make sure all the files shown below are copied inside the folder.

3. Now create a new uvision project as we have discussed in other non RTOS example project by selecting Target microcontroller as LPC2148. Creating a new RTOS project is shown in below images. Refer the below images to compile and build the RTOS project and images itself self explanatory.

Page 58: lpc2148

Revision 1.0 43

Page 59: lpc2148

LPC2148 ‐ User Manual 

4. Select Project New uvision project. Proceed the project creation by referring

the images given in this section

Revision 1.0 44

Page 60: lpc2148

LPC2148 ‐ User Manual 

Revision 1.0 45

Page 61: lpc2148

LPC2148 ‐ User Manual 

Revision 1.0 46

Page 62: lpc2148

LPC2148 ‐ User Manual 

5. Finally check the hex file in your project folder. Download the hex file using Flash

magic and verify the output in hyper terminal window.

Revision 1.0 47

Page 63: lpc2148

LPC2148 ‐ User Manual 

APPENDIX -I: Component List

COMPONENT LABEL DESCRIPTIONIC’s U1 ARM- LPC2148C

U2 MAX-232U3 24C16 - EEPROM

U4,U5 OP -07 (OPAMP)RG1 LM117,+3.3V (Voltage regulator)

Sensors CON8 LM35, Temperature sensorDisplay CON9 2x16 LCD DisplaySwitch S1 SW-Pb (System Reset)

S2 3x2 way switchS3 8 pin DIP switch

LEDs L1 Power LEDL2 On board LED (P0.13)L3 On board LED (P0.31)

Capacitors C1 33PFC2 33PFC3 22PFC4 22PFC5 10MFC6 22MFC7 22MFC8 22MFC9 22MFC10 22MFC11 22MF

DC1.1, DC1.2, DC1.3, 0.1MFDC1.4, DC1.5, DC2, DC3,

DC4, DC5 Resistors R1,R2,R3,R4,R5,R6,R8,R1 10K

1 R7 22K

R9,R10,R12,R13,R14,R15,1KR16VR1 1K (POT)

Diode D1 1N4148D2,D3 1N4007

Crystal X1 12MHzX2 32.768MHz

Battery B1 3.6V, 16mA

Revision 1.0 48

Page 64: lpc2148

LPC2148 ‐ User Manual 

APPENDIX-II: CONNECTORS & CONNECTION DETAILS

Type Label Description26 Pin FRC CON1 For GPIO20 Pin FRC CON2 For JTAG

DB9 CON3 UART0DB9 CON4 UART1

3 Pin RMC CON5 PWM output6 Pin RMC CON6 ADC input3 Pin RMC CON7 DAC output from OPAMP3 Pin RMC CON8 Temperature sensor input16 Pin RMC CON9 LCD DisplayPower jack C10 Power input

PS2 CON11 Keyboard interface

Connections Details for 26 pin FRC:

Revision 1.0 49

Page 65: lpc2148

LPC2148 ‐ User Manual 

Connection Details for LCD(16 pin RMC):

Connection Details for JTAG(20 pin FRC):

Revision 1.0 50

Page 66: lpc2148

LPC2148 ‐ User Manual 

APPENDIX - III : LPC2148 specification.

Features

• 16/32-bit ARM7TDMI-S microcontroller in a tiny LQFP64 package.

• 8 to 40 KB of on-chip static RAM and 32 to 512 kB of on-chip flash program

memory.

• 128 bit wide interface/accelerator enables high speed 60 MHz operation.

• In-System/In-Application Programming(ISP/IAP) via on-chip boot-loader

software. Single flash sector or full chip erase in 400 ms and

programming of 256 bytes in 1 ms.

• Embedded ICE RT and Embedded Trace interfaces offer real-time debugging

with the on-chip Real Monitor software and high speed tracing of

instruction execution.

• USB 2.0 Full Speed compliant Device Controller with 2 kB of endpoint RAM. In

addition, the LPC2146/8 provide 8 kB of on-chip RAM accessible to USB by

DMA. • One or two (LPC2141/2 vs. LPC2144/6/8) 10-bit A/D converters provide

a total of

6/14 analog inputs, with conversion times as low as 2.44 μs per channel.

• Single 10-bit D/A converter provides variable analog output.

• Two 32-bit timers/external event counters (with four capture and four compare

channels each), PWM unit (six outputs) and watchdog.

• Low power real-time clock with independent power and dedicated 32 kHz clock

input.

• Multiple serial interfaces including two UARTs (16C550), two Fast I2C-bus (400

kbit/s), SPI and SSP with buffering and variable data length capabilities.

• Vectored interrupt controller with configurable priorities and vector

addresses.

• Up to 45 of 5 V tolerant fast general purpose I/O pins in a tiny LQFP64

package.

• Up to nine edge or level sensitive external interrupt pins available.

• 60 MHz maximum CPU clock available from programmable on-chip PLL with

settling time of 100 μs.

Page 67: lpc2148

Revision 1.0 51

Page 68: lpc2148

LPC2148 ‐ User Manual 

• On-chip integrated oscillator operates with an external crystal in range

from 1

MHz to 30 MHz and with an external oscillator up to 50 MHz.

• Power saving modes include Idle and Power-down.

• Individual enable/disable of peripheral functions as well as peripheral

clock

scaling for additional power optimization.

• Processor wake-up from Power-down mode via external interrupt, USB,

Brown-

Out Detect (BOD) or Real-Time Clock (RTC).

• Single power supply chip with Power-On Reset (POR) and BOD circuits:

- CPU

operating voltage range of 3.0 V to 3.6 V (3.3 V ± 10 %) with 5 V

tolerant I/O

pads.

Page 69: lpc2148

Revision 1.0 52

Page 70: lpc2148

LPC2148 ‐ User Manual 

Pin Configuration:

For further studies about LPC2148 specification refer NXP’s website to download LPC2148 user manual.

Revision 1.0 53

Page 71: lpc2148

LPC2148 ‐ User Manual 

APPENDIX - IV: LPC2148 Add-On card Projects Source code:

1. Source code for Interrupt Buzzer:

#include <LPC214x.h> #include "ext.h"

int main() {

init_VIC(); init_Interrupt(); init_ports();

while(1)

{ //wait_for_turnoffRelay();

}}

2. Source code for Elevator_model:

#include <LPC214x.h> #include "elevator.h"

char floor_req, present_floor, buz;

void wait(unsigned int delay) // This function can be used to add delays{ unsigned int i; for(i=0;i<delay;i++);

}

int main(){unsigned int key,j;init_Matrix_7seg(); // Initialize matrix keyboard and 7segment dispalyclearall_7seg(); // clear 7 segment displaypresent_floor = 0;

Revision 1.0 54

Page 72: lpc2148

LPC2148 ‐ User Manual 

floor_req = 0; // default floor request is initialized to 0'th floorwhile(1) {

if(key != 0) // Accept only valid keys in key board{

switch(key)

{ case 5: case 8:

floor_req = 1; break;

case 1: case 4:

floor_req = 0; break;

case 9: case 12:

floor_req = 2; break;

case 13: case 16:

floor_req = 3; break;

default: break;}

}

if(floor_req == present_floor) {

// No Operation

Digit_Dispay(1,present_floo

r);

}

else if(floor_req > present_floor)

{while(present_floor < floor_req)

{ present_floor++;

//Display present floor

// increment floor number by one

stepper_clockwise(2); // run the motor clockwise for elevator to climb up

Digit_Dispay(1,present_floor); // Display the present floor

Page 73: lpc2148

Revision 1.0 55

Page 74: lpc2148

LPC2148 ‐ User Manual 

}IOCLR0 = 0x00010000;

for(j=0;j<80;j++) wait(65000);

IOSET0 = 0x00010000; }

else

{

// turn on buzzer which indicates lift has stopped

// turn off buzzer which indicates lift has stopped

while(present_floor >

floor_req)

{

present_floor--; // decrement the floor number by onestepper_anticlockwise(2); // run the motor anticlockwise for elevator to climb down Digit_Dispay(1,present_floor);

}

IOCLR0 = 0x00010000; // turn on buzzer which indicates lift has stopped

for(j=0;j<100;j++) wait(65000);

IOSET0 = 0x00010000; // turn off buzzer which indicates lift has stopped

} key = catch_key(); // scan for a valid key press

}

}

Page 75: lpc2148

Revision 1.0 56

Page 76: lpc2148

LPC2148 ‐ User Manual 

3. Source code for Matrix_7segment:

#include <LPC214x.h> #include "mat_7seg.h"

int main() { unsigned int key, last_key, Disp_key;init_Matrix_7seg(); clearall_7seg();last_key = 0;while(1) {

key = catch_key(); if(key != 0){if(key != last_key)

again(assume this as STEP1)

{Disp_key = key;

last_key = key;}

}Alpha_Dispay(4,Disp_ke

y); }

}

// Initialize matrix keyboard and 7segment dispaly // clear 7 segment display// Initialize this variable to zero

// scan for a valid key press // zero means no key is pressed

// check whether the same key is pressed

// valid new key is stored in another variable // this variable's value is used for STEP1

4. Source code for Stepper interface :

#include <LPC214x.H> /* LPC214x definitions */

#define step1 0x00010000 /* P1.16 */#define step2 0x00020000 /* P1.17 */

void wait (void) { /* wait function */int d;for (d = 0; d < 10000; d++); /* only to delay for LED flashes */

}

call_stepper_forw()

Page 77: lpc2148

Revision 1.0 57

Page 78: lpc2148

LPC2148 ‐ User Manual 

{ IOCLR1 = 0X00FF0000; IOSET1 = 0X00050000; wait(); wait(); wait(); wait(); IOCLR1 = 0X00FF0000; IOSET1 = 0X00070000; wait(); wait(); wait(); wait(); IOCLR1 = 0X00FF0000; IOSET1 = 0X00060000; wait(); wait(); wait(); wait(); IOCLR1 = 0X00FF0000; IOSET1 = 0X00040000; wait(); wait(); wait(); wait(); }

int main (void)

{ IODIR1 |= 0xFFFFFFFF;

IOCLR1 |= 0X00FF0000; wait();

while(1) /*Loop Forever*/{

call_stepper_forw();

Page 79: lpc2148

wait(); wait(); wait(); wait(); IOCLR1 = 0X00FF0000;

}}

Revision 1.0 58

Page 80: lpc2148

LPC2148 ‐ User Manual 

5. Source code for Switch_LED:

#include<LPC214x.H>

int main() { unsigned long value; unsigned int i;

IODIR1 |= 0xFF000000;

while(1) { value = IOPIN1;

value = value & 0x00FF0000;IOPIN1 = ((value << 8) | value);

} }

6. Source code for train_model:

#include <LPC214x.h> #include "train.h"

unsigned int delay;

void wait(unsigned int delay) // This function can be used to add delays{

{ unsigned int i; for(i=0;i<delay;i++);

}

int main() { unsigned int j;

init_stepper();

Revision 1.0 59

Page 81: lpc2148

LPC2148 ‐ User Manual 

init_buz();

IOCLR0 = 0x00010000; for(j=0;j<80;j++) wait(65000); IOSET0 = 0x00010000;

delay = 65500; stepper_clockwise(3); delay = 40000; stepper_clockwise(4); delay = 32000; stepper_clockwise(5); delay = 25000; stepper_clockwise(7); delay = 20000; stepper_clockwise(8); delay = 25000; stepper_clockwise(7); delay = 32000; stepper_clockwise(5); delay = 40000; stepper_clockwise(4); delay = 65500; stepper_clockwise(3); delay = 65534; stepper_clockwise(1); IOCLR0 = 0x00010000; for(j=0;j<80;j++) wait(65000); IOSET0 = 0x00010000; while(1);

}

Revision 1.0 60

Page 82: lpc2148

LPC2148 ‐ User Manual 

Revision 1.0 61