ESD All EXP
ESD All EXP
ESD All EXP
1) Addition:
AREA ADD, CODE ,READONLY
ENTRY
START
MOV R0,#05
MOV R1,#04
ADD R2,R0,R1
here B here
END
OUTPUT:
2) Subtraction:
AREA SUB, CODE, READONLY
ENTRY
START
MOV R0,#08
MOV R1,#02
SUB R2,R0,R1
here B here
END
OUTPUT:
3) Multiplication:
AREA MUL, CODE ,READONLY
ENTRY
START
MOV R0,#04
MOV R1,#03
MUL R2,R0,R1
here B here
END
OUTPUT:
4) ANDING:
AREA AND, CODE ,READONLY
ENTRY
START
MOV R0,#12
MOV R1,#08
AND R2,R0,R1
here B here
END
OUTPUT:
5) ORING:
AREA ORR, CODE ,READONLY
ENTRY
START
MOV R0,#05
MOV R1,#08
ORR R2,R0,R1
here B here
END
OUTPUT:
6) EXORING:
AREA XOR, CODE ,READONLY
ENTRY
START
MOV R0,#15
MOV R1,#06
EOR R2,R0,R1
here B here
END
OUTPUT:
Experiment No- 2
Name - Manali Harish Govekar
PRN -21UET305
Title: Assembly language program for arranging the numbers in
ascending and descending order.
1)Ascending Order:
AREA ASC, CODE, READONLY
ENTRY
START
MOV R5,#3
UP2 MOV R6,R5
LDR R0,=0x40000000
UP1 LDR R1,[R0]
LDR R2,[R0,#4]
CMP R1,R2
BLT LOOP
STR R2,[R0]
STR R1,[R0,#4]
LOOP ADD R0,R0,#4
SUBS R6,#1
BNE UP1
SUBS R5,#1
BNE UP2
HERE B HERE
END
Output:
1)Before Execution:
2)After Execution:
2)Descending Order:
AREA DES, CODE, READONLY
ENTRY
START
MOV R5,#3
UP2 MOV R6,R5
LDR R0,=0x40000000
UP1 LDR R1,[R0]
LDR R2,[R0,#4]
CMP R1,R2
BGT LOOP
STR R2,[R0]
STR R1,[R0,#4]
LOOP ADD R0,R0,#4
SUBS R6,#1
BNE UP1
SUBS R5,#1
BNE UP2
HERE B HERE
END
Output:
1)Before Execution:
2)After Execution:
Experiment No- 2
Name - Manali Harish Govekar
PRN -21UET305
Title: Assembly language program for Block Transfer.
AREA BLOCKTR,CODE,READONLY
ENTRY
START
MOV R2,#02
LDR R0,=0x40000000
LDR R1,=0x40000010
UP LDR R3,[R0],#04
STR R3,[R1],#04
SUBS R2,#1
BNE UP
here B here
END
OUTPUT :
1)Before Execution 2) After Execution
Experiment No- 2
Name - Manali Harish Govekar
PRN -21UET305
Title: Assembly language program for Block Exchange.
AREA BLOCKEX,CODE,READONLY
ENTRY
START
MOV R2,#03
LDR R0,=0x40000000
LDR R1,=0x40000010
UP LDR R3,[R0]
LDR R4,[R1]
STR R3,[R1],#04
STR R4,[R0],#4
SUBS R2,#1
BNE UP
here B here
END
OUTPUT :
1) Before Execution 2) After Execution
Experiment No- 3
Name - Manali Harish Govekar
PRN -21UET305
Title: Embedded C program for Flashing LED on GPIO ports of
LPC2148 using connected LEDs.
#include<LPC214x.h>
void delay(void);
int main()
{
PINSEL0=0x00;
IODIR0 = 0xFF;
while(1)
{
IOSET0 = 0xFF;
delay();
IOCLR0 = 0xFF;
delay();
}
}
void delay()
{
int i=0;
for(i=0;i<30000;i++);
}
OUTPUT:
Experiment No- 3
Name - Manali Harish Govekar
PRN -21UET305
Title: Embedded C program for creating running light effect on
GPIO ports of LPC2148 using connected LEDs.
#include<LPC214X.h>
void delay(void)
{
int i;
for(i=0;i<30000;i++);
}
int main()
{
int k;
PINSEL0=0x00;
IODIR0=0xFF;
while(1)
{
for(k=0x01;k<=0x80;k=k<<1)
{
IOSET0=k;
delay();
IOCLR0=k;
delay();
}
}
}
OUTPUT:
Experiment No- 4
Name - Manali Harish Govekar
PRN -21UET305
Title: Embedded C program for LCD interfacing LPC2148.
1) LCD Interfacing(8-Bit):
#include<LPC214X.H>
void delay()
{
int i,j;
for(i =0;i<20;i++)
{
for(j=0;j<2000;j++);
}
}
void lcd_cmd(char c)
{
IOPIN0 &=0x00;
IOPIN0 |= c;
IOCLR0 |= 0X400;
IOCLR0 |= 0X100;
IOSET0 |= 0X200;
delay();
IOCLR0 |= 0X200;
}
void init_lcd()
{
lcd_cmd(0x38);
lcd_cmd(0x01);
lcd_cmd(0x06);
lcd_cmd(0x0C);
lcd_cmd(0x80);
}
void lcd_d(char ch)
{ IOPIN0 &=0x00;
IOPIN0 |=ch;
IOCLR0|=0x400;
IOSET0 |=0x100;
IOSET0 |=0x200;
delay();
IOCLR0 |=0x200;
}
int main()
{
int i;
char s[] = "DKTE";
char s1[]="ETC";
PINSEL0 = 0x00;
IODIR0 = 0xFFF;
init_lcd();
for(i = 0;i<4;i++)
{
lcd_d(s[i]);
delay();
}
lcd_cmd(0xC0);
for(i = 0;i<4;i++)
{
lcd_d(s1[i]);
}
}
OUTPUT:
2) LCD Interfacing(4-Bit):
#include <LPC214X.H>
void delay()
{
unsigned int b;
for(b=0;b<=20000;b++);
}
void cmd_wr(unsigned int a)
{
IOCLR0=0x2000;
IOPIN0=((IOPIN0 & 0xFFE1FFFF)|((a & 0xf0)<<13));
IOSET0=0x10000;
delay();
IOCLR0=0x10000;
IOCLR0=0x2000;
IOPIN0=((IOPIN0 & 0xFFE1FFFF)|((a & 0x0f)<<17));
IOSET0=0x10000;
delay();
IOCLR0=0x10000;
}
OUTPUT:
Experiment No- 5
Name - Manali Harish Govekar
PRN -21UET305
Title: Embedded C program for 4x4 keypad interfacing to
LPC2148.
#include <LPC214X.H>
#define r1 (1<<17) //P1
#define r2 (1<<18)
#define r3 (1<<19)
#define r4 (1<<20)
#define c1 (1<<21)
#define c2 (1<<22)
#define c3 (1<<23)
#define c4 (1<<24)
void delay()
{
unsigned int b;
for(b=0;b<=200;b++);
}
void keypad_delay(void)
{
unsigned int t1,t2;
for(t1=0;t1<300;t1++)
for(t2=0;t2<1275;t2++);
}
if((IOPIN1&r1)==0)
{
key='4';
keypad_delay();
return key;
}
else if((IOPIN1&r2)==0)
{
key='5';
keypad_delay();
return key;
}
else if((IOPIN1&r3)==0)
{
key='6';
keypad_delay();
return key;
}
else if((IOPIN1&r4)==0)
{
key='*';
keypad_delay();
return key;
}
IOCLR1|=c3;
IOSET1|=(c1|c2|c4); //third column = 0
if((IOPIN1&r1)==0)
{
key='1';
keypad_delay();
return key;
}
else if((IOPIN1&r2)==0)
{
key='2';
keypad_delay();
return key;
}
else if((IOPIN1&r3)==0)
{
key='3';
keypad_delay();
return key;
}
else if((IOPIN1&r4)==0)
{
key='-';
keypad_delay();
return key;
}
IOCLR1|=c4;
IOSET1|=(c1|c2|c3); //forth column = 0
if((IOPIN1&r1)==0)
{
cmd_wr(0x01);
keypad_delay();
}
else if((IOPIN1&r2)==0)
{
key='0';
keypad_delay();
return key;
}
else if((IOPIN1&r3)==0)
{
key='=';
keypad_delay();
return key;
}
else if((IOPIN1&r4)==0)
{
key='+';
keypad_delay();
return key;
}
}
}
void lcd_init()
{
cmd_wr(0x02); // Initialize Lcd in 4-bit mode
cmd_wr(0x28); // enable 5x7 mode for chars
cmd_wr(0x0E); // Display OFF, Cursor ON
cmd_wr(0x01); // Clear Display
cmd_wr(0x80); // Set Curser to the beginning of first line
}
int main()
{
unsigned char str1[10]="KEY";
//unsigned char str2[10]="ENTC";
unsigned char j=0;
PINSEL0 = 0x00000000;
IODIR0 = 0Xffffffff;
PINSEL1 = 0x00000000;
IODIR1 = 0x01e00000;
lcd_init();
cmd_wr(0x80);
while(str1[j])
{
data_wr(str1[j]);
delay();
j++;
}
cmd_wr(0xC0);
while(1)
{
data_wr(keypad());
}
return 0;
}
OUTPUT:
Experiment No- 6
Name - Manali Harish Govekar
PRN -21UET305
Title: Embedded C program for generating square wave of 1KHz
using Timer0/1 in LPC2148.
#include <lpc214x.h>
int main(void)
{
PINSEL0=0x00;
IODIR0 = (1<<10); //Configure Pin P0.10 as Output to on/off the LED
PLL0CON = 0x01; //Enable PLL
PLL0CFG = 0x00024; //Multiplier and divider setup
PLL0FEED = 0xAA; //Feed sequence
PLL0FEED = 0x55;
while(!(PLL0STAT & 0x00000400)); //is locked?
PLL0CON = 0x03; //Connect PLL after PLL is locked
PLL0FEED = 0xAA; //Feed sequence
PLL0FEED = 0x55;
VPBDIV = 0x00; // PCLK is CCLK/4 i.e.15 MHz
T0CTCR = 0x00; //Set Timer 0 into Timer Mode
T0PR = 59999; //Increment T0TC at every 60000 clock cycles
//Count begins from zero hence subtracting 1
//60000 clock cycles @15Mhz = 4 mS
T0TCR = 0x02; //Reset Timer
while(1)
{
IO0SET = (1<<10); //Turn ON LED
delay_ms(5);
IO0CLR = (1<<10); //Turn LED OFF
delay_ms(5);
}
//return 0;
}
OUTPUT:
Experiment No- 7
Name - Manali Harish Govekar
PRN -21UET305
Title: Embedded C program for reading pot voltage value using
ADC in LPC2148.
#include <LPC214X.H>
int adc_get_val();
int main(void)
{
PINSEL0 &= 0x00300000; // select the pin function as GPIO and AD1.2(P0.10)
//PINSEL1=0x00000400; // AD1.6
IODIR0 |= 0x000000F0; // Set the port direction //P0.4-P0.7 port pins output
AD1CR=0x00200104; //
while(1)
{
if(adc_get_val() > 0x1FF)
{
IOCLR0 = 0x00000010; // LED OFF
}
else
{
IOSET0 = 0x00000010; // LED ON
}
}
}
int adc_get_val() // Reads the value for ADC1
{
int val;
AD1GDR = AD1GDR & 0x7FFFFFFF; // clear "done" bit
AD1CR = AD1CR | 0x01000000 ; // start conversion // make bit 26 25 24 = 001
// now wait for conversion to be over// check "done" bit
while(!(AD1GDR & 0x80000000));
val = (AD1GDR & 0x0000FFC0) >> 6; // bit 15..6 has data, so shift right by 6
places
return (val);
}
OUTPUT:
Experiment No- 8
Name - Manali Harish Govekar
PRN -21UET305
Title: Embedded C program to generate variable duty cycle output
waveform using PWM section in LPC2148.
#include <lpc214x.h>
void delay()
{
unsigned int k;
for (k=0;k<50000;k++);
}
int main(void)
{
int i;
initClocks();//Initialize PClk @60Mhz
initPWM(); //Initialize PWM
while(1)
{
for(i=1000;i<=10000;i=i+1000)
{
PWMMR4 = i; //T-ON=25% , Hence 25% Bright
PWMLER = (1<<4); //Update Latch Enable bit for PWMMR4
delay();
delay();
delay();
}
}
}
void initPWM(void)
{
PINSEL0 = 0x0020000; // Select PWM4 output for Pin0.8/TXD1/PWM4
PWMPCR = 0x0; //Select Single Edge PWM - by default its single Edged so this
line can be removed
PWMPR = 60-1; // 1 micro-second resolution
PWMMR0 = 10000; // 10ms period duration
PWMMR4 = 5000; // 0.5ms - pulse duration i.e width (Brigtness level)
PWMMCR = (1<<1); // Reset PWMTC on PWMMR0 match
PWMLER = (1<<0)|(1<<4); // update MR0 and MR4
PWMPCR = (1<<12); // enable PWM 4 channel output
PWMTCR = (1<<1) ; //Reset PWM TC & PR
//PWM Generation goes active now - LED must be 25% Bright after boot!!
//Now you can get the PWM output at Pin P0.8!
}
void initClocks(void)
{
PLL0CON = 0x01; //Enable PLL
PLL0CFG = 0x24; //Multiplier and divider setup
PLL0FEED = 0xAA; //Feed sequence
PLL0FEED = 0x55;