Vous êtes sur la page 1sur 41

Experiment- 1

Shivani
13049

Page 1

Experiment- 1
Aim: To study the architecture, pin diagram, pipeline system of ARM 7 and ARM
9 processor.
Architecture

Shivani
13049

Page 2

Arm is acronym for Acron RISC Machine / Advanced RISC Machine


Family of ISA (Instruction Set Architecture) based on a RISC (reduced Instruction Set
Computer) developed by British company

Features:

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


8 kB to 40 kB of on-chip static RAM and 32 kB to 512 kB of on-chip flash memory.
128-bit wide interface/accelerator enables high-speed 60 MHz operation.
In-System Programming/In-Application Programming (ISP/IAP) via on-chip boot
loader software. Single flash sector or full chip erase in 400 ms and programming of
256 bytes in 1 ms.
Embedded ICE RT and Embedded Trace interfaces offer real-time debugging with the
on-chip Real Monitor software and high-speed tracing of instruction execution.
USB 2.0 Full-speed compliant device controller with 2 kB of endpoint RAM.
In addition, the LPC2146/48 provides 8 kB of on-chip RAM accessible to USB by DMA.
One or two 10-bit ADCs provide a total of 6/14 analog inputs, with conversion times as
low as 2.44 ms per channel.
Single 10-bit DAC provides variable analog output
Two 32-bit timers/external event counters (with four capture and four compare channels
each), PWM unit (six outputs) and watchdog.
Low power Real-Time Clock (RTC) with independent power and 32 kHz clock input.
Multiple serial interfaces including two UARTs (16C550), two Fast I2C-bus (400 kbit/s),
SPI and SSP with buffering and variable data length capabilities.
Vectored Interrupt Controller (VIC) with configurable priorities and vector addresses.
Up to 45 of 5 V tolerant fast general purpose I/O pins in a tiny LQFP64 package.
Up to 21 external interrupt pins available.
60 MHz maximum CPU clock available from programmable on-chip PLL with settling
time of 100 ms.
On-chip integrated oscillator operates with an external crystal from 1 MHz to 25 MHz.
Power saving modes include Idle and Power-down.
Individual enable/disable of peripheral functions as well as peripheral clock scaling for
additional power optimization.

Shivani
13049

Page 3

Pin Description:

Shivani
13049

Page 4

Pin Description:
P0.0 to P0.31
Port 0 is a 32-bit I/O port with individual direction controls for each bit. Total of 31 pins of the
Port 0 can be used as a general purpose bidirectional digital I/Os while P0.31 is output only pin.
The operation of port 0 pins depends upon the pin function selected via the pin connect block.
Pins P0.24, P0.26 and P0.27 are not available.
P0.0/TXD0/ PWM1 (19 Pin)
P0.0 General purpose input/output digital pin (GPIO).
TXD0 Transmitter output for UART0.
PWM1 Pulse Width Modulator output 1.
P0.1/RXD0/ PWM3/EINT0 (21 Pin)
P0.1 General purpose input/output digital pin (GPIO).
RXD0 Receiver input for UART0.
PWM3 Pulse Width Modulator output 3.
EINT0 External interrupt 0 input
P0.2/SCL0/ CAP0.0 (22 Pin)
P0.2 General purpose input/output digital pin (GPIO).
SCL0 I2C0 clock input/output. Open-drain output (for I2C-bus compliance).
CAP0.0 Capture input for Timer 0, channel 0.
P0.3/SDA0/MAT0.0/EINT1 (26 Pin)
P0.3 General purpose input/output digital pin (GPIO).
SDA0 I2C0 data input/output. Open-drain output (for I2C-bus compliance).
MAT0.0 Match output for Timer 0, channel 0.
EINT1 External interrupt 1 input.
P0.4/SCK0/CAP0.1/AD0.6 (27 Pin)
P0.4 General purpose input/output digital pin (GPIO).
SCK0 Serial clock for SPI0. SPI clock output from master or input to slave.
CAP0.1 Capture input for Timer 0, channel 0.
AD0.6 ADC 0, input 6.
P0.5/MISO0/MAT0.1/AD0.7 (29 Pin)
P0.5 General purpose input/output digital pin (GPIO). I/O
MISO0 Master In Slave OUT for SPI0. Data input to SPI master or data
output from SPI slave.
MAT0.1 Match output for Timer 0, channel 1.
AD0.7 ADC 0, input 7.
P0.6/MOSI0/ CAP0.2/AD1.0 (30 Pin)
P0.6 General purpose input/output digital pin (GPIO).
MOSI0 Master Out Slave In for SPI0. Data output from SPI master or data input to SPI slave.
CAP0.2 Capture input for Timer 0, channel 2.
AD1.0 ADC 1, input 0. Available in LPC2144/46/48 only.
P0.7/SSEL0/PWM2/EINT2 (31Pin)
P0.7 General purpose input/output digital pin (GPIO).
Shivani
13049

Page 5

SSEL0 Slave Select for SPI0. Selects the SPI interface as a slave.
PWM2 Pulse Width Modulator output 2.
EINT2 External interrupt 2 input.
P0.8/TXD1/ PWM4/AD1.1 (33 Pin)
P0.8 General purpose input/output digital pin (GPIO).
TXD1 Transmitter output for UART1.
PWM4 Pulse Width Modulator output 4.
AD1.1 ADC 1, input 1. Available in LPC2144/46/48 only.
P0.9/RXD1/ PWM6/EINT3 (34 Pin)
P0.9 General purpose input/output digital pin (GPIO).
RXD1 Receiver input for UART1.
PWM6 Pulse Width Modulator output 6.
EINT3 External interrupt 3 input.
P0.10/RTS1/ CAP1.0/AD1.2 (35 Pin)
P0.10 General purpose input/output digital pin (GPIO).
RTS1 Request to Send output for UART1. LPC2144/46/48 only.
CAP1.0 Capture input for Timer 1, channel 0.
AD1.2 ADC 1, input 2. Available in LPC2144/46/48 only.
P0.11/CTS1/ CAP1.1/SCL1 (37 Pin)
P0.11 General purpose input/output digital pin (GPIO).
CTS1 Clear to Send input for UART1. Available in LPC2144/46/48 only.
CAP1.1 Capture input for Timer 1, channel 1.
SCL1 I2C1 clock input/output. Open-drain output (for I2C-bus compliance)
P0.12/DSR1/ MAT1.0/AD1.3 (38 Pin)
P0.12 General purpose input/output digital pin (GPIO).
DSR1 Data Set Ready input for UART1. Available in LPC2144/46/48 only.
MAT1.0 Match output for Timer 1, channel 0.
AD1.3 ADC input 3. Available in LPC2144/46/48 only.
P0.13/DTR1/MAT1.1/AD1.4 (39 Pin)
P0.13 General purpose input/output digital pin (GPIO).
DTR1 Data Terminal Ready output for UART1. LPC2144/46/48 only.
MAT1.1 Match output for Timer 1, channel 1.
AD1.4 ADC input 4. Available in LPC2144/46/48 only.
P0.14/DCD1/ EINT1/SDA1 (41 Pin)
P0.14 General purpose input/output digital pin (GPIO). DCD1 Data Carrier Detect input
for UART1. LPC2144/46/48 only.
EINT1 External interrupt 1 input.
SDA1 I2C1 data input/output. Open-drain output (for I2C-bus compliance)
P0.15/RI1/ EINT2/AD1.5 (45 Pin)
P0.15 General purpose input/output digital pin (GPIO).
RI1 Ring Indicator input for UART1. Available in LPC2144/46/48 only.
EINT2 External interrupt 2 input.
AD1.5 ADC 1, input 5. Available in LPC2144/46/48 only.
P0.16/EINT0/ MAT0.2/CAP0.2 (46 Pin)
Shivani
13049

Page 6

P0.16 General purpose input/output digital pin (GPIO).


EINT0 External interrupt 0 input.
MAT0.2 Match output for Timer 0, channel 2.
CAP0.2 Capture input for Timer 0, channel 2.
P0.17/CAP1.2/ SCK1/MAT1.2 (47 Pin)
P0.17 General purpose input/output digital pin (GPIO).
CAP1.2 Capture input for Timer 1, channel 2
SCK1 Serial Clock for SSP. Clock output from master or input to slave.
MAT1.2 Match output for Timer 1, channel 2.
P0.18/CAP1.3/ MISO1/MAT1.3 (53 Pin)
P0.18 General purpose input/output digital pin (GPIO).
CAP1.3 Capture input for Timer 1, channel 3.
MISO1 Master In Slave Out for SSP. Data input to SPI master or data
output from SSP slave.
MAT1.3 Match output for Timer 1, channel 3.
P0.19/MAT1.2/ MOSI1/CAP1.2 (54 Pin)
P0.19 General purpose input/output digital pin (GPIO).
MAT1.2 Match output for Timer 1, channel 2.
MOSI1 Master Out Slave In for SSP. Data output from SSP master or data
input to SSP slave.
CAP1.2 Capture input for Timer 1, channel 2.
P0.20/MAT1.3/SSEL1/EINT3 (55 Pin)
P0.20 General purpose input/output digital pin (GPIO).
MAT1.3 Match output for Timer 1, channel 3.
SSEL1 Slave Select for SSP. Selects the SSP interface as a slave.
EINT3 External interrupt 3 input.
P0.21/PWM5/ AD1.6/CAP1.3 (1 Pin)
P0.21 General purpose input/output digital pin (GPIO).
PWM5 Pulse Width Modulator output 5.
AD1.6 ADC 1, input 6. Available in LPC2144/46/48 only.
CAP1.3 Capture input for Timer 1, channel 3.
P0.22/AD1.7/ CAP0.0/MAT0.0 (2 Pin)
P0.22 General purpose input/output digital pin (GPIO).
AD1.7 ADC 1, input 7. Available in LPC2144/46/48 only.
CAP0.0 Capture input for Timer 0, channel 0.
MAT0.0 Match output for Timer 0, channel 0.
P0.23/VBUS (58 Pin)
P0.23 General purpose input/output digital pin (GPIO).
VBUS Indicates the presence of USB bus power.
P0.25/AD0.4/ AOUT (9 Pin)
P0.25 General purpose input/output digital pin (GPIO).
AD0.4 ADC 0, input 4.
AOUT DAC output. Available in LPC2142/44/46/48 only.
P0.28/AD0.1/ CAP0.2/MAT0.2 (13 Pin)
P0.28 General purpose input/output digital pin (GPIO).
Shivani
13049

Page 7

AD0.1 ADC 0, input 1.


CAP0.2 Capture input for Timer 0, channel 2.
MAT0.2 Match output for Timer 0, channel 2.
P0.29/AD0.2/ CAP0.3/MAT0.3 (14 Pin)
P0.29 General purpose input/output digital pin (GPIO).
AD0.2 ADC 0, input 2.
CAP0.3 Capture input for Timer 0, Channel 3.
MAT0.3 Match output for Timer 0, channel 3.
P0.30/AD0.3/ EINT3/CAP0.0 (15 Pin)
P0.30 General purpose input/output digital pin (GPIO).
AD0.3 ADC 0, input 3.
EINT3 External interrupt 3 input.
CAP0.0 Capture input for Timer 0, channel 0.
P0.31/UP_LED/CONNECT 17
P0.31 General purpose output only digital pin (GPO).
UP_LED USB GoodLink LED indicator. It is LOW when device is
Configured. It is HIGH when the device is not configured or during global suspend.
CONNECT Signal used to switch an external 1.5 kW resistor under the software control.
Used with the SoftConnect USB feature.
P1.0 to P1.31 I/O
Port 1: Port 1 is a 32-bit bidirectional I/O port with individual direction controls for each bit. The
operation of port 1 pins depends upon the pin function selected via the pin connect block. Pins 0
through 15 of port 1 are not available.
P1.16/ TRACEPKT0 16
P1.16 General purpose input/output digital pin (GPIO).
TRACEPKT0 Trace Packet, bit 0. Standard I/O port with internal pull-up.
P1.17/ TRACEPKT1 12
P1.17 General purpose input/output digital pin (GPIO).
TRACEPKT1 Trace Packet, bit 1. Standard I/O port with internal pull-up.
P1.18/ TRACEPKT2 8
P1.18 General purpose input/output digital pin (GPIO).
TRACEPKT2 Trace Packet, bit 2. Standard I/O port with internal pull-up.
P1.19/TRACEPKT3 4
P1.19 General purpose input/output digital pin (GPIO).
TRACEPKT3 Trace Packet, bit 3. Standard I/O port with internal pull-up.
P1.20/ TRACESYNC 48
P1.20 General purpose input/output digital pin (GPIO).
TRACESYNC Trace Synchronization. Standard I/O port with internal pull-up.
P1.21/ PIPESTAT0 44
P1.21 General purpose input/output digital pin (GPIO).
PIPESTAT0 Pipeline Status, bit 0. Standard I/O port with internal pull-up.
P1.22/ PIPESTAT1 40
P1.22 General purpose input/output digital pin (GPIO).
PIPESTAT1 Pipeline Status, bit 1. Standard I/O port with internal pull-up.
P1.23/ PIPESTAT2 36
P1.23 General purpose input/output digital pin (GPIO).
Shivani
13049

Page 8

PIPESTAT2 Pipeline Status, bit 2. Standard I/O port with internal pull-up.
P1.24/ TRACECLK 32
P1.24 General purpose input/output digital pin (GPIO).
TRACECLK Trace Clock. Standard I/O port with internal pull-up.
P1.25/EXTIN0 28
P1.25 General purpose input/output digital pin (GPIO).
EXTIN0 External Trigger Input. Standard I/O with internal pull-up.
P1.26/RTCK 24
P1.26 General purpose input/output digital pin (GPIO).
RTCK Returned Test Clock output. Extra signal added to the JTAG port.
P1.27/TDO 64
P1.27 General purpose input/output digital pin (GPIO).
TDO Test Data out for JTAG interface.
P1.28/TDI 60
P1.28 General purpose input/output digital pin (GPIO).
TDI Test Data in for JTAG interface.
P1.29/TCK 56
P1.29 General purpose input/output digital pin (GPIO).
TCK Test Clock for JTAG interface.
P1.30/TMS 52
P1.30 General purpose input/output digital pin (GPIO).
TMS Test Mode Select for JTAG interface.
P1.31/TRST 20
P1.31 General purpose input/output digital pin (GPIO).
TRST Test Reset for JTAG interface.
D+ 10
USB bidirectional D+ line.
D- 11
USB bidirectional D- line.
RESET 57
External reset input: A LOW on this pin resets the device, causing I/O ports
and peripherals to take on their default states, and processor execution to
Shivani
13049

Page 9

begin at address 0. TTL with hysteresis, 5 V tolerant.


XTAL1 62
Input to the oscillator circuit and internal clock generator circuits.
XTAL2 61
Output from the oscillator amplifier.
RTXC1 3
Input to the RTC oscillator circuit.
RTXC2 5
Output from the RTC oscillator circuit.
VSS 6, 18, 25, 42,50
Ground: 0 V reference.
VSSA 59
Analog ground: 0 V reference. This should nominally be the same voltage
as VSS, but should be isolated to minimize noise and error.
VDD 23, 43, 51
3.3 V power supply: This is the power supply voltage for the core and I/O
ports.
VDDA 7
Analog 3.3 V power supply: This should be nominally the same voltage as
VDD but should be isolated to minimize noise and error. This voltage is only
used to power the on-chip ADC(s) and DAC.
VREF 63
A/D converter reference voltage: This should be nominally less than or
equal to the VDD voltage but should be isolated to minimize noise and error.
Level on this pin is used as a reference for ADC(s) and DAC.
VBAT 49
RTC power supply voltage: 3.3 V on this pin supplies the power to the RTC.
Shivani
13049

Page 10

3 Stage Pipeline Systems:

Shivani
13049

Page 11

3 Stage Pipeline Systems:


3 stage pipeline system is classical fetch, execute and decode pipeline system. It reads an
instruction from memory and increments the value in instruction set register. The value is also
stored in program counter. Then the system decodes the instructions and prepares control signals
which are required for execution of these instructions.
The third stage does all the work:
1) Reading operands from register file
2) Performing ALU operations by fetching
3) And finally writing back the modified register file.
The result from ALU is directly written into the register bank. Thus completing the execution
stage of an instruction in one cycle. The results of load/store type of instructions are computed
by ALU and then placed on address bus and incremental will finally increments the other values
for next instruction.

Shivani
13049

Page 12

Experiment- 2

Shivani
13049

Page 13

Experiment- 2
Aim: Write ARM Processor program to Flash LED
#include LPC214x.h
void delay(unsigned long int h)
{
unsigned long int i, j;
for(j=0; j<h; j++)
for(i=0; i<5000; i++);
}
int main()
{
IODIR0 = 0xFFFFFFFF;
IODIR1=0xFFFFFFFF;
while(1)
{
IOCLR0=0xFFFFFFFF;
IOCLR1=0xFFFFFFFF;
delay(1000);
IOSET0=0xFFFFFFFF;
IOSET1=0xFFFFFFFF;

delay(2000);
}
}

Shivani
13049

Page 14

Experiment- 3

Shivani
13049

Page 15

Experiment- 3
Aim: Program to display string on LCD.
Procedure:
1) Connect data of LCD with pins P0.0 P0.7
2) Connect control of LCD with P0.8 - P0.15
3) Press the reset button and execute the program.

Program:
#include<lpc214x.h>
#define rs(1<<8)
#define e (1<<9)
void delay(unsigned log int h)
{
unsigned long int i, j;
for(j=0; j<h ;j++)
for(i=0; i<5000; i++);
void cmd_lcd(unsigned long int dat)
}
IOCLR0 = 0x00000FFF;
IOSET0 = dat;
IOSET0 = e;
delay(2);
IOCLR0 = e;
delay(2);
}
void string_lcd(char * str)
{
while(*str != \0)
{
data_lcd(*str++)
Shivani
13049

Page 16

}}
void init_lcd()
{
cmd_lcd(0x38);
cmd_lcd(0x01);
cmd_lcd (0x06);
cmd_lcd (0x0c);
cmd_lcd (0x80);
}
int main()
{
int i;
IODIR0 = 0xFFFFFFFF;
init_lcd();
while(1)
{
cmd_lcd(0x80);
string_lcd(Embedded System);
cmd_lcd(0xc0);
string_lcd(ECE 2011)
for(i=0; i<=6; i++)
{
cmd_lcd(0x1c);
delay(1000);
}
for(i=0; i<=6; i++)
{
cmd_lcd(0x18);
dealy(1000);
}}}

Shivani
13049

Page 17

Experiment- 4

Shivani
13049

Page 18

Experiment- 4
Aim: Interface relays and write a program to control
#include LPC214x.h
void delay(unsigned long int h)
{
unsigned long int i, j;
for(j=0; j<h; j++)
for(i=0; i<5000; i++);
}
int main()
{
unsigned char i,a;
IODIR0 = 0xFFFFFFFF;
IOCLR0 = 0xFFFFFFFF;
while(1)
{
a = 0x01;
IOSET0 = a<<16;
delay(1000);
for(i = 0; i<8; i++)
{
IOCLR0 = 0xFFFFFFFF;
a = a<<1;
IOSET0 = a<<16;
delay(1000);
}}
}

Shivani
13049

Page 19

Experiment- 5

Shivani
13049

Page 20

Experiment- 5
Aim: Interfacing of DC Motor wit ARM Processor.
Procedure: This is the programming code for dc motor control, in which the LPC daughter
card is interfaced with DC motor, LCD and Relay.
Output:
1) Press switch 1 for moving the motor anticlockwise.
2) Press switch 2 for clockwise motion.
3) Press switch 3 for stopping the motor.
Connections:
1)
2)
3)
4)

LCD data lines P1 (16 -23)


LCD control lines P1 (24 31)
Switch Connections P0 (16 23)
DC motor module P0 ( 8-15)

Program:
#include<LPC214x.h>
#define PCLK 30000000 UL
#include delay.h
#include lcd.h
int main()
{
PINSEL0 = 0x00000000;
PINSEL1 = 0x00000000;
IODIR0 = 0x00FFFF;
IOPIN = 0;
lcd-init();
lcd_sting_xy(DC Motor,1,1);
while(1)
Shivani
13049

Page 21

{
If(IO0PIN & (1<<16))
{
IOSET= 1<<9;
IOCLR= 1<<8;
lcd_sting_xy(anticlockwise,2,1)
}
if`(IO0PIN & (1<<17))
{
IO0SET= 1<<9;
IO0CLR= 1<<8;
lcd_string_xy(clockwise,2,1);
}
if(IO0PIN & (1<<18))
{
IO0CLR = (1<<8) | (1<<9);
lcd_string_xy(stop,2,1))
}}}

Shivani
13049

Page 22

Experiment- 6

Shivani
13049

Page 23

Experiment- 6
Aim: Interfacing of Stepper Motor wit ARM Processor.
Procedure:
1) connect Stepper Motor with P0.16 P0.23
2) Press the reset button to execute the program
Program:
void delay(unsigned log int h)
{
unsigned long int i, j;
for(j=0; j<h ;j++)
for(i=0; i<5000; i++);
}
int main()
{
IODIR0 = 0xFFFFFFFF;
IODIR1 = 0xFFFFFFFF;
while(1)
{
IOCLR0 = 0xFFFFFFFF;
IOSET0 =0x10000;
delay(1000);
IOCLR0 = 0xFFFFFFFF;
IOSET0 =0x40000;
delay(1000);
IOCLR0 = 0xFFFFFFFF;
IOSET0 =0x20000;
Shivani
13049

Page 24

delay(1000);
IOCLR0 = 0xFFFFFFFF;
IOSET0 =0x80000;
delay(1000);
IOCLR0 = 0xFFFFFFFF;
delay(1000); delay(1000);
delay(1000); delay(1000);
delay(1000); delay(1000);
}}

Shivani
13049

Page 25

Experiment- 7

Shivani
13049

Page 26

Experiment- 7
Aim: Interfacing of DAC.
Program:
This code is for external DAC. In this code LPC2148/38 daughter card and DAC module. Output
of the code is a triangular wave.
Conncections:
connect DAC module with P0( 0 7) and provide +12V . +5V supply to the module.
Program:
#include<LPC214x.h>
#define PCLK 30000000 UL
int main()
{
unsigned char I;
unsigned char j;
IO0DIR = 0xFF;
IO0SET=0x00;
while(1)
{
for(i=0; i<255; i++)
{
IOPIN0 = i;
for(j=0; j<6000; j++);
}
for(i=255; i>0; i--)

Shivani
13049

Page 27

{
IOPIN0 = I;
for(j=0; j<600; j++);
}}

Shivani
13049

Page 28

Experiment- 8

Shivani
13049

Page 29

Experiment- 8
Aim: Interfacing of ADC.
Procedure:
1)
2)
3)
4)
5)

connect p0.0-P0.7 with LCD DATa


connect P0.8-P0.15 with LCD control
connect P0.16-P0.23 with ADC control
connect P1.16-P1.23 with ADC DATa
Press reset buton to execute the program

Program
#include<lpc214x.h>
#define ALE(1<<18)
#define SOC(1<<17)
#define OE (1<<16)
#define EOC (1<<19)
#define SET0 (1<<20)
#defineSET1 (1<<21)
#define SET2(1<<22)
#define CLOCK(1<<23)
#define rs (1<<8)
#define e(1<<9)
void delay(unsigned log int h)
{
unsigned long int i, j;
for(j=0; j<h ;j++)
for(i=0; i<5000; i++);
}

Shivani
13049

Page 30

void clock()
{
int b;
for(b=0l b<=250; b++)
{
IOsET0 = CLOCK;
dealy(5);
IOCLR0= CLOCK;
delay(5);
}}
char adc()
{
char val;
IOCLR0 = EOC;
IOCLR0 = SET0|SET1|SET2;
delay(1);
IOSET0 = ALE; dealy(1);
IOSET0 = Soc; delay(1);
clock();
IOCLR0 = SOC; dealy(1);
IOCLR0 = AlE; dealy(1);
clock();
while(!(IOPIN0 & EOC));
IOSET0 = OE;
val = (IOPIN1 >>16);
Shivani
13049

Page 31

return(val);
}
void cmd_lcd(unsigned long int dat)
{ IOSET0 = 3;
delay(2);
IOCLR0 = e;
delay(2);
}
void string_lcd(char *str)
{
while(*str != 0)
{
data_lcd(*str++);
}
}
void init_lcd()
{
cmd_lcd(0x38);
cmd_lcd(0x01);
cmd_lcd (0x06);
cmd_lcd (0x0c);
cmd_lcd (0x80);
}
void number_lcd(int num)
{
data_lcd(num/100)+0x30);
Shivani
13049

Page 32

data_lcd(num/10)%10+0x30);
data_lcd((num%0) +0x30);
}
int main()
{
char dis;
IODIR0 = 0x00f7ffff;
IODIR1= 0x00000000;
IOCLR0 = 0xFFFFFFF;
IOCLR1 = 0xFFFFFFFF;
init_lcd();
string_lcd(Digital output);
IOCLR0 = SOC | OE| ALE;
IOSET0 = EOc;
dealy(1000);
while(1)
{
dis = adc();
cmd_lcd(0x04);
number_lcd(dis);
delay(1000);
}}

Shivani
13049

Page 33

Experiment- 9

Shivani
13049

Page 34

Experiment- 9
Aim: Interfacing of XBEE.
Output:
In this demo code, data send via Pc is directly to 2 Xbee send wirelessly to 1 xbee and on a board
this data is show on led module.

Connection
1st Xbee Module
converter module, first box header of converter module with ARM daughter card P0(8-15) and
second box header of converter module with first xbee module
2nd Xbee module
LED module P1(16-23)
Xbee setting

Set xbee for point to point communication mode


Set one xbee as coordinator and other as router for this set the Pan Id = 1234 same in both
xbee
Set the source address on one xbee be the destination address of other xbee. This setting
is for second xbee terminal
Xtal used is 12MHz

Program
#include<LPC214x.h>
#defien PCLK 30000000UL
#includedelay.h
void uart1_init(unsigned int);
void uart1_ send(unsigned char value);
unsigned uart1-rce();

Shivani
13049

Page 35

int main()
{
unsigned int a;
PINSEL0 = 0x00000000;
PINSEL1 = 0x00000000;
IO1DIR = 0xFFFFFF;
IO1CLR=0xFFFFFF;
delay_ms(100);
uart1_init(9600);
while(1)
{
a = uart_rec();
}}
void uart1_init(unsigned int Baud_Rate)
{
PINSEL0 |= (1<<16) | (1<<18);
U1LCR = 0x83;
U1DKM = 0x00;
U1DLL = PCLK
U1LCR = 0x03;
}
void uart1_send(unsigned char value)
{while(!(U1LST & 0x20));
U1THR =value;
}
Shivani
13049

Page 36

unsigned char uart1_rec()


{
while(!(U1LST & 0x01));
return(U1RBR);
}

Shivani
13049

Page 37

Experiment- 10

Shivani
13049

Page 38

Experiment- 10
Aim: Interfacing of RFID.
Output:
in this demo code two RFId card are used to control two device 1 and 2 connected with relay if
you swap card one time device is on and on the second time device is off.
Connection
LCD data lines P1(16-23)
LCD control lines P1(25-31)
RFId P0(8-15)
Relay P0(16-23)
External clock is 12MHz
Program
#include<LPC214x.h>
#define PCLK 30000000UL
#include delay.h
#include lcd.h
unsigned char buff[2];
void RFID_rec();
void uart1_init(unsigned int);
unsigned char uart1_rec();
int main()
{
unsigned char I, SI =1; S2= 1;
PINSEL0 = 0x00000000;
PINSEL1 = 0x00000000;
Shivani
13049

Page 39

IO0DIR = 0xFFFFFF;
IO0PIN = 0;
delay_ms(100);
lcd_init()l
uart1-init(9600);
lcd_string_xy(RFID READER,1,1)
while(!)
{
RFID_rec();
if(strcmp(buff, 72004DF5F63C)==0)
{
if(S1==1)
{
lcd_string_xy(Device 1 ON,2,1);
IO0SET = 1<<17;
S1=2;
}
else if(S1==2)
{
lcd_string_xy(Device 1 is off,2,1);
IO0CLR= 1<<18;
S2=1;
}}
void RFID-rec()
{
Shivani
13049

Page 40

unsigned char i;
for(i=0; i<12; i++)
buff[i] = uart1_rec();
buff[i] = 0;
}
void uart1_init(unsigned int Baud_Rate)
{
PINSEL0 |=(1<<16)|(1<<18);
U1LCR = 0x83;
U1DLM = 0x00;
U1DLL = PCLk/(16*Baud_Rate);
U1LCR = 0x03;
}
unsigned char uart1_rec()
{
while(!(U1LSR & 0x01));
return(U1RBR);
}

Shivani
13049

Page 41

Vous aimerez peut-être aussi