KEMBAR78
r23 MPMC Lab Manual Final | PDF | Assembly Language | Microcontroller
0% found this document useful (0 votes)
135 views91 pages

r23 MPMC Lab Manual Final

The document is a lab record for a Microprocessors and Microcontrollers course in the Electronics and Communication Engineering department. It outlines the vision and mission of the department, program educational objectives, and specific outcomes for students. Additionally, it includes a detailed index of experiments related to 8086 microprocessor, 8051 microcontroller, and Embedded C programming, along with sample assembly language programs for various arithmetic operations.

Uploaded by

mithul7095
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)
135 views91 pages

r23 MPMC Lab Manual Final

The document is a lab record for a Microprocessors and Microcontrollers course in the Electronics and Communication Engineering department. It outlines the vision and mission of the department, program educational objectives, and specific outcomes for students. Additionally, it includes a detailed index of experiments related to 8086 microprocessor, 8051 microcontroller, and Embedded C programming, along with sample assembly language programs for various arithmetic operations.

Uploaded by

mithul7095
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/ 91

MICROPROCESSORS

&
MICROCONTROLLERS
LAB RECORD

NAME

Roll No.

Class
&Bran
ch

DEPARTMENTOF
ELECTRONICSANDCOMMUNCIATIONENGINEERING
MICROPROCESSORS & MICROCONTROLLERS
LAB RECORD

Preparedby

YEAR/SEMESTER IIIB. TechI - SEM

: ECE

BRANCH :

DEPARTMENTOF
ELECTRONICSANDCOMMUNCIATIONENGINEERING
DepartmentofElectronics andCommunicationEngineering

VisionoftheDepartment
 Toproducetechnicallycompetentandcreativeengineerswhocancatertotheindustryandsocie
talrequirementsinthefieldofElectronics&CommunicationEngineering.

MissionoftheDepartment
M1: To impart quality engineering education to students to enhance ability to
pursueknowledgebyprovidingcore competencyand state ofthe artinfrastructure.

M2: To provide industry oriented learning for empowering and facilitating the
learnerthroughindustryinstituteinteractionandleadershipqualities.
M3: Topromote participation in research andextension activitiesfor addressing
thesocialneedsby providingvaluebasededucationalongwithlife-longlearningabilities.
ProgrammeEducationalObjectives(PEOs)
PEO_1: Attainprofessionalexcellenceorgainhigherdegreetofacechallengesposedby
industryandsociety.
PEO_2:Addresscomplexproblemsinaresponsive andinnovativemanner.
PEO_3: Gainreputationbyfunctioningeffectivelytoaddresssocialandethical
responsibilities.
ProgramOutcomes(POs)

EngineeringGraduateswillbeableto:
1. Engineering knowledge: Apply the knowledge of mathematics, science,
engineeringfundamentals, and an engineering specialization to the solution of complex
engineeringproblems.
2. Problemanalysis:Identify,formulate,reviewresearchliterature,andanalyzecomplex
engineering problems reaching substantiated conclusions using first principlesof
mathematics,naturalsciences,andengineeringsciences.
3. Design/development of solutions: Design solutions for complex engineering
problemsanddesignsystemcomponentsorprocessesthatmeetthespecifiedneedswithappr
opriate consideration for the public health and safety, and the cultural, societal,
andenvironmental considerations.
4. Conduct investigations of complex problems:Use research-based knowledge
andresearch methodsincluding design of experiments, analysis andinterpretation of
data,andsynthesisoftheinformationtoprovidevalidconclusions.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources,
andmodernengineeringandITtoolsincludingpredictionandmodelingtocomplexengineerin
gactivitieswithanunderstandingofthelimitations.
DepartmentofElectronics andCommunicationEngineering
DepartmentofElectronics andCommunicationEngineering

6. The engineer and society: Apply reasoning informed by the contextual knowledge
toassess societal, health, safety, legal and cultural issues and the consequent
responsibilitiesrelevanttotheprofessionalengineeringpractice.
7. Environmentandsustainability:Understandtheimpactoftheprofessionalengineeringsol
utionsinsocietalandenvironmentalcontexts,anddemonstratetheknowledge
of,andneedforsustainabledevelopment.
8. Ethics: Apply ethical principles and commit to professional ethics and
responsibilitiesand normsoftheengineeringpractice.
9. Individual and team work:Function effectively as an individual, and as
amemberorleaderindiverseteams,andinmultidisciplinarysettings.
10. Communication:Communicate effectively on complex engineering activities
withthe engineering community and with society at large, such as, being able to
comprehendand write effective reports and design documentation, make effective
presentations, andgiveandreceiveclearinstructions.
11. Projectmanagementand finance: Demonstrate knowledge andunderstanding ofthe
engineering and management principles and apply these to one’s own work, as
amemberandleaderinateam,tomanageprojectsandinmultidisciplinaryenvironments.
12. Life-long learning: Recognize the need for, and have the preparation and ability
toengage in independent and life-long learning in the broadest context of
technologicalchange.
ProgramSpecificOutcomes(PSOs)
AgraduateoftheElectronics&CommunicationEngineeringProgramwillbeableto:

13. Domain Specific Knowledge: Implement electronic systems related to


ElectronicsDevices&Circuits,VLSI,Signalprocessing,Microcomputers,EmbeddedandComm
unicationSystemstofulfillthe solutionstorealworldchallenges.

14. Hardware Product Development: Apply the software and hardware tools in
Analogand Digital Electronic circuit design to address complex Electronics and
Communicationengineeringproblems.
DepartmentofElectronics andCommunicationEngineering
DepartmentofElectronicsandCommunicationEngineering

INDEX

PART-A: 8086 Microprocessor & Interfacing Programs

PageN Signature
S.No Date NameoftheExperiment Marks
o. with Date

PART-B: 8051 Microcontroller & Interfacing Programs

PART-C: Embedded C Experiments using MSP430 Micro-controller

10

AdditionalExperiment

11

Faculty Signature
LISTOFEXPERIMENTS

PART A
8086 Microprocessor & Interfacing Programs

1) ARITHMETIC OPERATIONS USING VARIOUS ADDRESSING MODES


2) BIT MANIPULATION INSTRUCTIONS
3) ARRAY OPERATIONS
4) STRING MANIPULATIONS
5) DIGITAL CLOCK DESIGN USING 8086
6) STEPPER MOTOR WITH 8086

PART-B
PART-B: 8051 Microcontroller & Interfacing Programs
7) ARITHMETIC AND LOGICAL INSTRUCTIONS FOR 8051
8) TO VERIFY TIMERS/COUNTERS OF 8051

PART-C
Embedded C Experiments using MSP430 Micro-controller
9) INTRODUCTION TO MSP430 LAUNCH PAD AND PROGRAMMING
ENVIRONMENT. (Study Experiment)

10) INTERFACING AND PROGRAMMING GPIO PORTS

ADDITONAL EXPERIMENT

11) READ INPUT FROM SWITCH & GLOW LED


PARTA:
8086 Microprocessor & Interfacing
Programs
DEPT OF ECE MPMC LAB

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

EXPLANATION:

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

EXPLANATION:

NEC,GUDUR 14
DEPT OF ECE MPMC LAB

PART-A
EXP NO DATE
ARITHMETIC OPERATIONS
1
AIM: To write and execute Assembly language programs to perform simple
arithmetic operations using different addressing modes.
PROGRAMS:
(A) ADDITION OF TWO 16 - BIT NUMBERS
Address Opcode Label Mnemonic Operand Comment
Field Field Field Field Field Field
MOV SI,2000H Load SI with offset address
2000H
MOV AX,[SI] Load AX register with data
available at memory location SI
INC SI Increment SI content
INC SI Increment SI content
MOV BX,[SI] Load BX register with data
available at memory location SI
ADD AX,BX Add content of AX with BX,
result in AX register
INC SI Increment SI content
INC SI Increment SI content
MOV [SI],AX Copy the resultant data from AX
to SI location.
INT 03 Terminates the program execution

(B) SUBTRACTION OF TWO 16 - BIT NUMBERS


Address Opcode Label Mnemonic Operand Comment
Field Field Field Field Field Field
MOV BX,2000H Load BX with offset address
2000H
MOV AX,[BX] Load AX register with data
available at memory location BX
INC BX Increment BX content
INC BX Increment BX content
MOV DX,[BX] Load DX register with data
available at memory location BX
SUB AX,DX Add content of AX with DX,
result in AX register
INC BX Increment BX content
INC BX Increment BX content
MOV [BX],AX Copy the resultant data from AX
to BX location.
INT 03 Terminates the program execution

NEC,GUDUR 15
DEPT OF ECE MPMC LAB

INPUT OUTPUT
REGISTER DATA REGISTER DATA

EXPLANATION:

INPUT OUTPUT
REGISTER DATA ADDRESS DATA

EXPLANATION:

NEC,GUDUR 16
DEPT OF ECE MPMC LAB

(C) 16 - BIT UNSIGNED MULTIPLICATION

Address Opcode Label Mnemonic Operand Comment


Field Field Field Field Field Field
Load AX with data C123H
MOV AX,C123
Load BX with data 786AH
MOV BX,786A
Multiply the contents of AX &BX
registers and Store result in AX &
MUL BX
DX Registers
Store the lower word in 2000 i.e. the
MOV [2000],AX
content of AX
MOV [2002],DX Store the higher word in 2002 i.e.
the content of DX
Terminates the program execution
INT 03

(D) DIVISION OF 32 - BIT BY 16 - BIT NUMBERS

Address Opcode Label Mnemonic Operand Comment


Field Field Field Field Field Field
Load AX with data AB68H
MOV AX,AB68
Load DX with data 1234H
MOV DX,1234
Load BX with data 28C5H
MOV BX,28C5
Divide the contents of AX with
DIV BX
BX
Store the quotient in 2000
MOV [2000],AX
i.e. the content of AX
Store the remainder in 2002 i.e.
MOV [2002],DX
the content of DX
Terminates the program
INT 03
execution

NEC,GUDUR 17
DEPT OF ECE MPMC LAB

INPUT OUTPUT
ADDRESS DATA REGISTER DATA

EXPLANATION:

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

EXPLANATION:

NEC,GUDUR 18
DEPT OF ECE MPMC LAB

(E) SIGNED 8-BIT MULTIPLICATION

Address Opcode Label Mnemonic Operand Comment


Field Field Field Field Field Field
Load AL with data stored in
MOV AL,[2000]
the location 2000
Load BL with data stored in
MOV BL,[2001]
the location 2001
Perform signed multiplication
IMUL BL
Storetheresultin3000
MOV [3000],AX
i.e.thecontentofAX
Terminates the program
INT 03
execution

(F) SIGNED 8-BIT DIVISION

Address Opcode Label Mnemonic Operand Comment


Field Field Field Field Field Field
Load AX with data stored
MOV AX,[2000]
in the location 2000
Load BL with data stored
MOV BL,[2002]
in the location 2002
IDIV BL Performunsigneddivision
Store the result of AX in
MOV [3000],AX
the location 3000
Terminates the program
INT 03
execution

NEC,GUDUR 19
DEPT OF ECE MPMC LAB

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

EXPLANATION:

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

EXPLANATION:

NEC,GUDUR 20
DEPT OF ECE MPMC LAB

(G) ADD TWO ARRAY OF BYTES


Address Opcode Label Mnemonic Operand Comment
Field Field Field Field Field Field
CLC Clearcarryflag
MOV SI,2000H LoadtheSIwith2000address
MOV DI,3000H LoadtheDIwith3000address
MOV CL,[1050H] LoadcountCLwithdatastoredin
thelocation1500
LoadALregisterwithdata
L1: MOV AL,[SI]
availableatmemorylocationSI
Add content of AL withdata
ADC AL,[DI] availableinDIthenaddwith
carry,resultinALregister
CopytheresultantdatafromALto
MOV [SI],AL
SIlocation.
INC SI IncrementSIlocation
INC DI IncrementDIlocation
DEC CL DecrementcountCL
JNZ L1 Jumpifnotequaltozero
INT 03 Terminates the program execution

(H) SUBTRACT TWO ARRAY OF BYTES


Address Opcode Label Mnemonic Operand Comment
Field Field Field Field Field Field
CLC Clearcarryflag
MOV SI,2000H LoadtheSIwith2000address
MOV DI,3000H LoadtheDIwith3000address
MOV CL,[1050H] LoadcountCLwithdatastoredin
thelocation1500
LoadALregisterwithdata
L1: MOV AL,[SI]
availableatmemorylocationSI
Subtract content of AL with
SBB AL,[DI] borrow thendata available in DI,
resultinALregister
MOV [SI],AL CopytheresultantdatafromALto
SIlocation.
INC SI IncrementSIlocation
INC DI IncrementDIlocation
DEC CL DecrementcountCL
JNZ L1 Jumpifnotequaltozero
INT 03 Terminates the program execution

NEC,GUDUR 21
DEPT OF ECE MPMC LAB

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

EXPLANATION:

INPUT OUTPUT
ADDRESS DATA REGISTER DATA

EXPLANATION:

NEC,GUDUR 22
DEPT OF ECE MPMC LAB

(I) SQUARE OF A GIVEN NUMBER


Address Opcode Label Mnemonic Operand Comment
Field Field Field Field Field Field
Load the SI with offset
MOV SI,2000
address 2000.
LoadALregisterwith
MOV AL,[SI] data available at memory
location SI
Multiplythecontentsof
MUL AL AL &AL registers and Store
result in AX register
INC SI IncrementSIlocation
Store the result of AX in
MOV [SI],AX
thememory location SI
Terminate the program
INT 03
execution

(J) CUBE OF A GIVEN NUMBER


Address Opcode Label Mnemonic Operand Comment
Field Field Field Field Field Field
Load AL with data stored in
MOV AL,[2000]
the location 2000
Move data from AL register to
MOV BL,AL
BL register
MOV BH,00 LoadBHwithdata00H
Multiply the contents of AL
&AL registers and Store
MUL AL
result in AX register
Multiply the contents of AX
&BX registers and Store result
MUL BX
in AX & DX registers
Terminate the program
INT 03
execution

NEC,GUDUR 23
DEPT OF ECE MPMC LAB

INPUT OUTPUT
ADDRESS DATA REGISTER DATA

EXPLANATION:

NEC,GUDUR 24
DEPT OF ECE MPMC LAB

(K) FACTORIAL OF A GIVEN NUMBER


Address Opcode Label Mnemonic Operand Comment
Field Field Field Field Field Field
Load AX with data stored
MOV AX,[2000]
in the location 2000
Move data from AX
MOV BX,AX
register to BX register
Compare content of AX
CMP AX,0001
with 0001h
JZ L1 Jumpifequaltozero

CALL L2 Callsubprogram
Store the result of AX in
L1 MOV [2000],AX
the location 2000
Terminate the program
INT 03
execution
L2 DEC BX DecrementBX

JZ L3 Jumpifequaltozero
Multiply the contents of
MUL BX
AX &BX registers
CALL L2 Callsubprogram

L3 RET Returntomainprogram

INPUT OUTPUT
ADDRESS DATA REGISTER DATA

EXPLANATION:

NEC,GUDUR 25
DEPT OF ECE MPMC LAB

INPUT OUTPUT
ADDRESS DATA REGISTER DATA

EXPLANATION:

RESULT:

NEC,GUDUR 26
DEPT OF ECE MPMC LAB

VIVA QUESTION:

1. Define bit, nibble , byte and word and how byte,word represented in lower and
higher ranges?.

2. What is a Microprocessor.

3. How the parts 8086 internal architecture is divided? What are the functions of each
part of 8086?

4. What are general purpose registers in 8086 and What are the functions of General
purpose Registers?

5. What is pipelining and non pipelining?

NEC,GUDUR 27
DEPT OF ECE MPMC LAB

VIVA QUESTION:

6. What are the different addressing modes used in Assembly language? Give
examples.

7. How does immediate addressing mode differ from direct and indirect
addressing modes?

8. Can you explain how arithmetic operations like addition or subtraction are
performed in Assembly?

9. Why is register addressing mode considered faster than memory-based


addressing modes?

10. What is the role of the accumulator in arithmetic operations in Assembly


language?

NEC,GUDUR 28
DEPT OF ECE MPMC LAB

EXP NO DATE
BIT MANIPULATION INSTRUCTIONS
2

AIM: TowriteandexecuteAssemblylanguageprogramstoperformBitManipulation
instructions.

PROGRAM:

(A) POSITIVE OR NEGATIVE NUMBER

Address Opcode Label Mnemonic Operand Comment


Field Field Field Field Field Field
Load AL with data stored
MOV AL,[2000]
in the location 2000
Perform Shift Left
SHL AL,1
operation
JC L1 Jumpifcarrygenerates

MOV DL,00 LoadDLwithdata00H


Jump to location L2
JMP L2
without any condition
L1 MOV DL,01 LoadDLwithdata01H
Terminate the program
L2 INT 03
execution

NOTE:DL=00RepresentsPositiveNumberandDL=01RepresentsNegativeNumber

(B) ODD OR EVEN NUMBER

Address Opcode Label Mnemonic Operand Comment


Field Field Field Field Field Field
Load AL with data stored
MOV AL,[2000]
in the location 2000
MOV AH,00 LoadDHwithdata00H

MOV BL,02 LoadBLwithdata02H


Divide the contents of
DIV BL
AL with BL
Terminate the program
INT 03
execution

NOTE :AH=01RepresentsOddNumberandAH=00RepresentsEvenNumber

NEC,GUDUR 29
DEPT OF ECE MPMC LAB

INPUT OUTPUT
ADDRESS DATA REGISTER DATA

EXPLANATION:

NEC,GUDUR 30
DEPT OF ECE MPMC LAB

(C) NUMBER OF LOGICAL 1’S AND 0’S

Address Opcode Label Mnemonic Operand Comment


Field Field Field Field Field Field
Load AL with data stored
MOV AL,[2000]
in the location 2000
Load count CL with data
MOV CL,08
08h
Load DX withdata 0000H
MOV DX,0000
Perform Shift Left
L3 SHL AL,1
operation
JC L1 Jumpifcarrygenerates

INC DL IncrementDLlocation
Jump to location L2
JMP L2
without any condition
L1 INC DH IncrementDHlocation
Decrement CL. Go to
L2 LOOP L3
address(L3)IfCL≠0
Terminate the program
INT 03
execution

NOTE:DHRepresentsNumberofLogical1’sandDLRepresentsNumberof
Logical0’s

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

EXPLANATION:

RESULT:
NEC,GUDUR 31
DEPT OF ECE MPMC LAB

VIVA QUESTION:

Viva Questions

1. What are bit manipulation instructions? Explain with examples.

2. Differentiate between logical shift and arithmetic shift operations.

3. What is the difference between rotate and shift instructions?

4. How do RLC and RRC instructions work in 8051?

5. What is the use of the CPL instruction in 8051 or 8086?

NEC,GUDUR 32
DEPT OF ECE MPMC LAB

6. Which flags are affected during bit manipulation operations?

7. How do you set or clear a particular bit in a register?

8. What is the effect of the ANL and ORL instructions on bit-level data?

9. Write an assembly instruction to check if a bit is set or not.

10. Why are bit manipulation instructions important in embedded systems?

NEC,GUDUR 33
DEPT OF ECE MPMC LAB

EXP NO DATE
ARRAY OPERATIONS
3

AIM: TowriteandexecuteAssemblylanguageprogramstoperformArrayoperations
for8086.

PROGRAMS:

(A) ADDITION OF N-16 BIT NUMBERS

Address Opcode Label Mnemonic Operand Comment Field


Field Field Field Field Field
MOV SI,2000H LoadtheSIwith2000 offset
address
MOV CL,[SI] Load count CL with content of
2000 address.
INC SI IncrementSI content

MOV AX,[SI] Load AX register with data


availableatmemorylocationSI
DEC CL Decrement CL value

UP: INC SI IncrementSI content

INC SI IncrementSI content

MOV BX,[SI] Load BX register with data


availableatmemorylocationSI
ADD AX,BX AddcontentofAXwithBX,
result in AX register
DEC CL Decrement CL value

JNZ UP Jumpifnotequaltozero

INC SI IncrementSI content

INC SI IncrementSI content

MOV [SI],AX CopytheresultantdatafromAXto


SIlocation
INT 03 Terminate the program
Execution

NEC,GUDUR 34
DEPT OF ECE MPMC LAB

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

EXPLANATION:

NEC,GUDUR 35
DEPT OF ECE MPMC LAB

(B) SUBTRACTION OF N-16 BIT NUMBERS

Address Opcode Label Mnemonic Operand Comment Field


Field Field Field Field Field
MOV SI,2000H LoadtheSIwith2000 offset
address
MOV CL,[SI] Load count CL with content of
2000 address.
INC SI IncrementSI content

MOV AX,[SI] Load AX register with data


availableatmemorylocation
SI
DEC CL Decrement CL value

UP: INC SI IncrementSI content

INC SI IncrementSI content

MOV BX,[SI] Load BX register with data


availableatmemorylocation
SI
SUB AX,BX Subtract contentofAXwith
BX,result in AX register
DEC CL Decrement CL value

JNZ UP Jumpifnotequaltozero

INC SI IncrementSI content

INC SI IncrementSI content

MOV [SI],AX Copytheresultantdatafrom


AXto SIlocation
INT 03 Terminate the program
execution

NEC,GUDUR 36
DEPT OF ECE MPMC LAB

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

EXPLANATION:

NEC,GUDUR 37
DEPT OF ECE MPMC LAB

(C) LARGEST NUMBER


Address Opcode Label Mnemonic Operand Comment Field
Field Field Field Field Field
Load the SI with 2000
MOV SI,2000
offset address
Load count CL with
MOV CL,[1500] data stored in the
location1500
Load AL register with
MOV AL,[SI] data available at
memorylocationSI
DEC CL DecrementcountCL

L2 INC SI IncrementSIcontent
Compare content of AL
CMP AL,[SI] withdata available at
memorylocationSI
JNC L1 Jumpifnocarry
Load AL register with
MOV AL,[SI] data available at
memorylocationSI
L1 DEC CL Decrementcount
Jump if notequal to
JNZ L2
zero
Store the result of AL
MOV [3000],AL
in the location 3000
Terminate the program
INT 03
execution

NEC,GUDUR 38
DEPT OF ECE MPMC LAB

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

EXPLANATION:

NEC,GUDUR 39
DEPT OF ECE MPMC LAB

(D) SMALLEST NUMBER


Address Opcode Label Mnemonic Operand Comment Field
Field Field Field Field Field
Load the SI with 2000 offset
MOV SI,2000
address
Load count CL with data
MOV CL,[1500] stored in the memory 1500
Load AL register with data
MOV AL,[SI] available at
memorylocationSI
DEC CL Decrementcount

L2 INC SI IncrementSI
ComparecontentofAL
CMP AL,[SI] withdata available at
memory location SI
JC L1 Jumpifcarrygenerates
Load AL register with data
MOV AL,[SI] available at
memorylocationSI
L1 DEC CL Decrementcount
Jump if notequal to zero
JNZ L2
Store the result of AL in
MOV [3000],AL
the location 3000
Terminate the program
INT 03
execution

NEC,GUDUR 40
DEPT OF ECE MPMC LAB

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

EXPLANATION:

NEC,GUDUR 41
DEPT OF ECE MPMC LAB

(E) ASCENDING ORDER OF N 8-BIT NUMBERS

Address Opcode Label Mnemonic Operand Comment Field


Field Field Field Field Field
MOV SI,2000H Load the SI with 2000 offset
address
MOV BL,[SI] Load the content of SI to BL
Register
DEC BL Decrement BL register by one

UP: MOV CL,BL Load the value of BL to CL

INC SI IncrementSIcontent

UP1: MOV AL,[SI] Load AL register with data


available at memorylocationSI
INC SI IncrementSIcontent

CMP AL,[SI] ComparecontentofAL


withdata available at memory
location SI
JB DOWN Jump if below to specified label if
CF=1 and ZF=0
XCHG AL,[SI] Exchange the contents AL to
content of SI and vice versa
DEC SI Decrement SI

MOV [SI],AL Loads the content of SI with AL

INC SI IncrementSIcontent

DOWN: LOOP UP1 Loop to specified label

MOV SI,2000H Load SI register with offset


address 2000
DEC BL Decrement BL register

JNZ UP Check the count value zero. if not,


control transfers to specified label
INT 03 Terminate the program execution

NEC,GUDUR 42
DEPT OF ECE MPMC LAB

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

EXPLANATION:

NEC,GUDUR 43
DEPT OF ECE MPMC LAB

(F) DESCENDING ORDER OF N 8-BIT NUMBERS


Address Opcode Label Mnemonic Operand Comment Field
Field Field Field Field Field
MOV SI,2000H Load the SI with 2000 offset
Address
MOV BL,[SI] Load the content of SI to BL
Register
DEC BL Decrement BL register by one

UP1: MOV CL,BL Load the value of BL to CL

INC SI IncrementSIcontent

UP: MOV AL,[SI] Load AL register with data


available at memorylocationSI
INC SI IncrementSIcontent

CMP AL,[SI] ComparecontentofAL


withdata available at memory
location SI
JA DOWN Jump if above to specified label if
CF=0 and ZF=0
XCHG AL,[SI] Exchange the contents AL to
content of SI and vice versa
DEC SI Decrement SI

MOV [SI],AL Loads the content of SI with AL

INC SI IncrementSIcontent

DOWN: LOOP UP Loop to specified label

MOV SI,2000H Load SI register with offset


address 2000
DEC BL Decrement BL register

JNZ UP1 Check the count value zero. if not,


control transfers to specified label
INT 03 Terminate the program execution

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

EXPLANATION:

NEC,GUDUR 44
DEPT OF ECE MPMC LAB

RESULT:

VIVA QUESTION:

1. List any five control transfer instructions in 8086 microprocessor?

2. Write addressing modes of 8086 microprocessor?

3. What is Interrupt and what are the different types of interrupts?

4. How many pins are available in 8086 IC and what is the use of MN/¯MX?

5. What is the operation of M/--IO with read and write pins?

NEC,GUDUR 45
DEPT OF ECE MPMC LAB

6. How are arrays stored in memory in 8086 architecture?

7. How do you access individual elements of an array using assembly language?

8. Which registers are commonly used for array operations in 8086?

9. How do you implement a loop to process all elements of an array in 8086?

10. Write a simple logic to find the largest element in an array using 8086 instructions.

NEC,GUDUR 46
DEPT OF ECE MPMC LAB

EXP NO DATE
STRINGMANIPULATIONS
4

AIM: To write and execute Assembly language programs to perform string


manipulation instructions.

PROGRAMS:

(A) MOVE A BLOCK OF DATA

Address Opcode Label Mnemonic Operand Comment Field


Field Field Field Field Field
MOV SI,2000H Loads offset address 2000 to SI.

MOV DI,3000H Loads offset address 3000 to DI.

MOV CX,0005H Load CX register with count


value 0005.
CLD Clears direction flag DF=0.

REP Move string byte from


Source [SI] to Destination [DI]
MOVSB until count becomes zero
INT 03 Terminates the program
Execution

NEC,GUDUR 47
DEPT OF ECE MPMC LAB

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

EXPLANATION:

NEC,GUDUR 48
DEPT OF ECE MPMC LAB

(B) REVERSEASTRING

Address Opcode Label Mnemonic Operand Comment Field


Field Field Field Field Field
MOV SI,2000H Loads offset address 2000 to SI.

MOV DI,2004H Loads offset address 2004 to DI.

L1: MOV AL,[SI] Load the content of SI to AL

XCHG AL,[DI] Exchange the content of DI to AL


and vice versa
MOV [SI],AL Load AL to the content of SI

INC SI Increment SI

DEC DI Decrement DI

CMP SI,DI Compares string byte.

JB L1 Jump to the specified label

INT 03H Terminates the program execution

NEC,GUDUR 49
DEPT OF ECE MPMC LAB

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

EXPLANATION:

NEC,GUDUR 50
DEPT OF ECE MPMC LAB

(C) LENGTHOFTHESTRING
Address Opcode Label Mnemonic Operand Comment Field
Field Field Field Field Field
MOV SI,2000H Loads offset address 2000 to SI

MOV AL,00H Stores last byte of a string into


AL
MOV CL,00H Clears the CL register;

ABOVE: CMP AL,[SI] Compare string byte with AL;

JA L1 Jumps to specified label

JE L2 Jumps to specified label if


equal
L1: INC CL Increment CL
INC SI Increment SI

JMP ABOVE Jumps unconditionally to


specified label
L2: INC SI Increment SI
MOV [SI],CL Load the CL to content of SI
INT 03 Terminates the program

NOTE:Lastvalueshouldbetakenas00h

NEC,GUDUR 51
DEPT OF ECE MPMC LAB

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

EXPLANATION:

NEC,GUDUR 52
DEPT OF ECE MPMC LAB

(D) COMPARETHESTRING

Address Opcode Label Mnemonic Operand Comment Field


Field Field Field Field Field
MOV SI,2000H Loads offset address 2000 to SI.

MOV DI,3000H Loads offset address 3000 to DI.

MOV CX,0004H Loads CX register with count


value 0004.
CLD Clears Direction Flag..

REPE Repeat until Equal


CMPSB Compares string byte.

MOV [4000],CX Load the count value to content


of specified address 4000.
INT 03 Terminates the program

RESULT:

NEC,GUDUR 53
DEPT OF ECE MPMC LAB

VIVA QUESTIONS:

1. What is a string?

2. What are different operations performed on string?

3. What is string comparison?

4. How to perform reverse of a string?

5. How to move a block of string byte from one memory location to another?

NEC,GUDUR 54
DEPT OF ECE MPMC LAB

6. What are string manipulation instructions in 8086?

7. What is the function of the Direction Flag (DF) during string operations?

8. Which registers are used for source and destination in string instructions?

9. What is the purpose of the REP prefix in string manipulation?

10. How do MOVSB and MOVSW differ in operation

NEC,GUDUR 55
DEPT OF ECE MPMC LAB

EXP NO DATE
DIGITALCLOCK DESIGN
5

AIM: To write and execute Assembly language programs to perform Digital Clock
Design using 8086.

THEORYANDPROGRAMS:

Date/TimeFunctions
_2Ah-Getsystemdate
_2Bh-Setsystemdate
_2Ch-Getsystemtime
_2Dh-Setsystemtime

1. INT 21h Function 2Ah: Get system date


_ReturnsyearinCX,monthinDH,dayinDL,anddayofweekinAL

movah, 2Ah
Int 21h
mov year, cx
mov month, dh
mov day, dl
movdayOfWeek, al

2. INT 21h Function 2Bh: Set system date


_Sets the system date. AL = 0 if the function was not successful in modifying the
date.
mov ah,2Bh
mov cx,year
mov dh,month
mov dl,day
int 21h
cmp al,0
jnefailed

3. INT 21h Function 2Ch: Get system time


_ Returns hours (0-23) in CH, minutes (0-59) in CL, and seconds (0-59) in DH,
and hundredths (0-99)inDL.

movah,2Ch
int 21h
mov hours,ch
mov minutes,cl
movseconds,dh

NEC,GUDUR 56
DEPT OF ECE MPMC LAB

4. INT 21h Function 2Dh: Set system time


_Setsthesystemdate.AL=0ifthefunctionwasnotsuccessfulinmodifying
thetime.
movah,2Dh
mov ch,hours
mov cl,minutes
mov dh,seconds
int 21h
cmp al,0
jnefailed

RESULT:

VIVA QUESTIONS:

1.How is the clock signal generated in the 8086?


2.What is the maximum internal clock frequency of the 8086?
3.What is the clock frequency of the 8086, and how is it generated
4.How would you implement a digital clock using the 8086?
5.How would you handle time updates (seconds, minutes, hours) in the clock?
6. How can you access system time using 8086 assembly language?
7. What is the role of INT 21H in digital clock design?
8. How do you convert binary values to ASCII for display in a digital clock?
9. Which registers are commonly used to store hours, minutes, and seconds?
10. How is delay implemented in 8086 to simulate real-time clock behavior?

NEC,GUDUR 57
DEPT OF ECE MPMC LAB

STEPPERMOTORCIRCUITDIAGRAM:

NEC,GUDUR 58
DEPT OF ECE MPMC LAB

EXP NO STEPPERMOTORINTERFACING DATE

AIM: WriteanAssemblyLanguageProgramtointerfaceMicroprocessorwith
StepperMotor.

APPARATUS:

1) 8086Microprocessor-1
2) StepperMotorKit-1
3) RPS(+5V)-1
4) FRCCables.

PROCEDURE:

1. Connect Stepper Motor interfacing module to 8255-III of 8086 microprocessor


trainer through 26 pin FRC cable.
2. Enter the program from Specific Segment location of 8086 trainer / Specific offset
for 8086 trainer and make sure that the program is entered properly before
execution.
3. Executeyourprogramfromrespectivelocation&observetheStepperMotoroutput.

NEC,GUDUR 59
DEPT OF ECE MPMC LAB

STEPPERMOTOROUTPUTDATA:

NEC,GUDUR 60
DEPT OF ECE MPMC LAB

STEPPERMOTORPROGRAM:

NEC,GUDUR 61
DEPT OF ECE MPMC LAB

INPUT OUTPUT
REGISTER DATA REGISTER DATA

EXPLANATION:

INPUT OUTPUT
REGISTER DATA REGISTER DATA

EXPLANATION:

EXPLANATION:

RESULT:
NEC,GUDUR 62
DEPT OF ECE MPMC LAB

VIVA QUESTIONS:
1.What is a stepper motor?
2.How does a stepper motor work?
3.What is a step angle?
4.What is the difference between a stepper motor and a DC motor?
5.What is the stator and rotor in a stepper motor?
6, How does a stepper motor work and what makes it different from a DC motor?
7.What is the role of a driver circuit in interfacing a stepper motor with a
microprocessor?
8 How do you control the direction and step angle of a stepper motor in assembly
language?
9 What are the common step sequences used for rotating a stepper motor?
10 Which 8086 ports and instructions are used to send control signals to the stepper
motor?

NEC,GUDUR 63
DEPT OF ECE MPMC LAB

PARTB:
8051 Microcontroller & Interfacing
programs

NEC,GUDUR 64
DEPT OF ECE MPMC LAB

PART-B
EXP NO DATE
ARITHMETIC & LOGICAL OPERATIONS
7
AIM:TowriteandexecutetheALPto perform arithmetic & logical operations
oftwonumbersusing8051Microcontroller

PROGRAM:

(A) ADDITION OF TWO 8-BIT NUMBERS

Address Opcode Label Mnemonics Operand Comment


Field Field Field Field Field Field
121800 LCALL 1800H LCTInitialization
Call 'Result' on LCD Display
121886 LCALL 1886H
Put hexvalue in accumulator
7491 MAIN MOV A,#91h*
Add 2nd hex value in to
2459 ADD A,#59h*
accumulator
Call Hex to ASCII convert
1218B8 LCALL 18B8H
cmd
80FE HERE SJMP HERE Infiniteloop

(B) SUBTRACTION OF TWO 8-BIT NUMBERS

Address Opcode Label Mnemonics Operand Comment


Field Field Field Field Field Field
12 18 00 LCALL 1800H LCT Initialization
Call 'Result' on LCD
12 18 86 LCALL 1886H
Display
Move hex value into
74 91 MAIN MOV A,#91h*
Accumulator
Sub 2 nd hex value in to
94 59 SUBB A,#59h*
Accumulator
Call Hex to ASCII convert
12 18 B8 LCALL 18B8H
cmd
80 FE HERE SJMP HERE Infinite loop

NEC,GUDUR 65
DEPT OF ECE MPMC LAB

INPUT OUTPUT
REGISTER DATA REGISTER DATA

EXPLANATION:

INPUT OUTPUT
REGISTER DATA REGISTER DATA

EXPLANATION:

NEC,GUDUR 66
DEPT OF ECE MPMC LAB

(C) MULTIPLICATION OF TWO 8-BIT NUMBERS

Address Opcode Label Mnemonics Operand Comment


Field Field Field Field Field Field
12 18 00 LCALL 1800H LCT Initialization

12 18 86 LCALL 1886H Call 'Result' on LCD Display

74 F5 MAIN MOV A,#0F5h* Enter 1st Value Here

75 F0 65 MOV B#065h* Enter 2nd Value Here

A4 MUL AB Multiplication Operation

F8 MOV R0,B Move B value into R0 reg.


Move B value into acc for
E5 F0 MOV A,B
Display
Call Hex to ASCII convert
12 18 B8 LCALL 18B8H
cmd
Move B value into acc for
E8 MOV A,B
Display
Call Hex to ASCII convert
12 18 B8 LCALL 18B8H
cmd
80 FE HERE SJMP HERE Infinite loop

(D) DIVISION OF TWO 8-BIT NUMBERS

Address Opcode Label Mnemonics Operand Comment


Field Field Field Field Field Field
12 18 00 LCALL 1800H LCT Initialization
12 18 86 LCALL 1886H Call 'Result' on LCD Display
Move hex value into
74 F5 MAIN MOV A,#0F5h*
Accumulator
Sub 2 nd hex value in to
75 F0 65 MOV B#065h*
Accumulator
84 DIV AB Division Operation
Call Hex to ASCII convert
12 18 B8 LCALL 18B8H
cmd
move B value into
E5 F0 MOV A,B
accumulator for display
Call Hex to ASCII convert
12 18 B8 LCALL 18B8H
cmd
80 FE HERE SJMP HERE Infinite loop

NEC,GUDUR 67
DEPT OF ECE MPMC LAB

EXPLANATION:

INPUT OUTPUT
REGISTER DATA REGISTER DATA

EXPLANATION:

INPUT OUTPUT
REGISTER DATA REGISTER DATA

NEC,GUDUR 68
DEPT OF ECE MPMC LAB

(E) AND OPERATION

Address Opcode Label Mnemonics Operand Comment


Field Field Field Field Field Field
12 18 00 LCALL 1800H LCT Initialization
Call 'Result' on LCD
12 18 86 LCALL 1886H
Display
74 DA MAIN MOV A,#0DAH* Enter 1st value
Enter 2nd value, OR
44 53 ORL A,#053H*
operation
Call Hex to ASCII
12 18 B8 LCALL 18B8H
convert cmd
80 FE HERE SJMP HERE Infinite loop

(F) OR OPERATION

Address Opcode Label Mnemonics Operand Comment


Field Field Field Field Field Field
12 18 00 LCALL 1800H LCT Initialization
Call 'Result' on LCD
12 18 86 LCALL 1886H
Display
74 DA MAIN MOV A,#0DAH* Enter 1st value
Enter 2nd value, AND
54 53 ANL A,#053H*
operation
Call Hex to ASCII convert
12 18 B8 LCALL 18B8H
cmd
80 FE HERE SJMP HERE Infinite loop

NEC,GUDUR 69
DEPT OF ECE MPMC LAB

EXPLANATION:

INPUT OUTPUT
REGISTER DATA REGISTER DATA

INPUT OUTPUT
REGISTER DATA REGISTER DATA

EXPLANATI

NEC,GUDUR 70
DEPT OF ECE MPMC LAB

(G) XOR OPERATION


Address Opcode Label Mnemonics Operand Comment
Field Field Field Field Field Field
12 18 00 LCALL 1800H LCT Initialization
Call 'Result' on LCD
12 18 86 LCALL 1886H
Display
74 DA MAIN MOV A,#0DAH* Enter 1st value
Enter 2nd value, XOR
64 52 XRL A,#052H*
operation
Call Hex to ASCII convert
12 18 B8 LCALL 18B8H
cmd
80 FE HERE SJMP HERE Infinite loop

(H) NOT OPERATION

Address Opcode Label Mnemonics Operand Comment


Field Field Field Field Field Field
12 18 00 LCALL 1800H LCT Initialization

12 18 86 LCALL 1886H Call 'Result' on LCD Display

74 52 MAIN MOV A,#052H* Enter Hex value

F4 CPL A compliment (NOT operation)


Call Hex to ASCII convert
12 18 B8 LCALL 18B8H
cmd
80 FE HERE SJMP HERE Infinite loop

NEC,GUDUR 71
DEPT OF ECE MPMC LAB

INPUT OUTPUT
REGISTER DATA REGISTER DATA

EXPLANATION:

INPUT OUTPUT
REGISTER DATA REGISTER DATA

EXPLANATION:

NEC,GUDUR 72
DEPT OF ECE MPMC LAB

(I) NAND OPERATION

Address Opcode Label Mnemonics Operand Comment


Field Field Field Field Field Field
12 18 00 LCALL 1800H LCT Initialization
Call 'Result' on LCD
12 18 86 LCALL 1886H
Display
74 DA MAIN MOV A,#0DAH* Enter Hex value
Enter 2nd value, AND
54 53 ANL A,#053H*
operation
compliment (NOT
F4 CPL A
operation)
Call Hex to ASCII convert
12 18 B8 LCALL 18B8H
cmd
80 FE HERE SJMP HERE Infinite loop

(J) NOR OPERATION

Address Opcode Label Mnemonics Operand Comment


Field Field Field Field Field Field
12 18 00 LCALL 1800H LCT Initialization
Call 'Result' on LCD
12 18 86 LCALL 1886H
Display
74 DA MAIN MOV A,#0DAH* Enter Hex value
Enter 2nd value, OR
44 52 ORL A,#052H*
operation
1’s compliment (NOT
F4 CPL A
operation)
Call Hex to ASCII convert
12 18 B8 LCALL 18B8H
cmd
80 FE HERE SJMP HERE Infinite loop

RESULT:

NEC,GUDUR 73
DEPT OF ECE MPMC LAB

VIVA QUESTIONS:

1. What is a Microcontroller?

2. Write differences between microprocessor and microcontroller?

3. Give some examples of microprocessors?

4. Give some examples of microcontrollers?

5. What are the features of 8051 microcontrollers?

NEC,GUDUR 74
DEPT OF ECE MPMC LAB

6. What are the basic arithmetic instructions available in the 8051 microcontroller?

7. Which registers are commonly used to store operands and results in arithmetic
operations?

8. How do logical operations like AND, OR, and XOR work in 8051?

9. What is the difference between ADD and ADDC instructions in 8051?

10. Which flags are affected after arithmetic and logical operations in the 8051?

NEC,GUDUR 75
DEPT OF ECE MPMC LAB

EXP NO DELAY GENERATION USING NESTED DATE


LOOP / TIMERS
8

AIM: Write an 8051 program for Delay generation using (a) Nested loop (b) Timers.
PROGRAMS
(A) NESTEDLOOP

NOTE: Verify output at Port 3 LEDs. [Based on R0 value delay generated


between (0000 0000)b& (1111 1111)b]

Address Opcode Label Mnemonic Operand Field


Field Field Field Field
90, FF, 13 START MOV DPTR, #FF13
74, FF MOV A, #FF
F0 MOVX @DPTR, A
12, 44, 00 LCALL 4400 (DOWN)
74, 00 MOV A, #00
F0 MOVX @DPTR, A
12, 44, 00 LCALL 4400 (DOWN)
80, EF SJMP 4200 ( START)

78, 03 DOWN MOV R0, #03 (or) 01 (or) 05…


79, FF UP1 MOV R1, #FF
7A, FF UP2 MOV R2, #FF
DA, FE HERE DJNZ R2, 4406 ( HERE)
D9, FA DJNZ R1, 4404 (UP2)
D8, F6 DJNZ R0, 4402 (UP1)
22 RET

NEC,GUDUR 76
DEPT OF ECE MPMC LAB

(B) TIMER

Address Opcode Label Mnemonics Operand Field


Field Field Field Field
D2, F0 SETB B5 (P 3.5)
75, 89, 10 MOV 89 (TMOD), #10
7E, 00 MOV R6, #00
75, 8B, 08 MOV 8B (TL1), #08
75, 8D, 01 MOV 8D (TH1), #01
D2, 8E SETB 8E (TCON.6)
30, 8F, FD BACK JNB 8F (TCON.7), 410F (BACK)
C2, 8F CLR 8F (TCON.7)
C2, 8E CLR 8E (TCON.6)
0E INC R6
8E, 90 MOV P1, R6
EE MOV A, R6
12, 45, 00 LCALL 4500 (DELAY)

90, FF, 13 DELAY MOV DPTR, #FF13


F0 MOVX @DPTR, A
22 RET

NEC,GUDUR 77
DEPT OF ECE MPMC LAB

NOTE: Verify output at Port 3 LEDs. [Changing output from (0000 0000)b
to (1111 1111)b (It act as a Timer)]

RESULT:

NEC,GUDUR 78
DEPT OF ECE MPMC LAB

VIVA QUESTIONS:
1.What is a delay routine?

2.Why are delay routines needed in microprocessors?

3.What are the two main methods for generating delays in 8086 assembly
language?

4.What is a nested loop?

5.How does a nested loop create a delay?

6.What is a timer?

7 What is the difference between software delay and hardware delay in 8051?

8 How do nested loops create time delays in 8051 assembly programs?

9 What are the different timer modes available in 8051?

10 How is the delay time calculated when using Timer 0 or Timer 1?

NEC,GUDUR 79
DEPT OF ECE MPMC LAB

PARTC:
Embedded C Experiments using
MSP430 Microcontroller

NEC,GUDUR 80
DEPT OF ECE MPMC LAB

MSP-EXP430G2 Launch Pad

NEC,GUDUR 81
DEPT OF ECE MPMC LAB

PART-C

TASK NO Introduction to MSP430 launch pad and DATE


Programming Environment. (Study Experiment)
9

AIM: To study the MSP Launch pad and its programming environment.

HARDWARE SETUP
The Launch Pad experimenter board includes a pre-programmed MSP430 device
which is already located in the target socket. When the Launch Pad is connected to your
PC via USB, the demo starts with an LED toggle sequence. The on-board emulator
generates the supply voltage and all of the signals necessary to start the demo.

1. Connect the MSP430 Launch Pad to your PC using the included USB
Cable.
2. The driver installation starts automatically. If prompted for software, allow
Windows to install the softwareautomatically.

CODE COMPOSER STUDIO


Code Composer Studio (CCS) is the integrated development environment for the
whole span of TI Microcontrollers, DSPs and application processors. Code Composer
Studio includes a suite of tools used to develop and debug embedded applications. For
all device families, CCS includes compilers, source code editor, project build
environment, debugger, profiler, simulators and many other features.

Project Creation and Build:


A project contains all the files you will need to develop an executable output file
(.out) which can be run on the MSP430 hardware. To create a new project:
1. ClickF New CCSProject
2. Type in your Project name and make the selections shown below (your dialog may
look slightly different than thisone).
3. If you are using the MSP430G2553, make the appropriate choices for that part. Make
sure to click Empty Project (with main.c) and then clickFinish.
4. If you are1 writing an Assembly Code, select Empty Assembly-onlyProject.
5. Code Composer will add the named project to your workspace and display it in the
Project Explorer pane. Based on your template selection, it will also add a file called
main.c/ main.asm and open it forediting.
6. Change the include header file statement from#include <msp430.h>to
#include<msp430g2553.h>.

NEC,GUDUR 82
DEPT OF ECE MPMC LAB

7. Type in your program code in the main.c / main.asm file and saveit.
8. CCS can automatically save modified source files, build the program, open the debug
perspective view, connect and download it to the target (flash device), and then run the
program to the beginning of the main function. To do this, click on the "Debug" button

9. When the Ultra-Low-Power Advisor (ULP Advisor) appears, click theProceed


button.
10. When the download completes, CCS is in the Debug perspective. Notice the Debug
tab in the upper right-hand corner indicating that we are now in the "CCS Debug" view.
11. Click and drag the perspective tabs to the left until you can see all of both tabs. You
can observe that the program has run through the C-environment initialization routine in
the runtime support library and stopped at main() inmain.c.

Debug Environment
After completion of target download, CCS enters the Debug perspective. Notice
the Debug tab in the upper right-hand corner indicating that we are now in the "CCS
Debug" view. Click and drag the perspective tabs to the left until you can completely see
bothtabs.
The basic buttons that control the debug environment are located at the top of the
Debug pane. If the pane is closed accidentally, the Debug controls will disappear. To
bring back the debug controls, click
Clickthe Resume button to run thecode.
Click Suspend to stop code execution in the middle of the program. To single-step
into the code, click Step Into to help in debugging the program and check if each
line of code is producing the desired result.

Click Reset CPU and you should be back at the beginning ofmain().

The Terminate button will terminate the active debug session, close the debugger
and return CCS to the "CCS Edit" perspective. It also sends a reset to the Launch
Padboard.

RESULT:

NEC,GUDUR 83
DEPT OF ECE MPMC LAB

TASK NO INTERFACING AND PROGRAMMING GPIO PORTS DATE

10 (A)BLINKING GREEN LED

AIM: To write a C program to blink an LED using GPIO on MSP430G2.

APPARATUS: 1. MSP430 G2533 Launch pad.


2. USB Cable
3. CC Studio

PROCEDURE:
1. Connect the MSP-EXP430G2 Launch Pad to the PC using the USB cable supplied.
2. Build the program and debug the code into the Launch Pad using CCS to view the
status of the LED.
3. In the CCS debug perspective, select View Registers.

PROGRAM:

#include<msp430.h>
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P1DIR |= 0x01; // Set P1.0 to output direction
while(1) {
volatile unsigned long i; // Volatile to prevent
//optimization
P1OUT ^= 0x01; // Toggle P1.0 using XOR
i = 50000; // SW Delay
do i--;
while(i != 0);
}
}

RESULT:

NEC,GUDUR 84
DEPT OF ECE MPMC LAB

(B) BLIKING RED LED

AIM: To write a C program to blink an LED using GPIO on MSP430G2.

APPARATUS: 1. MSP430 G2533 Launch pad.


2. USB Cable
3. CC Studio

PROCEDURE:

1. Connect the MSP-EXP430G2 Launch Pad to the PC using the USB cable supplied.
2. Build the program and debug the code into the Launch Pad using CCS to view the
status of the LED.
3. In the CCS debug perspective, select View Registers.

PROGRAM:

#include<msp430.h>
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P1DIR |= 0x40; // Set P1.6 to output direction
while(1) {
volatile unsigned long i; // Volatile to prevent
//optimization
P1OUT ^= 0x40; // Toggle P1.6 using XOR
i = 50000; // SW Delay
do i--;
while(i != 0);
}
}

RESULT:

NEC,GUDUR 85
DEPT OF ECE MPMC LAB

(C) BLINKING RED & GREEN LED TOGETHER

AIM: To write a C program to blink an LED using GPIO on MSP430G2.

APPARATUS: 1. MSP430 G2533 Launch pad.


2. USB Cable
3. CC Studio

PROCEDURE:
1. Connect the MSP-EXP430G2 Launch Pad to the PC using the USB cable supplied.
2. Build the program and debug the code into the Launch Pad using CCS to view the
status of the LEDs.
3. In the CCS debug perspective, select View Registers.

PROGRAM:

#include<msp430.h>
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P1DIR |= 0x01; // Set P1.0 to output direction
P1DIR |= 0x40; // Set P1.6 to output direction

while(1) {
volatile unsigned long i; // Volatile to prevent
//optimization
P1OUT ^= 0x01; // Toggle P1.0 using XOR
P1OUT ^= 0x40; // Toggle P1.6 using XOR

i = 50000; // SW Delay
do i--;
while(i != 0);
}
}

RESULT:

NEC,GUDUR 86
DEPT OF ECE MPMC LAB

(D) BLINKING RED & GREEN LEDS ALTERNATIVELY

AIM: To write a C program to blink an LED using GPIO on MSP430G2.

APPARATUS: 1. MSP430 G2533 Launch pad.


2. USB Cable
3. CC Studio

PROCEDURE:
1. Connect the MSP-EXP430G2 Launch Pad to the PC using the USB cable supplied.
2. Build the program and debug the code into the Launch Pad using CCS to view the
status of the LEDs.
3. In the CCS debug perspective, select View Registers.

PROGRAM:

#include<msp430.h>
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P1DIR |= 0x01; // Set P1.0 to output direction
P1DIR |= 0x40; // Set P1.6 to output direction
P1OUT |= 0x01;
P1OUT&|= ~ 0x40;
while(1) {
volatile unsigned long i; // Volatile to prevent
//optimization
P1OUT ^= 0x01; // Toggle P1.0 using XOR
P1OUT ^= 0x40; // Toggle P1.6 using XOR

i = 50000; // SW Delay
do i--;
while(i != 0);
}
}

RESULT:

NEC,GUDUR 87
DEPT OF ECE MPMC LAB

VIVA QUESTIONS:
1. What is MSP 430 microcontroller?
2. What is the major advantage behind the MSP 430 microcontroller?
3. What is a GPIO port?
4. How do you interface the GPIO port with MSP 430?
5. What is a Launch pad?
6. What is the function of the P1DIR register in MSP430?
7. How do you set a particular GPIO pin as output in MSP430?
8. What is the role of the P1OUT register in controlling the LED?
9. How is delay implemented in a C program for MSP430?
10. Which clock source is typically used for timing in simple LED blink programs on MSP430

NEC,GUDUR 88
DEPT OF ECE MPMC LAB

ADDITIONAL EXPERIMENT

TASK NO DATE
READ INPUT FROM SWITCH & GLOW LED
11

AIM: To write a C program to read input from switch and glow LED using GPIO on
MSP430G2.

APPARATUS: 1. MSP430 G2533 Launch pad.


2. USB Cable
3. CC Studio

PROGRAM:

#include<msp430.h>
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P1DIR |= 0x40; // Set P1.6 to output direction
P1REN |= 0x08;
P1OUT |= 0X08;
while(1) {
if ((P1IN & BIT3)) { // If button is open(P1.3 HIGH)
P1OUT = P1OUT | BIT6; // ... turn on LED
} // or P1OUT |= BIT0;
else {
P1OUT = P1OUT & ~BIT6; // ... else turn it off.
// or P1OUT &= ~BIT0
}
}
}

RESULT:

NEC,GUDUR 89
DEPT OF ECE MPMC LAB

VIVA QUESTIONS:

1. What is a switch?

2. What are the two positions of the switch?

3. What is a CCS?

4. What is ULP advisor?

5. What is debugging?

6 How do you configure a GPIO pin as input in MSP430?

7 What is the purpose of the P1IN register in switch interfacing?

8 How can you detect a button press using GPIO in MSP430?

9 Why is debouncing important when reading input from a switch?

10 How do you control an LED based on switch input in MSP430 using C?

NEC,GUDUR 90
DEPT OF ECE MPMC LAB

NEC,GUDUR 91

You might also like