MPMC r15 Ece Manual 2019
MPMC r15 Ece Manual 2019
MPMC r15 Ece Manual 2019
LAB MANUAL
BATCH (R15)
Prepared by:
G.Ramanjaneya Reddy
O.Mohana Chandrika
GITAMW/ECE 1
(15A04607) MICROPROCESSORS AND MICROCONTROLLERS LABORATORY
Part A : 8086 Microprocessor Programs using MASM/8086 microprocessor kit.
1. Introduction to MASM Programming.
2. Programs using arithmetic and logical operations
3. Programs using string operations and Instruction prefix: Move Block, Reverse string,
Sorting, String comparison
4. Programs for code conversion
5. Multiplication and Division programs
6. Sorting and multi byte arithmetic
7. Programs using CALL and RET instructions
Part B Embedded C Experiments using MSP430 Microcontroller
1. Interfacing and programming GPIO ports in C using MSP430 (blinking LEDs , push
buttons)
2. Usage of Low Power Modes: ( Use MSPEXP430FR5969 as hardware platform and
demonstrate the low power modes and measure the active mode and standby mode current)
3. Interrupt programming examples through GPIOs
4. PWM generation using Timer on MSP430 GPIO
5. Interfacing potentiometer with MSP430
6. PWM based Speed Control of Motor controlled by potentiometer connected to MSP430
GPIO
7. Using ULP advisor in Code Composer Studio on MSP430
8. Low Power modes and Energy trace++:
a. Enable Energy Trace and Energy Trace ++ modes in CCS
b. Compute Total Energy, and Estimated lifetime of an AA battery.
GITAMW/ECE 2
Procedure for to run MASM on windows 7:
1. Switch on the computer.
2. Double click on dosbox
3. Type mount c c:\8086 and then enter
4. Type c: and then enter.
5. Type “edit” & press “enter” button
6. Type the program & select “file ->save as”
7. Save the file with an exetenxion “.asm”,(ex1.asm)
8. Select “file->exit”
9. Type the command “masm programname.asm” & press enter 4 times.
10. Check if any errors / warnings are there in your program ..if any errors are there modify
the program by giving the command ”edit programname.asm”
11. Again save the program.
12. Repeat step 9 until you get 0 errors & 0 warnings.
13. Then type the command “link programname.obj” (ex1.obj) & press enter 4 times
14. Then type the command “debug programname.exe”(ex1.exe) & press enter.
15. Give the command ” u “ to note the address & opcode of program.
16. give the command ” t“ to check the registers update after each & every instruction
execution. repeat this process until the program ends.
17. If the result is in memory location give the command “d ds:0000”
18. To quit from debugging mode type the command “q”
19. Repeat the same process from step 5 to execute the next program.
GITAMW/ECE 3
1. ARITHMETIC OPERATIONS
AIM:-
APPARATUS:-
THEORY:-
PROCEDURE:-
1)16-BIT ADDITION:-
DATA SEGMENT
A DW 2228H
B DW 2210H
RESULT DW ?
DATA ENDS
CODE SEGMENT
GITAMW/ECE 4
MOV DS, AX
MOV AX, A
MOV BX, B
CLC
ADD AX, BX
MOV [DI], DX
INT 03H
CODE ENDS
END START
0B8B:0000 28H
0B8B:0001 22H
0B8B:0002 10H
0B8B:0003 22H
0B8B:0004 38H
0B8B:0005 44H
2) 16-BIT SUBTRACTION:-
DATA SEGMENT
A DW 6668H
B DW 4428H
RESULTS DW?
DATA ENDS
CODE SEGMENT
GITAMW/ECE 5
START: MOV AX, DATA
MOV DS, AX
MOV AX, A
MOV BX, B
CLC
SUB AX, BX
MOV [DI], DX
INT 03H
CODE ENDS
END START
0B8B:0000 68H
0B8B:0001 66H
0B8B:0002 28H
0B8B:0003 44H
0B8B:0004 40H
0B8B:0005 22H
3)16-BIT MULTIPLICATION:-
DATA SEGMENT
A DW 2222H
B DW 0101H
RESULTS DW ?
DATA ENDS
GITAMW/ECE 6
CODE SEGMENT
MOV DS, AX
MOV AX, A
MOV BX, B
CLC
MUL AX, BX
MOV [DI],DX
INT 03H
CODE ENDS
ENDS START
0B8B:0000 22H
0B8B:0001 22H
0B8B:0002 45H
0B8B:0003 45H
OUTPUT:-ADDRESS DATA
0B8B:0004 22H
0B8B:0005 44H
0B8B:0006 22H
0B8B:0007 00H
GITAMW/ECE 7
4)16-BIT DIVISION:-
DATA SEGMENT
A DW 8888H
B DW 2222H
RESULTS DW ?
DATA ENDS
CODE SEGMENT
MOV DS, AX
MOV AX, A
MOV BX, B
CLC
DIV AX, BX
MOV [DI], DX
INT 03H
CODE ENDS
ENDS START
0B8B:0000 88H
0B8B:0001 88H
0B8B:0002 22H
0B8B:0003 22H
GITAMW/ECE 8
OUTPUT:-ADDRESS DATA
0B8B:0004 04H
0B8B:0005 00H
0B8B:0006 00H
0B8B:0007 00H
5) 1’S COMPLIMENT:-
DATA SEGMENT
A DW 1234H
RESULT DW?
DATA ENDS
CODE SEGMENT
MOV DS, AX
MOV AX, A
CLC
NOT AX
MOV [DI], AX
INT 03H
CODE ENDS
ENDS START
0B8B:0000 12H
0B8B:0001 34H
GITAMW/ECE 9
0B8B:0002 EDH
0B8B:0003 CBH
6)2’S COMPLEMENT:-
DATA SEGMENT
A DW 5432H
RESULTS DW ?
DATA ENDS
CODE SEGMENT
MOV DS, AX
MOV AX, A
CLC
NOT AX
INC DI
MOV [DI], AX
INT 03H
CODE ENDS
ENDS START
GITAMW/ECE 10
INPUT:- ADDRESS DATA
0B8B:0000 54H
0B8B:0001 32H
0B8B:0002 ABH
0B8B:0003 CEH
GITAMW/ECE 11
1.b. LOGICAL OPERATIONS
Aim:-
Apparatus:-
THEORY:-
Procedure:-
PROGRAMS:
AND OPERATION
DATA SEGMENT
OPR1 DW 8642H
OPR2 DW 4286H
RESULT DW (?)
DATA ENDS
CODE SEGMENT
MOV DS,AX
GITAMW/ECE 12
MOV AX, OPR1
CLC
AND AX, BX
MOV [DI], AX
INT 03H
CODE ENDS
END START
0B8B:0000 42H
0B8B:0001 86H
0B8B:0002 86H
0B8B:0003 42H
0B8B:0004 02H
0B8B:0005 02H
LOGICAL OR OPERATION:
DATA SEGMENT
OPR1 DW 4521H
OPR2 DW 5432H
RESULT DW?
DATA ENDS
CODE SEGMENT
GITAMW/ECE 13
MOV DS, AX
CLC
OR AX, BX
MOV [DI], AX
INT 03H
CODE ENDS
END START
0B8B:0000 42H
0B8B:0001 86H
0B8B:0002 86H
0B8B:0003 42H
0B8B:0004 C4H
0B8B:0005 C4H
DATA SEGMENT
OPR1 DW 8642H
OPR2 DW 4286H
RESULT DW?
DATA ENDS
CODE SEGMENT
GITAMW/ECE 14
START: MOV AX, DATA
MOV DS, AX
CLC
XOR AX, BX
MOV [DI], AX
INT 03H
CODE ENDS
END START
0B8B:0000 42H
0B8B:0001 86H
0B8B:0002 86H
0B8B:0003 42H
0B8B:0004 C4H
0B8B:0005 C4H
DATA SEGMENT
OPR DW 8642H
GITAMW/ECE 15
RESULT DW?
DATA ENDS
CODE SEGMENT
MOV DS, AX
CLC
NOT AX
MOV [DI], AX
INT 03H
CODE ENDS
END START
0B8B:0000 42H
0B8B:0001 86H
0B8B:0000 BDH
0B8B:0001 79H
DATA SEGMENT
OPR1 DW 4286H
OPR2 DW 8642H
GITAMW/ECE 16
RESULT DW ?
DATA ENDS
CODE SEGMENT
MOV DS, AX
CLC
NAND AX, BX
MOV [DI], AX
INT 03H
CODE ENDS
END START
0B8B:0000 42H
0B8B:0001 86H
0B8B:0002 86H
0B8B:0003 42H
0B8B:0004 C4H
0B8B:0005 C4H
GITAMW/ECE 17
DATA SEGMENT
OPR1 DW 4286H
COUNT DB 01H
RESULT DW(?)
DATA ENDS
CODE SEGMENT
MOV DS, AX
CLC
SHL AX, CL
MOV [DI], AX
INT 03H
CODE ENDS
END START
0B8B:0000 86H
0B8B:0001 42H
0B8B:0002 01H
0B8B:0003 0CH
0B8B:0004 85H
GITAMW/ECE 18
LOGICAL SHR OPERATION
DATA SEGMENT
OPR1 DW 4286H
COUNT DB 01H
RESULT DW(?)
DATA ENDS
CODE SEGMENT
MOV DS, AX
CLC
SHR AX, CL
MOV [DI], AX
INT 03H
CODE ENDS
END START
0B8B:0000 86H
0B8B:0001 42H
0B8B:0000 01H
0B8B:0003 43H
GITAMW/ECE 19
0B8B:0004 21H
DATA SEGMENT
OPR1 DW 8642H
COUNT DB 02H
RESULT DW (?)
DATA ENDS
CODE SEGMENT
MOV DS, AX
CLC
SAR AX, CL
MOV [DI], AX
INT 03H
CODE ENDS
END START
0B8B:0000 86H
0B8B:0001 42H
0B8B:0000 02H
GITAMW/ECE 20
0B8B:0003 A1H
0B8B:0004 10H
DATA SEGMENT
OPR1 DW 8642H
COUNT DB 02H
RESULT DW(?)
DATA ENDS
CODE SEGMENT
MOV DS, AX
CLC
SAL AX, CL
MOV [DI], AX
INT 03H
CODE ENDS
END START
0B8B:0000 86H
0B8B:0001 42H
0B8B:0000 02H
GITAMW/ECE 21
0B8B:0003 18H
0B8B:0004 0AH
DATA SEGMENT
OPR1 DW 8642H
COUNT DB 02H
RESULT DW?
DATA ENDS
CODE SEGMENT
MOV DS, AX
CLC
ROL AX, CL
MOV [DI], AH
MOV [DI], AL
INT 03H
CODE ENDS
END START
0B8B:0000 86H
0B8B:0001 42H
GITAMW/ECE 22
0B8B:0000 02H
0B8B:0003 19H
0B8B:0004 0AH
DATA SEGMENT
OPR1 DW 4286H
COUNT DB 02H
RESULT DW ?
DATA ENDS
CODE SEGMENT
MOV DS, AX
CLC
ROR AX, CL
MOV [DI], AH
MOV [DI], AL
INT 03H
CODE ENDS
END START
0B8B:0000 86H
GITAMW/ECE 23
0B8B:0001 42H
0B8B:0000 02H
0B8B:0003 18H
0B8B:0004 0AH
DATA SEGMENT
OPR1 DW 4286H
COUNT DB 02H
RESULT DW ?
DATA ENDS
CODE SEGMENT
MOV DS, AX
CLC
RCL AX, CL
MOV [DI], AH
MOV [DI], AL
INT 03H
CODE ENDS
END START
GITAMW/ECE 24
0B8B:0000 86H
0B8B:0001 42H
0B8B:0000 02H
0B8B:0003 18H
0B8B:0004 0AH
DATA SEGMENT
OPR1 DW 4286H
COUNT DB 02H
RESULT DW ?
DATA ENDS
CODE SEGMENT
MOV DS, AX
CLC
RCR AX, CL
MOV [DI], AH
MOV [DI], AL
INT 03H
CODE ENDS
END START
GITAMW/ECE 25
INPUT: - ADDRESS DATA
0B8B:0000 86H
0B8B:0001 42H
0B8B:0000 02H
0B8B:0003 A1H
0B8B:0004 10H
GITAMW/ECE 26
2. STRING OPERATIONS
AIM:-
APPARATUS:-
PROCEDURE:-
6. Execute the program line by line using T command or at once by using G command.
MOVE A STRING
DATA SEGMENT
COUNT DB 04H
B DB?
DATA ENDS
CODE SEGMENT
MOV DS, AX
GITAMW/ECE 27
L1: MOV AL, [SI]
MOV [DI], AL
INC SI
DEC DI
LOOP L1
INT 03H
CODE ENDS
END START
0B8B:0000 12H
0B8B:0001 13H
0B8B:0002 14H
0B8B:0003 15H
0B8B:0004 04H
0B8B:0005 12H
0B8B:0006 13H
0B8B:0007 14H
0B8B:0008 15H
Length of String
DATA SEGMENT
C DB?
DATA ENDS
CODE SEGMENT
GITAMW/ECE 28
START: MOV AX, DATA
MOV DS, AX
L1: INC DX
INC SI
CMP AH, AL
JNZ L1
INT 03H
CODE ENDS
END START
0B8B:0000 12H
0B8B:0001 13H
0B8B:0002 14H
0B8B:0003 FFH
0B8B:0004 03H
COMARISION OF A STRING
DATA SEGMENT
GITAMW/ECE 29
STR1 DB 11H, 12H, 13H, 54H
COUNT DB 03H
DATA ENDS
CODE SEGMENT
MOV DS, AX
MOV ES, AX
CLD
REPE CMPSB
JNZ L1
JMP L2
INT 03H
CODE ENDS
END START
0B8B:0000 11H
0B8B:0002 12H
0B8B:0003 13H
GITAMW/ECE 30
0B8B:0004 54H
0B8B:0005 12H
0B8B:0006 13H
0B8B:0007 54H
0B8B:0008 04H
0B8B:0009 01H
0B8B:000A 00H
ASCENDING ORDER
DATA SEGMENT
COUNT DB 04H
DATA ENDS
CODE SEGMENT
MOV DS, AX
JL L3
MOV [SI], AL
GITAMW/ECE 31
L3: INC SI
LOOP L1
DEC DI
JNZ L2
INT 03H
CODE ENDS
END START
0B8B:0000 10H
0B8B:0001 12H
0B8B:0002 14H
0B8B:0003 16H
0B8B:0004 04H
OUTPUT:-ADDRESS DATA
0B8B:0005 10H
0B8B:0006 12H
0B8B:0007 14H
0B8B:0008 16H
DESCENDING ORDER
DATA SEGMENT
COUNT EQU 05
RESULT DB?
GITAMW/ECE 32
DATA ENDS
CODE SEGMENT
MOV DS, AX
JG L3
XCHG [SI+1], AL
XCHG [SI], AL
L3: INC SI
LOOP L1
DEC DL
JNZ L2
INT 03H
CODE ENDS
END START
0B8B:0000 10H
0B8B:0001 12H
0B8B:0002 14H
0B8B:0003 16H
0B8B:0004 04H
GITAMW/ECE 33
OUTPUT:- ADDRESS DATA
0B8B:0005 16H
0B8B:0006 14H
0B8B:0007 12H
0B8B:0008 10H
REVERSE A STRING
DATA SEGMENT
RESULT DB?
DATA ENDS
CODE SEGMENT
MOV DS,AX
MOV DL, CL
PUSH AX
INC SI
DEC DL
JNZ L1
AGAIN: POP AX
MOV [DI], AX
GITAMW/ECE 34
INC DI
DEC DL
JNZ AGAIN
INT 03H
(OR)
DATA SEGMENT
COUNT DB 04H
B DB?
DATA ENDS
CODE SEGMENT
MOV DS, AX
MOV [DI], AL
INC SI
DEC DI
LOOP L1
INT 03H
CODE ENDS
END START
0B8B:0000 23H
GITAMW/ECE 35
0B8B:0001 24H
0B8B:0002 25H
0B8B:0003 26H
0B8B:0004 04H
0B8B:0005 26H
0B8B:0006 25H
0B8B:0007 24H
0B8B:0008 23H
DISPLAY STRING
DATA SEGMENT
DATA ENDS
CODE SEGMENT
MOV DS, AX
INT 21H
INT 21H
CODE ENDS
END START
GITAMW/ECE 36
0B8B:0000 0DH
0B8B:0001 0AH
0B8B:0002 SRECH
0B8B:0003 0DH
0B8B:0004 0AH
0B8B:0005 “ $”
0B8B:0006 SREC
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
DOWN: INC SI
DEC CL
JNZ UP1
DEC CH
GITAMW/ECE 37
JNZ UP2
INT 3
CODE ENDS
END START
GITAMW/ECE 38
3.Code Conversions
. To perform PACKED BCD to unpacked BCD and PACKED BCD to ASCII conversion.
Apparatus:-
THEORY:-
Procedure:-
DATA SEGMENT
COUNT DW 04H
OPR1 DW 84H
RESULT DW?
DATA ENDS
CODE SEGMENT
MOV DS, AX
GITAMW/ECE 39
MOV AL, [SI]
MOV AH, AL
CLC
ROR AH, CL
MOV [DI], AL
INC DI
MOV [DI], AH
INT 03H
CODE ENDS
END START
0B8B:0000 84H
0B8B:0001 04H
0B8B:0000 04H
0B8B:0001 08H
DATA SEGMENT
COUNT DW 04H
OPR1 DW 84H
GITAMW/ECE 40
RESULT DW ?
DATA ENDS
CODE SEGMENT
MOV DS, AX
MOV AH, AL
CLC
ROR AH, CL
MOV [DI], AL
INC DI
MOV [DI], AH
OR AX, 3030H
INT 03H
CODE ENDS
END START
0B8B:0000 84H
0B8B:0001 04H
0B8B:0000 38H
GITAMW/ECE 41
0B8B:0001 34H
GITAMW/ECE 42
4. MULTI BYTE OPERATIONS
AIM:-
To perform multi byte operations such as addition, subtractions of two bytes/16-bit length
number using MASM.
APPARATUS:-
THEORY:-
PROCEDURE:-
DATA SEGMENT
A DW 0030H, 0022H
B DW 0040H, 0024H
COUNT DW 02H
RESULT DW ?
DATA ENDS
CODE SEGMENT
GITAMW/ECE 43
MOV DS, AX
ADD AH, DH
MOV [BX], AH
INC SI
INC SI
INC DI
INC DI
INC BX
INC BX
LOOP L1
INT 03H
CODE ENDS
END START
0B8B:0000 00H
0B8B:0001 30H
0B8B:0002 00H
0B8B:0003 22H
0B8B:0004 00H
GITAMW/ECE 44
0B8B:0005 40H
0B8B:0006 00H
0B8B:0007 24H
0B8B:0008 02H
OUTPUT:-ADDRESS DATA
0B8B:0009 00H
0B8B:000A 70H
0B8B:000B 00H
0B8B:000C 46H
2)16-SUBTRACTION:-
DATA SEGMENT
A DW 0040H, 0024H
B DW 0030H, 0022H
COUNT DW 02H
RESULTS DW ?
DATA ENDS
CODE SEGMENT
MOV DS, AX
GITAMW/ECE 45
SUB AH, DH
MOV [BX], AH
INC SI
INC SI
INC DI
INC DI
INC BX
INC BX
LOOP L1
INT 03H
CODE ENDS
END START
0B8B:0000 00H
0B8B:0001 40H
0B8B:0002 00H
0B8B:0003 30H
0B8B:0004 00H
0B8B:0005 24H
0B8B:0006 00H
0B8B:0007 22H
0B8B:0008 02H
0B8B:0009 00H
0B8B:000A 10H
0B8B:000B 00H
0B8B:000C 02H
GITAMW/ECE 46
RESULT:-The multi byte operations 16-bit addition and subtraction are executed by using
MASM softwar
GITAMW/ECE 47
b. ASCII OPERATIONS
AIM:-
To perform the ASCII operation for addition, subtraction, multiplication and division using
MASM
APPARATUS:-
PROCEDURE:-
2. Write the program code, save the file and go to exit in the file menu.
3. Source file as to be converted into object file using MASM file name.asm command.
4. Once the OBJ FILE is generated send the OBJ FILE to the linker in order to generate the
EXE.file this can be done with LINK file filename.obj command.
6. Execute the program line by line using T command or at once by using G command.
DATA SEGMENT
OPRI DB 51H
OPR2 DB 36H
RESULT DB?
DATA ENDS
CODE SEGMENT
GITAMW/ECE 48
MOV DS, AX
CLC
ADD AL, BL
AAA
MOV [DI], AX
INT 03H
CODE ENDS
END START
0B7B:0000 51H
0B7B:0001 36H
0B7B:0002 07H
DATA SEGMENT
OPR1 DB 45H
OPR2 DB 34H
RESULT DB ?
CODE SEGMENT
MOV DS, AX
GITAMW/ECE 49
MOV AH, 00H
CLC
SUB AL, BL
AAS
MOV [DI], AX
INT 03H
CODE ENDS
END START
0B7B:0001 34H
0B7B:0002 01H
DATA SEGMENT
OPR1 DB 34H
OPR2 DB 04H
RESULT DB ?
DATA ENDS
CODE SEGMENT
MOV DS, AX
GITAMW/ECE 50
MOV AL OPR1
MOV BL OPR2
CLC
MUL BL
AAM
MOV [DI], AX
INT 03H
CODE ENDS
END START
0B7B:0000 34H
0B7B:0001 04H
0B7B:0002 00H
DATA SEGMENT
OPR1 DB 34H
OPR2 DB 02H
RESULT DB ?
DATA ENDS
CODE SEGMENT
MOV DS, AX
GITAMW/ECE 51
MOV AL, OPR1
CLC
DIV BL
AAD
MOV [DI], AX
INT 03H
CODE ENDS
END START
0B7B:000 34H
0B7B:0001 04H
OB7B:0002 0DH
GITAMW/ECE 52
PART-B: Embedded C Experiments using MSP430
AIM:
LEARNING OBJECTIVE:
REQUIREMENTS:
Procedure
1. Connect the MSP-EXP430G2 LaunchPad to the PC using the USB cable supplied.
2. Build, program and debug the code into the LaunchPad using CCS to
view the status of the red LED.
3. In the CCS debug perspective, select View Registers.
GITAMW/ECE 53
C PROGRAM CODE FOR RED LED Blink
#include<msp430.h>
int main(void) {
//P1DIR |= 0x40;
while(1) {
//optimization
GITAMW/ECE 54
P1OUT ^= 0x01; // Toggle P1.0 using XOR
//P1OUT ^= 0x40;
i = 50000; // SW Delay
do i--;
while(i != 0);
#include<msp430.h>
int main(void) {
P1DIR |= 0x40;
while(1) {
//optimization
P1OUT ^= 0x40;
i = 50000; // SW Delay
do i--;
while(i != 0);
#include<msp430.h>
int main(void) {
GITAMW/ECE 55
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P1DIR |= 0x40;
while(1) {
//optimization
P1OUT ^= 0x40;
i = 50000; // SW Delay
do i--;
while(i != 0);
#include<msp430.h>
int main(void) {
P1DIR |= 0x40;
while(1) {
//optimization
P1OUT ^= 0x40;
GITAMW/ECE 56
}
#include<msp430.h>
int main(void) {
P1REN |= 0x08;
P1OUT |= 0X08;
while(1) {
} // or P1OUT |= BIT0;
else {
#include<msp430.h>
int main(void) {
P1REN |= 0x08;
GITAMW/ECE 57
P1OUT |= 0X08;
while(1) {
else {
P1OUT |= BIT0;
C PROGRAM CODE FOR GREEN LED STAY ON 1SEC WHEN BUTTON PRESSED
#include<msp430.h>
int main(void) {
P1REN |= 0x08;
P1OUT |= 0X08;
while(1) {
GITAMW/ECE 58
if ((P1IN & BIT3))
i = 50000; // SW Delay
do i--;
while(i != 0);
else {
//P1OUT |= BIT0;
#include<msp430.h>
int main(void) {
P1DIR |= 0x01;
P1REN |= 0x08;
P1OUT |= 0X08;
while(1) {
GITAMW/ECE 59
P1OUT = P1OUT | BIT6; // ... turn on LED
else {
P1OUT |= BIT0;
RESULTS:
In the Debug Perspective in your CCS Studio window, select View Registers. Pause the running
code and in the
Registers tab, expand and view the registers P1OUT, P1DIR and WDTCTL. Compare the values
with your code.
GITAMW/ECE 60
2. LOW POWER MODES AND CURRENT MEASUREMENT
AIM:
To learn the various low power modes and measure current consumption both in active and
standby mode.
LEARNING OBJECTIVE:
REQUIREMENTS:
Digital Multimeter.
PROCEDURE:
2.Build, load, and run the code. The green LED will blink once every three or four seconds.
3.When done, halt the code and click the Terminate button to return to the “CCS Edit”.
5.The red lead of the multimeter should connect to the top (emulation side) Vcc pin on header J3
and the black lead
of the multimeter should connect to the bottom (target side) Vcc pin on header J3.
2.Build, load, and run the code. The green LED will blink once every three or four seconds.
3.When done, halt the code and click the Terminate button to return to the “CCS Edit”.
GITAMW/ECE 61
4.Remove all five jumpers on header J3.
5.The red lead of the multimeter should connect to the top (emulation side) Vcc pin on header J3
and the black lead
of the multimeter should connect to the bottom (target side) Vcc pin on header J3.
Main_active.c
#include <msp430g2553.h>
#ifndef TIMER0_A1_VECTOR
#endif
void FaultRoutine(void);
void ConfigWDT(void);
void ConfigClocks(void);
void ConfigPins(void);
void ConfigADC10(void);
void ConfigTimerA2(void);
void main(void)
GITAMW/ECE 62
{
ConfigWDT();
ConfigClocks();
ConfigPins();
ConfigADC10();
ConfigTimerA2();
_BIS_SR(GIE);
while(1)
void ConfigWDT(void)
void ConfigClocks(void)
// run FaultRoutine()
GITAMW/ECE 63
}
void FaultRoutine(void)
while(1); // TRAP
void ConfigPins(void)
P1OUT = 0;
void ConfigADC10(void)
void ConfigTimerA2(void)
CCTL0 = CCIE;
CCR0 = 36000;
GITAMW/ECE 64
#pragma vector=TIMER0_A0_VECTOR
_delay_cycles(100);
Main_standby.c:
#include <msp430g2553.h>
#ifndef TIMER0_A1_VECTOR
#endif
void FaultRoutine(void);
void ConfigWDT(void);
GITAMW/ECE 65
void ConfigClocks(void);
void ConfigPins(void);
void ConfigADC10(void);
void ConfigTimerA2(void);
void main(void)
ConfigWDT();
ConfigClocks();
ConfigPins();
ConfigADC10();
ConfigTimerA2();
// _BIS_SR(GIE);
while(1)
void ConfigWDT(void)
void ConfigClocks(void)
GITAMW/ECE 66
DCOCTL = CALDCO_1MHZ; // Set DCO step + modulation
void FaultRoutine(void)
while(1); // TRAP
void ConfigPins(void)
P1OUT = 0;
void ConfigADC10(void)
void ConfigTimerA2(void)
CCTL0 = CCIE;
CCR0 = 36000;
GITAMW/ECE 67
TACTL = TASSEL_1 + MC_2;
#pragma vector=TIMER0_A0_VECTOR
_delay_cycles(100);
RESULTS:
The current consumption in both active and standby mode is measured while running same
application code. In Main_standby.c the processer enters into low power mode LPM3 and waits
for ADC interrupt. The reading for both the cases are tabularized and show below for
MSP430G2553.
GITAMW/ECE 68
3. Interrupt Programming through GPIO
AIM:
To learn on-chip Timer and Interrupts. Configuration of Timer, Interrupts and its operations.
LEARNING OBJECTIVE:
Objective
The main objective of this experiment is to configure GPIO and interrupts for the
MSP430G2553. This experiment
will help to learn and understand the GPIO and interrupt peripherals and their operation.
REQUIREMENTS:
PROCEDURE
1. Connect the MSP-EXP430G2 LaunchPad to the PC using the USB cable supplied.
2. Build, program and debug the code into the LaunchPad using CCS to view the status of
the Red LED.
3. In the CCS debug perspective, select View Registers.
FLOW CHART:
GITAMW/ECE 69
PROGRAM:
GITAMW/ECE 70
#include <msp430.h>
int main(void)
#include <msp430.h>
int main(void)
GITAMW/ECE 71
P1IES |= BIT3; // P1.3 High/Low Edge
RESULT:
The Timer is configured for counter/compare mode to raise a interrupt every second. Interrupt
Service Routine (ISR) for Timer is created, that blink the led which is connected to P1.6.
GITAMW/ECE 72
AIM:
To control the on-board RED LED by taking the analog input from a Potentiometer.
LEARNING OBJECTIVE:
DESCRIPTION:
The MSP430G2553 has 10-bit ADC Converters denoted as ADC10. This means that an
analog input is converted into a maximum of 1024 discreet levels. There are multiple possible
input channels (8 external lines and 4 internal analog sources). The ADC10 can be configured to
convert a single channel or a block of contiguous channels and can optionally repeat its
conversions automatically. Each conversion takes multiple cycles. The timing is controlled by an
ADC clock. While a conversion is in progress and busy flag set; when the conversion is
complete, a valid result is stored in the ADC10MEM register. There is a possible interrupt
(signaled when a conversion is complete). There is also a 'data transfer controller' that can steal
cycles from the CPU and store a block of conversion results directly in memory.In the current
experiment, the analog input is provided by the potentiometer on analog channel A3 which is the
same pin as P1.3. The resistance of the potentiometer is varied by turning its knob, thereby
resulting in a varying analog voltage on A3.
This voltage is converted into 1024 discrete levels from 0V to 3V (since we set Vref=Vcc). The
Red LED must turn on when the voltage crosses the threshold of Vcc/2 (or the digital level 512)
REQUIREMENTS:
HARDWARE CONNECTIONS:
Connect the positive lead of the potentiometer to the VCC pin on the MSP430 Launchpad and
the negative lead to the GND pin. The output lead of the potentiometer is connected to pin P1.3
or Analog Channel A3. The jumpers for RXD and TXD are connected horizontally.
FLOW CHART
GITAMW/ECE 73
C LANGUAGE PROGRAM CODE:
#include <msp430g2553.h>
int main(void)
while(1)
GITAMW/ECE 74
if (ADC10MEM < 512) // ADC10MEM = A3 > 512?
else
RESULTS:
The LED is initially OFF when the resistance is at its maximum. As we turn the potentiometer
the LED turns ON after a certain point. This point is the ADC voltage level of 512.
The potentiometer reading can be viewed by watching the ADC10MEM register on CCStudio
Debug Perspective.
GITAMW/ECE 75
5. Using ULP Advisor on MSP430
AIM:
To optimize the power efficient application on MSP430 Launchpad by using ULP Advisor in
CCS Studio.
LEARNING OBJECTIVE:
Understanding of ULP Advisor capabilities and using ULP Advisor for creating optimized power
efficient applications on MSP430 Launchpad.
DESCRIPTION:
ULP Advisor provides advice on how to improve the energy efficiency of your
application based on comparing your code with a list of ULP rules at compile time. ULP Advisor
software is used at compile time to draw attention to inefficient code and help the developer to
fully utilize the ULP capabilities of MSP430 microcontrollers. This tool works at build time to
check your code against a list of ULP rules and identify possible areas where energy and power
use is inefficient. A description of the ULP rule in violation, a link to the ULP Advisor wiki
page, links to relevant documentation, code examples and forum posts are all included for each
rule violation in the application code. Once the feedback has been presented, the developer can
then learn more about the violation and go back to edit the code or continue to run the code as-is.
The ULP Advisor is built into Code Composer Studio™ IDE version 5.2 and newer. After
GITAMW/ECE 76
compiling the code, a list of the ULP rule violations is provided in the Advice window. Unlike
errors, these suggestions will not prevent your code from
Successfully compiling and downloading. This current experiment explains in detail how to use
ULP Advisor on MSP430G2. Three code files are included in this experiment, but only one file
is included in the build at a time. Each file performs the same function: every second an Analog-
to-Digital Converter (ADC) temperature measurement is taken, the degrees Celsius and
Fahrenheit are calculated, and the results are sent through the backchannel Universal
Asynchronous Receiver/Transmitter (UART) at 9600bps. The first experiment begins with an
inefficient implementation of this application. ULP Advisor is used to observe the extreme
inefficiency of this version. Based on the feedback from the ULP Advisor, improvements are
made for the somewhat efficient second version of the code. The process is repeated, and ULP
Advisor is used to compare this improved version with the original. Lastly, final steps are taken
to improve the code even further in the very efficient third version of the code.
*The above codes are written for MSP430FR5969 Launchpad. ULP Advisor tool help us in
evaluating the code for optimizing power and energy before debugging and is the feature of
CCS.
GITAMW/ECE 77
delay_cycles
REQUIREMENTS:
Check the box next to the 'ULP_Case_Study' project in the Discovered projects window.
Click Finish.
GITAMW/ECE 78
• Set as active project by left-clicking on the project name. The active build configuration
should be Inefficient. If not, right click on the project name in the Project Explorer, then click
Build Configurations → Set Active → Inefficient.
GITAMW/ECE 79
• Build the project.
• The Advice window shows suggestions from the ULP Advisor under the Power (ULP)
Advice heading. Click View→ Advice.
GITAMW/ECE 80
• Click the link #1532-D, which corresponds to the first ULP violation (for using sprintf()), to
open the ULP Advisor wiki page in a second tab titled Advice. All of the information for this
particular rule violation is provided
• Scroll down to the Remedy section. The first suggestion is to avoid using sprintf() altogether
and work with the raw data
GITAMW/ECE 81
RESULTS1:
In the ULP Advisor of Inefficient.c, the first suggestion is to avoid using sprintf(). The next
version of code I,e Efficient.c ULP Advisor implements that advice as shown in the below
GITAMW/ECE 82
diagram.
RESULT2:
GITAMW/ECE 83
AIM:
Learning Objective:
Description:
In this experiment, we are going to use our Launchpad’s analog input pin to read the voltage of
an AA battery. AA batteries when fully charged have a voltage level of around 1.5 – 1.6V.
Throughout the life of an AA battery, not only does the charge in the battery go down, but the
voltage also starts to dip. Eventually, the battery’s charge and voltage will drop all the way down
to its end-of life limit, which for an AA battery is typically around ~0.9V.
At 0.9V, we can expect the ADC10 to give an integer reading of around 256.
So to check if a battery has any life left in it, we can use the given code to check if the ADC10
reading is >256. If not then we know that this battery has no life left to be useable.
In the present experiment, we will connect our AA battery to the analog input channel A4 and
use the Green LED to indicate sufficient voltage.
Requirements:
1 AA Battery
2 wires/probes
GITAMW/ECE 84
The positive terminal of the AA battery is connected to channel A4 which is the same as pin P1.4
GITAMW/ECE 85
FLOW CHART:
#include <msp430.h>
int main(void)
GITAMW/ECE 86
while(1)
RESULTS: As long as the green LED glows, we know that the battery has sufficient charge
GITAMW/ECE 87