You are on page 1of 66

VIDHYA MANDHIR INSTITUTE OF

TECHNOLOGY

INGUR, ERODE 638 052

Department of Electronics and Communication Engineering

LABORATORY RECORD
EC6711 EMBEDDED LABORATORY

VII Semester B.E ECE

NAME :

REG. NO :

YEAR / SEM :
VIDHYA MANDHIR INSTITUTE OF
TECHNOLOGY

INGUR, ERODE 638 052

RECORD NOTE BOOK

REGISTER NO.

Certified that this is the bonafide record of work done by


Mr/Ms of the . Semester in
branch during the year in the
..laboratory.

Staff In-charge Head of the Department

Submitted for the Anna University Practical Examination held


on..

Internal Examiner External Examiner


TABLE OF CONTENT

Exp Page Marks


Date Name of the Experiment Sign.
No. No. (100)
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 Flashing of LEDS

Interfacing Stepper Motor and Temperature


9
Sensor

10 Implementing Zigbee Protocol with ARM

Interrupt Performance Characteristics Of


11
ARM And FPGA
Exp.No: 1
STUDY OF ARM EVALUATION SYSTEM
Date :

AIM
To study the ARM Evaluation System Architecture.

THEORY

The LPC2141/2/4/6/8 microcontrollers are based on a 32/16 bit ARM7TDMI-S CPU


with real-time emulation and embedded trace support, that combines the microcontroller with
embedded high speed flash memory ranging from 32 kB to 512 kB. A 128-bit wide memory
interface and a unique accelerator architecture enable 32-bit code execution at the maximum
clock rate. For critical code size applications, the alternative 16-bit Thumb mode reduces code by
more than 30 % with minimal performance penalty.

Due to their tiny size and low power consumption, LPC2141/2/4/6/8 are ideal for
applications where miniaturization is a key requirement, such as access control and point-of-sale.
A blend of serial communications interfaces ranging from a USB 2.0 Full Speed device, multiple
UARTs, SPI, SSP to I2Cs, and on-chip SRAM of 8 kB up to 40 kB, make these devices very
well suited for communication gateways and protocol converters, soft modems, voice
recognition and low end imaging, providing both large buffer size and high processing power.
Various 32-bit timers, single or dual 10-bit ADC(s), 10-bit DAC, PWM channels and 45 fast
GPIO lines with up to nine edge or level sensitive external interrupt pins make these
microcontrollers particularly suitable for industrial control and medical systems.

ARCHITECTURAL OVERVIEW

The LPC2141/2/4/6/8 consists of an ARM7TDMI-S CPU with emulation support, the


ARM7 Local Bus for interface to on-chip memory controllers, the AMBA Advanced High-
performance Bus (AHB) for interface to the interrupt controller, and the ARM Peripheral Bus
(APB, a compatible superset of ARMs AMBA Advanced Peripheral Bus) for connection to on-
chip peripheral functions. The LPC2141/24/6/8 configures the ARM7TDMI-S processor in little-
endian byte order.AHB peripherals are allocated a 2 megabyte range of addresses at the very top
of the 4 gigabyte ARM memory space. Each AHB peripheral is allocated a 16 kB address space
within the AHB address space. LPC2141/2/4/6/8 peripheral functions (other than the interrupt
controller) are connected to the APB bus. The AHB to APB bridge interfaces the APB bus to the
AHB bus.

Fig1.1 LPC2148 Pinning


APB peripherals are also allocated a 2 megabyte range of addresses, beginning at the 3.5
gigabyte address point. Each APB peripheral is allocated a 16 kB address space within the APB
address space.
The connection of on-chip peripherals to device pins is controlled by a Pin Connect
Block (see chapter "Pin Connect Block" on page 58). This must be configured by software to fit
specific application requirements for the use of peripheral functions and pins.

ARM7TDMI-S PROCESSOR

The ARM7TDMI-S is a general purpose 32-bit microprocessor, which offers high


performance and very low power consumption. The ARM architecture is based on Reduced
Instruction Set Computer (RISC) principles, and the instruction set and related decode
mechanism are much simpler than those of micro programmed Complex Instruction Set
Computers. This simplicity results in a high instruction throughput and impressive real-time
interrupt response from a small and cost-effective processor core.

Pipeline techniques are employed so that all parts of the processing and memory systems can
operate continuously. Typically, while one instruction is being executed, its successor is being
decoded, and a third instruction is being fetched from memory.

The ARM7TDMI-S processor also employs a unique architectural strategy known as THUMB,
which makes it ideally suited to high-volume applications with memory restrictions, or
applications where code density is an issue.

The key idea behind THUMB is that of a super-reduced instruction set. Essentially, the
ARM7TDMI-S processor has two instruction sets:

The standard 32-bit ARM instruction set.


A 16-bit THUMB instruction set.

The THUMB sets 16-bit instruction length allows it to approach twice the density of standard
ARM code while retaining most of the ARMs performance advantage over a traditional 16-bit
processor using 16-bit registers. This is possible because THUMB code operates on the same 32-
bit register set as ARM code.

Fig 1.2 LPC2148 Block Diagram

THUMB code is able to provide up to 65% of the code size of ARM, and 160% of the
performance of an equivalent ARM processor connected to a 16-bit memory system. The
ARM7TDMI-S processor is described in detail in the ARM7TDMI-S Datasheet that can be
found on official ARM website
On-chip static RAM
On-chip static RAM may be used for code and/or data storage. The SRAM may be
accessed as 8-bit, 16bit, and 32bit. The LPC2141, LPC2142/44 and LPC2146/48 provide 8kB,
16kB and 32kB of static RAM respectively. In case of LPC2146/48 only, an 8kB SRAM block
intended to be utilized mainly by the USB can also be used as a general purpose RAM for data
storage and code storage and execution.

Fig 1.3 ARM Evaluation System


1. The device LPC2148 from NXP.
2. 12.00 MHz Crystal Oscillator Device speed.
3. 32.768 KHz crystal oscillator for RTC clock.
4. Vref jumper setting for ADC external Voltage reference.
5. 5V Red LED indication.
6. 3V3 Green LED indication.
7. Battery for RTC backup running.
8. Power ON/OFF switch.
9. 9VDC input Power Jack.
10. Input switch for external interrupt. Optional: can be use for ISP manual
Programming Mode.
11. Input switch for Reset the device.
12. UART1 connectivity.
13. UART0 connectivity. Optional: Can be used for ISP programming
mode.
14. LEDs for PWM output.
15. PWM enable switch.
16. USB connector for ISP programming and serial port connectivity.
17. LED indication for to confirm the USB connection has been established.
18. Switch selection for ISP/UART. The selection will be for ISP if the
switch has been pressed else for UART.
19. Switch for to enable the ISP.
20. I/O port 10 pin FRC connector (FRC5).
21. I/O port 10 pin FRC connector (FRC4).
22. I/O port 10 pin FRC connector (FRC3).
23. I/O port 16 pin FRC connector (FRC2).
24. I/O port 10 pin FRC connector (FRC1).
25. LPC2148 Device Daughter card.
26. USB ISP programmer daughter card.

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

CN2 CN3
PIN NO: DESCRIPTION PIN NO: DESCRIPTION
1 P0.21/PWM5/AD1.6/CAP1.3 17 P0.31/UP_LED/CONNECT
2 P0.22/AD1.7/CAP0.0/MAT0.0 18 VSS
3 RTCX1 19 P0.0/TXD0/PWM1
4 P1.19/TRACEPKT3 20 P1.31/TRST
5 RTCX2 21 P0.1/RXD0/PWM3/EINT0
6 VSS 22 P0.2/SCL0/CAP0.0
7 VDDA 23 VDD
8 P1.18/TRACEPKT2 24 P1.26/RTCK
9 P0.25/AD0.4/AOUT 25 VSS
10 D+ 26 P0.3/SDA0/MAT0.0/EINT1
11 D- 27 P0.4/SCK0/CAP0.1/AD0.6
12 P1.17/TRACEPKT1 28 P1.25/EXTIN0
13 P0.28/AD0.1/CAP0.2/MAT0.2 29 P0.5/MISO0/MAT0.1/AD0.7
14 P0.29/AD0.2/CAP0.3/MAT0.3 30 P0.6/MOSI0/CAP0.2/AD1.0
15 P0.30/AD0.3/CAP0.0/EINT3 31 P0.7/SSEL0/PWM2/EINT2
16 P1.16/TRACEPKT0 32 P1.24/TRACECLK

CN4 CN1

PIN PIN
DESCRIPTION DESCRIPTION
NO: NO:
33 P0.8/TXD1/PWM4/AD1.1 49 VBAT
34 P0.9/RXD1/PWM6/EINT3 50 VSS
35 P0.10/RTS1/CAP1.0/AD1.2 51 VDD
36 P1.23/PIPESTAT2 52 P1.30/TMS
37 P0.11/CTS1/CAP1.1/SCL1 53 P0.18/CAP1.3/MISO1/MAT1.3
38 P0.12/DSR1/MAT1.0/AD1.3 54 P0.19/CAP1.2/MOSI1/MAT1.2
39 P0.13/DTR1/MAT1.1/AD1.4 55 P0.20/EINT3/SSEL1/MAT1.3
40 P1.22/PIPESTAT1 56 P1.29/TCK
41 P0.14/DCD1/EINT1/SDA1 57 RESET
42 VSS 58 P0.23/VBUS
43 VDD 59 VSSA
44 P1.21/PIPESTAT0 60 P1.28/TDI
45 P0.15/RI1/EINT2/AD1.5 61 XTAL2
46 P0.16/EINT0/MAT0.2/CAP0.2 62 XTAL1
47 P0.17/CAP1.2/SCK1/MAT1.2 63 VREF
48 P1.20/TRACESYNC 64 P1.27/TDO
FRC Pin Details:

FRC 1: FRC5: FRC 3:


PIN NO: DESCRIPTION PIN NO: DESCRIPTION PIN NO: DESCRIPTION
1 P0.16 1 P0.25 1 P0.3(SDA0)
2 P0.17 2 P0.28 2 P0.2(SCL0)
3 P0.18 3 P0.29 3 P0.14(SDA1)
4 P0.19 4 P0.30 4 P0.11(SCL1)
5 P0.20 5 P0.31 5 P0.16 ENT1
6 P0.21 6 NA 6 P0.15 ENT2
7 P0.22 7 RS232 TX1 7 RS232 TX0
8 P0.23 8 RS232 RX1 8 RS232 RX0
9 +5V 9 +5V 9 +5V
10 GND 10 GND 10 GND

FRC 2: FRC 4:
PIN NO: DESCRIPTION
PIN NO: DESCRIPTION
1 P0.8
1 P0.0
2 P0.9
2 P0.1
3 P0.10
3 P0.2
4 P0.11
4 P0.3
5 P1.16
5 P0.4
6 P1.17
6 P0.5
7 P1.18
7 P0.6
8 P1.19
8 P0.7
9 P1.20
9 +5V
10 P1.21
10 GND
11 P1.22
12 P1.23
13 +5V
14 NA
15 +3V3
16 GND

RESULT

Thus the ARM Evaluation system was studied.


EX .NO:2
INTERFACING ADC AND DAC
DATE:

AIM
To interface and program the ADC and DAC with ARM processor.

HARDWARE & SOFTWARE TOOLS REQUIRED

S.No Hardware Requirements Software Requirements Quantity

1. ARM Processor Keil Vision 5 1

2. USB/FRC Connector Flash magic 2

3. ADC Module, DAC Module, LED Module 1

4. Power Supply (5V, DC),CRO 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 andReset the device
into running mode.

Program:ADC

#include <LPC214x.h>
#include "stdio.h"
#include "UART0.h"
#include "PLL.h"
Char adc reading[16] ; // Variable to hold the ADC converted Value
voidADC_Init (void) // ADC initialation function
{
PINSEL0 = (PINSEL0 | 0x00000300 ); // P0.4 is configured as ADC Input
}
Unsigned int ADC_GetAdcReading ()
{
Unsigned int adc data;
AD0CR = 0x01200340 ;
while(!((adcdata = AD0GDR) & 0x80000000))
{
}
return((adcdata>> 6) & 0x3ff) ;
}
int main (void)
{
unsignedint delay;
floatadc;
Init Uart0();
ADC_Init() ;
UART0 Puts("ADC Test"); // Display ADC Test
while(1)
{
adc= ADC_GetAdcReading(); // Read AD0.7 reading
adc=(5*adc)/1023;
sprintf(adcreading,"\n ADC0 CH1= %.2f V",adc);
UART0Puts(adcreading) ;
for(delay=0;delay<60000;delay++);
}
}

Program: DAC

#include <LPC214x.h>
#include <stdio.h>
unsigned int delay,AoutValue = 0 ; // Variable to store the output value of DAC
int main (void)
{
PINSEL1 = PINSEL1 | 0x00080000 ;
while(1)
{
for(AoutValue = 0 ; AoutValue < 1024 ; AoutValue ++)
{
for(delay=0;delay<1000;delay++);
DACR = AoutValue << 6 ;
}
for(AoutValue = 1024 ; AoutValue > 0 ; AoutValue --)
{
for(delay=0;delay<1000;delay++);
DACR = AoutValue << 6 ;
}
} }
RESULT
Thus the Conversion of Analog to Digital and Digital to Analog is performed and verified
with ARM processor successfully.
EX NO : 3
INTERFACING LED AND PWM
DATE :

AIM

To interface and programming LED and PWM with ARM processor.

HARDWARE & SOFTWARE TOOLS REQUIRED

S.No Hardware Requirements Software Requirements Quantity

1. ARM Processor Keil Vision 5 1

2. USB/FRC Connector Flash magic 2

3. ADC Module, DAC Module, LED Module 1

4. Power Supply (5V, DC),CRO 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:LED

#include "LPC214x.h"
int main(void)
{
PINSEL1 = (PINSEL1 &~ 0xFFFF0000) ; // Configure P0.16 to P0.23 as GPIO
IO1DIR = (IO1DIR |~ 0x00FF0000) ; // Configure P0.16 to P0.23 as Input
PINSEL2 = (PINSEL2 &~ 0x0000FFFF) ; // Configure P1.16 to P1.23 as GPIO
IO1DIR = (IO1DIR | 0x00FF0000) ; // Configure P1.16 to P1.23 as O/P
while(1)
{
IO1CLR = ~(IO0PIN & 0x00FF0000);
IO1SET = (IO0PIN & 0x00FF0000) ;
}
return 0;
}

PROGRAM: PWM

#include "LPC214x.h"
#include "PWM.h"
#include "lpc_types.h"
volatile unsigned int *MR_Reg ;
unsigned char flag=0,flag1 = 0;
int i = 0;
void RedLedGlow(void);
void GreenLedGlow(void);
void BlueLedGlow(void);
void ALLLedGlow(void);
void updateCount(volatile unsigned int *MR_Register, int val );
int main (void)

{
while(1)

{
RedLedGlow();
GreenLedGlow();
BlueLedGlow();
ALLLedGlow();
}
}

void RedLedGlow(void)

{
PWM_Init( RED, PWM_CYCLE );

MR_Reg = (volatile unsigned int *)&(PWMMR2);


updateCount(MR_Reg,LER1_EN);
}

void GreenLedGlow(void)

{
PWM_Init( GREEN, PWM_CYCLE );
MR_Reg = (volatile unsigned int *)&(PWMMR4); // Load Match control register
updateCount(MR_Reg,LER2_EN); // Update counts
}
void BlueLedGlow(void)
{
PWM_Init( BLUE, PWM_CYCLE );
MR_Reg = (volatile unsigned int *)&(PWMMR6); // Load Match control register
updateCount(MR_Reg,LER3_EN); // Update counts
}
void ALLLedGlow(void)
{
int complete = 0, count = 0;
flag = 0x00;
flag1 = 0x00;
PWM_Init( ALL, PWM_CYCLE );
while(complete == 0)

{
for(i=0;i<=PWM_OFFSET;i++);
if(flag == 0x00)
{
PWMMR2 = PWMMR2 + 10;
PWMMR4 = PWMMR4 + 10;
PWMMR6 = PWMMR6 + 10;
PWMLER = LER1_EN | LER2_EN | LER3_EN ;
if(PWMMR4 >= 49000)
{
flag = 0xff;
flag1 = 0xff;
if(count == 1)
complete = 1;
PWMLER = LER1_EN | LER2_EN | LER3_EN ;
}
}
else if(flag1 == 0xff)
{
PWMMR2 = PWMMR2 - 10;
PWMMR4 = PWMMR4 - 10;
PWMMR6 = PWMMR6 - 10;
PWMLER = LER2_EN ;
if(PWMMR4 <= 500)
{
flag1 = 0x00;
flag = 0x00;
count = 1;
PWMLER = LER1_EN | LER2_EN | LER3_EN ;
}
}
}
}
void updateCount(volatile unsigned int *MR_Register, int val )
{
int complete = 0, count = 0;
flag = 0x00;
flag1 = 0x00;
while(complete == 0)
{
for(i=0;i<=PWM_OFFSET;i++);
if(flag == 0x00)
{
*MR_Register = *MR_Register + 10;
PWMLER = val ;
if(*MR_Register >= 49000)
{
flag1 = 0xff;
flag = 0xff;
if(count == 1)
complete = 1;
PWMLER = val ;
}
}
else if(flag1 == 0xff)
{
*MR_Register = *MR_Register - 10;
PWMLER = val ;

if(*MR_Register <= 500)


{
flag = 0x00;
flag1 = 0x00;
count = 1;
PWMLER = val ;
}
}
}
}

RESULT

Thus the Interfacing of LED and PWM is performed and verified with ARM processor
successfully.
EX NO : 4 INTERFACING REAL TIME CLOCK AND

DATE : SERIAL PORT

AIM

To interface and programming RTC and serial port with ARM processor.

HARDWARE & SOFTWARE TOOLS REQUIRED

S.No Hardware Requirements Software Requirements Quantity

1. ARM Processor Keil Vision 5 1

2. USB/FRC Connector Flash magic 2

3. LCD Module 1

4. 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:RTC

#include "LPC214x.h"
#include <stdio.h>
#include "I2C.h"
#include "TIMER.h"
void I2C_Init (void)
{
PCONP= 0x00000080;
PINSEL0= 0x00000050 ;
I2C0CONCLR= 0x6C; // clear all I2C config bits
I2C0CONSET = 0x40; // set I2EN
I2C0SCLH = 60;
I2C0SCLL = 60;
}
unsigned char I2C_WaitStatus (unsigned char u8status)
{
TIMER0_RESET();
TIMER0_ENABLE();

while (T0TC < RTC_WAIT_TIME_OUT)


{
if (I2C0CONSET & 8) // poll SI bit
{
if (I2C0STAT == u8status)
{
TIMER0_DISABLE();
return TRUE;
}
}
}
TIMER0_DISABLE();
return FALSE;
}
unsigned char I2C_ReadFromRTC (unsigned char u32startAddr, unsigned char *u8ptr2arr,
unsigned int u32len)
{
unsigned int u32i;
for (u32i=0;u32i<u32len;u32i++)
{
I2C0CONSET = 0x20;
if (!I2C_WaitStatus(0x08))
return FALSE;
I2C0DAT= RTC_DEVADDR;
I2C0CONCLR= 0x2C; // clear all except I2EN
if (!I2C_WaitStatus(0x18)) // 0x18: ready for data byte
return FALSE;
I2C0DAT= (u32startAddr & 0x000000FF) ;
I2C0CONCLR= 0x2C;
if (!I2C_WaitStatus(0x28))
return FALSE;
I2C0CONCLR= 0x08; // clear SI flag
I2C0CONSET = 0x10; // generate stop condition
I2C0CONSET = 0x20; // Start set
if (!I2C_WaitStatus(0x08))
return FALSE;
I2C0DAT= RTC_DEVADDR|0x01;
I2C0CONCLR= 0x28;
if (!I2C_WaitStatus(0x40)) // 0x40: ready for data byte
return FALSE;
I2C0CONCLR= 0x2C; // clear all except I2EN
if (!I2C_WaitStatus(0x58))
return FALSE;
u8ptr2arr[u32i]= (unsigned char)I2C0DAT ;
u32startAddr++;
I2C0CONSET = 0x10; // generate stop condition
I2C0CONCLR= 0x2C;
}
return TRUE;
}
unsigned char I2C_WriteToRTC (unsigned char u32startAddr, unsigned char u8ptr2arr,
unsigned int u32len)
{
unsigned int u32i,u32j;
for (u32i = 0; u32i < u32len; u32i++)
{
I2C0CONSET = 0x20; // Start set
if (!I2C_WaitStatus(0x08)) // 0x08: ready for device address
return FALSE;
I2C0DAT= RTC_DEVADDR;
I2C0CONCLR= 0x2C; // clear all except I2EN
if (!I2C_WaitStatus(0x18)) // 0x18: ready for data byte
return FALSE;
I2C0DAT= (u32startAddr & 0x000000FF);
I2C0CONCLR= 0x2C; // clear all except I2EN
if (!I2C_WaitStatus(0x28)) // 0x28: ACK has been received
return FALSE;
I2C0DAT= (u8ptr2arr)&0x000000FF;
u32startAddr++;
I2C0CONCLR= 0x2C; // clear all except I2EN
if (!I2C_WaitStatus(0x28)) // 0x28: ACK has been received
return FALSE;
I2C0CONSET = 0x10; // generate stop condition
I2C0CONCLR= 0x2C;
for (u32j=20;u32j>0;u32j--)
{
I2C0CONSET = 0x20; // Start set
if (!I2C_WaitStatus(0x08)) // 0x08: ready for device address
return FALSE;
I2C0DAT= RTC_DEVADDR;
I2C0CONCLR= 0x2C;
if (I2C_WaitStatus(0x18)) // 0x18: ready for data byte
break;
else
{
I2C0CONCLR= 0x2C;
I2C0CONSET = 0x10; // generate stop condition
I2C0CONCLR= 0x2C;
}
}
I2C0CONSET = 0x10; // generate stop condition
I2C0CONCLR= 0x2C;
}
return TRUE;
}

PROGRAM: SERIAL PORT

#include <LPC214x.h>
#include <string.h>
#include "PLL.h"
#include "UART0.h"
void InitUart0(void)
{
PINSEL0 |= 0x00000005 ;
U0LCR=0x83;
VPBDIV=0x01;
U0DLL = DIVISOR&0xFF;//=0x86;
U0DLM=(DIVISOR>>8)&0xFF ;//0x01;
U0LCR=0x03 ;
U0FCR=0x05 ;
}
char UART0putchar(char ch)
{
if (ch=='\n')
{
while (!(U0LSR&0x20))
{
}
U0THR='\r';
}
while (!(U0LSR&0x20))
{
}
U0THR=ch;
return ch;
}
char UART0getchar(void)
{
char ch;
while (!(U0LSR&0x01))
{
}
ch=U0RBR;
return ch;
}
void UART0Puts(char* PCString)
{
while(*PCString)
{
UART0putchar(*PCString) ;
PCString++ ;
}
}
char UART0_IsReady(void)
{
return (U0LSR&0x01);
}

RESULT

Thus the interfacing of Real Time Clock and programming of Serial port with ARM
processor is done successfully.
EX .NO:5
INTERFACING KEYBOARD AND LCD
DATE:

AIM

To interface and program the Keyboard and LCD with ARM processor.

HARDWARE & SOFTWARE TOOLS REQUIRED

S.No Hardware Requirements Software Requirements Quantity

1. ARM Processor Keil Vision 5 1

2. USB/FRC Connector Flash magic 2

3. Keyboard Module, LCD Module 1

4. Power Supply (5V, DC),CRO 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:KEYBOARD

#include <LPC214x.h>
#include "KBD.h"
#define RET0 0x00010000 // P0.16
#define RET1 0x00020000 // P0.17
#define RET2 0x00040000 // P0.18
#define RET3 0x00080000 // P0.19
#defineALL_RET (RET0|RET1|RET2|RET3)
#define SCAN0 0x00100000 // P0.20
#define SCAN1 0x00200000 // P0.21
#define SCAN2 0x00400000 // P0.22
#define SCAN3 0x00800000 // P0.23
const unsigned int KBD_u32scanport1[4]={SCAN0,SCAN1,SCAN2,SCAN3};
const unsigned int KBD_u32retport[4]={RET0,RET1,RET2,RET3};
#define CRYSTAL_FREQUENCY_IN_HZ 12000000
#define PLL_MULTIPLIER 1
#define DEL_LOOPS
int KBD_i32keydown;
void KBD_cdelay(void)
{
int i32i;
for (i32i=0; i32i<5*DEL_LOOPS; i32i++) {}
}
int KBD_i32the_sc ;
intKBD_kbhit (void)
{
int i32sc;
int i32ret ;
for(i32sc = 0;i32sc < 4 ; i32sc ++)
{
IO0DIR = KBD_u32scanport1[i32sc]; // For RS and RW of LCD
IO0CLR = KBD_u32scanport1[i32sc] ;
KBD_cdelay() ;
i32ret = IO0PIN & ALL_RET ;
if (KBD_i32keydown == -1)
{
switch(i32ret)
{
case (ALL_RET & (~RET0)) :
KBD_i32the_sc = i32sc ;
KBD_i32keydown = (i32sc * 4) ;
return 1 ;
case (ALL_RET & (~RET1)) :
KBD_i32the_sc = i32sc ;
KBD_i32keydown = (i32sc * 4) + 1 ;
return 1 ;
case (ALL_RET & (~RET2)) :
KBD_i32the_sc = i32sc ;
KBD_i32keydown = (i32sc * 4) + 2 ;
return 1 ;
case (ALL_RET & (~RET3)) :
KBD_i32the_sc = i32sc ;
KBD_i32keydown = (i32sc * 4) + 3 ;
return 1 ;
}
}
else
{
if (i32sc == KBD_i32the_sc)
{
if (i32ret == ALL_RET)
{
KBD_i32keydown = -1 ; // key has been released
}
}
}
}
return 0 ;
}
intKBD_rdkbd(void)
{
while(!KBD_kbhit()) {}
return KBD_i32keydown ;
}
PROGRAM:LCD

#include <LPC214x.h>
#include <stdio.h>
void SmallDelay (void)
{
volatile inti,j;
j = 0;
for(i=0;i<810;i++)
{
j++;
}
}
void Delay250 (void)
{
volatile intk,j ;
j =200;
for(k = 0 ; k < 100 ; k ++)
{
j-- ;
}
}
void DelayMs (int n)
{
volatile int k ;
for(k = 0 ; k < n ; k ++)
{
Delay250() ;
Delay250() ;
}
}
void LcdCmd(unsigned char cmd)
{
if (cmd& 0x01)
IO1SET = (1<<16);
else
IO1CLR = (1<<16);
if (cmd& 0x02)
IO1SET = (1<<17);
else
IO1CLR = (1<<17);
if (cmd& 0x04)
IO1SET = (1<<18);
else
IO1CLR = (1<<18);
if (cmd& 0x08)
IO1SET = (1<<19);
else
IO1CLR = (1<<19);
if (cmd& 0x10)
IO1SET = (1<<20);
else
IO1CLR = (1<<20);
if (cmd& 0x20)
IO1SET = (1<<21);
else
IO1CLR = (1<<21);
if (cmd& 0x40)
IO1SET = (1<<22);
else
IO1CLR = (1<<22);
if (cmd& 0x80)
IO1SET = (1<<23);
else
IO1CLR = (1<<23);
IO1CLR = 0x03000000 ; // CLEAR(0) RS and EN
SmallDelay() ;
IO1SET = 0x01000000 ; // SET(1) EN
SmallDelay() ;
IO1CLR = 0x01000000 ; // CLEAR(0) EN
SmallDelay() ;
}
void LcdDat(unsigned char dat)
{
if (dat& 0x01)
IO1SET = (1<<16);
else
IO1CLR = (1<<16);
if (dat& 0x02)
IO1SET = (1<<17);
else
IO1CLR = (1<<17);
if (dat& 0x04)
IO1SET = (1<<18);
else
IO1CLR = (1<<18);
if (dat& 0x08)
IO1SET = (1<<19);
else
IO1CLR = (1<<19);
if (dat& 0x10)
IO1SET = (1<<20);
else
IO1CLR = (1<<20);
if (dat& 0x20)
IO1SET = (1<<21);
else
IO1CLR = (1<<21);
if (dat& 0x40)
IO1SET = (1<<22);
else
IO1CLR = (1<<22);
if (dat& 0x80)
IO1SET = (1<<23);
else
IO1CLR = (1<<23);
IO1SET = 0x02000000 ; // SET(1) RS
SmallDelay() ;
IO1CLR = 0x01000000 ; // CLEAR(0) EN
SmallDelay() ;
IO1SET = 0x01000000 ; // SET(1) EN
SmallDelay() ;
IO1CLR = 0x01000000 ; // CLEAR(0) EN
SmallDelay() ;
}
void LcdInit (void)
{
//IO1DIR = 0x03000000 ; // Configure P1.24(EN) and P1.25(RS) as Output
//IO1CLR = 0x03000000 ; // CLEAR(0) P1.24(EN) and P1.25(RS)
IO1DIR |= 0x03FF0000 ; // Configure P0.15(D4), P0.17(D5), P0.22(D6) and
P0.30(D7) as Output
IO1CLR |= 0x03FF0000 ; // CLEAR(0) P0.15(D4), P0.17(D5), P0.22(D6) and
P0.30(D7)
DelayMs(6) ;
LcdCmd(0x03) ;
DelayMs(6) ;
LcdCmd(0x03) ;
Delay250() ;
LcdCmd(0x03) ;
Delay250() ;
LcdCmd(0x02) ;
Delay250() ;
LcdCmd(0x38) ;
LcdCmd(0x01);
LcdCmd(0x08) ;
LcdCmd(0x0c) ;
LcdCmd(0x06) ;
}
void DisplayRow (int row, char *str)
{
int k ;
if (row == 1)
LcdCmd(0x80) ;
else
LcdCmd(0xc0) ;
for(k = 0 ; k < 16 ; k ++)
{
if (str[k])
LcdDat(str[k]) ;
else
break ;
}
while(k < 16)
{
LcdDat(' ') ;
k ++ ;
}
}
void display_char(int row, char *str)
{
LcdCmd(0x80) ;
LcdDat(*str) ;
}
RESULT

Thus the Interfacingof Keyboard and LCD is performed and verified with ARM processor
successfully.
EX .NO:6
INTERFACING EPROM AND INTERRUPT
DATE:

AIM:

To interface and program the EPROM and Interrupt with ARM processor.

HARDWARE & SOFTWARE TOOLS REQUIRED

S.No Hardware Requirements Software Requirements Quantity

1. ARM Processor Keil Vision5 1

2. USB/FRC Connector Flash magic 2

3. Keyboard Module, LCD Module , LED Module 1

4. 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: EPROM

#include "LPC214x.h"
#include <stdio.h>
#include "PLL.h"
#include "I2C.h"
#include "TIMER.h"
void I2C_Init (void)
{
PCONP= 0x00000080;
PINSEL0= 0x00000050 ;
I2C0CONCLR= 0x6C;
I2C0CONSET = 0x40;
I2C0SCLL =
PERIFERAL_OPERATING_FREQUENCY_IN_HZ/(2*EPROM_OPERATING_FREQUENC
Y_IN_HZ);
}
unsigned char I2C_WaitStatus (unsigned char u8status)
{
TIMER0_RESET();
TIMER0_ENABLE();
while (T0TC < RTC_WAIT_TIME_OUT)
{
if (I2C0CONSET & 8) // poll SI bit
{
if (I2C0STAT == u8status)
{
TIMER0_DISABLE();
return TRUE;
}
}
}
TIMER0_DISABLE();
return FALSE;
}
unsigned char I2C_ReadFromRTC (unsigned char u32startAddr, unsigned char *u8ptr2arr,
unsigned int u32len)
{
unsigned int u32i;
for (u32i=0;u32i<u32len;u32i++)
{
I2C0CONSET = 0x20;
if (!I2C_WaitStatus(0x08))
return FALSE;
I2C0DAT= RTC_DEVADDR;
I2C0CONCLR= 0x2C;
if (!I2C_WaitStatus(0x18)) // 0x18: ready for data byte
return FALSE;
I2C0DAT= (u32startAddr & 0x000000FF) ;
I2C0CONCLR= 0x2C;
if (!I2C_WaitStatus(0x28))
return FALSE;
I2C0CONCLR= 0x08;
I2C0CONSET = 0x10;
I2C0CONSET = 0x20;
if (!I2C_WaitStatus(0x08))
return FALSE;
I2C0DAT= RTC_DEVADDR|0x01;
I2C0CONCLR= 0x28;
if (!I2C_WaitStatus(0x40)) // 0x40: ready for data byte
return FALSE;
I2C0CONCLR= 0x2C;
if (!I2C_WaitStatus(0x58))
return FALSE;
u8ptr2arr[u32i]= (unsigned char)I2C0DAT ;
u32startAddr++;
I2C0CONSET = 0x10;
I2C0CONCLR= 0x2C;
}
return TRUE;
}
unsigned char I2C_WriteToRTC (unsigned char u32startAddr, unsigned char u8ptr2arr,
unsigned int u32len)
{
unsigned int u32i,u32j;
for (u32i = 0; u32i < u32len; u32i++) // write data byte wise
{
I2C0CONSET = 0x20;
if (!I2C_WaitStatus(0x08))
return FALSE;
I2C0DAT= RTC_DEVADDR;
I2C0CONCLR= 0x2C;
if (!I2C_WaitStatus(0x18)) // 0x18: ready for data byte
return FALSE;
I2C0DAT= (u32startAddr & 0x000000FF);
I2C0CONCLR= 0x2C;
if (!I2C_WaitStatus(0x28))
return FALSE;
I2C0DAT= (u8ptr2arr)&0x000000FF;
u32startAddr++;
I2C0CONCLR= 0x2C;
if (!I2C_WaitStatus(0x28)) // 0x28: ACK has been received
return FALSE;
I2C0CONSET = 0x10;
I2C0CONCLR= 0x2C;
for (u32j=20;u32j>0;u32j--)
{
I2C0CONSET = 0x20;
if (!I2C_WaitStatus(0x08))
return FALSE;
I2C0DAT= RTC_DEVADDR;
I2C0CONCLR= 0x2C;
if (I2C_WaitStatus(0x18))
break;
else
{
I2C0CONCLR= 0x2C;
I2C0CONSET = 0x10;
I2C0CONCLR= 0x2C;
}
}
I2C0CONSET = 0x10;
I2C0CONCLR= 0x2C;
}
return TRUE;
}
unsigned char I2C_ReadFromEPROM (unsigned int u32startAddr, unsigned char *u8ptr2arr,
unsigned int u32len)
{
unsigned int u32i;
if (u32startAddr + u32len > EPROM_SIZE)
return FALSE;
for (u32i=0;u32i<u32len;u32i++)
{
I2C0CONSET = 0x20;
if (!I2C_WaitStatus(0x08))
return FALSE;
I2C0DAT= EPROM_DEVADDR;
I2C0CONCLR= 0x2C;
if (!I2C_WaitStatus(0x18))
return FALSE;
I2C0DAT= (u32startAddr & 0x000000FF) ;
#ifndef
EPROM_24C02
I2C0CONCLR= 0x2C;
if (!I2C_WaitStatus(0x28))
return FALSE;
I2C0CONCLR= 0x08;
I2C0DAT= ((u32startAddr & 0x0000FF00)>>8) &0xFF;
#endif
I2C0CONCLR= 0x2C;
if (!I2C_WaitStatus(0x28))
return FALSE;
I2C0CONCLR= 0x08;
I2C0CONSET = 0x10;
I2C0CONSET = 0x20;
if (!I2C_WaitStatus(0x08))
return FALSE;
I2C0DAT= EPROM_DEVADDR|0x01;
I2C0CONCLR= 0x28;
if (!I2C_WaitStatus(0x40))
return FALSE;
I2C0CONCLR= 0x2C;
if (!I2C_WaitStatus(0x58))
return FALSE;
u8ptr2arr[u32i]= (unsigned char)I2C0DAT ;
u32startAddr++;
I2C0CONSET = 0x10;
I2C0CONCLR= 0x2C;
}
return TRUE;
}
unsigned char I2C_WriteToEPROM (unsigned int u32startAddr, unsigned char *u8ptr2arr,
unsigned int u32len)
{
unsigned intu32i,u32j;
if (u32startAddr + u32len > EPROM_SIZE)
return FALSE;
for (u32i = 0; u32i < u32len; u32i++)
{
I2C0CONSET = 0x20; // Start set
if (!I2C_WaitStatus(0x08))
return FALSE;
I2C0DAT = EPROM_DEVADDR;
I2C0CONCLR= 0x2C; // clear all except I2EN
if (!I2C_WaitStatus(0x18)) // 0x18: ready for data byte
return FALSE;
I2C0DAT = (u32startAddr & 0x000000FF);
#ifndef EPROM_24C02
I2C0CONCLR= 0x2C;
if (!I2C_WaitStatus(0x28))
return FALSE;
//I2C0CONCLR= 0x08; // clear SI flag
I2C0DAT= ((u32startAddr & 0x0000FF00)>>8) &0xFF;
#endif
I2C0CONCLR= 0x2C; // clear all except I2EN
if (!I2C_WaitStatus(0x28))
return FALSE;
I2C0DAT= (u8ptr2arr[u32i])&0x000000FF;
u32startAddr++;
I2C0CONCLR= 0x2C; // clear all except I2EN
if (!I2C_WaitStatus(0x28))
return FALSE;
I2C0CONSET = 0x10; // generate stop condition
I2C0CONCLR= 0x2C;
for (u32j=20;u32j>0;u32j--)
{
I2C0CONSET = 0x20; // Start set
if (!I2C_WaitStatus(0x08))
return FALSE;
I2C0DAT= EPROM_DEVADDR;
I2C0CONCLR= 0x2C; // clear all except I2EN
if (I2C_WaitStatus(0x18)) // 0x18: ready for data byte
break;
else
{
I2C0CONCLR= 0x2C;
I2C0CONSET = 0x10; // generate stop condition
I2C0CONCLR= 0x2C;
}
}
I2C0CONSET = 0x10; // generate stop condition
I2C0CONCLR= 0x2C;
}
return TRUE;
}
PROGRAM: INTERUPT

#include <stdio.h>
#include <LPC214x.h>
#include "VIC.h"
void Eint1ISR(void)__irq;
unsigned char Eint1Detect = 0;
void InitEint1(void)
{
PINSEL0 |= 0x20000000 ; // Initialize EINT0 Interrupt Pin
EXTMODE |= 0x00 ; // Level sensitive mode on EINT1
EXTPOLAR |= 0x00 ; // Low-active or Negative edge sensitive
EXTINT = 0x02;
}
int main (void);
int main (void)
{
IO1DIR |= 0x00010000 ;
IO1SET |= 0x00010000 ; // PGM LED will be ON
//setupISR(1,EINT1_INT,Eint1ISR,IRQ_SEL) ; // Set up ISR void setupISR(int
i32vec, int i32irq, void *func,int i32sel)
if (IRQ_SEL)
VICIntSelect |= (1<<EINT1_INT);
else
VICIntSelect &= ~(1<<EINT1_INT);
VICIntEnable |= (1<<EINT1_INT);
(&VICVectCntl0)[1]=EINT1_INT|0x20;
(&VICVectAddr0)[1]=(unsigned long)Eint1ISR;
InitEint1(); // Initialize EINT0
while(1)
{
if(Eint1Detect) // Check flag
{
Eint1Detect = 0 ; // Clear flag
IO1SET |= 0x00010000 ; // PGM LED will be ON
}
}
}
void Eint1ISR(void)__irq
{
IO1CLR |= 0x00010000 ; // PGM LED will be ON
Eint1Detect = 1 ; // Set flag
EXTINT = 0x02; // Clear EINT0 interrupt flag
ISR_DONE() ;
}

RESULT

Thus the Conversion of EPROM and Interrupt is performed and verified with ARM
processor successfully.
EX .NO:7
MAILBOX
DATE:

AIM:

To program the mailbox with ARM processor.

HARDWARE & SOFTWARE TOOLS RQUIRED

S.No Hardware Requirements Software Requirements Quantity

1. ARM Processor Keil Vision5 1

2. USB/FRC Connector Flash magic 2

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: MAILBOX

#include <RTL.h>
#include <LPC21xx.H>
#include <stdio.h>
#define BAUDRATE 19200 // Set Baudrate value
#define CRYSTAL_FREQUENCY_IN_HZ 12.000000
#define PCLK CRYSTAL_FREQUENCY_IN_HZ * 1
#define DIVISOR (PCLK/(16*BAUDRATE))
OS_TID tsk1;
OS_TID tsk2;
typedefstruct
{
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);
voidinit_serial ()
{
PINSEL0 = 0x00000005;
U0LCR = 0x83;
VPBDIV=0x01;
U0DLL = DIVISOR&0xFF;
U0DLM=(DIVISOR>>8)&0xFF ;
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);
mptr = _alloc_box (mpool);
mptr->voltage = 223.72;
mptr->current = 17.54;
mptr->counter = 120786;
os_mbx_send (&MsgBox, mptr, 0xffff);
IOSET1 = 0x10000;
os_dly_wait (100);
mptr = _alloc_box (mpool);
mptr->voltage = 227.23;
mptr->current = 12.41;
mptr->counter = 170823;
os_mbx_send (&MsgBox, mptr, 0xffff);
os_tsk_pass ();
IOSET1 = 0x20000;
os_dly_wait (100);
mptr = _alloc_box (mpool);
mptr->voltage = 229.44;
mptr->current = 11.89;
mptr->counter = 237178;
os_mbx_send (&MsgBox, mptr, 0xffff);
IOSET1 = 0x40000;
os_dly_wait (100);
os_tsk_delete_self ();
}
task void rec_task (void)
{
T_MEAS *rptr;
for (;;)
{
os_mbx_wait (&MsgBox, (void **)&rptr, 0xffff);
printf ("\nVoltage: %.2f V",rptr->voltage);
printf ("\nCurrent: %.2f A",rptr->current);
printf ("\nNumber of cycles: %d\n",rptr->counter);
free_box (mpool, rptr);
}
}
int main (void)
{
IODIR1 = 0xFF0000;
init_serial ();
init_box (mpool, sizeof(mpool);
sizeof(T_MEAS));
os_sys_init (send_task);
}

RESULT

Thus the programming of mailbox with ARM processor is done successfully.


EX .NO:8
FLASHING OF LEDS
DATE:

AIM

To interface and program flashing of LED with ARM processor.

HARDWARE & SOFTWARE TOOLS REQUIRED

S.No Hardware Requirements Software Requirements Quantity

1. ARM Processor Keil Vision 5 1

2. USB/FRC Connector Flash magic 2

3. LED Module 1

4. 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: FLASHING LED

#include <LPC214x.h>
volatile unsigned int delay;
int main (void)
{
PINSEL2 = (PINSEL2 &~ 0x0000FFFF) ;
IO1DIR = (IO1DIR | 0x00FF0000) ;
while(1)
{
IO1CLR = (IO1CLR | 0x00FF0000);
for(delay=0; delay<350000; delay++); // delay
IO1SET |=0x00FF0000;// SET (1) P0.10 to P0.13 and P0.18 to P0.21, LEDs OFF
for(delay=0; delay<350000; delay++); // delay
}
}

RESULT

Thus the interfacing programming of Flashing LED with ARM processor is done
successfully.
EX .NO: 9 INTERFACING STEPPER MOTOR AND TEMPERATURE

DATE: SENSOR

AIM
To interface stepper motor and temperature sensor using ARM processor.

HARDWARE & SOFTWARE TOOLS REQUIRED

S.No Hardware Requirements Software Requirements Quantity

1. ARM Processor Keil Vision5 1

2. USB/FRC Connector Flash magic 2

3. Stepper Motor Module ,Keyboard Module ,LCD module 1

4. Power Supply (5V, DC),CRO 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: STEPPER MOTOR

#include <LPC214x.h>
#define PHASEA 0x90000000 // Phase A value 1001
#define PHASEB 0x50000000 // Phase B value 0101
#define PHASEC 0x60000000 // Phase C value 0110
#define PHASED 0xA0000000 // Phase D value 1100
unsignedint delay ; // Delay function definition
int main(void)
{
PINSEL1 = PINSEL1 & ~ 0xFF000000 ;
IO0DIR = IO0DIR | 0xF0000000 ;
IO0SET = IO0SET | 0xF0000000 ;
while(1)
{
IO0SET = PHASED ;
IO0CLR = (~PHASED) &0xF0000000 ;
for(delay=0; delay<30000; delay++) ;
IO0SET = PHASEC ;
IO0CLR = (~PHASEC) &0xF0000000 ;
for(delay=0; delay<30000; delay++) ;
IO0SET = PHASEB ;
IO0CLR = (~PHASEB) &0xF0000000 ;
for(delay=0; delay<30000; delay++) ;
IO0SET = PHASEA ;
IO0CLR = (~PHASEA) &0xF0000000 ;
for(delay=0; delay<30000; delay++) ;
}
}
PROGRAM: TEMPERATURE SENSOR

#include <LPC214x.h>
#include "stdio.h"
#include "UART0.h"
#include "PLL.h"
char adcreading[16] ; // Variable to hold the ADC converted Value
void ADC_Init (void)
{
PINSEL0 = (PINSEL0 | 0x00000C00 ); // P0.5 is configured as ADC Input
}
unsigned int ADC_GetAdcReading ()
{
unsigned int adcdata;
AD0CR = 0x01200380 ;
while(!((adcdata = AD0GDR) & 0x80000000))
{
}
return((adcdata >> 6) & 0x3ff) ; // Return 10 bit result
}
int main (void)
{
unsigned int delay,adc;
float Temp, Temperature;
//float adc;
InitUart0();
ADC_Init() ;
UART0Puts("ADC Test");
while(1)
{
adc = ADC_GetAdcReading();
Temp = (adc * 3.3);
Temperature = (Temp / 1023) * 100;
sprintf(adcreading,"\nTemp =%0.03f *C",Temperature) ;
UART0Puts(adcreading) ;
for(delay=0;delay<60000;delay++);
}
}

RESULT

Thus the interfacing of stepper motor and temperature sensor is verified successfully by
using ARM processor.
EX .NO:10
IMPLEMENTING ZIGBEE PROTOCOL WITH ARM
DATE:

AIM
To implement Zigbee protocol with ARM processor.

HARDWARE & SOFTWARE TOOLS REQUIRED

S.No Hardware Requirements Software Requirements Quantity

1. ARM Processor Keil Vision 5 1

2. USB/FRC Connector Flash magic 2

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 see the finished indication and output at the SPJ terminal. Finally Reset the device
into running mode.
PROGRAM: XBEE LCD KEYPAD

#include <LPC214x.h>
#include <stdio.h>
#include <string.h>
#include "PLL.h"
#include "lpc_types.h"
#include "UART0.h"
#include "UART1.h"
volatile unsigned int delay;
int main(void)
{
InitUART1();
PINSEL1 = (PINSEL1 &~ 0x0000FFFF) ; // Configure P1.16 to P1.23 as GPIO
IO0DIR = (IO0DIR | 0x0F000000) ; // Configure P1.16 to P1.23 as Output
PINSEL2 = (PINSEL2 &~ 0x00000000) ; // Configure P0.16 to P0.23 as GPIO
IO1DIR = (IO1DIR |~ 0x00010000) ; // Configure P0.16 to P0.23 as Input
IO0SET = (IO0SET | 0x0F000000);
while(UART1CharReceived() | (~(IO1PIN & 0xFFFEFFFF)))
{
if(UART1CharReceived() && (UART1getchar() == 'A'))
{
IO0CLR = (IO0CLR | 0x0F000000);
for(delay=0; delay<5000; delay++);
}
IO0SET = (IO0SET | 0x0F000000);
for(delay=0; delay<5000; delay++);
if(!(IO1PIN & 0x00010000))
{
UART1putchar('A') ;
}
}
}

RESULT

Thus the implementation of Zigbee protocol is verified successfully using ARM


processor.
EX .NO:11
INTERRUPT PERFORMANCE CHARACTERISTICS OF ARM AND
FPGA
DATE:

AIM:
To identity the interrupt Performance Characteristics of ARM and FPGA with ARM
processor.

HARDWARE & SOFTWARE TOOLS REQUIRED

S.No Hardware Requirements Software Requirements Quantity

1. ARM Processor Keil Vision5 1

2. USB/FRC Connector Flash magic 2

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 see the finished indication and output at the SPJ terminal. Finally Reset the device
into running mode.

PROGRAM: FPGA

#include <stdio.h>
#include <LPC214x.h>
#include "Timer.h"
#include "VIC.h"
#include "UART0.h"
unsigned char timer_mode = 0;
unsigned int toggle_mode = 0;
unsigned char Eint1Detect = 0;
unsigned long int Int_Count = 0,Int_Count_Temp = 0;
int volatile j;
unsigned long int FPGA_Count=0;
void Eint1ISR(void)__irq;
void Timer0ISR(void)__irq;
void InitEint1(void)
{
PINSEL0 |= 0x20000000; // Initialize EINT0 Interrupt Pin
EXTMODE |= 2; //Edge sensitive mode on EINT1
EXTPOLAR = 0; //Falling Edge Sensitive
EXTINT = 0x02; // Clear EINT1 interrupt flag
}
void Init_VIC_INT(void)
{
VICVectAddr0 = (unsigned long)Eint1ISR;
VICVectCntl0 = 0x20|EINT1_INT;
VICIntEnable |= (1<<EINT1_INT);
}
void Init_VIC_Timer(void)
{
VICVectAddr1 = (unsigned long)Timer0ISR;
VICVectCntl1 = 0x20|TIMER0_INT;
VICIntEnable |= (1<<TIMER0_INT); //enable timer0 interrupt
}
int main (void);
int main (void)
{
unsigned int volatile p;
unsigned int byte1=0,byte2=0,byte3=0,byte4=0;
IO1DIR |= 0x32000000;
IO1DIR = (IO1DIR &~ 0x00FF0000) ; // Configure P0.16 to P0.23 as Input
VPBDIV = 0x01;
InitUart0();
Init_VIC_Timer();
Init_VIC_INT();
printf("Test\n");
TIMER_Init ();
InitEint1(); // Initialize EINT0
while(1)
{
if(toggle_mode==1)
{
Int_Count = Int_Count_Temp;
Int_Count_Temp=0;
IO1CLR |= 0x30000000;
IO1SET |= 0x02000000 ; // Set Ack to FPGA as 1
for(p=0;p<10;p++);
byte1 = ((IO1PIN & 0x00FF0000)>>16);
IO1SET |= 0x10000000;
IO1CLR |= 0x20000000;
for(p=0;p<10;p++);
byte2 = ((IO1PIN & 0x00FF0000)>>16);
IO1SET|= 0x20000000;
IO1CLR |= 0x10000000;
for(p=0;p<10;p++);
byte3 = ((IO1PIN & 0x00FF0000)>>16);
IO1SET|= 0x30000000;
for(p=0;p<10;p++);
byte4 = ((IO1PIN & 0x00FF0000)>>16);
IO1CLR |= 0x02000000;
FPGA_Count = (byte1) | (byte2 << 8) | (byte3 << 16) |(byte4 << 24) ;
printf("FPGA_Count = %d Int_Count = %d\n",FPGA_Count,Int_Count);
toggle_mode = 0;
}
}
}
void Timer0ISR(void)__irq
{
toggle_mode=1;
T0IR = 0xff;
VICVectAddr= 0 ;
}
void Eint1ISR(void)__irq
{
Int_Count_Temp++;
EXTINT = 0x02; // Clear EINT0 interrupt flag
VICVectAddr= 1 ;
}
RESULT

Thus interrupt Performance Characteristics of ARM and FPGA is verified successfully


with ARM processor.

You might also like