LPC2148 User Manual
LPC2148 User Manual
boardUserManual
LPC2148UserManual
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:
Revision1.0
LPC2148UserManual
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
Revision1.0
LPC2148UserManual
Revision1.0
LPC2148UserManual
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:
9 RS232 connectors (2)
9 26 pin FRC for user I/O interface
9 20 pin JTAG interface
9 6 pin RMC for ADC interface
9 3pin RMC for PWM
9 3 pin RMC for DAC
9 PS2 connector for Keyboard interface
9 16 pin RMC for LCD module interface
Other peripherals:
9 126KB I2C based EEPROM
9 2 line x 16 character LCD
9 Temperature sensor
Revision1.0
LPC2148UserManual
2. Get going:
2.1 System Requirements:
Windows XP
Serial or parallel port
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.
LPC2148UserManual
Figure 3.1
Note:
In COM port option of step1 given in the Flash magic tool select the
appropriate port you are using.
Revision1.0
LPC2148UserManual
16pinRMC
connectorfor
LCDinterface
PS2
connector
for
Keyboard
26pinFRC
male
connector
foruserI/O
ARM7TDMI
LPC2148
Microcontroller
DB9
female
connector
forUART0
DB9
female
connector
forUART1
LM35
Temperature
sensorand
amplification
circuitry
20pinFRC
male
connector
forJTAG
RMCconnectors
forPWM,DAC
andADC
interface
Revision1.0
LPC2148UserManual
J1
JumperJ1isinJ12position (Topview)
Figure:4.1
J1
SwitchS2inpositionP1
Figure:4.2
SwitchS2inpositionP2
Revision1.0
LPC2148UserManual
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. 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
Revision1.0
LPC2148UserManual
Figure 5.1
Figure5.2
10
LPC2148UserManual
10. Now you can see the LEDs L2 and L3 on board glows.
Revision1.0
11
LPC2148UserManual
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
Revision1.0
12
LPC2148UserManual
Figure 5.5
6. Press Reset button. Now, in the hyper terminal window you can view the data
sent from microcontroller.
Revision1.0
13
LPC2148UserManual
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
14
LPC2148UserManual
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
Revision1.0
15
LPC2148UserManual
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
10.
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
Revision1.0
16
LPC2148UserManual
11.
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.
Revision1.0
17
LPC2148UserManual
Figure 7.1
2. Select Folders/Extension tab in the newly opened window. (refer figure 7.2).
Revision1.0
18
LPC2148UserManual
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.
Revision1.0
19
LPC2148UserManual
c:\Cygnus
Figure7.4
5. Then click OK.
Double click the setup file FlashMagic.exe and follow the instructions while installation.
20
LPC2148UserManual
Figure 9.1
Revision1.0
21
LPC2148UserManual
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.
Revision1.0
22
LPC2148UserManual
Revision1.0
23
LPC2148UserManual
LPC2148 under
Revision1.0
24
LPC2148UserManual
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)
{}
}
Revision1.0
25
LPC2148UserManual
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
Revision1.0
26
LPC2148UserManual
Revision1.0
27
LPC2148UserManual
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.
Revision1.0
28
LPC2148UserManual
Revision1.0
29
LPC2148UserManual
Revision1.0
30
LPC2148UserManual
Revision1.0
31
LPC2148UserManual
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.
Revision1.0
32
LPC2148UserManual
15. You must get 0 Errors message at the Output window, as shown below
Revision1.0
33
LPC2148UserManual
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
Revision1.0
34
LPC2148UserManual
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.
Revision1.0
35
LPC2148UserManual
Revision1.0
36
LPC2148UserManual
Processor(port)
related files
Board Support
Package related files
Driver files (depends
on application)
Compiler related
files(here GCC
compiler is used)
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)
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.
Revision1.0
37
LPC2148UserManual
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.
Revision1.0
38
LPC2148UserManual
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.
Revision1.0
39
LPC2148UserManual
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.
Revision1.0
40
LPC2148UserManual
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.
Revision1.0
41
LPC2148UserManual
Revision1.0
42
LPC2148UserManual
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.
Revision1.0
43
LPC2148UserManual
4. Select Project New uvision project. Proceed the project creation by referring
the images given in this section
Revision1.0
44
LPC2148UserManual
Revision1.0
45
LPC2148UserManual
Revision1.0
46
LPC2148UserManual
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.
Revision1.0
47
LPC2148UserManual
COMPONENT
ICs
Sensors
Display
Switch
LEDs
Capacitors
Resistors
Diode
Crystal
Battery
Revision1.0
48
LPC2148UserManual
Revision1.0
49
LPC2148UserManual
Revision1.0
50
LPC2148UserManual
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.
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.
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.
60 MHz maximum CPU clock available from programmable on-chip PLL with
Revision1.0
51
LPC2148UserManual
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.
Revision1.0
52
LPC2148UserManual
Pin Configuration:
For further studies about LPC2148 specification refer NXPs website to download
LPC2148 user manual.
Revision1.0
53
LPC2148UserManual
#include <LPC214x.h>
#include "ext.h"
int main()
{
init_VIC();
init_Interrupt();
init_ports();
while(1)
{
}
//wait_for_turnoffRelay();
int main()
{
unsigned int key,j;
init_Matrix_7seg();
clearall_7seg();
present_floor = 0;
Revision1.0
54
LPC2148UserManual
floor_req = 0;
while(1)
{
if(key != 0)
{
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
//Display present floor
Digit_Dispay(1,present_floor);
}
else if(floor_req > present_floor)
{
while(present_floor < floor_req)
{
present_floor++;
stepper_clockwise(2);
Digit_Dispay(1,present_floor);
Revision1.0
55
LPC2148UserManual
}
IOCLR0 = 0x00010000;
for(j=0;j<80;j++)
wait(65000);
IOSET0 = 0x00010000;
}
else
{
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();
Revision1.0
56
LPC2148UserManual
/* LPC214x definitions */
#define step1
#define step2
/* P1.16 */
/* P1.17 */
/* wait function */
/* only to delay for LED flashes */
0x00010000
0x00020000
57
LPC2148UserManual
{
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();
}
/*Loop Forever*/
58
LPC2148UserManual
int main()
{
unsigned int j;
init_stepper();
Revision1.0
unsigned int i;
for(i=0;i<delay;i++);
59
LPC2148UserManual
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);
Revision1.0
60
LPC2148UserManual
Revision1.0
61