r23 MPMC Lab Manual Final
r23 MPMC Lab Manual Final
&
MICROCONTROLLERS
LAB RECORD
NAME
Roll No.
Class
&Bran
ch
DEPARTMENTOF
ELECTRONICSANDCOMMUNCIATIONENGINEERING
MICROPROCESSORS & MICROCONTROLLERS
LAB RECORD
Preparedby
: 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:
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
PageN Signature
S.No Date NameoftheExperiment Marks
o. with Date
10
AdditionalExperiment
11
Faculty Signature
LISTOFEXPERIMENTS
PART A
8086 Microprocessor & Interfacing Programs
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)
ADDITONAL EXPERIMENT
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
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
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
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
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
NEC,GUDUR 23
DEPT OF ECE MPMC LAB
INPUT OUTPUT
ADDRESS DATA REGISTER DATA
EXPLANATION:
NEC,GUDUR 24
DEPT OF ECE MPMC LAB
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?
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?
NEC,GUDUR 28
DEPT OF ECE MPMC LAB
EXP NO DATE
BIT MANIPULATION INSTRUCTIONS
2
AIM: TowriteandexecuteAssemblylanguageprogramstoperformBitManipulation
instructions.
PROGRAM:
NOTE:DL=00RepresentsPositiveNumberandDL=01RepresentsNegativeNumber
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
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
NEC,GUDUR 32
DEPT OF ECE MPMC LAB
8. What is the effect of the ANL and ORL instructions on bit-level data?
NEC,GUDUR 33
DEPT OF ECE MPMC LAB
EXP NO DATE
ARRAY OPERATIONS
3
AIM: TowriteandexecuteAssemblylanguageprogramstoperformArrayoperations
for8086.
PROGRAMS:
JNZ UP Jumpifnotequaltozero
NEC,GUDUR 34
DEPT OF ECE MPMC LAB
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
EXPLANATION:
NEC,GUDUR 35
DEPT OF ECE MPMC LAB
JNZ UP Jumpifnotequaltozero
NEC,GUDUR 36
DEPT OF ECE MPMC LAB
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
EXPLANATION:
NEC,GUDUR 37
DEPT OF ECE MPMC LAB
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
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
INC SI IncrementSIcontent
INC SI IncrementSIcontent
NEC,GUDUR 42
DEPT OF ECE MPMC LAB
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
EXPLANATION:
NEC,GUDUR 43
DEPT OF ECE MPMC LAB
INC SI IncrementSIcontent
INC SI IncrementSIcontent
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
EXPLANATION:
NEC,GUDUR 44
DEPT OF ECE MPMC LAB
RESULT:
VIVA QUESTION:
4. How many pins are available in 8086 IC and what is the use of MN/¯MX?
NEC,GUDUR 45
DEPT OF ECE MPMC LAB
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
PROGRAMS:
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
INC SI Increment SI
DEC DI Decrement DI
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
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
RESULT:
NEC,GUDUR 53
DEPT OF ECE MPMC LAB
VIVA QUESTIONS:
1. What is 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
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?
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
movah, 2Ah
Int 21h
mov year, cx
mov month, dh
mov day, dl
movdayOfWeek, al
movah,2Ch
int 21h
mov hours,ch
mov minutes,cl
movseconds,dh
NEC,GUDUR 56
DEPT OF ECE MPMC LAB
RESULT:
VIVA QUESTIONS:
NEC,GUDUR 57
DEPT OF ECE MPMC LAB
STEPPERMOTORCIRCUITDIAGRAM:
NEC,GUDUR 58
DEPT OF ECE MPMC LAB
AIM: WriteanAssemblyLanguageProgramtointerfaceMicroprocessorwith
StepperMotor.
APPARATUS:
1) 8086Microprocessor-1
2) StepperMotorKit-1
3) RPS(+5V)-1
4) FRCCables.
PROCEDURE:
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:
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
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
(F) OR OPERATION
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
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
RESULT:
NEC,GUDUR 73
DEPT OF ECE MPMC LAB
VIVA QUESTIONS:
1. What is a Microcontroller?
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?
10. Which flags are affected after arithmetic and logical operations in the 8051?
NEC,GUDUR 75
DEPT OF ECE MPMC LAB
AIM: Write an 8051 program for Delay generation using (a) Nested loop (b) Timers.
PROGRAMS
(A) NESTEDLOOP
NEC,GUDUR 76
DEPT OF ECE MPMC LAB
(B) TIMER
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?
3.What are the two main methods for generating delays in 8086 assembly
language?
6.What is a timer?
7 What is the difference between software delay and hardware delay in 8051?
NEC,GUDUR 79
DEPT OF ECE MPMC LAB
PARTC:
Embedded C Experiments using
MSP430 Microcontroller
NEC,GUDUR 80
DEPT OF ECE MPMC LAB
NEC,GUDUR 81
DEPT OF ECE MPMC LAB
PART-C
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.
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
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
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
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
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
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.
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?
3. What is a CCS?
5. What is debugging?
NEC,GUDUR 90
DEPT OF ECE MPMC LAB
NEC,GUDUR 91