Anda di halaman 1dari 62

ARM7 LPC2148 Development board User Manual

No.56, Venkatesan Chowdry Street, West Tambaram, Chennai - 600045 Ph: 044-43159192/22266935 Cell: 98411 33919. Email: smmicrrosystem@gmail.com

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 users 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 Users Guide and, specifically, the Warnings and Restrictions notice in the Users 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 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

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

LPC2148 User Manual

12.3 Creating new RTOS project ...... 41 APPENDIX- I : APPENDIX-II : Component List 47 Connectors & Connection Details .......48

APPENDIX-III : LPC2148 Specification.. . 50 APPENDIX- IV : LPC2148 Add-On card Projects Source code...54

Revision 1.0

LPC2148 User Manual

1. INTRODUCTION: SM Micrros 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

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) 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

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

LPC2148 User Manual

4. LPC2148 Board Hardware: 4.1 Functional Overview:


16 pin RMC connector for LCD interface

PS2 connector for Keyboard

DB9 female connector for UART0

26 pin FRC male connector for user I/O

ARM7TDMI LPC2148 Microcontroller

DB9 female connector for UART1

LM35 Temperature sensor and amplification circuitry RMC connectors for PWM, DAC and ADC interface

20 pin FRC male connector for JTAG

Revision 1.0

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

Jumper J1 is in J12 position (Top view)

Figure: 4.1
1 2 3

J1

Jumper J1 is in J23 position (Top view)

3x2 way Switch S2: 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

Figure: 4.2
8

Revision 1.0

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. 2. 3. 4. 5. LEDs L2 and L3 which is on development board itself UART0 and UART1 LCD Display ADC 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

Revision 1.0

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

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 Programs AccessoriesCommunications Hyper terminal. You can view the window as shown below.

Revision 1.0

11

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

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

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 UART1s 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

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

Revision 1.0

15

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

Revision 1.0

16

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.

Revision 1.0

17

LPC2148 User Manual

7.Setting up Gcc compiler: Gcc compiler is a open source C cross compiler. Here we are using Cygnuss 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

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 compilers Folder path and Prefix as given below.
Revision 1.0

19

LPC2148 User Manual

GNU-Tool-Prefix : arm-uclibcGNU-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

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

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.

Revision 1.0

22

LPC2148 User Manual

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

Revision 1.0

23

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

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> /* LPC214x definitions */ int main (void) { IODIR0 = 0x80000200; IOCLR0 = 0x80000200; while (1) { } }

/* 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

Revision 1.0

25

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

LPC2148 User Manual

Then click the close button.

Revision 1.0

27

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

LPC2148 User Manual

Revision 1.0

29

LPC2148 User Manual

Revision 1.0

30

LPC2148 User Manual

Revision 1.0

31

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

LPC2148 User Manual

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

Revision 1.0

33

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

Revision 1.0

34

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.

Revision 1.0

35

LPC2148 User Manual

11. LPC2148 Development board schematics:

Revision 1.0

36

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 1 OS related files FILES 1.os_core.c 15.os_cfg.h 2.os_debug_r.c 16.ucos_ii.h 3.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 1.os_cpu_c.c 2.os_cpu_a.s 3.start.s 4.os_cpu.h 5.LPC214X.h 1.bsp.c 2.bsp.h 1.lcd.c 2.uart0_driver.c 3.lcd.h 4.uart0.h 1.ROM.ld (linker script files)

Processor(port) related files

3 4

Board Support Package related files Driver files (depends on application) Compiler related files(here GCC compiler is used)

Table 10.1 In 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 GCC compiler.

Revision 1.0

37

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 given to you with LPC2148 utilities CD. Its shown below for your reference.
Revision 1.0

38

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

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.

Revision 1.0

40

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

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

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.

Revision 1.0

43

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

LPC2148 User Manual

Revision 1.0

45

LPC2148 User Manual

Revision 1.0

46

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

LPC2148 User Manual

COMPONENT ICs

Sensors Display Switch

LEDs

Capacitors

Resistors

Diode Crystal Battery

APPENDIX -I: Component List LABEL DESCRIPTION U1 ARM- LPC2148C U2 MAX-232 U3 24C16 - EEPROM U4,U5 OP -07 (OPAMP) RG1 LM117,+3.3V (Voltage regulator) CON8 LM35, Temperature sensor CON9 2x16 LCD Display S1 SW-Pb (System Reset) S2 3x2 way switch S3 8 pin DIP switch L1 Power LED L2 On board LED (P0.13) L3 On board LED (P0.31) C1 33PF C2 33PF C3 22PF C4 22PF C5 10MF C6 22MF C7 22MF C8 22MF C9 22MF C10 22MF C11 22MF DC1.1, DC1.2, DC1.3, 0.1MF DC1.4, DC1.5, DC2, DC3, DC4, DC5 R1,R2,R3,R4,R5,R6,R8,R1 10K 1 R7 22K R9,R10,R12,R13,R14,R15, 1K R16 VR1 1K (POT) D1 1N4148 D2,D3 1N4007 X1 12MHz X2 32.768MHz B1 3.6V, 16mA

Revision 1.0

48

LPC2148 User Manual

APPENDIX-II: CONNECTORS & CONNECTION DETAILS Type Label Description 26 Pin FRC CON1 For GPIO 20 Pin FRC CON2 For JTAG DB9 CON3 UART0 DB9 CON4 UART1 3 Pin RMC CON5 PWM output 6 Pin RMC CON6 ADC input 3 Pin RMC CON7 DAC output from OPAMP 3 Pin RMC CON8 Temperature sensor input 16 Pin RMC CON9 LCD Display Power jack C10 Power input PS2 CON11 Keyboard interface Connections Details for 26 pin FRC:

Revision 1.0

49

LPC2148 User Manual

Connection Details for LCD(16 pin RMC):

Connection Details for JTAG(20 pin FRC):

Revision 1.0

50

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 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 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. Up to 45 of 5 V tolerant fast general purpose I/O pins in a tiny LQFP64 package. (ISP/IAP) via on-chip boot-loader software. Single flash sector or full chip erase in 400 ms and programming of 256

Revision 1.0

51

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, BrownOut 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.

Revision 1.0

52

LPC2148 User Manual

Pin Configuration:

For further studies about LPC2148 specification refer NXPs website to download LPC2148 user manual.

Revision 1.0

53

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) { unsigned int i; for(i=0;i<delay;i++); } int main() { unsigned int key,j; init_Matrix_7seg(); clearall_7seg(); present_floor = 0;
Revision 1.0

// This function can be used to add delays

// Initialize matrix keyboard and 7segment dispaly // clear 7 segment display

54

LPC2148 User Manual

floor_req = 0; while(1) { if(key != 0) { switch(key) {

// default floor request is initialized to 0'th floor // Accept only valid keys in key board

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) { Digit_Dispay(1,present_floor); } else if(floor_req > present_floor) { while(present_floor < floor_req) { present_floor++; stepper_clockwise(2);

// No Operation //Display present floor

// increment floor number by one // run the motor clockwise for elevator to climb up // Display the present floor 55

Digit_Dispay(1,present_floor);
Revision 1.0

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 one stepper_anticlockwise(2); // run the motor anticlockwise for elevator to climb down Digit_Dispay(1,present_floor); } IOCLR0 = 0x00010000; for(j=0;j<100;j++) wait(65000); IOSET0 = 0x00010000; } key = catch_key(); } } // scan for a valid key press // turn off buzzer which indicates lift has stopped // turn on buzzer which indicates lift has stopped

Revision 1.0

56

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(); // Initialize matrix keyboard and 7segment dispaly clearall_7seg(); // clear 7 segment display last_key = 0; // Initialize this variable to zero while(1) { // scan for a valid key press key = catch_key(); if(key != 0) // zero means no key is pressed { if(key != last_key) // check whether the same key is pressed again(assume this as STEP1) { Disp_key = key; // valid new key is stored in another variable // this variable's value is used for STEP1 last_key = key; } } Alpha_Dispay(4,Disp_key); } } 4. Source code for Stepper interface : #include <LPC214x.H> #define step1 #define step2 0x00010000 0x00020000 /* LPC214x definitions */ /* P1.16 */ /* P1.17 */

void wait (void) { int d; for (d = 0; d < 10000; d++); } call_stepper_forw()


Revision 1.0

/* wait function */ /* only to delay for LED flashes */

57

LPC2148 User Manual

{ IOCLR1 IOSET1 wait(); wait(); wait(); wait(); IOCLR1 IOSET1 wait(); wait(); wait(); wait(); IOCLR1 IOSET1 wait(); wait(); wait(); wait(); IOCLR1 IOSET1 wait(); wait(); wait(); wait(); }

= 0X00FF0000; = 0X00050000;

= 0X00FF0000; = 0X00070000;

= 0X00FF0000; = 0X00060000;

= 0X00FF0000; = 0X00040000;

int main (void) { IODIR1 |= 0xFFFFFFFF; IOCLR1 |= 0X00FF0000; wait(); while(1) { call_stepper_forw(); wait(); wait(); wait(); wait(); IOCLR1 = 0X00FF0000; } }
Revision 1.0

/*Loop Forever*/

58

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

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

LPC2148 User Manual

Revision 1.0

61

Anda mungkin juga menyukai