0% found this document useful (0 votes)
2 views

MPMCLab_final

The document is a laboratory manual for the Microprocessor and Microcontrollers Lab course at Gayatri Vidya Parishad College of Engineering for the academic year 2022-2023. It outlines course outcomes, program outcomes, and specific objectives, along with a detailed list of experiments and their respective algorithms and programs. The manual aims to enhance students' practical skills in electronics and communication engineering through various assembly language programming tasks.

Uploaded by

taranimula2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

MPMCLab_final

The document is a laboratory manual for the Microprocessor and Microcontrollers Lab course at Gayatri Vidya Parishad College of Engineering for the academic year 2022-2023. It outlines course outcomes, program outcomes, and specific objectives, along with a detailed list of experiments and their respective algorithms and programs. The manual aims to enhance students' practical skills in electronics and communication engineering through various assembly language programming tasks.

Uploaded by

taranimula2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 66

Gayatri Vidya Parishad College of Engineering (Autonomous)

(Approved by AICTE, Affiliated to JNTUK, Kakinada) Madhurawada, Visakhapatnam-530048

Laboratory Manual
for

Microprocessor and Microcontrollers Lab


(Course code: 20EC1123)

B. Tech ECE VI Semester Academic Year

2022-2023

Department of Electronics and Communication


Engineering
Microprocessor and Microcontroller Lab

Course Code: 20EC1123 L T P C


0 0 3 1.5

Prerequisites: Microprocessor and Microcontroller

Course Outcomes (CO’s):


1 Apply Assembly language programs for arithmetic operations.(L3)

2 Illustrate Data Searching and Data sorting Techniques.(L3)

3 Demonstrate the Interfacing of DC Motor/Stepper Motor with microcontroller.(L4)

4 Analyze the Interfacing of DAC, ADC based peripherals.(L4)

5 Develop the Interfacing of GLCD with ARM.(L3)

Program Outcomes (POs):


Graduates will be able to apply the knowledge of mathematics, science,
PO1 engineering fundamentals to solve complex electronics and communication
engineering problems.
Graduates will attain the capability to identify, formulate and analyse
problems related to electronics and communication engineering and
PO2
substantiate the conclusions using the first principles of sciences and
engineering.
Graduates will be in a position to design solutions for electronics and
communication engineering problems and design system components and
PO3 processes that meet the specified needs with appropriate consideration for
public health and safety.
Graduates will be able to perform analysis and interpretation of data by using
PO4 research methods such as design of experiments to synthesize the information
and to provide valid conclusions.
Graduates will be able to select and apply appropriate techniques from the
available resources and modern electronics and communication engineering
PO5
and software tools and will be able to predict and model complex
engineering activities with an understanding of the practical limitations.
Graduates will be able to carry out their professional practice in electronics
PO6 and communication engineering by appropriately considering and weighing
the issues related to society and culture and the consequent responsibilities.
PO7 Graduates will be able to understand the impact of the professional
engineering solutions on environmental safety and legal issues.
PO8 Graduates will transform into responsible citizens by resorting to
professional ethics and norms of the engineering practice.
Graduates will be able to function effectively in individual capacity as well
PO9
as a member in diverse teams and in multidisciplinary streams.
Graduates will be able to communicate fluently on complex engineering
PO10 activities with the engineering community and society and will be able to
prepare reports and make presentations effectively.
Graduates will be able to demonstrate knowledge and understanding of the
PO11 engineering and management principles and apply the same while managing
projects in multidisciplinary environments.
Graduates will engage themselves in independent and life-long learning in
PO12 the broadest context of technological change while continuing professional
practice in their specialized areas of electronics and communication
engineering.

Program Specific Objectives (PSOs):


PSO1 Specify, analyze, design, prototype and test electronic systems that perform
analog and digital signal processing.
PSO2 Analyze and design wired and wireless/RF communication systems
Specify, design, and implement prototype HW/SW for VLSI and Embedded
PSO3
Systems

Course Outcomes versus Program Outcomes:


COs PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2 PSO3
CO1 2 2 2 2 3
CO2 1 1 1 3 3 3 3 3
CO3 2 3 3 3 3
CO4 3 3 3 3 3 2 2 3 2 3
CO5 3 3 3 3 S 2 3 3 3
3 - Strong correlation, 2 – Moderate correlation,1-low correlation Blank - No correlation
VISION OF THE DEPARTMENT

The vision of Electronics and Communication Engineering Department is


to be in the lead to create and develop professional and intellectual human
capital in electronics and communication engineering and applications in
order to foster the technological, economic and social enrichment of the
state and the nation and to contribute to global village connectivity.

MISSION OF THE DEPARTMENT

● To play professional role to create, develop, organize and manage


complex technologies and products, contribute to the betterment of society
and evolve better quality of living in a world increasingly influenced by
scientific and technological innovation.

● To provide students of Electronics & Communication Engineering an


environment of academic freedom that will ensure the exchange of ideas
and the dissemination of knowledge in this discipline.

● To recognize as a place that encourages research excellence and diversity


in thought and endeavor in multidisciplinary applications.
LIST OF EXPERIMENTS

1. 16 bit Arithmetic operations


2. ASCII to packed BCD Conversion
3. String operations
4. Data searching
5. Sorting of a given array.
6. Checksum / Cyclic Redundancy Check
computation of a given string.
7. Stepper Motor control.
8. Potentiometer
9. Seven Segment display LCD
10. PWM Wave generation
11. LCD
12. Sine wave Generation with DAC

1
EXPERIMENT-1

16 BIT ARITHMETIC OPERATIONS

AIM: To write an ALP to perform 16 bit Arithmetic operations using MASM software.

SOFTWARE USED: (Microsoft macro assembler) MASM software.

INSTRUCTIONS USED:

MOV: Transfers data from one register to another

ADD: Adds the data in destination operand to accumulator and stores the result in
accumulator.

ADDC: Adds the data in destination operand along with carry to accumulator and stores the
result in accumulator.

SUBB: subtract with borrow

CLR C: clear carry flag.

ALGORITHM FOR ADDITION:

Step 1: Start
Step 2: Move data into registers
Step 3: Perform addition operations
Step 4: Store sum and carry
Step 5: Move data to ports.
Step 6: Stop

ALGORITHM FOR SUBTRACTION:

Step 1: Start
Step 2: Move data into registers
Step 3: Perform subtraction operations
Step 4: Store difference and borrow
Step 5: Move data to ports.
Step 6: Stop

2
FLOW CHART:

Start

Move data into registers

Add/subtract/Multiply/divide data in
destination register to accumulator

Store sum/difference/product
along with carry

Move result to ports

Stop

3
PROGRAM:

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
num1 dw 1234h
num2 dw 1000h
sum dw 02h dup(?)
diffdw 02h dup(?)
mltdw 02h dup(?)
dvsdw 02h dup(?)
DATA ENDS
CODE SEGMENT
start: mov AX,DATA
MOV DS,AX
MOV CX, 0000H
MOV AX,NUM1
MOV BX, NUM2
CLC
ADD AX, BX
ADC CX,0000H
MOV SUM,AX
MOV SUM+2, CX
MOV AX,NUM1
SUB AX,BX
MOV CX,0000H
SBB CX,0000H
MOV diff,ax
MOV DIFF+2,CX
MOV AX, NUM1
MOV DX,0000H
MULBX

4
MOVMLT,AX
MOV MLT+2, DX
MOV AX, NUM1
MOV DX,0000H
DIV BX
MOVDVS,AX
MOV DVS+2,DX
MOV AH,4CH
INT 21H
CODE ENDS
END START

RESULT:

1. 8 bit ADDITION

SUM=P1:68H

2. 16 bit ADDITION

SUM=P1, P2:68ACH

3. 8 bit SUBTRACTION

DIFFERENCE=P1:22H

4. 16 bit SUBTRACTION

DIFFERENCE=P1, P2:4444H

5
EXPERIMENT-2

ASCII TO PACKED BCD


AIM: To write an ALP to convert ASCII to BCD and BCD to ASCII using MASM

software.

SOFTWARE USED: Microsoft macro Assembler (MASM).

INSTRUCTIONS USED:

MOV: Transfers data from one register to another

MOVX: MOVX moves a byte to or from External Memory into or from the Accumulator

RET: Return from Subroutine

SJMP: SJMP jumps unconditionally to the address specified

ANL: ANL does a bitwise "AND" operation between operand1 and operand

SWAP: SWAP swaps bits 0-3 of the Accumulator with bits 4-7 of the Accumulator

ALGORITHM:

Step 1: Move BCD value into Accumulator

Step 2: Move the content of location address into Accumulator

Step 3: Move the data from A to R2

Step 4: Value of Accumulator is Ended with 0FH

Step 5: Swap Accumulator

Step 6: Or Acc with 30H

Step 7: Increment DPTR

Step 8: Move the converted data into memory location


Step 9: End

FLOW CHART:
PROGRAM:

ASCII TO PACKED BCD

ASSUME CS:CODE, DS:DATA


DATA SEGMENT
num1 dw '4'
num2 dw '5'
result dw 01h dup(?)
DATA ENDS
CODE SEGMENT
start:MOV AX,DATA
MOV DS,AX
MOV AX,NUM1
AND AX,0FH
SHL AX,4H
MOV BX,AX
MOV AX,NUM2
AND AX,0FH
ADD AX,BX
MOV RESULT,AX
INT 3H
CODE ENDS
END START
PACKED BCD TO UNPACKED BCD
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
numdw 71h
result dw 02h dup(?)
DATA ENDS
CODE SEGMENT
start:MOV AX,DATA
MOV DS,AX
MOV AX,num
MOV BX,10H
DIV BX
MOV result,DX
MOV result+1 AX
INT 03H
CODE ENDS
END START

RESULT: ASCII value for 45H is E.

BCD value is 54 for ASCII value of 6.


EXPERIMENT-3

STRING OPERATIONS
AIM: Write an assembly language program to find length of a string and to perfrorm reversal of a
string operation using MASM software.

SOFTWARE USED: Microsoft macro assembler (MASM).

INSTRUCTIONS USED:

MOV: Transfers data from one register to another

CJNE: Compare direct byte to Acc and Jump if Not Equal

DJNZ: Decrement register and Jump if Not Zero

INC: Increment register

CLR C : clear carry flag.

ALGORITHM:

LENGTH OF A STRING:
Step 1: Set up segments.
Step 2: Define data segment.
Step 3: Define code segment.
Step 4: Initialize registers.
Step 5: Loop to calculate string length:
a. Load character into AL.
b. Increment counters SI and CX.
c. Check for null terminator.
d. Jump back if not found.
Step 6: Adjust string length.
Step 7: Prepare to terminate.
Step 8: End code segment.
Step 9: End program.

REVERSAL OF A STRING:
Step 1: Set up segments.
Step 2: Define data segment.
Step 3: Define code segment.
Step 4: Initialize registers.
Step 5: Loop to reverse the string:
a. Load word into AX.
b. Store word at destination.
c. Update pointers and counters.
d. Check for loop continuation.
Step 6: Reversal of string complete.
Step 7: Prepare to terminate.
Step 8: End code segment.
Step 9: End program.
FLOW CHART:
Length of a string: Reversal of a string:

Start Start

Set up segments. Set up segments.

Define data segment. Define data segment.

Define code segment. Define code segment.

Initialize registers. Initialize registers.

Loop to calculate string Loop to reverse the string:


length:
Load character into AL. Load word into AX.

Increment counters SI and CX. Store word at destination.

Check for null terminator. Update pointers and counters.

Jump back if not found. Check for loop continuation

Adjust string length. Reversal of string complete.

Prepare to terminate. Prepare to terminate.

End code segment. End code segment.

Stop
Stop
PROGRAM:

LENGTH OF A STRING:
ASSUME CS:CODE, DS:DATA
DATA SEGMENT
STR1 DB 'HELLO'
COUNT DB 01H DUP(?)
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV CX,0
MOV SI, offset STR1
BACK: MOV AL,[SI]
INC SI
INC CX
CMP AL,00H
JNZ BACK
DEC CX
MOV AH,4CH
INT 21H
CODE ENDS
END START
REVERSAL OF A STRING:

; REVERSAL OF A STRING
ASSUME CS:CODE, DS:DATA
DATA SEGMENT
STR1 DB 'HELLO'
COUNT EQU 06H
STRREV DB 06H DUP(?)
DATA ENDS
CODE SEGMENT
start: mov AX,DATA
MOV DS,AX
MOV CX,COUNT
mov SI, offset STR1
MOV DI, OFFSET STRREV
ADD SI,05H
back: MOV AX,[SI]
MOV [DI],AX
DEC SI
INC DI
DEC CL
JNZ back
MOV AH,4CH
INT 21H
CODE ENDS
END START

RESULT: Given string length is known and reversal of the string is performed.
EXPERIMENT NO: 4

SEARCHING THE NUMBERS FROM A GIVEN


ARRAY
AIM: Write an assembly language program to search a number from a given array using MASM
software.

SOFTWARE USED: (Microsoft macro assembler) MASAM software.

INSTRUCTIONS USED:

MOV: Transfers data from one register to another.

CJNE: Compare direct byte to Acc and Jump if Not Equal.

DJNZ: Decrement register and Jump if Not Zero.

INC: Increment register.

CLR C : Clear carry flag.

ALGORITHM:

Step 1: Initialize R0 with RAM address 20H


Step 2: Move count value to R1 register.
Step 3: Move the required number to B register.
Step 4: Clear R2 Register.
Step 5: Move first Value to Accumulator from RAM location 20H
Step 6: Compare A And B if not equal go to step 9
Step 7: Move accumulator value to R3.
Step 8: Increment R2.
Step 9: Increment R0.
Step 10: Decrement R1 if R1 not equal to 0 go to step 5
FLOW CHART:
PROGRAM:

ASSUME CS: CODE, DS:DATA


DATA SEGMENT
num1 DB 09H,12H,56H,45H,36H
DATA ENDS
CODE SEGMENT
start: mov AX,DATA
MOV DS,AX
MOV CL,05H
MOV BL,45H
MOV DX,00H
movsi, offset num1

UP1:MOV AL,[SI]

CMP AL,BL
JNZ DOWN
INC DX ; REPRESENTS THE REPETITION TIMES

DOWN: INC SI
DEC CL
JNZ UP1
MOV AH,4CH
INT 21H
CODE ENDS
END START

RESULT: Given number is searched from the given array.


EXPERIMENT-5

SORT THE NUMBERS FROM A GIVEN


ARRAY
AIM: Write an assembly language program for arranging in ascending/descending order using

MASM Software.
SOFTWARE USED: (Microsoft macro assembler) MASAM software.

INSTRUCTIONS USED:

MOV: Transfers data from one register to another

ADD: Adds the data in destination operand to accumulator and stores the result in accumulator.

INC DPTR: Increment Data Pointer.

DJNZ: Decrement register and Jump if Not Zero

CLR C: Clear carry flag.

ALGORITHM:

ASCENDING ORDER

Step 1: Initialize counter 1


Step 2: Initialize memory pointer
Step 3: Initialize counter 2
Step 4: Save lower byte of memory address
Step 5: Get the number
Step 6: Save the number
Step 7: Increment the memory pointer
Step 8: Get the next number

Step 9: If not equal check for greater or less


Step 10: If carry is zero go to step 13

Step 11: Otherwise go to skip

Step 12: Exchange

Step 13: Increment DPTR

Step 14: If R1 not equal to 0 go to BACK

Step 15: If R0 not equal to 0 go to AGAIN

DESCENDING ORDER

Step 1: Initialize counter 1


Step 2: Initialize memory pointer
Step 3: Initialize counter 2
Step 4: Save lower byte of memory address
Step 5: Get the number
Step 6: Save the number
Step 7: Increment the memory pointer
Step 8: Get the next number
Step 9: If not equal check for greater or less
Step 10: If carry is 1 go to step 13
Step 11: Otherwise go to skip
Step 12: Exchange
Step 13: Increment DPTR
Step 14: If R1 not equal to 0 go to BACK
Step 15: If R0 not equal to 0 go to AGAIN
FLOW CHART:

Ascending Order:
Descending Order:
PROGRAM FOR ASCENDING ORDER:

DATA SEGMENT
STRING1 DB 99H,12H,56H,45H,36H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV CH,04H
UP2: MOV CL,04H
LEA SI,STRING1
UP1: MOV AL,[SI]
MOV BL,[SI+1]
CMP AL,BL
JC DOWN
MOV DL,[SI+1]
XCHG [SI],DL
MOV [SI+1],DL
DOWN: INC SI
DEC CL
JNZ UP1
DEC CH
JNZ UP2
INT 3
CODE ENDS
END START
PROGRAM FOR DESCENDING ORDER:
DATA SEGMENT
STRING1 DB 99H,12H,56H,45H,36H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV CH,04H
UP2: MOV CL,04H
LEA SI,STRING1
UP1:MOV AL,[SI]
MOV BL,[SI+1]
CMP AL,BL
JNC DOWN
MOV DL,[SI+1]
XCHG [SI],DL
MOV [SI+1],DL
DOWN: INC SI
DEC CL
JNZ UP1
DEC CH
JNZ UP2
INT 3
CODE ENDS
END START

RESULT:
Inputs: x: 0x2000 -- 05h, 02h, 01h, 04h

Output: x: 0x2000 -- 01h, 02h, 04h, 05h


EXPERIMENT-6

CHECKSUM / CYCLIC REDUNDANCY


CHECK COMPUTATION OF A GIVEN
STRING
AIM: To write an ALP to find checksum for a given word using MASM software.

SOFTWARE USED: (Microsoft macro assembler) MASAM software.

INSTRUCTIONS USED:

MOV: Transfers data from one register to another

DJNZ: Decrement register and Jump if Not Zero

INC: Increment register

CLR C: clear carry flag.

ALGORITHM FOR CHECKSUM:

Step 1: Start.
Step 2: Initialize the DPTR register with starting address of data
Step 3: Initialize R0 register
Step 4: Clear accumulator
Step 5: Move the contents of data from starting address into accumulator
Step 6: Add the contents of data one by one
Step 7: Move the result into register B
Step 8: Increment R1 on generation of carry
Step 9: Increment the DPTR
Step 10: Repeat the process till R0 becomes zero
Step 11: Complement the result in accumulator
Step 12: Stop
FLOW CHART:
PROGRAM:

;checksum of the name DIVYA


ASSUME CS:CODE, DS:DATA
DATA SEGMENT
listdb 44h,49h,56h,59h,41h
sumdb 00h
resultdb 01h dup(?)
DATA ENDS
CODE SEGMENT
start: mov AX,DATA
MOV DS,AX
MOV CX, 0005H
mov SI, offset LIST
back: MOV AL,[SI]
addsum,AL
INC SI
DEC CL
JNZ back
mov AL, SUM
neg al
mov result, al
MOV AH,4CH
INT 21H
CODE ENDS
END START

RESULT: Checksum for given word is calculated and verified.


EXPERIMENT – 7

STEPPER MOTOR

AIM: To perform the rotation of stepper motor in clockwise and anti-clockwise direction.

HARDWARE USED: ARM LPC2929 board, Interfacing Board and Stepper Motor.

SOFTWARE USED: Keil-μ vision 4.

THEORY:
A stepper motor or a step motor is a brushless, asynchronous motor which divides a full rotation
into a number of steps. Unlike a brushless DC motor which rotates continuously when a fixed DC
voltage is applied to it, a step motor in discrete step angles. The stepper motors therefore are
manufactured with steps per revolution of 12,24,72,144,180,200, resulting in stepping angles of
30,15,5,2.5,2 and 1.8 degrees per step. The stepper motor can be controlled with or without
feedback.

ALGORITHM:
Step 1: Start.
Step 2: Declare Dir as value as 0x00.
Step 3: Initialize GPIO3_OR value as 0x000000FF.
Step 4: Declare SFSP2_26 value as 0x03 << 2.
Step 5: Initialize GLCD.
Step 6: Clear GLCD.
Step 7: Set the LCD back color as blue, text color as white.
Step 8: Display first line of LCD as “GVPCOE”, second line as “ECE” and third line as
“EMBEDDED SYSTEMS LAB”.
Step 9: Set LCD back color as white and text color as blue.
Step 10: Display fourth line of LCD as “stepper motor”.
Step 11: Check the condition if condition is true, go to next step, otherwise go to
step 18.
Step 12: Check the condition “ Dir =1”. If the condition is true, go to next step
otherwise go to step 18.
Step 13: Initialize GPIO3_DR.
Step 14: Initialize “delay (50000)” function.
Step 15: Initialize variable r as random unsigned integer.
Step 16: Check the condition “x>0”; if it is true, go to next step otherwise go to step18.
Step 17: Decrement x and go to step 16.
Step 18: Return to next step.
Step 19: Initialize GPIO3_OR.
Step 20: Repeat steps from step 14 to step 18.
Step 21: Initialize GPIO3_OR.
Step 22: Repeat steps from step14 to step 18.
Step 23: Initialize GPIO3_OR.
Step 24: Repeat steps from step 14 to step 18.
Step 25: Initialize GPIO3_OR.
Step 26: Repeat steps from step 14 to step 18.
Step 27: Initialize GPIO3_OR.
Step 28: Repeat steps from step 14 to step 18.
Step 29: Initialize GPIO3_OR.
Step 30: Repeat steps from step 14 to step 18.
Step 31: Initialize GPIO3_OR.
Step 32: Repeat steps from step 14 to step 18.
Step 33: Check the condition if true go to next step otherwise go to step 41.
Step 34: Check the condition if true go to next step otherwise go to step 41.
Step 35: Initialize “direction ( )” function.
Step 36: Declare Dir =~ Dir.
Step 37: Check the condition, if true go to next step, else go to step 41.
Step 38: Display “clockwise” and go to step 41.
Step 39: Display “anti-clockwise” and go to step 41.
Step 40: Repeat steps from step 14 to step 18.
Step 41: Stop.
FLOW CHART:
PROGRAM:
#include <LPC29xx.H>
#include "GLCD.h"

static unsigned char Dir=0x00;


void delay(unsigned int x);
void Direction(void);

main()
{
/*Configure GPIO pins as Outputs */
GPIO3_DR |= 0x000000FF; /* Configure the BUTTON(S1) GPIO pin as Input with internal
pull-up */
SFSP2_26 = (0x03 << 2);

GLCD_Init (); /* GLCD initialization */


GLCD_Clear(White); /* Clear the GLCD */
GLCD_SetBackColor(Blue); /* Set the Back Color */
GLCD_SetTextColor(White); /* Set the Text Color */

GLCD_DisplayString(0, 0, 1," GVPCOE ");


GLCD_DisplayString(1, 0, 1," ECE ");
GLCD_DisplayString(2, 0, 1," EMBEDDED SYSTEMS LAB ");

GLCD_SetBackColor(White); /* Set the Back Color */


GLCD_SetTextColor(Blue); /* Set the Text Color */

GLCD_DisplayString(4, 0,1," Stepper Motor " );


GLCD_DisplayString(6, 0,1," Demo " );
GLCD_DisplayString(8, 0, 1," Anti Clockwise "); /* Display "Anti Clockwise" on LCD */

while(1)
{
if(Dir) /* Clockwise Direction */
{
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00) | 0x00000088;
/* Write data for clock wise direction*/
delay(50000);
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00) | 0x00000044;
/* Write data for clock wise direction*/
delay(50000);
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00) | 0x00000022;
/* Write data for clock wise direction*/
delay(50000);
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00) | 0x00000011;
/* Write data for clock wise direction*/
delay(50000);
}
else /* AntiClockwise Direction */
{
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00) | 0x00000011;
/* Write data for anticlock wise direction*/
delay(50000);
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00) | 0x00000022;
/* Write data for anticlock wise direction*/
delay(50000);
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00) | 0x00000044;
/* Write data for anticlock wise direction*/
delay(50000);
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00) | 0x00000088;
/* Write data for anticlock wise direction*/
delay(50000);
}

if(!(GPIO2_PINS & (1 << 26))) /* Is Button S1 Pressed ? */


{
while(!(GPIO2_PINS & (1 << 26))); /* Wait until released */
Direction(); /* Call Direction Function */
}
}
}
void delay(unsigned int x) /* Delay Routine */
{
for(;x>0;x--);
}
void Direction(void)
{
Dir = ~Dir; /* Complement the Direction */
//GLCD_Clear(White); /* Clear the GLCD */

if(Dir)
GLCD_DisplayString (8, 0, 1," Clockwise ");
/*Display "Clockwise" on LCD */
else
GLCD_DisplayString (8, 0,1, " Anti Clockwise ");
/* Display "Anti Clockwise" on LCD */
delay(50000);
}

RESULT: Hence, performed the rotation of stepper motor in clockwise and anti-clockwise direction.
EXPERIMENT – 8

POTENTIOMETER

AIM: To perform ADC Channel testing with a rotator potentiometer on LPC2929 board.

HARDWARE USED: ARM LPC2929 Board, Interfacing Board.

SOFTWARE USED: Keil-μ vision 4.

THEORY:

Analog to digital converter (ADC) is a digital converter that is used to converter analog
signal/voltage into its equivalent digital number. The conversion is required so that the micro
controller can process that numbers and make it human hearable. The ADC is characterized by
resolution, which indicates the number of digital valves that can be measured. In LPC2929
microcontroller, we have in-built 10 bit ADC i.e. resolution=10 bit and maximum value = 2^10 =
1024. Digital valve lies between 0 to 1023.one of the most important term relate ADC is step size.
Step size is minimum change in input voltage which can be resolved by ADC.

ALGORITHM:

STEP 1: Start

STEP 2: Define the AD0_value, AD2_val as short data type.

STEP 3: Initialize num, dir, AD_val old as integer data type.

STEP 4: Initialize ADC_CLK_CONF by performing shift and or operation.

STEP 5: Initialize the base CLK in MSCSS

STEP 6: Initialize MTIMO_PR, Match registers – MR0, MR2, MCR, EMR1 and TCR.

STEP 7: Initialize ADC_CLK_CONF by performing shift and or operation.


Step 8: Initialize REQUEST_16,2, ADCO_CONFIG, ADC0_CTRL, ADC0_ENABLE,

TMO_PR, MR0, MR2, TCR, enable and TMR_CLK_CONFIG.

Step 9: Initialize the GLCD value.

Step 10: Clear the GLCD Display.

Step 11: Set the back ground color as blue.

Step 12: Set the text color as white.

Step 13: Print the ADC value.

Step 14: Display the ADC values on the LCD.

Step 15: Initialize i as zero

Step 16: Check i&lt; 12000000 condition, if condition is true go to the next step, otherwise go to

the step 25.


Step 17: Check the infinity loop condition, if condition is true, go to the next step, otherwise go to

step 25.
Step 18: Check the if condition. If condition is true, go to the next step, otherwise go to step 25.

Step 19: Set the text as blue color.

Step 20: Print the ADC values.

Step 21: Display the ADC value LCD.

Step 22: Set the text color as red.

Step 23: Represent the analog values on LCD.

Step 24: Initialize the AD value_old as AD_value .

Step 25: Increment the i value.

Step 26: Check the if condition. If condition is true, go to the next step, otherwise go to step 29.

Step 27: Initialize clock as zero.

Step 28: Stop


FLOW CHART:
F

T
F

T
F

T
PROGRAM:

#include <stdio.h>
#include <LPC29xx.H>
#include "GLCD.h" /* LCD function prototypes */

#define TMR_CLK 96000000 /* In Hz */


#define __ADC0 /* Comment this part to select ADC2 */
#define AD_VALUE_MAX 0x3FF /*10 bit resolution*/
#define LED_NUM 8 /* Number of LEDs used for blinking */

const unsigned intled_mask[] = { 1 << 16, 1 << 17, 1 << 18, 1 << 19, 1 << 20, 1 << 21 , 1 << 22, 1 <<
23 };
const unsigned intbut_mask[] = { 1 << 26, 1UL << 27 };
volatile short AD0_val, AD2_val;
char text[40]; /* Import external functions from Serial.c file */

extern void init_serial (void);


extern char Speed;
extern volatile unsigned char Clock;
extern volatile unsigned char Clock1s;

/* Change LED blinking speed depending on buttons pressed */


voidchange_speed (void)
{
if (!(GPIO2_PINS &but_mask[0]))
{ /* S1 - speed up */
if (Speed > 0) Speed --;
}
if (!(GPIO2_PINS &but_mask[1]))
{ /* S2 - slow down */
if (Speed < 10) Speed ++;
}
}

int main (void)


{
inti;
intnum = 0;
intdir = 1;
intAD_valueOld = 0;
static short LEDState;

#ifdef __ADC0
#define AD_value AD0_val
#else
#define AD_value AD2_val
#endif
Speed = 5; /* Initial speed at half */

/* Configure the BUTTON's GPIO pins as Inputs with internal pull-up */


SFSP2_26 = (0x03 << 2);
SFSP2_27 = (0x03 << 2);
GPIO2_DR &= ~(0x03UL << 26);

/* Configure the LED's GPIO pins as Outputs */


GPIO2_DR |= (0xFF << 16);

/* Configure MSCSS clock = PLL clock / 2 = 96 MHz (max allowed 125 MHz) */
MSCSS_CLK_CONF = (2UL << 24) | (1 << 11) | (1 << 2);
MTIM0_PR = (96000000/1000) - 1; /* Prescaler to drive timer with 1 ms */
MTIM0_MR0 = (10 - 1); /* Match value = 10 * 1ms = 10 ms -> ADC0*/
MTIM0_MR2 = (10 - 1); /* Match value = 10 * 1ms = 10 ms -> ADC2*/
MTIM0_MCR = (1 << 4); /* On Match 2 event reset timer */
MTIM0_EMR |= (3 << 4); /* Match 0 event generate logic 1 -> ADC0*/
MTIM0_EMR |= (3 << 8); /* Match 2 event generate logic 1 -> ADC2*/
MTIM0_TCR = 1; /* Start Timer 0 */

/* Configure ADC clock = FDIV0 / 1 = 4 MHz (max allowed 4.5 MHz) */


ADC_CLK_CONF = (5UL << 24) | (1 << 11) | (0 << 2);

/* Setup ADC2 IN0 to convert in 10-bit resolution and generate interrupt */


ADC0_CTRL = (1<<1); /* Stop ADC conversion */
SFSP0_4 = 5; /* Configure P0.4 as analog input */

/* Setup ADC0 interrupt generation */


INT_REQUEST_16 = (1 << 28) | /* Enable setting of priority level */
(1 << 27) | /* Enable setting interrupt target */
(1 << 26) | /* Write enable of new settings */
(1 << 16) | /* Enable interrupt request */
(1 << 8) | /* Interrupt target is IRQ interrupt */
(15 << 0); /* Priority level 15, disable nesting */

ADC0_ACC0 = 0x0000000A; /* Set ADC0 IN0 10-bit resolution */


ADC0_CONFIG = (1 << 14); /* ADC single scan, start on pos edge */
ADC0_CTRL = 4; /* Copy the configuration */
ADC0_INT_SET_ENABLE = 1; /* Enable end of scan interrupt */

ADC2_CTRL = (1<<1); /* Stop ADC conversion */


SFSP0_16 = 1; /* Configure P0.16 as analog input */

/* Setup ADC2 interrupt generation */


INT_REQUEST_18 = (1 << 28) | /* Enable setting of priority level */
(1 << 27) | /* Enable setting interrupt target */
(1 << 26) | /* Write enable of new settings */
(1 << 16) | /* Enable interrupt request */
(1 << 8) | /* Interrupt target is IRQ interrupt */
(15 << 0); /* Priority level 15, disable nesting */
ADC2_ACC0 = 0x0000000A; /* Set ADC2 IN0 10-bit resolution */
ADC2_CONFIG = (1 << 14); /* ADC single scan, start on pos edge */
ADC2_CTRL = 4; /* Copy the configuration */
ADC2_INT_SET_ENABLE = 1; /* Enable end of scan interrupt */

/* Configure timer clock = PLL clock / 2 = 96 MHz */


TMR_CLK_CONF = (2UL << 24) | (1 << 11) | (1 << 2);

/* Setup Timer 0 interrupt generation */


INT_REQUEST_2 = (1 << 28) | /* Enable setting of priority level */
(1 << 27) | /* Enable setting interrupt target */
(1 << 26) | /* Write enable of new settings */
(1 << 16) | /* Enable interrupt request */
(1 << 8) | /* Interrupt target is IRQ interrupt */
(15 << 0); /* Priority level 15, disable nesting */

/* Setup Timer 0 to generate interrupt every 10 ms */


TIM0_PR = (TMR_CLK /1000) - 1; /* Prescaler to drive timer with 1 ms */
TIM0_MR0 = (10 - 1); /* Match value = 10 * 1ms = 10 ms */
TIM0_MCR = 1; /* On Match 0 event reset timer */
TIM0_INT_SET_ENABLE = 1; /* Enable Match 0 to generate interrupt */
TIM0_TCR = 1; /* Start Timer 0 */

init_serial (); /* Init UART */


GLCD_Init (); /* GLCD initialization */
GLCD_Clear(White); /* Clear the GLCD */
GLCD_SetBackColor(Blue); /* Set the Back Color */
GLCD_SetTextColor(White); /* Set the Text Color */

GLCD_DisplayString(0, 0, " GVPCOE ");


GLCD_DisplayString(1, 0, " ECE ");
GLCD_DisplayString(2, 0, " EMBEDDED SYSTEMS LAB ");

GLCD_SetBackColor(White); /* Set the Back Color */


GLCD_SetTextColor(Blue); /* Set the Text Color */
sprintf(text, "AD value = 0x%04X", AD_value);
GLCD_DisplayString(4, 0, (unsigned char *)text);

for (i = 0; i< 12000000; i++); /* Wait for initial display */

for (;;)
{ /* Loop forever */
if (AD_value != AD_valueOld)
{
GLCD_SetTextColor(Blue); /* Set the Text Color */
sprintf(text, "AD value = 0x%04X", AD_value);
GLCD_DisplayString(4, 0, (unsigned char *)text);

GLCD_SetTextColor(Red);
GLCD_Bargraph (0, 120, 320, 24, AD_value);
AD_valueOld = AD_value;
}
if (Clock)
{ /* LED activate and deactivate */
Clock = 0;
LEDState ^= 0x01;
change_speed(); /* Check buttons to change LED speed */
if (LEDState)
{
GPIO2_OR |= led_mask[num]; /* Turn LED on */
}
else
{
GPIO2_OR &= ~led_mask[num]; /* Turn LED off */

/* Calculate 'num': 0,1,...,LED_NUM-1,LED_NUM-1,...,1,0,0,... */


num += dir;
if (num == LED_NUM) { dir = -1; num = LED_NUM-1; }
else if (num< 0) { dir = 1; num = 0; }
}
}
if (Clock1s)
{ /* Output AD value on UART every 1 sec*/
Clock1s = 0;
printf ("AD value = 0x%04x\n\r", AD_value);
}
}
}

RESULT: ADC channel testing is done with a rotator potentiometer using LPC2929 Board.
EXPERIMENT – 9

SEVEN SEGMENT DISPLAY


AIM: To interface the 7 segment display to LPC2929 board and display the required contents on
7 segment display.

HARDWARE USED: ARM LPC2929 board, Seven Segment Display board.

SOFTWARE USED: Keil-μ vision 4.

THEORY:
Seven Segment Displays is the most common devices used for displaying digits and alphabet.
You can see the seven segment display devices in TV shows counting down to ‘0’. Use of
LEDs in seven segment displays made it more popular. The binary information can be
displayed in the form of decimal using this seven segment display. Its wide range of
applications is in microwave ovens, calculators, washing machines, radios, digital clocks etc.
The seven segment displays are made up of either LEDs or LCDs. Light emitting diode is P-N
junction diode which emits in the form of heat. These LEDs or LCDs are used to display the
required numeral or alphabet. Single seven segment or number of segments arranged in an
order meets our requirements.

ALGORITHM:
Step 1: Start.
Step 2: Calling and delay function.
Step 3: Declare I as unsigned long integer.
Step 4: Initialize i=0.
Step 5: Check i<15000000 condition, if true go to next step, otherwise go to step 7.
Step 6: Declare i, j, m, k, s as unsigned char.
Step 7: Initialize char display[6][4].
Step 8: Initialize GPIO2_DR 1 = 0x00010000.
Step 9: Initialize GPIO3_DE 1 = 0x0000100.
Step 10: Initialize the GLCD
Step 11: Clear the GLCD value.
Step 12: Set the GLCD back color as blue.
Step 13: Set the GLCD text color as white.
Step 14: Display GLCD first string as GVPCOE, second string as ECE, third string as EMBEDDED
SYSTEMS LAB.
Step 15: Set GLCD back color as white.
Step 16: Set GLCD text color as blue.
Step 17: Display GLCD fifth string as 7 segment display, eighth string as demo.
Step 18: Check while condition, if true go to next step otherwise go to step 34.
Step 19: Initialize i=0.
Step 20: Check i<6 condition, if true go to next step otherwise go to step 34.
Step 21: Initialize j=0.
Step 22: Check j<4 condition, if true go to next step, else step 33.
Step 23: Initialize s= display[i][j].
Step 24: Initialize k=0.
Step 25: Check k<8 condition, if true go to next step, otherwise go to step33.
Step 26: Initialize m=s.
Step 27: Perform operation on m=m&0*80.
Step 28: Check m == 0 condition, if true go to next step, otherwise go to step 30.
Step 29: GPIO3_DR = (GPIO_OR & 0xFFFFFEFF).
Step 30: Initialize the GPIO3_OR = (GPIO3_OR & 0xFFFFFEFF)|0X00000100.
Step 31: Initialize the GPIO2_OR = GPIO_OR & 0Xfffeffff.
Step 32: Initialize s << 1.
Step 33: Call the delay function.
Step 34: Stop.
FLOW CHART:
PROGRAM:
#include <LPC29xx.H>
#include "GLCD.h"

void delay(void) /* Delay routine I between the Groups*/


{
unsigned long i;
for(i=0;i<5000000;i++);
}

int main()
{
unsigned char i,j,k,m,s;
/* Look Up Table To Display */
unsigned char display[5][4]= { 0xff,0xff,0xff,0xff, 0x86,0xc7,0x86,0xc6, 0x87,0xde,0xc0,0xbf,
0x92,0x91,0x92,0xff,
0x87,0x86,0xc8,0x92 }; /* Values passed to 7 Segment */

GPIO2_DR |= 0x00010000;
GPIO3_DR |= 0x00000100; /* Configure GPIO pins as Outputs */

GLCD_Init (); /* GLCD initialization */


GLCD_Clear(White); /* Clear the GLCD */
GLCD_SetBackColor(Blue); /* Set the Back Color */
GLCD_SetTextColor(White); /* Set the Text Color */

GLCD_DisplayString(0, 0, 1," GVPCOE ");


GLCD_DisplayString(1, 0, 1," ECE ");
GLCD_DisplayString(2, 0, 1," EMBEDDED SYSTEMS LAB ");

GLCD_SetBackColor(White); /* Set the Back Color */


GLCD_SetTextColor(Blue); /* Set the Text Color */

GLCD_DisplayString(4, 0,1," 7 Segment Display " );


GLCD_DisplayString(6, 0,1," Demo " );

while(1)
{
for(i=0;i<5;i++) /*Number of Groups(5) */
{
for(j=0;j<4;j++) /* Number of LEDs(4) per Group*/
{
s = display[i][j]; /* code to Display */
for(k=0;k<8;k++) /* Number of Segments Per LED */
{
m = s;
m = m & 0x80;
if(m == 0)
/* Send Data */
GPIO3_OR = (GPIO3_OR & 0xFFFFFEFF);

else
GPIO3_OR = (GPIO3_OR & 0xFFFFFEFF) | 0x00000100;
GPIO2_OR = (GPIO2_OR & 0xFFFEFFFF) | 0x00010000; /*
Send Clock */
GPIO2_OR = (GPIO2_OR & 0xFFFEFFFF);
s <<= 1;
}
}
delay();
}

}
}

RESULT: Hence performed the interface of the 7 segment display to LPC2929 board and displayed
the required contents on 7 segment display.
EXPERIMENT – 10

PWM WAVE GENERATION

AIM: To generate square wave or control Pulse Width Modulator using LPC 2929 board.

HARDWARE USED: ARM LPC2929 board, CRO.

SOFTWARE USED: Keil-µ vision 4 Software.

THEORY:
Pulse width modulation (PWM), or pulse-duration modulation (PDM), is a method of reducing the
average power delivered by an electrical signal, by effectively chopping it up into discrete parts.
The average value of voltage (and current) fed to the load is controlled by turning the switch
between supply and load on and off at a fast rate. The longer the switch is on compared to the off
periods, the higher the total power supplied to the load. Along with maximum power point
tracking (MPPT), it is one of the primary methods of reducing the output of solar panels to that
which can be utilized by a battery PWM is particularly suited for running inertial loads such as
motors, which are not as easily affected by this discrete switching, because their inertia causes them
to react slowly. The PWM switching frequency has to be high enough not to affect the load, which
is to say that the resultant waveform perceived by the load must be as smooth as possible.

ALGORITHM:
Step 1: Start.
Step 2: Configure GPIO pins as output.
Step 3: Initialize GLCD.
Step 4: Clear the GLCD.
Step 5: Set the back color.
Step 6: Set the text color.
Step 7: Display the string on the GLCD.
Step 8: Set the back color.
Step 9: Set the text color.
Step 10: Display the string on the GLCD.
Step 11: Loop for high amplitude.
Step 12: Delay routine.
Step 13: Loop for high amplitude.
Step 14: Delay routine.
Step 15: Stop.
FLOW CHART:
PROGRAM:
#include <LPC29xx.H>
#include "GLCD.h"
void delay(void) /* Delay Routine */
{
unsigned char i;
for(i=0;i<100;i++);
}

main()
{
unsigned char i=0,j=0;
GPIO3_DR |= 0x0000FFFF; /* Configure GPIO pins as Outputs */

GLCD_Init (); /* GLCD initialization */


GLCD_Clear(White); /* Clear the GLCD */
GLCD_SetBackColor(Blue); /* Set the Back Color */
GLCD_SetTextColor(White); /* Set the Text Color */

GLCD_DisplayString(0, 0, 1," GVPCOE ");


GLCD_DisplayString(1, 0, 1," ECE ");
GLCD_DisplayString(2, 0, 1," EMBEDDED SYSTEMS LAB ");

GLCD_SetBackColor(White); /* Set the Back Color */


GLCD_SetTextColor(Blue); /* Set the Text Color */

GLCD_DisplayString(4, 0,1," PWM DEMO" );


GLCD_DisplayString(6, 0,1," SQUARE WAVE " );

while(1)
{
for(i=0; i<0x0FF; i++)
{
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00)| 0x000000FF;
GPIO3_OR = (GPIO3_OR & 0xFFFF00FF)| 0x0000FF00;
delay();
}
for(j=0xFF; j>0; j--)
{
GPIO3_OR = (GPIO3_OR & 0xFFFF00FF) ;
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00);
delay();
}
}
}

RESULT: Hence, demonstration of PWM using LPC 2929 board is performed and observed.
EXPERIMENT -11

LCD INTERFACING

AIM: To perform LCD interfacing on LPC2929 Board.

HARDWARE USED: ARM LPC2929 Board.

SOFTWARE USED: Keil-μ vision 4.

THEORY:
A liquid-crystal display (LCD) is a flat-panel display or other electronically modulated optical device
that uses the light-modulating properties of liquid crystals combined with polarizers. Liquid crystals do
not emit light directly, [1] instead using a backlight or reflector to produce images in color or
monochrome. LCDs are available to display arbitrary images (as in a general-purpose computer
display) or fixed images with low information content, which can be displayed or hidden, such as
preset words, digits, and seven-segment displays, as in a digital clock. They use the same basic
technology, except that arbitrary images are made from a matrix of small pixels, while other displays
have larger elements. LCDs can either be normally on (positive) or off (negative), depending on the
polarizer arrangement.

ALGORITHM:
Step 1: Start.
Step 2: Declare int type variables ‘a’ i.e. Variable ‘a’ as integer.
Step 3: Initialize LCD.
Step 4: Clear the previous data on the LCD Display.
Step 5: Set the LCD background color as blue.
Step 6: Set the LCD text color as white.
Step 7: Display LCD first line as “GVPCOE”
Step 8: Display LCD second line as “ECE”
Step 9: Display LCD third line as “EMBEDDED SYSTEMS LAB”
Step 10: Initialize i=0
Step 11: Check i<12000000 condition, if the condition is true then go to step, otherwise go to step13.
Step 12: Increment ‘i’ valve and g to step11.
Step 13: Stop
FLOW CHART:
PROGRAM:
#include <LPC29xx.H>
#include "GLCD.h"
#include <stdio.h>

unsigned char mess[] = {' ',' ','I','S',' ','T','Y','P','E','D',0x00};


unsigned char disp1[] = {'E','N','T','E','R',' ','A',' ','K','E','Y',0x00};

/* Import external functions from Serial.c file */


extern void init_serial (void);
externintgetkey (void);
externintsendchar (intch);

void delay(unsigned int x)


{
unsignedinti,j;
for(i=0; i<10; i++)
{
for(j=0; j<x; j++);
}
}

void delay1()
{
unsignedinti,j;
for(i=0; i<0x50; i++)
{
for(j=0; j<0x4fb; j++);
}
}
/* Function to display the character entered from the keyboard */
voidDisp_Key(unsigned long c)
{
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00) | c;
/* E R/W* RS */
GPIO3_OR = (GPIO3_OR & 0xFFFF00FF) | (0xFA << 8); /* 0 1 0 */
GPIO3_OR = (GPIO3_OR & 0xFFFF00FF) | (0xF9 << 8); /* 0 0 1 */
GPIO3_OR = (GPIO3_OR & 0xFFFF00FF) | (0xFD << 8); /* 1 0 1 */
GPIO3_OR = (GPIO3_OR & 0xFFFF00FF) | (0xF9 << 8); /* 0 0 1 */
delay(50);
}

/* Function to issue the series of commands to the LCD module */


voidCommand_Write(unsigned long com_word)
{
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00) | com_word; /* Send commands to the LCD through
GPIO1 */
/* E R/W* RS */
GPIO3_OR = (GPIO3_OR & 0xFFFF00FF) | (0xFB << 8); /* 0 1 1 */
GPIO3_OR = (GPIO3_OR & 0xFFFF00FF) | (0xF8 << 8); /* 0 0 0 */
GPIO3_OR = (GPIO3_OR & 0xFFFF00FF) | (0xFC << 8); /* 1 0 0 */
GPIO3_OR = (GPIO3_OR & 0xFFFF00FF) | (0xF8 << 8); /* 0 0 0 */
delay(50);
}

/* Function to read characters from a string and displaying the same by calling the Disp_keyfucntion
*/
void Disp_String1(void)
{
inti=0;
while(disp1[i] != 0x00)
{
Disp_Key(disp1[i]);
delay1();
i++;
}
}

/* Function to initialize the LCD module */


voidinit_lcd(void)
{
int j;
unsigned long command;
j = 0x9f; /* Delay given for the voltage rise from 0V to 5V */
delay(j);

command = 0x38; /* Issue software reset for the LCD module */


Command_Write(command);
j = 0x13F;
delay(j);

command = 0x38; /* Function set 8-bit, 1 line 5*7 font */


Command_Write(command);
j = 0x13F;
delay(j);

command = 0x38; /* Function set 8-bit, 1 line 5*7 font */


Command_Write(command);

command = 0x38; /* Function set 8-bit, 1 line 5*7 font */


Command_Write(command);

command = 0x0c; /* Display on off control. Diplay on, cursor off, */


Command_Write(command); /* blink off */

command = 0x01; /* Clear the LCD display */


Command_Write(command);
}

voidDisp_Message(void)
{
inti;
i = 0;
while(mess[i] != 0x00)
{
Disp_Key(mess[i]);
i ++;
}
}

int main()
{
unsigned long com_word;
unsigned char c;

GPIO2_DR |= 0x00FF0000; /* Configure GPIO pins as Outputs */


GPIO3_DR |= 0x0000FFFF;

GLCD_Init (); /* GLCD initialization */


GLCD_Clear(White); /* Clear the GLCD */
GLCD_SetBackColor(Blue); /* Set the Back Color */
GLCD_SetTextColor(White); /* Set the Text Color */

GLCD_DisplayString(0, 0,1, " GVPCOE ");


GLCD_DisplayString(1, 0,1, " ECE ");
GLCD_DisplayString(2, 0,1, " EMBEDDED SYSTEMS LAB ");

GLCD_SetBackColor(White); /* Set the Back Color */


GLCD_SetTextColor(Blue); /* Set the Text Color */
GLCD_DisplayString(4, 0,1," LCD Interface " );
GLCD_DisplayString(6, 0,1," Demo " );

init_serial();
init_lcd();
com_word = 0x80;
Command_Write(com_word);
delay1();
delay1();
Disp_String1(); /* Displays the "ENTER A KEY" message on LCD */
printf("\n\rESA LCD INTERFACE DEMO PROGRAM \n\r ");
printf("\n\rEnter any key to clear the display\n\r ");
c = getkey();

com_word = 0x01; /* Clears the LCD Display */


Command_Write(com_word);
com_word = 0x80; /* Bring the cursor to the home location */
Command_Write(com_word);

while(1)
{
printf("\n Enter Key \t"); /* Enter the key to be displayed on the display */
c = getkey();

sendchar(c); /* Displays the key entered on hyper terminal */


printf(" is typed\n\r ");

Disp_Key(c); /* Displays the key entered on LCD Interface*/


delay1();
Disp_Message(); /* Displays the "IS TYPED" message on LCD */
com_word = 0x02;
Command_Write(com_word);
delay(10);
}
}

RESULT: LCD Interfacing is executed and observed on LPC2929 Board.


EXPERIMENT – 12

WAVEFORM GENERATION WITH DAC


AIM: To control Digital to Analog Converter (DAC) using LPC 2929 board.

HARDWARE USED: ARM LPC2929 board, DAC driver, CRO.

SOFTWARE USED: Keil-µ vision 4 Software.

THEORY:
In electronics, a digital-to-analog converter (DAC, D/A, D2A, or D-to-A) is a system that converts
a digital signal into an analog signal. An analog-to-digital converter (ADC) performs the reverse
function. There are several DAC architectures; the suitability of a DAC for a particular application
is determined by figures of merit including: resolution, maximum sampling frequency and others.
Digital-to-analog conversion can degrade a signal, so a DAC should be specified that has
insignificant errors in terms of the application. DACs are commonly used in music players to
convert digital data streams into analog audio signals. They are also used in televisions and mobile
phones to convert digital video data into analog video signals. These two applications use DACs at
opposite ends of the frequency/resolution trade-off. The audio DAC is a low-frequency, high-
resolution type while the video DAC is a high-frequency low- to medium-resolution type.

ALGORITHM:
Step 1: Start.
Step 2: Configure GPIO pins as output.
Step 3: Initialize GLCD.
Step 4: Clear the GLCD.
Step 5: Set the back color.
Step 6: Set the text color.
Step 7: Display the string on the GLCD.
Step 8: Set the back color.
Step 9: Set the text color.
Step 10: Display the string on the GLCD.
Step 11: Loop for high amplitude.
Step 12: Delay routine.
Step 13: Loop for high amplitude.
Step 14: Delay routine.
Step 15: Stop.

FLOW CHART:
PROGRAM:
#include <LPC29xx.H>
#include "GLCD.h"
void delay(void) /* Delay Routine */
{
unsigned char i;
for(i=0;i<100;i++);
}
main()
{
unsignedinti,j;
GPIO3_DR |= 0x0000FFFF; /* Configure GPIO pins as Outputs */

GLCD_Init (); /* GLCD initialization */


GLCD_Clear(White); /* Clear the GLCD */
GLCD_SetBackColor(Blue); /* Set the Back Color */
GLCD_SetTextColor(White); /* Set the Text Color */

GLCD_DisplayString(0, 0, 1," GVPCOE ");


GLCD_DisplayString(1, 0, 1," ECE ");
GLCD_DisplayString(2, 0, 1," EMBEDDED SYSTEMS LAB ");

GLCD_SetBackColor(White); /* Set the Back Color */


GLCD_SetTextColor(Blue); /* Set the Text Color */
GLCD_DisplayString(4, 0,1," DUAL DAC DEMO " );
/* Display Triangular Wave on LCD */
GLCD_DisplayString(6, 0,1," TRIANGULAR WAVE" );
while(1)
{
for(i=0; i<0x0FF; i++)
{
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00)| i;
GPIO3_OR = (GPIO3_OR & 0xFFFF00FF) | (i<< 8);
delay();
}
for(j=0x0FF; j>0; j--)
{
GPIO3_OR = (GPIO3_OR & 0xFFFF00FF) | (j << 8);
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00) | j;
delay();
}
}
}
RESULT: Hence, Control Digital to Analog Convertor (DAC) using LPC2929 board is performed and

performed and observed.

You might also like