EC8711 EMBEDDED LABORATORY Lab Manual
EC8711 EMBEDDED LABORATORY Lab Manual
EC8711 EMBEDDED LABORATORY Lab Manual
ANNE’S
COLLEGE OF ENGINEERING AND TECHNOLOGY
(An ISO 9001:2015 certified Institution)
Anguchettypalayam, Panruti – 607 106
OBSERVATION NOTE
NAME : _________________________________________________________
REGISTER NO : _________________________________________________________
SYLLABUS
LIST OF EXPERIMENTS
1. Study of ARM evaluation system
2. Interfacing ADC and DAC.
3. Interfacing LED and PWM.
4. Interfacing real time clock and serial port.
5. Interfacing keyboard and LCD.
6. Interfacing EPROM and interrupt.
7. Mailbox.
8. Interrupt performance characteristics of ARM and FPGA.
9. Flashing of LEDS.
10. Interfacing stepper motor and temperature sensor.
11. Implementing zigbee protocol with ARM.
OUTCOMES:
At the end of the course, the student should be able to:
Write programs in ARM for a specific Application
Interface memory and Write programs related to memory operations
Interface A/D and D/A convertors with ARM system
Analyse the performance of interrupt
Write programmes for interfacing keyboard, display, motor and sensor.
Formulate a mini project using embedded system
LIST OF EXPERIMENTS
The µVision4 IDE offers numerous features and advantages that help you quickly and
successfully develop embedded applications. They are easy to use and are guaranteed to help you
achieve your design goals.
Software Flow
First open the icon keil µvision4 and the follow the steps are given below. The menu
bar provides you with menus for editor operations, project maintenance, development tool option
settings, program debugging, external tool control, window selection and manipulation, and on-line help.
The toolbar buttons allow you to rapidly execute µVision4 commands. A Status Bar provides editor and
debugger information. The various toolbars and the status bar can be enabled or disabled from the View
Menu commands.
Creating a New Project
Below mentioned procedures will explains the steps required to setup a simple application and to generate HEX
output.
STEP 1: Go to “Project” and close the current project “Close Project”.
STEP 4: Create a folder and give a proper name that can be related to the Project.
STEP 5: A small window will pop up with name “Select Device for Target ‘Target 1’”, and select the data
base NXP founded by Philips.
STEP 10: Can be start to write *.asm/c code on the editor window.
STEP 11: Can be save the file, if the program is in “C” save as “filename.C” or else save as “filename.ASM”.
STEP 12: Add this source file to Group1, Go to the “Project Workspace” drag the +mark “Target 1” in
that right click on “Source Group1” and click on “Add Files to Group “Source Group1””.
STEP 13: A small window will pop up with name “Add Files to Group Source Group1”, by default, the
Files of type will be in C source Files (*.C). If the program is in C, have to select C source Files (*.C) or
select ASM Source file (*.s,*.src,*.a*).
STEP 14: Then go to “Project” click on “Build Target” or F7. Output window will display related error and
warning messages.
Simulation
Part:
STEP 15: Go to “Project” menu, click on “Rebuild all target Files” and start Debug. From View menu can
get Memory Window and from Peripherals can get I/O ports, Serial etc. For access internal memory
type i:0x_memory location example: i:0x30 and for external and program memory x:0x_memory location,
c:0x_memory location respectively. From Register window we can edit and access the values also.
HEX file creation:
STEP 16: Follow the STEP up to 14, then go to “Project” and click on “Option for Group ‘Source
Group1’”. There a small window will open with name “Option for Target ‘Target1’”. In that window, go to
first menu “Device”, can be select LPC2148.
STEP 17: Next go to Target menu, set clock frequency as 12.0 MHz and select Thumb mode in the code
generation selection box.
STEP 18: Then go to Output menu and click on create HEX file.
STEP 21: For creating Hex file go to “Project” menu and click on “Rebuild all target Files”
FLASH MAGIC
Introduction:
NXP Semiconductors produce a range of Microcontrollers that feature both on-chip Flash
memory and the ability to be reprogrammed using In-System Programming technology. Flash Magic is
Windows software from the Embedded Systems Academy that allows easy access to all the ISP features
provided by the devices.
These features include:
Flash Magic provides a clear and simple user interface to these features and more as described in
the following sections. Under Windows, only one application may have access the COM Port at any one time,
preventing other applications from using the COM Port. Flash Magic only obtains access to the selected COM
Port when ISP operations are being performed. This means that other applications that need to use the
COM Port, such as debugging tools, may be used while Flash Magic is loaded. Note that in this manual third
party Compilers are listed alphabetically. No preferences are indicated or implied.
Installation Procedure for Flash Magic software:
STEP 22: For programming with communication port, first select the device LPC2148 in ARM 7 category,
COM port will be COM 1, baud rate 9600, interface None [ISP], Oscillator frequency 12.0 MHz and click
on erase of flash code Rd plot.
STEP 23: Under the menu Options, go to Advanced options.
STEP 24: Under the menu Advanced options, go to Hardware configuration, click on the Use DTR and
RTS to control RST and ISP pin.
STEP 25: Next browse the path of hex file and select the file.
STEP 26: After selecting ISP mode on the Hardware Kit and click on start.
STEP 27: After the above steps device will start to program.
STEP 28: Finally can be see the finished indication and Reset the device into running mode.
Programming through USB:
STEP 1: Connect the USB cable between ARM-7 LPC2148 Trainer Kit and PC. Connect the power supply to
the trainer kit and power up. After can see a popup window with name “Found New Hardware CP2102 USB
to UART Bride Controller“.
STEP 2: Select on Install from a list or specific location (Advanced) and click “Next”.
STEP 3: Browse for the driver file location and select the folder, click next.
STEP 4: After that can see New Hardware wizard, and then click on finish.
Thank you for using ARM 7 LPC2148 Trainer Kit designed for educational training purpose and
the embedded device from NXP. This document is a User’s guide which describes the complete
hardware design of the ARM 7 LPC2148 Trainer Kit.
Features:
1. Device daughter card, easy and flexible to upgrade the device.
2. Four 10 pin individual digital or analog I/O ports are available.
3. One16 pin digital I/O port is available.
4. Inbuilt LEDs are available for PWM output.
5. Inbuilt push to on switch for Reset.
6. Inbuilt push to on switch for External Interrupt.
7. USB ISP programmer inbuilt.
8. On board Serial to USB bridge is available
Device Daughter Board Details:
CN6 CN8
PIN NO: DESCRIPTION PIN NO: DESCRIPTION
1 P0.21/PWM5/AD1.6/CAP1.3 33 P0.8/TXD1/PWM4/AD1.1
2 P0.22/AD1.7/CAP0.0/MAT0.0 34 P0.9/RXD1/PWM6/EINT3
3 RTCX1 35 P0.10/RTS1/CAP1.0/AD1.2
4 P1.19/TRACEPKT3 36 P1.23/PIPESTAT2
5 RTCX2 37 P0.11/CTS1/CAP1.1/SCL1
6 VSS 38 P0.12/DSR1/MAT1.0/AD1.3
7 VDDA 39 P0.13/DTR1/MAT1.1/AD1.4
8 P1.18/TRACEPKT2 40 P1.22/PIPESTAT1
9 P0.25/AD0.4/AOUT 41 P0.14/DCD1/EINT1/SDA1
10 D+ 42 VSS
11 D- 43 VDD
12 P1.17/TRACEPKT1 44 P1.21/PIPESTAT0
13 P0.28/AD0.1/CAP0.2/MAT0.2 45 P0.15/RI1/EINT2/AD1.5
14 P0.29/AD0.2/CAP0.3/MAT0.3 46 P0.16/EINT0/MAT0.2/CAP0.2
15 P0.30/AD0.3/CAP0.0/EINT3 47 P0.17/CAP1.2/SCK1/MAT1.2
16 P1.16/TRACEPKT0 48 P1.20/TRACESYNC
CN7 CN5
PIN NO: DESCRIPTION PIN NO: DESCRIPTION
17 P0.31/UP_LED/CONNECT 49 VBAT
18 VSS 50 VSS
19 P0.0/TXD0/PWM1 51 VDD
20 P1.31/TRST 52 P1.30/TMS
21 P0.1/RXD0/PWM3/EINT0 53 P0.18/CAP1.3/MISO1/MAT1.3
22 P0.2/SCL0/CAP0.0 54 P0.19/CAP1.2/MOSI1/MAT1.2
23 VDD 55 P0.20/EINT3/SSEL1/MAT1.3
24 P1.26/RTCK 56 P1.29/TCK
25 VSS 57 RESET
26 P0.3/SDA0/MAT0.0/EINT1 58 P0.23/VBUS
27 P0.4/SCK0/CAP0.1/AD0.6 59 VSSA
28 P1.25/EXTIN0 60 P1.28/TDI
29 P0.5/MISO0/MAT0.1/AD0.7 61 XTAL2
30 P0.6/MOSI0/CAP0.2/AD1.0 62 XTAL1
31 P0.7/SSEL0/PWM2/EINT2 63 VREF
32 P1.24/TRACECLK 64 P1.27/TDO
FRC PIN DETAILS:
FRC 1 FRC 2 FRC 3
PIN NO: DESCRIPTION PIN NO: DESCRIPTION PIN NO: DESCRIPTION
1 P0.16 1 P0.8 1 P0.3(SDA0)
2 P0.17 2 P0.9 2 P0.2(SCL0)
3 P0.18 3 P0.10 3 P0.14(SDA1)
4 P0.19 4 P0.11 4 P0.11(SCL1)
5 P0.20 5 P1.16 5 P0.16 ENT1
6 P0.21 6 P1.17 6 P0.15 ENT2
7 P0.22 7 P1.18 7 RS232 TX0
8 P0.23 8 P1.19 8 RS232 RX0
9 +5V 9 P1.20 9 +5V
10 GND 10 P1.21 10 GND
11 P1.22
12 P1.23
FRC 5
13 +5V FRC 4
PIN NO: DESCRIPTION
14 NA PIN NO: DESCRIPTION
1 P0.25
15 +3V3 1 P0.0
2 P0.28
16 GND 2 P0.1
3 P0.29
3 P0.2
4 P0.30
4 P0.3
5 P0.31
5 P0.4
6 NA
6 P0.5
7 RS232 TX1
7 P0.6
8 RS232 RX1
8 P0.7
9 +5V
9 +5V
10 GND
10 GND
INTERFACE CARD DETAILS:
LED MODULE MATRIX KEYPAD STEPPER MOTOR
PIN NO DESCRIPTION PIN NO DESCRIPTION PIN NO DESCRIPTION
1 Led1 1 Row1 1 Input1
2 Led2 2 Row2 2 Input2
3 Led3 3 Row3 3 Input3
4 Led4 4 Row4 4 Input4
5 Led5 5 Column1 5 NA
6 Led6 6 Column2 6 NA
7 Led7 7 Column3 7 NA
8 Led8 8 Column4 8 NA
9 +5V 9 +5V 9 +5V
10 GND 10 GND 10 GND
LCD DAC
PIN NO DESCRIPTION PIN NO DESCRIPTION
1 NA 1 NA
2 RS 2 NA
3 R/W 3 NA
4 EN 4 NA
5 D0 5 A8
6 D1 6 A7
7 D2 7 A6
8 D3 8 A5
9 D4 9 A4
10 D5 10 A3
11 D6 11 A2
12 D7 12 A1
13 +5V 13 +5V
14 -5V 14 -5V
15 +3V3 15 NA
16 GND 16 GND
TOGGLE SWITCH DC MOTOR SEVEN SEGMENT
PIN NO DESCRIPTION PIN NO DESCRIPTION PIN NO DESCRIPTION
1 SW1 1 INPUT1 1 SHIFT CLK
2 SW2 2 ENABLE 2 DATA IN
3 SW3 3 NA 3 LATCH CLK
4 SW4 4 INPUT2 4 NA
5 SW5 5 NA 5 NA
6 SW6 6 NA 6 NA
7 SW7 7 NA 7 NA
8 SW8 8 NA 8 NA
9 +5V 9 +5V 9 +5V
10 GND 10 GND 10 GND
EXP NO:
LED & FLASHING OF LED’S
DATE
AIM:
To write and execute the program for LED & Flashing Led’s with ARM7 (LPC2148)
processor.
PROCEDURE
1. Create a New project, Go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μvision Project Create New Project Select Device for Target.
3. Select the data base NXP LPC2148.
4. Add Startup file and Next go to “File” and click “New”.
5. Write a program on the editor window and save as “Main.c”.
6. Add this source file to Group and click on “Build Target” or F7.
7. Create a Hex file from “Project” menu and click on “Rebuild all target Files”.
8. Open Flash magic and select the device LPC2148 in ARM 7 category, Choose the
hardware connected COM port, baud rate 9600, interface None [ISP], Oscillator frequency
12.0 MHz and click on erase of flash code Rd plot.
9. Next browse the path of hex file and select the file.
10. After selecting ISP mode on the Hardware Kit and click on start then device will start to
program
11. Finally can be see the finished indication and values in SPJ Terminal and Reset the
device into running mode.
LED INTERFACING:
CIRCUIT DIAGRAM:
PROGRAM:
#include <lpc214x.h>
int i;
int main()
{
IODIR0=(1<<3);
while(1)
{
IOSET0=(1<<3);
for(i=0;i<120000;i++);
IOCLR0=(1<<3);
for(i=0;i<120000;i++);
}
}
FLASHING OF LED:
CIRCUIT DIAGRAM:
PROGRAM:
TYPE-I:
#include <lpc214x.h>
int i;
int main()
{
IODIR0=0x000000FF;
while(1)
{
IOSET0=0x000000AA;
for(i=0;i<120000;i++);
IOCLR0=0x000000AA;
for(i=0;i<120000;i++);
}
}
TYPE-II:
#include <lpc214x.h>
int i,b;
int main()
{
IODIR0=0x000000FF;
while(1)
{
for(b=0;b<8;b++)
{
IOSET0=(1<<b);
for(i=0;i<120000;i++);
IOCLR0=(1<<b);
for(i=0;i<120000;i++);
}
}
}
TYPE-III
#include <lpc214x.h>
int i;
int main()
{
IODIR0=(1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7);
while(1)
{
IOSET0=(1<<0);
for(i=0;i<120000;i++);
IOCLR0=(1<<0);
for(i=0;i<120000;i++);
IOSET0=(1<<1);
for(i=0;i<120000;i++);
IOCLR0=(1<<1);
for(i=0;i<120000;i++);
IOSET0=(1<<2);
for(i=0;i<120000;i++);
IOCLR0=(1<<2);
for(i=0;i<120000;i++);
IOSET0=(1<<3);
for(i=0;i<120000;i++);
IOCLR0=(1<<3);
for(i=0;i<120000;i++);
IOSET0=(1<<4);
for(i=0;i<120000;i++);
IOCLR0=(1<<4);
for(i=0;i<120000;i++);
IOSET0=(1<<5);
for(i=0;i<120000;i++);
IOCLR0=(1<<5);
for(i=0;i<120000;i++);
IOSET0=(1<<6);
for(i=0;i<120000;i++);
IOCLR0=(1<<6);
for(i=0;i<120000;i++);
IOSET0=(1<<7);
for(i=0;i<120000;i++);
IOCLR0=(1<<7);
for(i=0;i<120000;i++);
}
}
#include <lpc214x.h>
int b,i;
int main()
{
IODIR0=0x000000FF;
while(1)
{
for(b=0;b<8;b++)
{
IOSET0=(1<<b);
for(i=0;i<120000;i++);
IOCLR0=(1<<b);
for(i=0;i<120000;i++);
}
for(b=7;b>=0;b--)
{
IOSET0=(1<<b);
for(i=0;i<120000;i++);
IOCLR0=(1<<b);
for(i=0;i<120000;i++);
}
}
}
PROGRAM:
#include <lpc214x.h>
int i,b;
int main()
{
IODIR0=0x000000FF;
IODIR0=~(1<<16);
while(1)
{
if((IOPIN0&(1<<16))==0)
{
for(b=0;b<8;b++)
{
IOSET0=(1<<b);
for(i=0;i<120000;i++);
IOCLR0=(1<<b);
for(i=0;i<120000;i++);
}
}
else
{
IOCLR0=0x000000FF;
}
}
}
PROGRAM:
#include <lpc214x.h>
int i,b;
int main()
{
IODIR0=0x000000FF;
IODIR0=~(1<<16)&~(1<<23);
while(1)
{
if((IOPIN0&(1<<16))==0)
{
for(b=0;b<8;b++)
{
IOSET0=(1<<b);
for(i=0;i<120000;i++);
IOCLR0=(1<<b);
for(i=0;i<120000;i++);
}
}
else if((IOPIN0&(1<<23))==0)
{
for(b=7;b>=0;b--)
{
IOSET0=(1<<b);
for(i=0;i<120000;i++);
IOCLR0=(1<<b);
for(i=0;i<120000;i++);
}
}
else
{
IOCLR0=0x000000FF;
}
}
}
RESULT:
EXP NO:
INTERFACING OF LCD
DATE
AIM:
To write and execute the program for LCD with ARM7 (LPC2148) processor.
PROCEDURE
1. Create a New project, Go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μvision Project Create New Project Select Device for Target.
3. Select the data base NXP LPC2148.
4. Add Startup file and Next go to “File” and click “New”.
5. Write a program on the editor window and save as “Main.c”.
6. Add this source file to Group and click on “Build Target” or F7.
7. Create a Hex file from “Project” menu and click on “Rebuild all target Files”.
8. Open Flash magic and select the device LPC2148 in ARM 7 category, COM port will be
COM 3, baud rate 9600, interface None [ISP], Oscillator frequency 12.0 MHz and click on
erase of flash code Rd plot.
9. Next browse the path of hex file and select the file.
10. After selecting ISP mode on the Hardware Kit and click on start then device will start to
program
11. Finally can be see the finished indication and values in SPJ Terminal and Reset the
device into running mode.
INTERFACING LCD:
CIRCUIT DIAGRAM:
PROGRAM:
#include <lpc214x.h>
#include <lcd.h>
int main()
{
LCD_INIT();
LCDSTR(0x00000084,"St.ANNES");
LCDSTR(0x000000C2,"ENGG COLLEGE");
while(1)
{
}
}
LCD LAYOUT:
80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F
C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
OUTPUT:
RESULT:
EXP NO:
INTERFACING OF MATRIX KEYBOARD
DATE
AIM:
To write and execute the program for Matrix Keyboard with ARM7 (LPC2148) processor.
PROCEDURE
1. Create a New project, Go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μvision Project Create New Project Select Device for Target.
3. Select the data base NXP LPC2148.
4. Add Startup file and Next go to “File” and click “New”.
5. Write a program on the editor window and save as “Main.c”.
6. Add this source file to Group and click on “Build Target” or F7.
7. Create a Hex file from “Project” menu and click on “Rebuild all target Files”.
8. Open Flash magic and select the device LPC2148 in ARM 7 category, COM port will be
COM 3, baud rate 9600, interface None [ISP], Oscillator frequency 12.0 MHz and click on
erase of flash code Rd plot.
9. Next browse the path of hex file and select the file.
10. After selecting ISP mode on the Hardware Kit and click on start then device will start to
program
11. Finally can be see the finished indication and values in SPJ Terminal and Reset the
device into running mode.
KEYBOARD INTERFACING:
CIRCUIT DIAGRAM:
PROGRAM:
#include <lpc214x.h>
#include <lcd.h>
#include <keyboard.h>
int main()
{
LCD_INIT();
LCDSTR(0x00000080,"Matrix Keypad");
LCDSTR(0x000000C0,"Key Pressed: ");
while(1)
{
IO0CLR = CLR;
IO0SET = C1;
delay_ms(10);
if(scan(R1))LCDSTR(0x000000CC,"0"); //K1
if(scan(R2))LCDSTR(0x000000CC,"4"); //K5
if(scan(R3))LCDSTR(0x000000CC,"8"); //K9
if(scan(R4))LCDSTR(0x000000CC,"C"); //K13
IO0CLR = CLR;
IO0SET = C2;
if(scan(R1))LCDSTR(0x000000CC,"1"); //K2
if(scan(R2))LCDSTR(0x000000CC,"5"); //K6
if(scan(R3))LCDSTR(0x000000CC,"9"); //K10
if(scan(R4))LCDSTR(0x000000CC,"D"); //K14
IO0CLR = CLR;
IO0SET = C3;
if(scan(R1))LCDSTR(0x000000CC,"2"); //K3
if(scan(R2))LCDSTR(0x000000CC,"6"); //K7
if(scan(R3))LCDSTR(0x000000CC,"A"); //K11
if(scan(R4))LCDSTR(0x000000CC,"E"); //K15
IO0CLR = CLR;
IO0SET = C4;
if(scan(R1))LCDSTR(0x000000CC,"3"); //K4
if(scan(R2))LCDSTR(0x000000CC,"7"); //K8
if(scan(R3))LCDSTR(0x000000CC,"B"); //K12
if(scan(R4))LCDSTR(0x000000CC,"F"); //K16
}
}
RESULT:
EXP NO:
INTERFACING OF SERIAL PORT
DATE
AIM:
To write and execute the program for Serial Port with ARM7 (LPC2148) processor.
PROCEDURE
1. Create a New project, Go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μvision Project Create New Project Select Device for Target.
3. Select the data base NXP LPC2148.
4. Add Startup file and Next go to “File” and click “New”.
5. Write a program on the editor window and save as “Main.c”.
6. Add this source file to Group and click on “Build Target” or F7.
7. Create a Hex file from “Project” menu and click on “Rebuild all target Files”.
8. Open Flash magic and select the device LPC2148 in ARM 7 category, COM port will be
COM 3, baud rate 9600, interface None [ISP], Oscillator frequency 12.0 MHz and click on
erase of flash code Rd plot.
9. Next browse the path of hex file and select the file.
10. After selecting ISP mode on the Hardware Kit and click on start then device will start to
program
11. Finally can be see the finished indication and values in SPJ Terminal and Reset the
device into running mode.
SERIAL PORT:
CIRCUIT DIAGRAM:
PROGRAM:
#include <lpc214x.h>
#include <delay.h>
#include <usart.h>
int main()
{
usart0_init();
while(1)
{
getchar();
delay_ms(1000);
}
}
CIRCUIT DIAGRAM:
PROGRAM:
#include <lpc214x.h>
#include <delay.h>
#include <usart.h>
int key_pressed;
int main()
{
usart0_init();
IODIR0=(1<<7);
IOCLR0=(1<<7);
printf("\n Serial Communication \n");
while(1)
{
initial_state:
printf("\n Key Pressed Is: ");
key_pressed=getchar();
if(key_pressed=='A')
{
IOSET0=(1<<7);
printf("\n LED ON \n");
delay_ms(100);
goto initial_state;
}
else if(key_pressed=='S')
{
IOCLR0=(1<<7);
printf("\n LED OFF \n");
delay_ms(100);
goto initial_state;
}
else
{
printf("\n INVALID KEY \n");
delay_ms(100);
goto initial_state;
}
}
}
RESULT:
EXP NO:
INTERFACING OF STEPPER MOTOR
DATE
AIM:
To write and execute the program for Stepper Motor with ARM7 (LPC2148) processor.
PROCEDURE
1. Create a New project, Go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μvision Project Create New Project Select Device for Target.
3. Select the data base NXP LPC2148.
4. Add Startup file and Next go to “File” and click “New”.
5. Write a program on the editor window and save as “Main.c”.
6. Add this source file to Group and click on “Build Target” or F7.
7. Create a Hex file from “Project” menu and click on “Rebuild all target Files”.
8. Open Flash magic and select the device LPC2148 in ARM 7 category, COM port will be
COM 3, baud rate 9600, interface None [ISP], Oscillator frequency 12.0 MHz and click on
erase of flash code Rd plot.
9. Next browse the path of hex file and select the file.
10. After selecting ISP mode on the Hardware Kit and click on start then device will start to
program
11. Finally can be see the finished indication and values in SPJ Terminal and Reset the
device into running mode.
Pin No
0.16 0.17 0.18 0.19
Clock
PROGRAM:
#include <lpc214x.h>
#include <delay.h>
int main()
{
IODIR0=(1<<16)|(1<<17)|(1<<18)|(1<<19);
while(1)
{
//FORWARD DIRECTION
IOCLR0=(1<<16);
IOCLR0=(1<<17);
IOSET0=(1<<18);
IOSET0=(1<<19);
delay_ms(10);
IOCLR0=(1<<16);
IOSET0=(1<<17);
IOSET0=(1<<18);
IOCLR0=(1<<19);
delay_ms(10);
IOSET0=(1<<16);
IOSET0=(1<<17);
IOCLR0=(1<<18);
IOCLR0=(1<<19);
delay_ms(10);
IOSET0=(1<<16);
IOCLR0=(1<<17);
IOCLR0=(1<<18);
IOSET0=(1<<19);
delay_ms(10);
}
}
Pin No
0.16 0.17 0.18 0.19
Clock
PROGRAM:
#include <lpc214x.h>
#include <delay.h>
int main()
{
IODIR0=(1<<16)|(1<<17)|(1<<18)|(1<<19);
while(1)
{
//REVERSE DIRECTION
IOSET0=(1<<16);
IOCLR0=(1<<17);
IOCLR0=(1<<18);
IOSET0=(1<<19);
delay_ms(10);
IOSET0=(1<<16);
IOSET0=(1<<17);
IOCLR0=(1<<18);
IOCLR0=(1<<19);
delay_ms(10);
IOCLR0=(1<<16);
IOSET0=(1<<17);
IOSET0=(1<<18);
IOCLR0=(1<<19);
delay_ms(10);
IOCLR0=(1<<16);
IOCLR0=(1<<17);
IOSET0=(1<<18);
IOSET0=(1<<19);
delay_ms(10);
}
}
RESULT:
EXP NO:
INTERFACING OF REAL TIME CLOCK
DATE
AIM:
To write and execute the program for Real Time Clock with ARM7 (LPC2148) processor.
PROCEDURE
1. Create a New project, Go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μvision Project Create New Project Select Device for Target.
3. Select the data base NXP LPC2148.
4. Add Startup file and Next go to “File” and click “New”.
5. Write a program on the editor window and save as “Main.c”.
6. Add this source file to Group and click on “Build Target” or F7.
7. Create a Hex file from “Project” menu and click on “Rebuild all target Files”.
8. Open Flash magic and select the device LPC2148 in ARM 7 category, COM port will be
COM 3, baud rate 9600, interface None [ISP], Oscillator frequency 12.0 MHz and click on
erase of flash code Rd plot.
9. Next browse the path of hex file and select the file.
10. After selecting ISP mode on the Hardware Kit and click on start then device will start to
program
11. Finally can be see the finished indication and values in SPJ Terminal and Reset the
device into running mode.
PROGRAM:
#include <lpc21xx.h>
#include <rtc.h>
#include <lcd.h>
int main()
{
SETTIME();
LCD_INIT();
LCDSTR(0x00000080,"REAL TIME CLOCK ");
LCDSTR(0x000000C0," ");
while(1)
{
LCD_CMD (0x000000C3);
LCD_DATA(HOUR/10 + '0');
LCD_DATA(HOUR%10 + '0');
LCD_DATA(':') ;
LCD_DATA(MIN/10 + '0');
LCD_DATA(MIN%10 + '0');
LCD_DATA(':') ;
LCD_DATA(SEC/10 + '0');
LCD_DATA(SEC%10 + '0');
}
}
RESULT:
AIM:
To write and execute the program for ADC with ARM7 (LPC2148) processor.
7 ADC Module 1
PROCEDURE
1. Create a New project, Go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μvision Project Create New Project Select Device for Target.
3. Select the data base NXP LPC2148.
4. Add Startup file and Next go to “File” and click “New”.
5. Write a program on the editor window and save as “Main.c”.
6. Add this source file to Group and click on “Build Target” or F7.
7. Create a Hex file from “Project” menu and click on “Rebuild all target Files”.
8. Open Flash magic and select the device LPC2148 in ARM 7 category, COM port will be
COM 3, baud rate 9600, interface None [ISP], Oscillator frequency 12.0 MHz and click on
erase of flash code Rd plot.
9. Next browse the path of hex file and select the file.
10. After selecting ISP mode on the Hardware Kit and click on start then device will start to
program
11. Finally can be see the finished indication and values in SPJ Terminal and Reset the
device into running mode.
TEMPERATURE SENSOR:
CIRCUIT DIAGRAM:
PROGRAM:
#include <lpc214x.h>
#include <string.h>
#include <delay.h>
#include <lcd.h>
#include <adc.h>
int main()
{
LCD_INIT();
INIT_ADC();
LCDSTR(0x00000082,"TEMPERATURE");
LCDSTR(0x000000C0,"DEGREE C=");
while(1)
{
TEMP = READ_ADC();
ADC = (1000*(TEMP*(3.901/1024)))-100;
LCD_CMD(0x000000CA);
delay_ms(1000);
CONVERT_ADC1(ADC);
}
}
PROGRAM:
#include <lpc214x.h>
#include <delay.h>
#include <lcd.h>
#include <adc.h>
int main()
{
LCD_INIT();
INIT_ADC();
LCDSTR(0x00000086,"ADC");
LCDSTR(0x000000C0,"VOLTAGE =");
while(1)
{
for(count=0;count<10000;count++)
{
temp_sum = temp_sum+READ_ADC();
}
temp_adv=temp_sum/10000;
TEMP=temp_adv;
temp_sum=0;
ADC = 1000*(TEMP*(3.92/1024));
LCD_CMD(0x000000CA);
CONVERT_ADC(ADC);
}
}
RESULT:
AIM:
To write and execute the program for DAC with ARM7 (LPC2148) processor.
PROCEDURE
1. Create a New project, Go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μvision Project Create New Project Select Device for Target.
3. Select the data base NXP LPC2148.
4. Add Startup file and Next go to “File” and click “New”.
5. Write a program on the editor window and save as “Main.c”.
6. Add this source file to Group and click on “Build Target” or F7.
7. Create a Hex file from “Project” menu and click on “Rebuild all target Files”.
8. Open Flash magic and select the device LPC2148 in ARM 7 category, COM port will be
COM 3, baud rate 9600, interface None [ISP], Oscillator frequency 12.0 MHz and click on
erase of flash code Rd plot.
9. Next browse the path of hex file and select the file.
10. After selecting ISP mode on the Hardware Kit and click on start then device will start to
program
11. Finally can be see the finished indication and values in SPJ Terminal and Reset the
device into running mode.
PROGRAM:
SIN WAVE:
#include<lpc214x.h>
#include<math.h>
unsigned int i;
int value;
int main()
{
PINSEL1 = 0X00080000;
while(1)
{
for(i=0;i<=360;i++)
{
value = 512+400*sin(i*0.01744); //sin(2*pi*t/T)
DACR = value<<6;
}
}
}
SQUARE WAVE:
#include<LPC214x.H>
int main()
{
unsigned int a,b;
unsigned int delay;
PINSEL1 = 0X00080000;
while(1)
{
a=0x00;
DACR=a<<6;
for(delay=0; delay<120; delay++);
b=0x3FF;
DACR=b<<6;
for(delay=0; delay<120; delay++);
}
}
TRIANGULAR WAVE:
#include<lpc214x.h>
unsigned int i;
int main()
{
PINSEL1 = 0X00080000;
while(1)
{
for(i=0;i<=1023;i++)
{
DACR = i<<6;
}
for(i=1023;i>0;i--)
{
DACR = i<<6;
}
}
}
RAMP WAVE:
#include<lpc214x.h>
unsigned int i;
int main(void)
{
PINSEL1 = 0x00080000;
while (1)
{
for(i = 0 ; i <= 1023; i++)
{
DACR = i << 6 ;
}
}
}
#include<lpc214x.h>
unsigned int i = 0;
void wait(void)
{
unsigned int delay;
for(delay=0;delay<120;delay++);
}
unsigned int
datatable[25]={0x00,0x0F,0x1F,0x2F,0x3F,0x4F,0x5F,0x6F,0x7F,0x8F,0x9F,0xAF,0xBF,0xCF,0
xDF,0xEF,0xFF,0x100,0x150,0x200,0x250,0x300,0x350,0x399};
int main (void)
{
PINSEL1=0x00200000;
while (1)
{
for(i=0;i<25;i++)
{
DACR=(datatable[i]<<6);
wait();
}
}
}
RESULT:
EXP NO:
INTERFACING OF PULSE WIDTH MODULATION
DATE
AIM:
To write and execute the program for PWM with ARM7 (LPC2148) processor.
PROCEDURE
1. Create a New project, Go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μvision Project Create New Project Select Device for Target.
3. Select the data base NXP LPC2148.
4. Add Startup file and Next go to “File” and click “New”.
5. Write a program on the editor window and save as “Main.c”.
6. Add this source file to Group and click on “Build Target” or F7.
7. Create a Hex file from “Project” menu and click on “Rebuild all target Files”.
8. Open Flash magic and select the device LPC2148 in ARM 7 category, COM port will be
COM 3, baud rate 9600, interface None [ISP], Oscillator frequency 12.0 MHz and click on
erase of flash code Rd plot.
9. Next browse the path of hex file and select the file.
10. After selecting ISP mode on the Hardware Kit and click on start then device will start to
program
11. Finally can be see the finished indication and values in SPJ Terminal and Reset the
device into running mode.
PROGRAM:
#include <lpc214x.h>
#include <pwm.h>
int main()
{
IODIR0=0X000000FF;
IOCLR0=0X000000FF;
PWM_INIT();
INIT_ADC();
while(1)
{
PWM = READ_ADC();
if(PWM>0x000003FF) PWM=0x000003FF;
PWMMR2 = PWM;
PWMLER=0X06;
}
}
RESULT:
EXP NO:
INTERFACING INTERRUPT
DATE
AIM:
To write and execute the program for Interrupt with ARM7 (LPC2148) processor.
PROCEDURE
1. Create a New project, Go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μvision Project Create New Project Select Device for Target.
3. Select the data base NXP LPC2148.
4. Add Startup file and Next go to “File” and click “New”.
5. Write a program on the editor window and save as “Main.c”.
6. Add this source file to Group and click on “Build Target” or F7.
7. Create a Hex file from “Project” menu and click on “Rebuild all target Files”.
8. Open Flash magic and select the device LPC2148 in ARM 7 category, COM port will be
COM 3, baud rate 9600, interface None [ISP], Oscillator frequency 12.0 MHz and click on
erase of flash code Rd plot.
9. Next browse the path of hex file and select the file.
10. After selecting ISP mode on the Hardware Kit and click on start then device will start to
program
11. Finally can be see the finished indication and values in SPJ Terminal and Reset the
device into running mode.
INTERRUPT:
CIRCUIT DIAGRAM:
PROGRAM:
#include<lpc21xx.h>
#include<interrupt.h>
#include<delay.h>
unsigned int b;
int main(void)
{
init_ext();
IODIR0=0x000000FF;
while(1)
{
for(b=0;b<8;b++)
{
IOSET0=(1<<b);
delay_ms(100);
IOCLR0=(1<<b);
delay_ms(100);
}
}
}
RESULT:
EXP NO:
INTERFACING EEPROM
DATE
AIM:
To write and execute the program for EEPROM with ARM7 (LPC2148) processor.
PROCEDURE
1. Create a New project, Go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μvision Project Create New Project Select Device for Target.
3. Select the data base NXP LPC2148.
4. Add Startup file and Next go to “File” and click “New”.
5. Write a program on the editor window and save as “Main.c”.
6. Add this source file to Group and click on “Build Target” or F7.
7. Create a Hex file from “Project” menu and click on “Rebuild all target Files”.
8. Open Flash magic and select the device LPC2148 in ARM 7 category, COM port will be
COM 3, baud rate 9600, interface None [ISP], Oscillator frequency 12.0 MHz and click on
erase of flash code Rd plot.
9. Next browse the path of hex file and select the file.
10. After selecting ISP mode on the Hardware Kit and click on start then device will start to
program
11. Finally can be see the finished indication and values in SPJ Terminal and Reset the
device into running mode.
EEPROM:
CIRCUIT DIAGRAM:
PROGRAM:
#include <lpc21xx.h>
#include <lcd.h>
#include <eeprom.h>
#include <keyboard.h>
char buf[16];
unsigned char cnt=0;
int main()
{
LCD_INIT();
LCDSTR(0x00000082,"EEPROM TEST ");
LCDSTR(0x000000C0,"COMMAND ENTER: 1");
cnt=1;
while(1)
{
IO0CLR = CLR;
IO0SET = C1;
delay_ms(10);
if(scan(R1))
{
LCDSTR(0x000000C0,"COMMAND ENTER: 1");
cnt=1;
}
if(scan(R2))
{
if(cnt==1)
{
eeprom_write(0,"HI PANRUTI ");
LCDSTR(0x000000C0,"Writting Message");
delay_ms(2000);
LCDSTR(0x000000C0,"Success ");
}
if(cnt==2)
{
eeprom_write(0,"HI CUDDALORE ");
LCDSTR(0x000000C0,"Writting Message");
delay_ms(2000);
LCDSTR(0x000000C0,"Success ");
}
if(cnt==3)
{
eeprom_write(0,"HI NEYVELI ");
LCDSTR(0x000000C0,"Writting Message");
delay_ms(2000);
LCDSTR(0x000000C0,"Success ");
}
if(cnt==4)
{
eeprom_write(0,"HI PONDICHERRY ");
LCDSTR(0x000000C0,"Writting Message");
delay_ms(2000);
LCDSTR(0x000000C0,"Success ");
}
}
IO0CLR = CLR;
IO0SET = C2;
if(scan(R1))
{
LCDSTR(0x000000C0,"COMMAND ENTER: 2");
cnt=2;
}
if(scan(R2))
{
eeprom_read(0,16, buf);
LCDSTR(0x000000C0,"Reading Message ");
delay_ms(2000);
LCDSTR(0x000000C0,buf);
}
IO0CLR = CLR;
IO0SET = C3;
if(scan(R1))
{
LCDSTR(0x000000C0,"COMMAND ENTER: 3");
cnt=3;
}
if(scan(R2))
{
eeprom_write(0 , "Nothing Here ");
LCDSTR(0x000000C0,"Erasing Message ");
delay_ms(2000);
LCDSTR(0x000000C0,"Completed ");
cnt=5;
}
IO0CLR = CLR;
IO0SET = C4;
if(scan(R1))
{
LCDSTR(0x000000C0,"COMMAND ENTER: 4");
cnt=4;
}
}
}
RESULT:
EXP NO:
INTERFACING ZIGBEE PROTOCOL WITH ARM
DATE
AIM:
To write and execute the program for Zigbee Protocol with ARM7 (LPC2148) processor.
PROCEDURE
1. Create a New project, Go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μvision Project Create New Project Select Device for Target.
3. Select the data base NXP LPC2148.
4. Add Startup file and Next go to “File” and click “New”.
5. Write a program on the editor window and save as “Main.c”.
6. Add this source file to Group and click on “Build Target” or F7.
7. Create a Hex file from “Project” menu and click on “Rebuild all target Files”.
8. Open Flash magic and select the device LPC2148 in ARM 7 category, COM port will be
COM 3, baud rate 9600, interface None [ISP], Oscillator frequency 12.0 MHz and click on
erase of flash code Rd plot.
9. Next browse the path of hex file and select the file.
10. After selecting ISP mode on the Hardware Kit and click on start then device will start to
program
11. Finally can be see the finished indication and values in SPJ Terminal and Reset the
device into running mode.
ZIGBEE TRANSMITTER:
CIRCUIT DIAGRAM:
LPC2148 ZIGBEE
TX
PROGRAM:
#include <LPC21xx.H>
#include <delay.h>
#include <zigbee.h>
int main()
{
usart0_init();
while(1)
{
sendchar('A');
delay_ms(1000);
sendchar('B');
delay_ms(1000);
}
}
ZIGBEE RECEIVER:
CIRCUIT DIAGRAM:
LPC2148 ZIGBEE
RX
PC
TERMINAL
WINDOW
PROGRAM:
#include <LPC21xx.H>
#include <delay.h>
#include <zigbee.h>
unsigned char key=0;
int main(void)
{
usart0_init();
IODIR0 = 0X00FF0000;
IOCLR0= 0X00FF0000;
while(1)
{
key= getchar();
if(key=='A')
{
IOSET0= 0X000F0000;
delay_ms(500);
IOCLR0= 0X000F0000;
}
if(key=='B')
{
IOSET0= 0X00F00000;
delay_ms(500);
IOCLR0= 0X00F00000;
}
}
}
RESULT:
EXP NO:
MAILBOX
DATE
AIM:
To write and execute the program for Mailbox with ARM7 (LPC2148) processor.
PROCEDURE
1. Create a New project, Go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μvision Project Create New Project Select Device for Target.
3. Select the data base NXP LPC2148.
4. Add Startup file and Next go to “File” and click “New”.
5. Write a program on the editor window and save as “Main.c”.
6. Add this source file to Group and click on “Build Target” or F7.
7. Create a Hex file from “Project” menu and click on “Rebuild all target Files”.
8. Open Flash magic and select the device LPC2148 in ARM 7 category, COM port will be
COM 3, baud rate 9600, interface None [ISP], Oscillator frequency 12.0 MHz and click on
erase of flash code Rd plot.
9. Next browse the path of hex file and select the file.
10. After selecting ISP mode on the Hardware Kit and click on start then device will start to
program
11. Finally can be see the finished indication and values in SPJ Terminal and Reset the
device into running mode.
MAILBOX:
BLOCK DIAGRAM:
TERMINAL
LPC2148 MODE
PROGRAM:
#include <RTL.h>
#include <LPC21xx.H>
#include <stdio.h>
OS_TID tsk1;
OS_TID tsk2;
typedef struct
{
float voltage;
float current;
U32 counter;
}T_MEAS;
os_mbx_declare (MsgBox,16);
_declare_box (mpool,sizeof(T_MEAS),16);
__task void send_task (void);
__task void rec_task (void);
void init_serial ()
{
PINSEL0 = PINSEL0 | 0X00000005;
U0LCR = 0X83;
U0DLL = 0Xbb;
U0DLM = 0X00;
U0LCR = 0X03;
}
__task void send_task (void)
{
T_MEAS *mptr;
tsk1 = os_tsk_self ();
tsk2 = os_tsk_create (rec_task, 0);
os_mbx_init (MsgBox, sizeof(MsgBox));
os_dly_wait (5);
RESULT:
EXP NO:
PERFORMANCE CHARACTERISTICS OF ARM
DATE
AIM:
To write and execute the program for Interrupt Performance Characteristics of ARM
with ARM7 (LPC2148) processor.
1 ARM Processor 1
2 USB/FRC Connector 1
3 Power Supply (5V, DC) 1
PROCEDURE
1. Create a New project, Go to “Project” and close the current project “Close Project”.
2. Next Go to the Project New μvision Project Create New Project Select Device for Target.
3. Select the data base NXP LPC2148.
4. Add Startup file and Next go to “File” and click “New”.
5. Write a program on the editor window and save as “Main.c”.
6. Add this source file to Group and click on “Build Target” or F7.
7. Create a Hex file from “Project” menu and click on “Rebuild all target Files”.
8. Open Flash magic and select the device LPC2148 in ARM 7 category, COM port will be
COM 3, baud rate 9600, interface None [ISP], Oscillator frequency 12.0 MHz and click on
erase of flash code Rd plot.
9. Next browse the path of hex file and select the file.
10. After selecting ISP mode on the Hardware Kit and click on start then device will start to
program
11. Finally can be see the finished indication and values in SPJ Terminal and Reset the
device into running mode.
PROGRAM:
#include <lpc214x.h>
#include <string.h>
#include <lcd.h>
#include <pll.h>
void CONVERT_DATA(unsigned int);
void SEC_DELAY(void);
void ext_interrupt(void)__irq
{
EXTINT = 0X02; /* Clear interrupt flag */
count++;
VICVectAddr = 0x00000000; /* Acknowledge Interrupt */
}
void init_ext(void)
{
PINSEL0 |= 0X20000000; /* enable EXT1 */
EXTMODE = 0X02; /* edge sensitive */
EXTPOLAR = 0X02; /* on rising edge */
VICVectAddr0 =(unsigned int)ext_interrupt; /* Set Interrupt Vector in 0 */
VICVectCntl0 = 0x0000002F; /* Use it for EXT1 Interrupt */
VICIntEnable = 0x00008000; /* enable EXT1 INTERRUPT */
}
int main()
{
init_ext();
LCD_INIT();
LCDSTR(0x00000080,"Counter: ");
LCDSTR(0x000000C0,"ARM PERFORMANCE");
while(1)
{
SEC_DELAY();
LCD_CMD(0x00000088);
CONVERT_DATA(count);
count=0;
}
void SEC_DELAY()
{
T0PR = 0x0000270F; //0x0000270F
T0MR0 = 0x00000BA1 ; //0x000004B0
T0TCR = 0x01;
while(T0TC != T0MR0);
T0MCR = 0x00000002;
T0TCR = 0x02;
}
RESULT:
#include <string.h>
extern void DELAY(unsigned int);
extern void LCDSTR(unsigned char ADDRESS,char *MSG);
extern void LCD_DATA(unsigned char);
extern void LCD_CD(unsigned int);
extern void LCD_INIT(void);
void LCD_INIT()
{
IO0DIR =0x00F00E00; // P0.9 ----- P0.11 LCD DATA
IO1DIR =0X00FF0000; // P1.16 --- P1.23 LCD CONTROL
LCD_CMD(0x00000038); //function set: 8-bit, 2 line, 5x7 dots
LCD_CMD(0x0000000C); //display on, cursor off
LCD_CMD(0x00000001); //clear display screen
LCD_CMD(0x00000006); //entry mode
}
keyboard.h:
#include <stdint.h>
#define C1 0X00E00000
#define C2 0X00D00000
#define C3 0X00B00000
#define C4 0X00700000
#define R1 0x000E0000
#define R2 0x000D0000
#define R3 0x000B0000
#define R4 0x00070000
void delay_ms(uint16_t j)
{
uint16_t x,i;
for(i=0;i<j;i++)
{
for(x=0; x<6000; x++); }
}
#include <stdint.h>
void delay_ms(uint16_t j)
{
uint16_t x,i;
for(i=0;i<j;i++)
{
for(x=0; x<6000; x++);
}
}
eeprom.h:
rtc.h:
void SETTIME(void)
{
CCR = 0x02;
HOUR = 12;
MIN = 10;
SEC = 00;
CCR = 0x11;
}
adc.h:
void INIT_ADC()
{
PINSEL1 |= 0x01000000;
AD0CR = 0x00200602;
}
void PWM_INIT()
{
PINSEL0 = 0X00008000; // Enable PWM2 -- P0.7
PWMLER = 0X00000004; // Set latch register
PWMPR = 0X00000000; // Prescale 0
PWMMR0 = 0X000003FF; // 120 KHz Frequency
PWMMR2 = 0X000003FF; // 50% Duty Cycle 7C 0,62,124,186
PWMMCR = 0X00000002; // Set only Match0 control
PWMPCR = 0X00000400;
PWMTCR = 0X00000009;
}
int READ_ADC()
{
int VAL;
AD0CR |= 0x01000000; /* Start A/D Conversion */
do
{
VAL = AD0DR1; /* Read A/D Data Register */
}
while (!(VAL & 0x80000000)); /* Wait for end of A/D Conversion */
AD0CR &= ~0x01000000; /* Stop A/D Conversion */
VAL >>=6;
VAL = VAL & 0x3FF;
return(VAL);
}
void CONVERT_ADC(unsigned int ADC)
{
unsigned int CNT1,CNT2,CNT3,CNT4;
unsigned char DATA1,DATA2,DATA3,DATA4;
CNT1 = ADC % 10000/1000;
CNT2 = ADC % 1000/100;
CNT3 = ADC % 100/10;
CNT4 = ADC % 10/1;
DATA1 = CNT1 | 0x30;
DATA2 = CNT2 | 0x30;
DATA3 = CNT3 | 0x30;
DATA4 = CNT4 | 0x30;
LCD_DATA(DATA1);
LCD_DATA('.');
LCD_DATA(DATA2);
LCD_DATA(DATA3);
LCD_DATA(DATA4);
return;
}
interrupt.h:
void init_ext(void)
{
PINSEL0 |= 0X20000000; /* enable EXT1 */
EXTMODE = 0X02; /* edge sensitive */
EXTPOLAR = 0X02; /* on rising edge */
VICVectAddr0 =(unsigned int)ext_interrupt; /* Set Interrupt Vector in 0 */
VICVectCntl0 = 0x0000002F; /* Use it for EXT1 Interrupt */
VICIntEnable = 0x00008000; /* enable EXT1 INTERRUPT */
}
void DELAY(unsigned long VALUE)
{
while(VALUE>0)
{
VALUE--;
}
}
pwm.h:
void INIT_ADC()
{
PINSEL1 |= 0x01000000;
AD0CR = 0x00200602;
}
void PWM_INIT()
{
PINSEL0 = 0X00008002; // Enable PWM2 -- P0.7
PWMPR = 0X00000000; // Prescale 0
PWMMR0 = 0X000003FF; // 120 KHz Frequency
PWMMR2 = 0X000003FF; // 50% Duty Cycle 7C 0,62,124,186
PWMMCR = 0X00000002; // Set only Match0 control
PWMPCR = 0X00000600;
PWMTCR = 0X00000009;
}
int READ_ADC()
{
int VAL;
AD0CR |= 0x01000000; /* Start A/D Conversion */
do
{
VAL = AD0DR1; /* Read A/D Data Register */
}
while (!(VAL & 0x80000000)); /* Wait for end of A/D Conversion */
AD0CR &= ~0x01000000; /* Stop A/D Conversion */
VAL >>=6;
VAL = VAL & 0x3FF;
return(VAL);
}
usart.h:
#include <stdio.h>
#include <time.h>
#include <rt_misc.h>
void usart0_init(void);
void usart1_init(void);
short check_usart(void);
int getchar_attempt (unsigned int);
short usart_print;
void usart1_init(void)
{
PINSEL0= (PINSEL0 & (~(0x0F<<16)))|(5<<16); /*Select the AD0.3 of P0.30*/
U1LCR &= 0xFC;//
U1FCR=0x07; //enable and clear FIFOs
U1LCR=0x83; //8-N-1, enable divisors
U1DLL=0xc3; //9600 baud (9615)
U1DLM=0x00;
U1LCR=0x03; //8-N-1, disable divisors
}
#define CR 0x0D
else
{
if (ch == '\n')
{
while (!(U1LSR & 0x20));
U1THR = CR; /* output CR */
}
while (!(U1LSR & 0x20));
return (U1THR = ch);
}
void usart_flush ()
{ /* Read character from Serial Port */
if(usart_print==0)
{
while ((U0LSR & 0x01))
{
getchar();
}
return;
}
else
{
while ((U1LSR & 0x01))
{
getchar();
}
return;
}
}
short check_usart(void)
{
if (U0LSR & 0x01)
{
return 0;
}
if (U1LSR & 0x01)
{
return 1;
}
return 255;
}
pll.h:
void INIT_PLL()
{
PLL0CFG=0x00000024; // TO GENERATE 60 MHZ CCLK
PLL0CON=0x00000001;
PLL0FEED=0x000000AA; // UPDATE THE PLL REGISTER
PLL0FEED=0x00000055;
while(!(PLL0STAT & 0x00000400)); // CHECK WHETHRT THE CCLK IS GENERATED EXAXT
VALUE
PLL0CON=0x00000003; // CONNECT PLL
PLL0FEED=0x000000AA; // UPDATE THE PLL REGISTER
PLL0FEED=0x00000055;
VPBDIV=0x00000002; // PCLK=1/2*CCLK
}
serial.h:
zigbee.h:
DC MOTOR INTERFACE:
#include <lpc214x.h>
#include <delay.h>
int main()
{
IODIR0=(1<<0)|(1<<3);
while(1)
{
IOSET0=(1<<0);
delay_ms(1000);
IOCLR0=(1<<0);
delay_ms(1000);
IOSET0=(1<<3);
delay_ms(1000);
IOCLR0=(1<<3);
delay_ms(1000);
}
}