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

EMBEDDED LAB MANUAL PDF

The document is a lab manual for the Embedded System Design course at BDT College of Engineering, detailing the syllabus and experiments for the B.E. VI Semester. It includes assembly language programming tasks and interfacing projects using the 8051 microcontroller. General instructions for students and a brief introduction to microcontrollers are also provided.
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)
30 views

EMBEDDED LAB MANUAL PDF

The document is a lab manual for the Embedded System Design course at BDT College of Engineering, detailing the syllabus and experiments for the B.E. VI Semester. It includes assembly language programming tasks and interfacing projects using the 8051 microcontroller. General instructions for students and a brief introduction to microcontrollers are also provided.
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/ 45

UNIVERSITY BDT COLLEGE OF ENGINEERING, Davanagere

(A constituent college of Visvesvaraya Technological University, Belagavi)

DEPARTMENT OF ELECTRONICS AND COMMUNICATION

EMBEDDED SYSTEM DESIGN


BEC601

B.E – VI Semester

Lab Manual 2025-26

Prepared by: Reviewed by:


SANGEETHA G R Dr. Manjanaik N
UNIVERSITY BDT COLLEGE OF ENGINEERING, Davanagere
(A constituent college of Visvesvaraya Technological University, Belagavi)

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

SYLLABUS
CO ARM & MICROCONTROLLERS LAB
Sub Code: EC601 IA Marks: 5
Hrs/week: 02

I. PROGRAMMING

1 Write an ALP to i) multiply two 16-bit binary numbers. ii) add two 64-bit numbers.
2 Write an ALP to find the sum of first 10 integer numbers.
3 Write an ALP to find factorial of a number.
4 Write an ALP to add an array of 16-bit numbers and store the 32-bit result in internal RAM.
5 Write an ALP to find the square of a number (1 to 10) using look-up table.
6 Write an ALP to find the largest/smallest number in an array of 32 numbers.
7 Write an ALP to arrange a series of 32-bit numbers in ascending/descending order.
8 i) Write an ALP to count the number of ones and zeros in two consecutive memory locations. ii)Write an
ALP to Scan a series of 32-bit numbers to find how many are negative.

II. INTERFACING

Write C programs to interface 8051 chip to Interfacing modules to develop single


chip solutions.

9 Interface a Stepper motor and rotate it in clockwise and anti-clockwise direction.


10 Interface a DAC and generate Triangular and Square waveforms.
11 Display the Hex digits 0 to F on a 7-segment LED interface, with a suitable delay in between.
12 Interface a simple Switch and display its status through Relay, Buzzer and LED.
GENERAL INSTRUCTIONS TO STUDENTS

• Students should come with thorough preparation for the experiment to be conducted.

• Students should take prior permission from the concerned faculty before availing the

leave.

• Students should come with formals. And to be present on time in the laboratory.

• Students will not be permitted to attend the laboratory unless they bring the practical

record fully completed in all respects pertaining to the experiment conducted in the

previous class.

• Students will be permitted to attend laboratory unless the bring the observation book

fully completed in all respects pertaining to the experiment conducted in the present class.

• They should obtain the signature of the staff-in-charge in the observation book after

completing each experiment.

• Practical record and observation book should be maintained neatly.


EMBEDDED SYSTEM DESIGN 2025-26

CONTENTS

PART-A1: Assembly language programming using 8051


1 Write an ALP to i) multiply two 16-bit binary numbers.
ii) add two 64-bit numbers.
2 Write an ALP to find the sum of first 10 integer numbers.
3 Write an ALP to find factorial of a number.
4 Write an ALP to add an array of 16-bit numbers and store the 32-bit result in internal RAM.
5 Write an ALP to find the square of a number (1 to 10) using look-up table.
6 Write an ALP to find the largest/smallest number in an array of 32 numbers.
7 Write an ALP to arrange a series of 32-bit numbers in ascending/descending order.
8 i) Write an ALP to count the number of ones and zeros in two consecutive memory locations.
ii)Write an ALP to Scan a series of 32-bit numbers to find how many are negative.

PART-B: 8051 Interfacing programs


9 Interface a Stepper motor and rotate it in clockwise and anti-clockwise direction.
10 Interface a DAC and generate Triangular and Square waveforms.
11 Display the Hex digits 0 to F on a 7-segment LED interface, with a suitable delay in between.
12 Interface a simple Switch and display its status through Relay, Buzzer and LED.

Dept. of ECE, UBDTCE,DAVANAGERE 1


EMBEDDED SYSTEM DESIGN 2025-26

INTRODUCTION

Earlier to Microcontrollers, Microprocessors were greatly used for each and


every purpose. Microprocessors were containing ALU, general purpose register, stack
pointer, program counter, clock counter and so many other features which the today’s
Microcontroller also possesses. But the difference between them exists with respect to
the number of instructions, access times, size, reliability, PCB size and so on.
Microprocessor contains large instruction set called as CISC processor whereas
Microcontroller contains less number of instructions and is called as RISC processor.
The access time is less in case of microcontrollers compared to microprocessors and
the PCB size reduces in case of microcontrollers.
There are many versions of microcontrollers 8051, 80528751, AT8951 from
Atmel Corporation and many more. In this manual we will study about the 8051
architecture, its features, programming and interfacing.
MCS 8051 is an 8-bit single chip microcontroller with many built-in functions
and is the core for all MCS-51 devices.
The main features of the 8051 core are:
 Operates with single Power Supply +5V.
 8-bit CPU optimized for control applications.
 16-bit program counter (PC) and 16-bit data pointer (DPTR).
 8-bit program status word (PSW).
 8-bit stack pointer (SP).
 4K Bytes of On-Chip Program Memory (Internal ROM or EPROM).
 128 bytes of On-Chip Data Memory (Internal RAM):
 Four Register Banks, each containing 8 registers (R0 to R7) [Total 32 reg]
 16-bytes of bit addressable memory.
 80 bytes of general-purpose data memory (Scratch Pad Area).
 Special Function Registers (SFR) to configure/operate microcontroller.
 32 bit bi-directional I/O Lines (4 ports P0 to P3).
 Two 16-bit timers/counters (T0 and T1).
 Full duplex UART (Universal Asynchronous Receiver/Transmitter).
 On-Chip oscillator and clock circuitry.

Dept. of ECE, UBDTCE,DAVANAGERE 2


EMBEDDED SYSTEM DESIGN 2025-26

EXTERNAL
INTERRUPTS

4K
ROM TIMER 1
INTERRUPT 128 Byte RAM COUNTER
CONTROL INPUTS
TIMER 0

CPU

OSC BUS CONTROL 4 I/O PORTS SERIAL CONTROL

P0 P2 P1 P3 TXD RXD
X1 X2
ADDRESS /
DATA

Fig.1. General Block Diagram of 8051 Microcontroller Architecture

STEPS TO CREATE AND COMPILE Keil µVision-3/4 PROJECT:

1. Double Click on the icon on the desktop.


2. Close any previous projects that were opened using – Project -> Close.
3. Start Project – New Project, and select the CPU from the device database
(Database-Atmel- AT89C51ED2 or AT89C51RD2 as per the board).On clicking
‘OK’, the following option is displayed. Choose ‘No’.

4. Create a source file (using File->New), type in the assembly or C program and save
this (filename.asm/filename.c) and add this source file to the project using either
one of the following two methods. (i) Project->Manage->Components,
Environment Books->addfiles-> browse to the required file -> OK
“OR” ii) right click on the Source Group in the Project Window and the Add
Files to Group option.

Dept. of ECE, UBDTCE,DAVANAGERE 3


EMBEDDED SYSTEM DESIGN 2025-26

5. Set the Target options using -> Project – Options for Target opens the
µ Options for Target – Target configuration dialog. Set the Xtal
(Crystal frequency) frequency as 11.0592 MHz, and also the Options for Target –
Debug – use either Simulator / Keil Monitor- 51 driver.

6. If Keil Monitor- 51 driver is used click on Settings -> COM Port settings select
the COM Port to which the board is connected and select the baud rate as 19200 or
9600 (recommended). Enable Serial Interrupt option if the user application is not
using on-chip UART, to stop program execution.
7. Build the project; using Project -> Build Project. 
application and links. Any errors in the code are indicated by – “Target not created”
in the Build window, along with the error line. Debug the errors. After an error free,
to build go to Debug mode.

8. Now user can enter into Debug mode with Debug- Start / Stop Debug session

dialog. Or by clicking in the icon.


9. The program is run using the Debug-Run command & halted using Debug-Stop

Running. Also the (reset, run, halt) icons can be used. Additional icons

are (step, step over, and step into, run till cursor).
10. If it is an interface program the outputs can be seen on the LCD, CRO, motor, led
status, etc. If it is a part-A program, the appropriate memory window is opened
using View -> memory window (for data RAM & XRAM locations), Watch
window (for timer program), serial window,etc. Note:
To access data RAM area type address as D: 0020h. Similarly to access the DPTR region (XRAM-
present on chip in AT89C51ED2) say 9000h location type in X: 09000H.

Dept. of ECE, UBDTCE,DAVANAGERE 4


EMBEDDED SYSTEM DESIGN 2025-26

Experiment 1
Write an ALP to i) multiply two 16-bit binary numbers.
ii) add two 64-bit numbers.

TO MULTIPLY TWO 16 BIT NUMBERS

ORG 0000H
MOV R0,#0FFH ;MSB1
MOV R1,#0EFH ;MSB2
MOV R2,#0FFH ;LSB1
MOV R3,#9DH ;LSB2
MOV A,R2
MOV B,R3
MUL AB
MOV R4,A
MOV R5,B
MOV A,R2
MOV B,R1
MUL AB
MOV R6,B
ADDC A,R5
MOV R5,A
MOV A,R1
MOV B,R4
MUL AB
ADDC A,R5
MOV R5,A
MOV A,B
ADDC A,R6
MOV R6,A
MOV A,R1
MOV B,R2
MUL AB
ADDC A,R6
MOV R6,A
MOV A,B
ADDC A,#00H
MOV R7,A
END

Dept. of ECE, UBDTCE,DAVANAGERE 5


EMBEDDED SYSTEM DESIGN 2025-26

TO ADD TWO 64 BIT NUMBERS

MOV DPTR ORG 0000H


JMP MAIN
SUBRT:
MOV A,@R0
MOV B.@R1
ADDC A,B
MOV 038H,A
JNC L5
L5:INC R7
DEC R0
DEC R1
RET
MAIN:CLR C
MOV R7,#0
MOV 017H,#8BH
MOV 016H,#7AH
MOV 015H,#6FH
MOV 014H,#5EH
MOV 013H,#4DH
MOV 012H,#3CH
MOV 011H,#2BH
MOV 010H,#1AH
MOV 025H,#1BH
MOV 024H,#2AH
MOV 023H,#3FH
MOV 022H,#4EH
MOV 021H,#5DH
MOV 020H,#6CH
MOV 019H,#7BH
MOV 018H,#8AH

Dept. of ECE, UBDTCE,DAVANAGERE 6


EMBEDDED SYSTEM DESIGN 2025-26

Experiment 2
Write an ALP to find the sum of first 10 integer numbers.

ORG 0x0000 ; Set the origin address

MOV R0, #0 ; Initialize the sum to zero


MOV R1, #1 ; Initialize the loop counter to 1

LOOP:
ADD A, R1 ; Add the current value of the loop counter to the accumulator
INC R1 ; Increment the loop counter
CJNE R1, #11, LOOP ; Continue the loop if the counter is less than 11

; At this point, the sum is stored in the accumulator

; You can store the result in a register or memory location if needed

HALT ; Halt the processor

END ; End of the program

Dept. of ECE, UBDTCE,DAVANAGERE 7


EMBEDDED SYSTEM DESIGN 2025-26

Experiment 3

Write an ALP to find factorial of a number.


SUM OF FIRST TEN INTEGER NUMBERS

ORG 0x0000 ; Set the origin address

MOV R0, #1 ; Initialize the sum to zero


MOV R1, #1 ; Initialize the loop counter to 1

LOOP:
ADD A, R1 ; Add the current value of the loop counter to the accumulator
INC R1 ; Increment the loop counter
CJNE R1, #11, LOOP ; Continue the loop if the counter is less than 11

; At this point, the sum is stored in the accumulator

; You can store the result in a register or memory location if needed

; For example, storing in register B:


MOV B, A

END

Dept. of ECE, UBDTCE,DAVANAGERE 8


EMBEDDED SYSTEM DESIGN 2025-26

Experiment 4

Write an ALP to add an array of 16-bit numbers and store the 32-bit result in internal RAM.

MOV DPTR, #0X1111 ; Load the address of the first 16-bit number
MOVX A, @DPTR ; Load the least significant byte of NUM1 to accumulator
ADD A, #0 ; Clear carry flag
MOV R0, A ; Store the result in R0

INC DPTR ; Move to the next byte of NUM1


MOVX A, @DPTR ; Load the most significant byte of NUM1 to accumulator
ADDC A, #0 ; Add with carry
MOV R1, A ; Store the result in R1

MOV DPTR, #0X1234 ; Load the address of the second 16-bit number
MOVX A, @DPTR ; Load the least significant byte of NUM2 to accumulator
ADD A, R0 ; Add with the least significant byte of NUM1
MOV R0, A ; Store the result in R0

INC DPTR ; Move to the next byte of NUM2


MOVX A, @DPTR ; Load the most significant byte of NUM2 to accumulator
ADDC A, R1 ; Add with the most significant byte of NUM1 and carry
MOV R1, A ; Store the result in R1

; At this point, R0 and R1 contain the least and most significant parts of the 32-bit result

INC DPTR
END

Dept. of ECE, UBDTCE,DAVANAGERE 9


EMBEDDED SYSTEM DESIGN 2025-26

Experiment 5
Write an alp to find the square of a number

; Square of a number in 8051 assembly language

ORG 0x0000 ; Start address of the program

MOV A, #5 ; Load the number to be squared into register A

MOV B, A ; Copy the number to register B for multiplication

MUL AB ; Multiply the number in A with B, result in B:A

MOV DPL, A ; Copy the least significant byte of the result to DPL
MOV DPH, B ; Copy the most significant byte of the result to DPH

; Now, DPH:DPL contains the square of the original number

END ; End of the program

Dept. of ECE, UBDTCE,DAVANAGERE 10


EMBEDDED SYSTEM DESIGN 2025-26

Experiment 6
Write an ALP to find the largest/smallest number in an array of 32 numbers.

ORG 0x0000 ; Start address of the program

ARRAY_SIZE EQU 4 ; Number of elements in the array (32 bits / 4 bytes)


ARRAY_ADDR EQU 0x2000 ; Starting address of the array in external RAM

MAIN:
MOV DPTR, #ARRAY_ADDR ; Load the starting address of the array
MOV R0, #0 ; Initialize loop counter R0
MOV A, #0xFF ; Initialize smallest value to maximum
MOV B, #0 ; Initialize largest value to minimum

LOOP:
MOVX A, DPTR ; Load the current 32-bit value from the array

; Check if the current value is smaller than the smallest


CJNE A, 0xFF, NOT_LESS_THAN_SMALLEST ; If not equal to 0xFF, proceed

MOV A, B ; Update the smallest value


SJMP CONTINUE_LOOP

NOT_LESS_THAN_SMALLEST:
; Check if the current value is greater than the largest
CJNE A, B, NOT_GREATER_THAN_LARGEST ; If not equal to B, proceed

MOV A, B ; Update the largest value

NOT_GREATER_THAN_LARGEST:
INC DPTR ; Move to the next 32-bit value in the array
INC R0 ; Increment loop counter
CJNE R0, #ARRAY_SIZE, LOOP ; Continue the loop until all elements are processed

; At this point, A contains the smallest value, and B contains the largest value

CONTINUE_LOOP:
; Add any further processing or output as needed

END ; End of the program

Dept. of ECE, UBDTCE,DAVANAGERE 11


EMBEDDED SYSTEM DESIGN 2025-26

7 Write an ALP to arrange a series of 32-bit numbers in ascending/descending order.

.MODEL SMALL
.STACK 100H
.DATA
NUMBERS DB 5, 3, 8, 1, 9 ; Array of numbers to be sorted
COUNT DB 5 ; Number of elements in the array
MSG1 DB 'Sorted in Ascending Order: $'
MSG2 DB 0DH, 0AH, 'Sorted in Descending Order: $'

.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX

; Display message for ascending order


MOV DX, OFFSET MSG1
MOV AH, 09H
INT 21H

CALL SORT_ASCENDING
CALL DISPLAY_ARRAY

; Display message for descending order


MOV DX, OFFSET MSG2
MOV AH, 09H
INT 21H

CALL SORT_DESCENDING
CALL DISPLAY_ARRAY

MOV AH, 4CH


INT 21H

MAIN ENDP

;----------------------------------------------------------
; Subroutine to Sort Array in Ascending Order (Bubble Sort)
;----------------------------------------------------------
SORT_ASCENDING PROC
MOV CX, COUNT
DEC CX
OUTER_LOOP1:
MOV SI, 0
MOV DX, CX
INNER_LOOP1:
MOV AL, NUMBERS[SI]
MOV BL, NUMBERS[SI+1]
CMP AL, BL
JBE SKIP_SWAP1
; Swap values
MOV NUMBERS[SI], BL
MOV NUMBERS[SI+1], AL
SKIP_SWAP1:
INC SI
DEC DX
JNZ INNER_LOOP1
LOOP OUTER_LOOP1
RET
SORT_ASCENDING ENDP

Dept. of ECE, UBDTCE,DAVANAGERE 12


EMBEDDED SYSTEM DESIGN 2025-26

;----------------------------------------------------------
; Subroutine to Sort Array in Descending Order (Bubble Sort)
;----------------------------------------------------------
SORT_DESCENDING PROC
MOV CX, COUNT
DEC CX
OUTER_LOOP2:
MOV SI, 0
MOV DX, CX
INNER_LOOP2:
MOV AL, NUMBERS[SI]
MOV BL, NUMBERS[SI+1]
CMP AL, BL
JAE SKIP_SWAP2
; Swap values
MOV NUMBERS[SI], BL
MOV NUMBERS[SI+1], AL
SKIP_SWAP2:
INC SI
DEC DX
JNZ INNER_LOOP2
LOOP OUTER_LOOP2
RET
SORT_DESCENDING ENDP

;----------------------------------------------------------
; Subroutine to Display Array Elements
;----------------------------------------------------------
DISPLAY_ARRAY PROC
MOV CX, COUNT
MOV SI, 0
DISPLAY_LOOP:
MOV DL, NUMBERS[SI] ; Get number
ADD DL, 30H ; Convert to ASCII
MOV AH, 02H
INT 21H ; Print character
MOV DL, ' ' ; Print space
INT 21H
INC SI
LOOP DISPLAY_LOOP
MOV DL, 0DH ; New Line
INT 21H
MOV DL, 0AH
INT 21H
RET
DISPLAY_ARRAY ENDP

END MAIN

Dept. of ECE, UBDTCE,DAVANAGERE 13


EMBEDDED SYSTEM DESIGN 2025-26

8 i) Write an ALP to count the number of ones and zeros in two consecutive memory locations.
ii)Write an ALP to Scan a series of 32-bit numbers to find how many are negative.
To count zeros

ORG 0H
MOV DPTR,# DATA START
MOV R0,#00
MOV R1,#00
MOVX A,@DPTR
CALL CountBits
CountBits:
MOV B,#09
CountLoop:
Rlc a
JNC OnesBit
JNC R1
SJMP BitEnd
OnesBit:
JNC R0
Bit END:
DJNZ B,CountLoop
RET
DatatStart:
DB 10101011B
DB 11001100B
END

TO FIND NEGATIVE NUMBERS

ORG 0H
MOV DPTR,#5000H
MOVX A,@DPTR
CPLA
INC A
MOV DPTR,#6000H
MOVX @DPTR,A
END

Dept. of ECE, UBDTCE,DAVANAGERE 14


EMBEDDED SYSTEM DESIGN 2025-26

HARDWARE PROGRAMS
Steps
Project Creation in Keil uvision4 IDE:
_ Create a project folder before creating NEW project.
_ Use separate folder for each project
_ Open Keil uVision4 IDE software by double clicking on “Keil Uvision4” icon.
_ Go to “Project” then to “New Project” and save it with a name in the
Respective Project folder, already you created.
_ Select the device as “NXP (founded by Philips)” In that “LPC1768” then
Press OK and then press “NO” button to add “system_LPC17xx.s” file.
_ Go to “File” In that “New” to open an editor window. Create your source file
And use the header file “LPC17xx.h” in the source file and save the file. Color
syntax highlighting will be enabled once the file is saved with a Recognized
extension such as “.C “.
_ Right click on “Source Group 1” and select the option “Add Files to Group
'Source Group 1' “add the. C source file(s) to the group.
_ Again right click on Source Group 1 and select the option “Add Existing Files
to Group 'Source Group 1' “add the library file start.lib : So it is
recommended to copy the file
CD:ALS-SDA-ARMCTXM3-06 \SOFTWARE\library\standard_library\start.lib to the project folder and add to the
source group.
_ Then go to “Project” in that “Translate” to compile the File (s).
_ Go to “Project” in that “Build Target” for building all source files such as
“.C”,”.ASM”, “.h”, files, etc…This will create the hex file if no warnings & no
Errors.
_ In Project Window Right click “TARGET1” and select “options for target
‘TARGET1’
_ Then go to option “Target” in that
_ Xtal 12.0MHz and Use MicroLIB
_ Select IROM1 (starting 0×0 size 0×8000).
_ Select IRAM1 (starting 0×10000000 size 0×8000).
_ Then go to option “Output”
_ Select “Create Hex file”.
_ Then go to option “Linker”
_ Select use memory layout from target dialogue

Go to Flash Magic, select port by checking in ‘this pc’-properties-ports


Upload the hex file, switch on the kit, run the program

Dept. of ECE, UBDTCE,DAVANAGERE 15


EMBEDDED SYSTEM DESIGN 2025-26

Experiment 9
Interface a Stepper motor and rotate it in clockwise and anti-clockwise direction.

a. Circuit Diagram:

8 P 0.0 Stepper
Motor Stepper
0 Motor
Driver circuit
5 P 0.7
1

Theory:
Stepper motor is an electromechanical device which converts electrical
pulses into discrete mechanical movements. The shaft or spindle of a stepper motor
rotates in discrete step increments when electrical command pulses are applied to it
in the proper sequence. The motors rotation has several direct relationships to these
applied input pulses. The sequence of the applied pulses is directly related to the
direction of motor shafts rotation. The speed of the motor shafts rotation is directly
related to the frequency of the input pulses and the length of rotation is directly
related to the number of input pulses applied.

Stepper Motor Advantages:


1. The rotation angle of the motor is proportional to the input pulse.
2. The motor has full torque at standstill (if the windings are energized)
3. Precise positioning and repeatability of movement since good stepper motors
have an accuracy of 3 – 5% of a step and this error is non cumulative from
one step to the next.
4. Excellent response to starting/stopping/reversing.
5. Very reliable since there are no contact brushes in the motor. Therefore the
life of the motor is simply dependant on the life of the bearing.
6. The motors response to digital input pulses provides open-loop
control, making the motor simpler and less costly to control.
7. It is possible to achieve very low speed synchronous rotation with a load
that is directly coupled to the shaft.
8. A wide range of rotational speeds can be realized as the speed is
proportional to the frequency of the input pulses.
Stepper Motor Disadvantages:
1. Resonances can occur if not properly controlled.
2. Not easy to operate at extremely high speeds.
Open Loop Operation:
One of the most significant advantages of a stepper motor is its ability to be
accurately controlled in an open loop system. Open loop control means no feedback
information about position is needed. This type of control eliminates the need for

Dept. of ECE, UBDTCE,DAVANAGERE 16


EMBEDDED SYSTEM DESIGN 2025-26

expensive sensing and feedback devices such as optical encoders. Your position is
known simply by keeping track of the input step pulses.

#include <LPC17xx.H>
void clock_wise(void);
void anti_clock_wise(void);
unsigned long int var1,var2;
unsigned int i=0,j=0,k=0;

int main(void)
{
LPC_PINCON->PINSEL4 = 0x00000000; //P2.0 to P2.3 GPIO
LPC_GPIO2->FIODIR = 0x0000000F; //P2.0 to P2.3 output
while(1)
{
for(j=0;j<50;j++) //50 times in Clock wise Rotation
clock_wise();

for(k=0;k<65000;k++); //Delay to show anti_clock Rotation

for(j=0;j<50;j++) //50 times in Anti Clock wise Rotation


anti_clock_wise();

for(k=0;k<65000;k++); //Delay to show clock Rotation


}
//End of while(1)
}
//End of main
void clock_wise(void)
{
var1 = 0x00000001; //For Clockwise
for(i=0;i<=3;i++) //for A B C D Stepping
{
LPC_GPIO2->FIOCLR = 0X0000000F;
LPC_GPIO2->FIOSET = var1;
var1 = var1<<1; //For Clockwise
for(k=0;k<15000;k++); //for step speed variation
}
}
void anti_clock_wise(void)
{
var1 = 0x0000008; //For Anticlockwise
for(i=0;i<=3;i++) //for A B C D Stepping
{
LPC_GPIO2->FIOCLR = 0X0000000F;
LPC_GPIO2->FIOSET = var1;
var1 = var1>>1; //For Anticlockwise
for(k=0;k<15000;k++); //for step speed variation
}
}

Dept. of ECE, UBDTCE,DAVANAGERE 17


EMBEDDED SYSTEM DESIGN 2025-26

Experiment 10
Interface a DAC and generate Triangular waveform. */
/********************************************************************
*
ARM MBED LPC1768 has a 10-bit DAC in-built with single DAC (analog output) channel. This DAC can be used to
output analog data on the only single pin (p18). This analog output data can vary in the range between VSS and VCC.

The DAC can be used to generate a sine wave signal. To generate this signal, the VREF and the DAC are initialized first,
then the output value can be changed by writing a new value to the DACn. DATA register. Before the sine wave is
generated, the samples corresponding to a period are calculated and stored in a buffer.

Input 00H and FFH at regular intervals, to generate a square wave. The frequency can be varied by varying the time delay.
TRIANGULAR WAVEFORM GENERATION By outputing digital data from 00H to FFH in steps of 01H and then
from FFH to 00H. Decrementing in steps of 01H, the triangular waveform is generated.

* External DAC interface (Triangle Wave)


* Controller : LPC1768
* Project : ALS-SDA-ARMCTXM3-06
* Description : This example explains about how Triangular Wave is generated.P0.4 to P0.11 are used to get the
Digital values.
0xff
/\ /\
/ \ / \
/ \ / \
/ \ / \
/ \ / \
0x00 / \/ \

********************************************************************
*******/
#include <LPC17xx.H>
int main ()
{
unsigned long int temp=0x00000000;
unsigned int i=0;

LPC_PINCON->PINSEL0 &= 0xFF0000FF ; // Configure P0.4 to


P0.11 as GPIO
LPC_GPIO0->FIODIR |= 0x00000FF0 ;
LPC_GPIO0->FIOMASK = 0XFFFFF00F;

while(1)
{//output 0 to FE
for(i=0;i!=0xFF;i++)
{
temp=i;
temp = temp << 4;
LPC_GPIO0->FIOPIN = temp;
}
// output FF to 1
for(i=0xFF; i!=0;i--)
{
temp=i;
temp = temp << 4;
LPC_GPIO0->FIOPIN = temp;
}
}//End of while(1)

Dept. of ECE, UBDTCE,DAVANAGERE 18


EMBEDDED SYSTEM DESIGN 2025-26

}//End of main()
Interface a DAC and generate Square waveform. */
/********************************************************************
*
* External DAC interface (Square Wave)
* Controller : LPC1768
* Project : ALS-SDA-ARMCTXM3-06
* Description : This example explains about how Sqaure Wave is generated.P0.4 to P0.11 are used to get the Digital
values.
0xff ________
| | |
| | |
| | |
| |
|
0x00 | |_________|

***************************************************************************/
#include <LPC17xx.H>
void delay(void);
int main ()
{
LPC_PINCON->PINSEL0 &= 0xFF0000FF ; //
Configure P0.4 to P0.11 as GPIO
LPC_GPIO0->FIODIR |= 0x00000FF0 ;
LPC_GPIO0->FIOMASK = 0XFFFFF00F;
while(1)
{
LPC_GPIO0->FIOPIN = 0x00000FF0 ;
delay();
LPC_GPIO0->FIOCLR = 0x00000FF0 ;
delay();
}
}

void delay(void)
{
unsigned int i=0;
for(i=0;i<=9500;i++);
}

Dept. of ECE, UBDTCE,DAVANAGERE 19


EMBEDDED SYSTEM DESIGN 2025-26

Experiment 11
Display the Hex digits 0 to F on a 7-segment LED interface, with an appropriate delay in
between. */

• Read the numbers n1 and n2 from keyboard and display them on


seven segment.
• Read the operand from the keypad if key pressed is B (+), C (-), D (*), E
(/) then respective operation is performed.
• Result is displayed on 2 digit seven segment display.
• If any time the key pressed value returned as 10h then clear the LCD.

PS
PS

Keypad

8051µC

7-Seg
Display

/* Description :\\\\\\\\\\\\\\\DISPLAY ARE CONNECTED IN COMMON CATHODE


MODE\\\\\\\\\\\\\\\\\\\\\
Port0 Connected to data lines of all 7 segement displays
a
----
f| g |b
|----|
e| |c
---- . dot
d
a = P0.04
b = P0.05
c = P0.06
d = P0.07
e = P0.08
f = P0.09
g = P0.10
dot = P0.11
*//

Dept. of ECE, UBDTCE,DAVANAGERE 20


EMBEDDED SYSTEM DESIGN 2025-26

#include <LPC17xx.h>
unsigned int delay, count=0, Switchcount=0,j;

unsigned int Disp[16]={0x000003f0, 0x00000060, 0x000005b0, 0x000004f0, 0x00000660,0x000006d0,


0x000007d0, 0x00000070, 0x000007f0, 0x000006f0,
0x00000770,0x000007c0,
0x00000390, 0x000005e0, 0x00000790, 0x00000710 };

#define ALLDISP 0x00180000


//Select all display
#define DATAPORT 0x00000ff0
//P0.4 to P0.11 : Data lines connected to drive Seven Segments
int main (void)
{
LPC_PINCON->PINSEL0 = 0x00000000;
LPC_PINCON->PINSEL1 = 0x00000000;
LPC_GPIO0->FIODIR = 0x00180ff0;

while(1)
{
LPC_GPIO0->FIOSET |= ALLDISP;
LPC_GPIO0->FIOCLR = 0x00000ff0;
// clear the data lines to 7-segment displays
LPC_GPIO0->FIOSET = Disp[Switchcount]; // get the 7-segment display
value from the array

for(j=0;j<4;j++)
for(delay=0;delay<30000;delay++); //
delay

Switchcount++;
if(Switchcount == 0x10)
// 0 to F has been displayed ? go back to 0
{
Switchcount = 0;
LPC_GPIO0->FIOCLR = 0x00180ff0;
}
}
}

Dept. of ECE, UBDTCE,DAVANAGERE 21


EMBEDDED SYSTEM DESIGN 2025-26

Experiment 12
Interface a simple Switch and display its status through Relay, Buzzer and LED. */

PIC is a family of Harvard architecture microcontrollers made by Microchip Technology. The PIC architecture is
distinctively minimalist. It is characterized by the following features:

• Separate code and data spaces (Harvard architecture).


• A small number of fixed length instructions.
• Single-cycle execution (4 clock cycles).
• A single accumulator (W), the use of which (as source operand) is implied (i.e. is not encoded in the opcode).
• All RAM locations function as registers as both source and/or destination of math and other functions.
• 32 Kb Flash memories, 2K RAM, 256 bytes EEPROM.
• 2 comparators, 10 bit 13 channel ADC, 35 I/O Ports, 3 Timers, SPI and I2C supported.

#include <LPC17xx.H>
int main(void)
{
LPC_PINCON->PINSEL1 = 0x00000000;
//P0.24,P0.25 GPIO
LPC_GPIO0->FIODIR = 0x03000000;
//P0.24 configured output for buzzer,P0.25 configured output for Relay/Led
while(1)
{
if(!(LPC_GPIO2->FIOPIN & 0x00000800)) //Is GP_SW(SW4) is
pressed??
{
LPC_GPIO0->FIOSET = 0x03000000;
//relay on
}
else
{
LPC_GPIO0->FIOCLR = 0x03000000;
//relay off
}
}
}//end int main(void)

Dept. of ECE, UBDTCE,DAVANAGERE 22


EMBEDDED SYSTEM DESIGN 2025-26

Additional Programs
1. Program to generate arithmetic progression. //Tn=a+(n-

1)d
mov r1,#03h //d
mov r2,#01h //a mov r3,#08h
mov
r0,#30h
mov
30h,r2
mov
r4,#01h
next: mov a,r1
mov
b,r4
mul
ab
addc
a,r2
inc r0
mov
@r0,a
inc r4
djnz
r3,next
end

2. Program to find the 2 out of 5 code.

mov r0,#30h ; r0 as pointer


mov a,@r0 ; no. to the Acc.
ANL a,#0e0h
jnz notvalid ; checks the 1st 3bits
mov a,@r0
mov r2,#5 ; r2 as counter
mov r1,#00h ; r0 stores no. of ones
clr c
check: rrc a
jnc skip
inc r1 ; if carry increment r1
skip: djnz r2,check
mov A,r1
clr c
subb A,#02h
jnz notvalid ; (a)!= 0 ===> (r2)!= 2 no. is not valid.
inc r0
mov @r0,#0ffh ; valid 2 out of 5 code
sjmp exit
Dept. of ECE, UBDTCE,DAVANAGERE 23
EMBEDDED SYSTEM DESIGN 2025-26

notvalid: inc r0
mov @r0,#11h ; in valid 2 out of 5 code
exit: sjmp exit
end

Dept. of ECE, UBDTCE,DAVANAGERE 24


EMBEDDED SYSTEM DESIGN 2025-26

3. Program to generate first ten Fibonacci numbers.

Mov dptr, #9000h


Mov r3, #08h
Movx a, @dptr
Mov r0,a
Inc dptr
Movx a, @dptr
Back: xch a, r0
Add a,r0
Inc dptr
Movx @dptr,a
Djnz r3,back
Lcall 0003h

4. Program to add multibyte numbers.

Mov dptr,#9000h
Mov r1,#04h
Mov r2,#90h
Mov r3,#91h
Mov r4,#92h
Clr c
Mov dph,r2
Back: movx a, @dptr
Mov r5,a
Mov dph,r3
Movx a,@dptr
Addc a,r5 //Note:For multibyte subtraction put subb a,r5
Mov dph,r4
Movx @dptr,a
Inc dptr
Djnz r1,back
Jnc end1
Mov a,#01h
Movx @dptr, a
End1:lcall 0003h
End

Dept. of ECE, UBDTCE,DAVANAGERE 25


EMBEDDED SYSTEM DESIGN 2025-26

REFERENCES

1. “The 8051 Microcontroller and Embedded Systems – using assembly and C ”-,
by Muhammad Ali, Mazidi and Janice Gillespie Mazidi and Rollin D. McKinlay; PHI,
2006 / Pearson, 2006

2. “MSP430 Microcontroller Basics”, John Davies, Elsevier, 2010

3. “The 8051 Microcontroller Architecture, Programming & Applications”, 2e


Kenneth J. Ayala ;Penram International, 1996 / Thomson Learning 2005.

4. “The 8051 Microcontroller”, V.Udayashankar and MalikarjunaSwamy, TMH,


2009

5. “Microcontrollers: Architecture, Programming, Interfacing and System


Design”,Raj Kamal, “Pearson Education, 2005

Dept. of ECE, UBDTCE,DAVANAGERE 26


EMBEDDED SYSTEM DESIGN 2025-26

Viva Questions
1. What do you mean by Embedded System? Give examples.
2. Why are embedded Systems useful?
3. What are the segments of Embedded System?
4. What is Embedded Controller?
5. What is Microcontroller?
6. List out the differences between Microcontroller and Microprocessor.
7. How are Microcontrollers more suitable than Microprocessor for Real Time
Applications?
8. What are the General Features of Microcontroller?
9. Explain briefly the classification of Microcontroller.
10. Explain briefly the Embedded Tools.
11. Explain the general features of 8051 Microcontroller.
12. How many pin the 8051 has?
13. Differentiate between Program Memory and Data Memory.
14. What is the size of the Program and Data memory?
15. Write a note on internal RAM. What is the necessity of register banks? Explain.
16. How many address lines are required to address 4K of memory? Show the
necessary calculations.
17. What is the function of accumulator?
18. What are SFR’s? Explain briefly.
19. What is the program counter? What is its use?
20. What is the size of the PC?
21. What is a stack pointer (SP)?
22. What is the size of SP?
23. What is the PSW? And briefly describe the function of its fields.
24. What is the difference between PC and DPTR?
25. What is the difference between PC and SP?
26. What is ALE? Explain the functions of the ALE in 8051.
27. Describe the 8051 oscillator and clock.
28. What are the disadvantages of the ceramic resonator?
29. What is the function of the capacitors in the oscillator circuit?
30. Show with an example, how the time taken to execute an instruction can be
calculated.
31. What is the Data Pointer register? What is its use in the 8051?
32. Explain how the 8051 implement the Harvard Architecture?
33. Explain briefly the difference between the Von Neumann and the Harvard
Architecture.
34. Describe in detail how the register banks are organized.
35. What are the bit addressable registers and what is the need?
36. What is the need for the general purpose RAM area?
37. Write a note on the Stack and the Stack Pointer.
38. Why should the stack be placed high in internal RAM?
39. Explain briefly how internal and external ROM gets accessed.
40. What are the different addressing modes supported by 8051 Microcontroller ?
41. Explain the Immediate Addressing Mode.
42. Explain the Register Addressing Mode.
43. Explain the Direct Addressing Mode.

Dept. of ECE, UBDTCE,DAVANAGERE 27


EMBEDDED SYSTEM DESIGN 2025-26

44. Explain the Indirect Addressing Mode.


45. Explain the Code Addressing Mode.
46. Explain in detail the Functional Classification of 8051 Instruction set
47. What are the instructions used to operate stack?
48. What are Accumulator specific transfer instructions?
49. What is the difference between INC and ADD instructions?
50. What is the difference between DEC and SUBB instructions?
51. What is the use of OV flag in MUL and DIV instructions?
52. What are single and two operand instructions?
53. Explain Unconditional and Conditional JMP and CALL instructions.
54. Explain the different types of RETURN instructions.
55. What is a software delay?
56. What are the factors to be considered while deciding a software delay?
57. What is a Machine cycle?
58. What is a State?
59. Explain the need for Hardware Timers and Counters?
60. Give a brief introduction on Timers/Counter.
61. What is the difference between Timer and Counter operation?
62. How many Timers are there in 8051?
63. What are the three functions of Timers?
64. What are the different modes of operation of timer/counter?
65. Give a brief introduction on the various Modes.
66. What is the count rate of timer operation?
67. What is the difference between mode 0 and mode 1?
68. What is the difference Modes 0,1,2 and 3?
69. How do you differentiate between Timers and Counters?
70. Explain the function of the TMOD register and its various fields?
71. How do you control the timer/counter operation?
72. What is the function of TF0/TF1 bit
73. Explain the function of the TCON register and its various fields?
74. Explain how the Timer/Counter Interrupts work.
75. Explain how the 8051 counts using Timers and Counters.
76. Explain Counting operation in detail in the 8051.
77. Explain why there is limit to the maximum external frequency that can be
counted.
78. What’s the benefit of the auto-reload mode?
79. Write a short note on Serial and Parallel communication and highlight their
advantages and disadvantages.
80. Explain Synchronous Serial Data Communication.
81. Explain Asynchronous Serial Data Communication.
82. Explain Simplex data transmission with examples.
83. Explain Half Duplex data transmission with examples.
84. Explain Full Duplex data transmission with examples.
85. What is Baud rate?
86. What is a Modem?
87. What are the various registers and pins in the 8051 required for Serial
communication? Explain briefly.
88. Explain SCON register and the various fields.
89. Explain serial communication in general (synchronous and asynchronous). Also
explain the use of the parity bit.

Dept. of ECE, UBDTCE,DAVANAGERE 28


EMBEDDED SYSTEM DESIGN 2025-26

90. Explain the function of the PCON register during serial data communication.
91. How the Serial data interrupts are generated?
92. How is data transmitted serially in the 8051? Explain briefly.
93. How is data received serially in the 8051? Explain briefly.
94. What are the various modes of Serial Data Transmission? Explain each mode
briefly.
95. Explain with a timing diagram the shift register mode in the 8051.
96. What is the use of the serial communication mode 0 in the 8051?
97. Explain in detail the Serial Data Mode 1 in the 8051.
98. Explain how the Baud rate is calculated for the Serial Data Mode 1.
99. How is the Baud rate for the Multiprocessor communication Mode calculated?
100. Explain in detail the Multiprocessor communication Mode in the 8051.
101. Explain the significance of the 9th bit in the Multiprocessor communication
Mode.
102. Explain the Serial data mode 3 in the 8051.
103. What are interrupts and how are they useful in Real Time Programming?
104. Briefly describe the Interrupt structure in the 8051.
105. Explain about vectored and non-vectored interrupts in general.
106. What are the five interrupts provided in the 8051?
107. What are the three registers that control and operate the interrupts in 8051?
108. Describe the Interrupt Enable (IE) special function register and its various
bits.
109. Describe the Interrupt Priority (IP) special function register and its need.
110. Explain in detail how the Timer Flag interrupts are generated.
111. Explain in detail how the Serial Flag interrupt is generated.
112. Explain in detail how the External Flag interrupts are generated.
113. What happens when a high logic is applied on the Reset pin?
114. Why the Reset interrupt is called a non-maskable interrupt?
115. Why do we require a reset pin?
116. How can you enable/disable some or all the interrupts?
117. Explain how interrupt priorities are set? And how interrupts that occur
simultaneously are handled.
118. What Events can trigger interrupts, and where do they go after getting
triggered?
119. What are the actions taken when an Interrupt Occurs?
110. What are Software generated interrupts and how are they generated?
111. What is RS232 and MAX232?
112. What is the function of RS and E pins in an LCD?
113. What is the use of R/W pin in an LCD?
114. What is the significance of DA instruction?
115. What is packed and unpacked BCD?
116. What is the difference between CY and OV flag?
117. When will the OV flag be set?
118. What is an ASCII code?

Dept. of ECE, UBDTCE,DAVANAGERE 29


EMBEDDED SYSTEM DESIGN 2025-26

MICROCONTROLLER - LAB QUESTION BANK

1. a) Write an ALP to move a Block of N-data starting at location X to location Y


using 8051/MSP430
b) Write a C program to interface stepper motor to 8051.

2. a) Write an ALP to find cube of given 8-bit data using 8051 /MSP430.
b) Write a C program to interface stepper motor to 8051.

3. a) Write an ALP to implement a binary/decimal up/down counter using 8051


/MSP430.
b) Write a C program to interface stepper motor to 8051.

4. a) Write an ALP to find the largest / smallest element in an array using 8051.
b) Write a C program to interface stepper motor to 8051.

5. a) Write an ALP to exchange two blocks of data present at location X and Y


respectively using 8051/MSP430
b) Write a C program to generate Sine waveform using DAC. Display the
waveform on CRO.

6. a) Write an ALP to arrange a set of N 8-bit numbers starting at location X in


ascending/descending order using 8051 /MSP430.
b) Write a C program to generate triangular wave of amp = (1V-5V) using
DAC. Display the waveform on CRO.

7. a) Write an ALP to perform 16-bit multiplication using 8051 /MSP430.


b) Write a C program to generate Ramp wave of amp = (1V-5V) using DAC.
Display the waveform on CRO.

8. a) Write an ALP to convert two digit BCD number to its equivalent ASCII value
using 8051 /MSP430.
b) Write a C program to generate square wave of amp = (1V-5V) using
DAC. Display the waveform on CRO.

9. a) Write an ALP to find whether the given number is palindrome or not using
8051.
b) Write a C program to generate Sine waveform using DAC. Display the
waveform on CRO.

Dept. of ECE, UBDTCE,DAVANAGERE 30


EMBEDDED SYSTEM DESIGN 2025-26

10. a) Write an ALP to convert given Hexadecimal number to its equivalent Decimal
number using 8051 /MSP430.
b) Write a C program to interface DC motor to 8051.

11. a) Write an ALP to convert given Decimal number to its equivalent Hexadecimal
using 8051 /MSP430.
b) Write a C program to interface DC motor to 8051.

12. a) Write an ALP to perform 16-bit addition/subtraction using 8051/ MSP430.


b) Write a C program to interface DC motor to 8051.

13. a) Write an ALP to count number of 1’s and 0’s in the given 8-bit data using 8051
/MSP430.
b) Write a C program to interface Elevator to 8051.

14. a) Write an ALP to convert given ASCII number to its equivalent Decimal
number.
b) Write a C program to interface Elevator to 8051

15. a) Write an ALP to find whether given number is even or odd using 8051
/MSP430.
b) Write a C program to interface LCD panel and Hex keypad to 8051.

16. a) Write an ALP to convert given Decimal number to its equivalent ASCII using
8051 /MSP430.
b) Write a C program to interface LCD panel and Hex keypad to 8051.

Dept. of ECE, UBDTCE,DAVANAGERE 31


EMBEDDED SYSTEM DESIGN 2025-26

Annexure-A
MCS-51 Instruction set
Instruction Set

Dept. of ECE, UBDTCE,DAVANAGERE 32


EMBEDDED SYSTEM DESIGN 2025-26

Dept. of ECE, UBDTCE,DAVANAGERE 33


EMBEDDED SYSTEM DESIGN 2025-26

Dept. of ECE, UBDTCE,DAVANAGERE 34


EMBEDDED SYSTEM DESIGN 2025-26

Annexure -B
8051 Special Function Registers:
1. Timer Mode Control Register (TMOD):
TMOD can be considered to be two duplicate 4-bit registers, each of which
controls the action of one of the timers. The “Timer” or “Counter” function is selected
by control bits C/T, and in different operating modes, which are selected by bit-pairs
(M1, M0) in TMOD.
MSB LSB
GATE C/T M1 M0 GATE C/T M1 M0

Timer 1 Timer 0
Gating control when set. Counter “x” is enabled only while “INTx” pin is
GATE high and “TRx” control pin is set. When cleared Timer “x” is enabled
whenever “TRx” control bit is set.
Timer or Counter Selector cleared for Timer operation (input from internal
C/T system clock.) Set for Counter operation (input from “Tx” input pin).
M1 M0 OPERATI0N
0 0 13-bit Timer/Counter 5-bits of “TLx” and 8-bits of “THx” are used.
0 1 16-bit Timer/Counter 8-bits of “TLx” and 8-bits of “THx” are cascaded.
8-bit auto-reload Timer/Counter “THx” holds a value which is to be
1 0
reloaded into “TLx” each time it overflows.
(Timer 0) TL0 is an 8-bit Timer/Counter controlled by the standard Timer
1 1 0 control bits. TH0 is an 8-bit timer only controlled by Timer 1 control bits.
Timer/Counter 1 stopped.

2. Interrupt Enable (IE) Register :

Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0


EA x x ES ET1 EX1 ET0 EX0

Symbol Name and Function


Enable All. If 0, Disables all interrupts and no interrupt is acknowledged. If
EA 1, each interrupt can be individually enabled or disabled by programming
appropriate bit.
x Reserved
x -
ES Enable Serial Interrupt. If 1, enables TI or RI to generate interrupt.

ET1 Enable Timer 1 interrupt. If 1, Enables the TF1 to generate the interrupt.
EX1 Enable External interrupt 1. If 1, Enables the INT1 to generate the interrupt.
ET0 Enable Timer 0 interrupt. If 1, Enables the TF0 to generate the interrupt.
EX0 Enable External interrupt 0. If 1, Enables the INT0 to generate the interrupt.

Dept. of ECE, UBDTCE,DAVANAGERE 35


EMBEDDED SYSTEM DESIGN 2025-26

3. Timer Control Register (TCON):


TCON has control bits and flags for the timers in the upper nibble, and control
bits and flags for the external interrupts in lower nibble.
MSB LSB
TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0

Bit Symbol Function


Timer 1 overflow flag. Set by hardware on Timer/Counter
TCON.7 TF1 overflow. Cleared by hardware when processor vectors to
interrupt routine, or clearing the bit in software.
Timer 1 Run control bit. Set/cleared by software to turn
TCON.6 TR1
Timer/Counter on/off.
Timer 0 overflow flag. Set by hardware on Timer/Counter
TCON.5 TF0 overflow. Cleared by hardware when processor vectors to
interrupt routine, or by clearing the bit in software.
Timer 0 Run control bit. Set/cleared by software to turn
TCON.4 TR0
Timer/Counter on/off.
Interrupt 1 Edge flag. Set by hardware when external interrupts
TCON.3 IE1
edge detected. Cleared when interrupt processed.
Interrupt 1 type control bit. Set/cleared by software to specify
TCON.2 IT1
falling edge/low level triggered external interrupts.
Interrupt 0 Edge flag. Set by hardware when external interrupts
TCON.1 IE0
edge detected. Cleared when interrupt processed.
Interrupt 0 Type control bit. Set/cleared by software to specify
TCON.0 IT0
falling edge/low Level triggered external interrupts.

4. Interrupt Priority (IP) Register:


Each source of the interrupt can be individually programmed to be in either of
the two priority levels. The priorities can be assigned to each interrupt by programming
appropriate bits in the SFR Interrupt Priority Register.
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
x x x PS PT1 PX1 PT0 PX0

Symbol Name and Function


x Reserved
PS Priority of Serial Interrupt. If 1, Priority of Serial Interrupt is higher
PT1 Priority of Timer 1 interrupt. If 1, Priority of Timer 1 interrupt is higher
PX1 Priority of External interrupt 1. If 1, Priority of the INT1 is higher
PT0 Priority of Timer 0 interrupt. If 1, Priority of Timer 0 Interrupt is higher
PX0 Priority of External interrupt 0. If 1, Priority of the INT0 is higher

Dept. of ECE, UBDTCE,DAVANAGERE 36


EMBEDDED SYSTEM DESIGN 2025-26

5. Serial Port Control Register (SCON):


The serial port control and status register is the Special Function Register
SCON. This register contains not only the mode selection bits, but also the 9th data bit
for transmit and receive (TB8 and RB8) and the serial port interrupt bits (TI and RI).
MSB LSB
SM0 SM1 SM2 REN TB8 RB8 TI RI

Where SM0, SM1 specify the serial port mode, as follows:


SM0 SM1 Mode Description Baud Rate
0 0 0 Shift register f osc / 12
0 1 1 8-bit UART Variable
1 0 2 9-bit UART f osc / 64 or fosc /32
1 1 3 9-bit UART variable

Enables the multiprocessor communication feature in Modes 2 and 3. In Mode 2 or


3, if SM2 is set to 1, then Rl will not be activated if the received 9th data bit (RB8)
SM2
is 0. In Mode 1, if SM2=1 then RI will not be activated if a valid stop bit was not
received. In Mode 0, SM2 should be 0.
Enables serial reception. Set by software to enable reception. Clear by software to
REN disable reception.
The 9th data bit that will be transmitted in Modes 2 and 3. Set or clear by software
TB8 as desired.
In Modes 2 and 3, is the 9th data bit that was received. In Mode 1, it SM2=0, RB8 is
RB8 the stop bit that was received. In Mode 0, RB8 is not used.
Transmit interrupt flag. Set by hardware at the end of the 8th bit time in Mode 0, or
TI at the beginning of the stop bit in the other modes, in any serial transmission. Must
be cleared by software only.
Receive interrupt flag. Set by hardware at the end of the 8th bit time in Mode 0, or
RI halfway through the stop bit time in the other modes, in any serial reception (except
see SM2). Must be cleared by software only.

Practice does not make perfect. Only


perfect practice makes perfect.

Dept. of ECE, UBDTCE,DAVANAGERE 37


EMBEDDED SYSTEM DESIGN 2025-26

Annexure C
Architecture of MSP430 microcontroller

Figure : Internal Architecture of MSP 430


Addressing mode

All the addressing modes for the source operand and all four addressing modes for the
destination operand can address the complete address space. The bit number show the
content of the As resp. Ad mode bits.

Table 1: Addressing modes in MSP 430

Dept. of ECE, UBDTCE,DAVANAGERE 38


EMBEDDED SYSTEM DESIGN 2025-26

Instruction Set of MSP430

Dept. of ECE, UBDTCE,DAVANAGERE 39


Microcontrollers Lab-10ESL47 2015-16

APPENDIX D
MCU 8051IDE
MCU 8051 IDE is a new modern graphical integrated development environment for
microcontrollers based on 8051. For those who believe 8051 is a great piece of
technology this IDE is a new way how to see and feel these still famous
microcontrollers. MCU 8051 IDE is noncommercial open-source software
primarily for Microsoft Windows and GNU/Linux Supported programming languages
are C language and assembly. It has its own assembler and support for 2 external
assemblers. For C language it uses SDCC compiler. There are packages for various
Linux distributions (.rpm and .deb), and installer for Microsoft Windows. This IDE
contains simulator, source code editor, assembler, HW programmer and much other
tools. Simulator supports over 79 MCU primarily from Atmel. There is also support
for simple hardware simulation (like LEDs, keys, etc.).

Dept. of EEE, C.I.T., Gubbi 40


Microcontrollers Lab-10ESL47 2015-16

List of major Features

❖ Advanced simulator with support for more than 79 MCUs.


❖ Built-in optimizing macro assembler
❖ Support for C language
❖ Simple external hardware simulation
❖ Interactive help for assembly language
❖ Interrupt monitor & editor
❖ Advanced source code editor
➢ Syntax highlight
➢ Syntax validation
➢ Pop-up based auto-completion
➢ Editor command line Interactive map of SFR
❖ Tools for converting between various data files related to MCUs
❖ Editor of bit addressable area in the simulated MCU
❖ Stopwatch timer
❖ Special calculator optimized for use with 8051
❖ Assembler symbol viewer
❖ Base converter
❖ 8 segment display editor
❖ Hexadecimal editor
❖ Interactive ASCII chart
❖ Simple graphical notepad
❖ Various information windows, tool tips, legends
❖ IO Ports monitor
Virtual Hardware Simulator

MCU 8051 IDE simulator is also equipped with a few simulated simple
hardware devices, which can be connected to the simulated MCU. These virtual
hardware components are intended primarily to offer a better insight into
programs interacting with things like LEDs or keys.

Dept. of EEE, C.I.T., Gubbi 41


Microcontrollers Lab-10ESL47 2015-16

Fig: Virtual Hardware Examples

Dept. of EEE, C.I.T., Gubbi 42

You might also like