Sunteți pe pagina 1din 26

A SSI GNMEN T -1 |1

SCHOOL OF ELECTRONICS ENGINEERING

MICROCONTROLLER AND IT’S APPLICATIONS (ECE3003)


DIGITAL ASSIGNMENT-1
SLOT-E2
QUESTION PAPER SET: NOV 2011 D1

SUBMITTED BY:

S.NO NAME REGISTRATION


NUMBER
1 P.SURYA TEJA 17BEC0178
2 BATTULA BHARATH KUMAR 17BEC0200
3 CHALICHAM HANISH 17BEC0211
4 CHAMALA VENKATA SAI SUDHEER 17BEC0229
5 MANOJ KUMAR PENTELA 17BEC0232
6 BHARATHWAJ A G 17BEC0287
7 VIGHNESH KURRA 17BEC0289
8 MINKUS JAIN 17BEC0299
9 V V YASWANTH 17BEC0310
10 DADIREDDY SAI THEJA 17BEC0323
11 SHIKKAR SINGH 17BEC0325

SUBMITTED TO:

PROF.SUNDAR.S

DEPT OF EMBEDDED TECHNOLOGY


A SSI GNMEN T -1 |2

Q1) (A) Mention the criteria for choosing a microcontroller


Answer) Criteria for choosing a microcontroller:

 A microcontroller has many uses in consumer electronics and


communication devices like cell phones and computers, and in
medical instruments like ECG machines and monitors. Also, in
industrial settings, it can be used to control temperature or pressure,
count time, measure speed, or activate the braking system. Because
microcontrollers are suitable for specific tasks, it is essential to choose
a microcontroller that is most appropriate for a project. There are
many factors to consider

Three main criteria for choosing a microcontroller are:


 Meeting the computing needs of the task at hand efficiently and cost effectively like

 Speed
 Packaging
 Power consumption
 The amount of RAM and ROM on chip
 The number of I/O pins and the timer on chip
 How easy to upgrade to higherperformance or lower power-consumption versions
 Cost per unit

 Availability of software development tools, such as compilers, assemblers, and debuggers ‰

 Wide availability and reliable sources of the microcontroller

 The 8051 family has the largest number of diversified (multiple source)
suppliers like:
A SSI GNMEN T -1 |3

Q1) (B) List the characteristics of Embedded System.


Ans) The characteristics of embedded system are measurable features during the
implementation of system.

 Single-functioned − An embedded system usually performs a specialized


operation and does the same repeatedly. For example: A pager always
functions as a pager.
 Tightly constrained − All computing systems have constraints on design
metrics, but those on an embedded system can be especially tight. Design
metrics is a measure of an implementation's features such as its cost, size,
power, and performance. It must be of a size to fit on a single chip, must
perform fast enough to process data in real time and consume minimum
power to extend battery life.
 Reactive and Real time − Many embedded systems must continually react to
changes in the system's environment and must compute certain results in real
time without any delay. Consider an example of a car cruise controller; it
continually monitors and reacts to speed and brake sensors. It must compute
acceleration or de-accelerations repeatedly within a limited time; a delayed
computation can result in failure to control of the car.
 Power consumption - This is a very important factor for all embedded system
which are powered by batteries. So the amount of power will be consumed by
the system, which decides the capacity or lifetime of battery.
 Flexibility - The flexibility is the ability to change the functionality of the
system without investing additional NRE cost and hence software is typically
considered very flexible as it can be updated at any time with new version.
 Processor power - The embedded systems are controlled by microcontrollers
or digital signal processor (DSP). It can handle one or many specific task which
require very powerful processor.
 Operating system - The embedded operating system is needed in embedded
system to limit the function depending on the embedded device and may only
run a single application which is crucial to the devices operation. Due to this
the operating system must be reliable and able to run with tight constraints
on memory, size, time and processing power.
 Microprocessors based − It must be microprocessor or microcontroller based.
 Memory − It must have a memory, as its software usually embeds in ROM. It
does not need any secondary memories in the computer.
A SSI GNMEN T -1 |4

 Connected − It must have connected peripherals to connect input and output


devices.
 HW-SW systems − Software is used for more features and flexibility.
Hardware is used for performance and security.
Advantages

 Easily Customizable
 Low power consumption
 Low cost
 Enhanced performance
Disadvantages

 High development effort


 Larger time to market

Q2a)An 8051 microcontroller is used to implement a thermostat. The 8 bit


digital value of the temperature is input to port 1. An output signal to turn on
the heater is attached to pin 2.0. if the temperature is above the constant set
point THIGH, the program is to turn the heater off. The program also keeps
an internal count of number of times the furnace turns on.

Program:
org 0000h

mov p1,#0ffh

mov p2,#00h

here:mov a,p1

cjne a,00111000b,next

setb p2.0

ret

next:nop
A SSI GNMEN T -1 |5

cjne a,00111100b,next1

clr p2.0

ret

next1:nop

sjmp here

end

Output:

Q2 b) Using 8051 microcontroller write a program to get a data x from port 1


and perform the expression Y=2*X^2+5*X+7 and send the output Y to port 2.

ANSWER:

Tabulation 1

INPUT(X) 2*X^2 Hex 5*X Hex Y=2*X^2+5*X+7 Hex


value value value
0 0 0 0 0 7 7
1 2 2 5 5 14 E
2 8 8 10 A 25 19
3 18 12 15 F 40 28
A SSI GNMEN T -1 |6

4 32 20 20 14 59 3B
5 50 32 25 19 82 52
6 72 48 30 1E 109 6D
7 98 62 35 23 140 8C
8 128 80 40 28 175 AF

Tabulation 2

INPUT(X) DB
0 07H, 00H,00H
1 07H,02H,05H
2 07H,08H,0AH
3 07H,12H,0FH
4 07H,20H,14H
5 07H,32H,19H
6 07H,48H,1EH
7 07H,62H,23H
8 07H,80H,28H

Using the above table we give inputs accordingly to the code and get the
output for given input.

Program:
Org 0000h

Mov dptr,#200h

Mov r0,#3

Loop:clr a

Movc a,@a+dptr

Add a,r2

Jnc next

Inc r3

Next :inc dptr


A SSI GNMEN T -1 |7

Mov r2,a

Djnz r0,loop

Org 200h

DB 07h,00h,00h

End

Output: (for x=0) Output: (for x=1) Output: (for x=2)

Output: (for x=3) Output: (for x=4) Output: (for x=5)


A SSI GNMEN T -1 |8

Output: (for x=6) Output: (for x=7) Output: (for x=8)

Result: So, using the above code we have added the given input and
generated the output.

Observation: From the above figure, we can visualise that the output
expression has been obtained.
Q3) Write an ALP to toggle bit p1.2 continuously every 50ms.use TIMER 0 to
create the delay.

Program: Comment section:


ORG 0000H //Representation of starting address

MOV TMOD,#01H //Here we are using Timer 0 in Mode 1

HERE:MOV TL0,#0FDH //Here we load these values that are

MOV TH0,#4BH obtained after the calculations

CPL P1.2

ACALL DELAY //Calling the delay

SJMP HERE

DELAY:SETB TR0 //Starting the timer


A SSI GNMEN T -1 |9

AGAIN:JNB TF0,AGAIN //Monitoring the timer flag for 1/0

CLR TR0 //Clearing the timer

CLR TF0 //Clearing the timer flag

RET

END

Calculations:
1) Divide the given time by 1.085usec
Time (T’) = Time/1.085usec = 46,082.9493

2) Round the obtained value


Rounded value (y) = 46,083

3) Subtract y from 65536(because we are using mode 1)


Final value (y’) = 19,453
4) Convert y’ to hexadecimal and load first 8 bits to TH and next 8 bits to TL of
the respective timer used.
Y’ (hex) = 4BFD
5) Load the values as said accordingly in the previous step
TH0 = 4BH
TL0 = 0FDH

Output:

Result: So, using the above code we have generated the waveform with the
given delay.

Observation: From the above figure, we can visualise that the


waveform has been generated.
A S S I G N M E N T - 1 | 10

Q4A) Distinguish between RISC and CISC in detail with an example

BASIS FOR
RISC CISC
COMPARISON

Emphasis on Software Hardware

Includes Single clock Multi-clock

Instruction-set size Small Large

Instruction formats fixed (32-bit) format Varying formats (16-64


bits each instruction).

Addressing modes used Limited to 3-5 12-24

General purpose registers 32-192 8-24


used

Memory inferences Register to register Memory to memory

Cache design Split data cache and Unified cache for


instruction cache. instructions and data.

Clock rate 50-150 MHz 33-50 MHz

Cycles Per Instruction Single cycle for all CPI between 2 and 15.
instructions and an
average CPI < 1.5.

CPU Control Hardwired without Microcoded using


control memory. control memory (ROM).

By taking Intel 80836 as example for RISC microprocessor and MIPS R2000
as example for CISC microprocessor distinguished the difference between them.
A S S I G N M E N T - 1 | 11

MIPS R2000 Intel 80386

Date announced 1986 1985

Instruction size(bits) 32 Variable

Address space(size, 32 bits, flat 32 bits, segmented with


model) paging support

Data alignment Aligned No

Data addressing modes 2 11

Protection Page Segmented Scheme

Integer registers (number, 31 GPR*32 bits 8 GPR*32 bits, 6 segment


model, size) registers*16 bits, 2 other *
16 bits

Separate floating-point 16*32 or 16*64 bits 8*80 bits


registers
Floating-point format IEEE 754 single, double IEEE 754 single, double,
extended

Q4.B) Give the functionality of the 8051 microcontroller when the following
pins are asserted

a. EA
Pin 30 − This is EA pin which stands for External Access input. It is used to
enable/disable the external memory interfacing.

b. ALE
Pin 31 − This is ALE pin which stands for Address Latch Enable. It is used
to demultiplex the address-data signal of port.

c. PSEN
This is an output pin. PSEN stands for “program store enable.” In an 8031-
based system in which an external ROM holds the program code, this pin is
A S S I G N M E N T - 1 | 12

connected to the OE pin of the ROM. This pin is used to enable external
program memory.

d. INT0
Low level triggered

Whenever a low level is detected on the INT0 pin while global and external
interrupts are enabled, the controller jumps to interrupt service routine (ISR) to
serve interrupt.

Falling edge triggered

Whenever falling edge is detected on the INT0 pin while global and ext. interrupts
are enabled, the controller jumps to interrupt service routine (ISR) to serve
interrupt.

e. RD

RD pin is used as control pin for accessing the external data memory
(External RAM). Pin 17 (RD): Reading Signal to read the contents of
external RAM.

Q5) Read the following program and specify the content in SP register,
content in stack with memory address after execution of each instruction

Default stack pointer value:07H


PSW REGISTER

7 6 5 4 3 2 1 0
cy Ax cy F0 RS1 RS0 ov - p

Banks:

Rs1 Rs0 Bank


0 0 0
0 1 1
A S S I G N M E N T - 1 | 13

1 0 2
1 1 3
Program: Comment section:
MOV SP,#5FH //moving the stack pointer value to 5FH

SETB PSW.3 //Moving to bank 1 register

MOV R0,#3FH //Implication to Ro of bank 1 register (i.e 08H)

MOV R1,#0E4H //Implication to R1 of bank 1 register (i.e 09H)

MOV R2,#0A5H //Implication to R2 of bank 1 register (i.e 0AH)

MOV R3,#6AH //Implication to R3 of bank 1 register (i.e 0BH)

MOV R4,#7BH //Implication to R4 of bank 1 register (i.e 0CH)

MOV R5,#0B7H //Implication to R5 of bank 1 register (i.e 0DH)

PUSH 01 //SP:60H; content in 60H is 0E4H

PUSH 02 //SP:61H; content in 61H is 0A5H

POP 04 //SP:60H; content in 04H is 0A5H (04H is 0CH since Bank-1)

PUSH 03 //SP:61H; content in 61H is 6AH

POP 02 //SP:60H; content in 02H is 6AH (02H is 0AH since Bank-1)

POP 03 //SP:5FH; content in 03H is 0E4H (03H is 0BH since Bank-1)

Output:
A S S I G N M E N T - 1 | 14

Result: So, using the above code we have pushed or popped back the data in
the given address.

Observation: From the above figure, we can visualise the stack


pointer and the value in the registers.

Q6)(a) Write a program to send the message “GLOBAL WARMING” to


serial port. Assume a SW is connected to pin P1.2.Monitor its status
and set the baud rate as Follows:
SW = 0, 4800 baud rate
SW = 1, 9600 baud rate
Assume XTAL = 11.0592 MHz, 8-bit data, and 1 stop bit. Use Hyper
terminal for your Results
Program: Comment section:
ORG 0000H

XX:MOV DPTR,#MYDATA

MOV TMOD,#00100000B //TIMER 1 MODE 2

JNB P1.2,ZERO //CHECK P1.2 IF P1.2=0 JUMP TO ZERO

MOV TH1,#-3 //9600 BAUD RATE

MOV SCON,#01010000B //8-bit, 1 stop, REN enabled

SETB TR1 //start timer 1

MOV R1,#14

AGAIN1:CLR A

MOVC A,@A+DPTR

MOV SBUF,A //place value in buffer

HERE1:JNB TI,HERE1 //wait until transmitted

CLR TI

INC DPTR //DPTR=DPTR+1


A S S I G N M E N T - 1 | 15

DJNZ R1,AGAIN1

SJMP XX

ZERO:MOV TH1,#-6 //4800 BAUD RATE

MOV SCON,#01010000B //8-bit, 1 stop, REN enabled

SETB TR1 //start timer 1

MOV R1,#14

AGAIN:CLR A

MOVC A,@A+DPTR

MOV SBUF,A //place value in buffer

HERE:JNB TI,HERE //wait until transmitted

CLR TI //clear

INC DPTR

DJNZ R1,AGAIN

SJMP XX

MYDATA:DB'GLOBAL WARMING

END

CALCULATIONS:

1) Divide 28,800 by the given baud rate


2) Given baud rate=9600,4800
3) Load the negative of obtained value after division, into TH1
4) 28,800/4800=6 => -6 to be loaded into TH1 for 4800 baud rate
5) 28,800/9600=3 => -3 to be loaded into TH1 for 9600 baud rate
A S S I G N M E N T - 1 | 16

OUTPUT:

The switch is ON (9600 baud rate):

The switch is OFF (4800 baud rate):


A S S I G N M E N T - 1 | 17

Result: So, using the above code we have transferred the data in accordance
to switch with respective baud rate.

Observation: From the above figure, we can visualise that the data
has been transferred with the given baud rate
Q6)(b) (i) Write an ALP for 8051 to receive bytes of data serially and send
them through port-1.set the baud rate at 4800.

Program: Comment section:


ORG 0000H

ZZ:MOV TMOD,#20H // TIMER 1 IN MODE 2

MOV TH1,#-6 //4800 BAUD RATE value

MOV SCON,#50H //SCON register must be filled with 5OH for data transfer

SETB TR1

XX:JNB RI,XX

MOV A,SBUF

MOV P1,A

CLR RI

SJMP XX

END

CALCULATIONS:

1) Divide 28,800 by the given baud rate


2) Given baud rate=4800
3) Load the negative of obtained value after division, into TH1
4) 28,800/4800=6 => -6 to be loaded into TH1 for 4800 baud rate
A S S I G N M E N T - 1 | 18

Output:

FOR INPUT VALUE OF ‘5’

Result: So, using the above code we have RECEIVED the data serially.

Observation: From the above figure, we can visualise that the data
has been received with the given baud rate and can visualize the
received data in port-1.
Q6Bii).Draw the pin out of RS-232 DB9 serial connector. Mention the
functionality of each pin
Answer) The RS-232(X) is a serial communication protocol, commonly used for transferring
and receiving the serial data between two devices. It supports both synchronous and
asynchronous data transmissions. Many devices in the industrial environment are still using RS-
232 communication cable. Rs-232 cable is used to identify the difference of two signal levels
between logic 1 and logic 0. The logic 1 is represented by the -12V and logic 0 is represented the
+12V. The RS-232 cable works at different baud rates like 9600 bits/s, 2400bits/s, 4800bits/s
etc. The RS-232 cable has two terminal devices namely Data Terminal Equipment and Data
communication Equipment. Both devices will send and receives the signals. The data terminal
equipment is a computer terminal and data communication Equipment is modems, or
controllers etc.
The most commonly used type of serial cable connectors are 9-pin connectors DB9 and 25-pin
connector DB-25. Each of them may be a male or female type. Nowadays most of the computers
use the DB9 connector for asynchronous data exchange. The maximum length of RS-232 cable is
50ft.
A S S I G N M E N T - 1 | 19

DB9 PINOUT AND SIGNALS FOR THE PC RS232 CONNECTOR (SERIAL AND
RS232 PORTS)

DB9 pin D-SUB male

Pin Name Direction Description


1 CD «— Carrier Detect
2 RXD «— Receive Data
3 TXD —» Transmit Data
4 DTR —» Data Terminal Ready
5 GND System Ground
6 DSR «— Data Set Ready
7 RTS —» Request to Send
8 CTS «— Clear to Send
9 RI «— Ring Indicator
Q7) Assume that pin P3.3 (INT 1) is connected to a pulse generator, write a
program in which the falling edge of the pulse will send a high to p1.3, which
is connected to an LED .In other words, the LED is turned on and off at the
same rate as the pulse is applied to int1 pin.

Program: Comment section:


ORG 0000H

LJMP MAIN //JUMPS TO MAIN FUNCTION

ORG 0013H

SETB P1.3 //SETS THE PIN TO 1

RETI //RETURN INERRUPT, WHICH IS USED TO RETURN FROM INTERRUPT

ORG 0030H

MAIN:MOV IE,#10000100B //FILLING THE IE REGISTER

SETB TCON.2 //TO MAKE THE TRIGGERING –EDGE TRIGGERED

XX:SJMP XX

END
A S S I G N M E N T - 1 | 20

Output:

Result: So, using the above code we have switched on the led connected to
pin 1.3.

Observation: From the above figure, we can visualise that switch has
been turned on.
Q8) (A)

1) Write the 8051 instructions to enable timer 1 interrupt and external


hardware interrupt 1.

IE REGISTER

7 6 5 4 3 2 1 0
EA - ET2 ES ET1 EX1 ET0 EX0

IP REGISTER

7 6 5 4 3 2 1 0
- - PT2 PS PT1 PX1 PT0 PX0

(i) Write the 8051 instructions to enable timer 1 interrupt and external
hardware interrupt 1.

Program: Comment section:


ORG 0030H

MAIN:MOV IE,#10001100B //enables TIMER 1 and INT1

END
A S S I G N M E N T - 1 | 21

(ii) Write the 8051 instructions to make timer 1 interrupt and external
hardware interrupt 1 as highest priority interrupts

Program: Comment section:


ORG 0030H

MAIN: MOV IP,#00001100B //TIMER1 and INT1 with highest priority

MOV IE,#10001100B //enables TIMER 1 and INT1

END

(iii) After enabling mention all interrupts sorting from highest to lowest
priority.

PRIORITY IN DECREASING ORDER (i.e FROM HIGHER TO LOWER):

1) INT1
2) TF1
3) INT0
4) TF0
5) TI & RI

Q8) (B) Write an assembly language program to transfer value 41H serially
(one bit at a time) via pin p2.1.send one low bit at the start and one high bit
at the end of the data. Send the byte LSB first.

Program: Comment section:


ORG 0000H
MOV A,#41H; //LOAD A WITH 41H
CLR P2.1; //SEND LOW BIT AT THE START
MOV R5,#8; //NUMBER OF BITS TO SEND
AGAIN: RRC A
MOV P2.1,C //send CY to P2.1
DJNZ R5,AGAIN
SETB P2.1 //SEND HIGH BIT AT THE END
END
A S S I G N M E N T - 1 | 22

Output:


Q9 a) List all the steps the ARM core will automatically perform
when an exception causes a mode change

ANS: When an exception occurs, the following happens


inside the core:
1. The CPSR is copied to the SPSR of the mode being
entered.
2. The CPSR bits are set as appropriate to the mode being
entered, the core is set to ARM state, and the relevant
interrupt disable flags are set*.
3. The appropriate set of banked registers are banked in.
4. The return address is stored to the link register (of the
relevant mode)
5. The PC is set to the relevant vector address.
A S S I G N M E N T - 1 | 23

Q9 b) Discuss about the 4 major design rules on which te RISC


philosophy is implemented

ANS: The RISC design philosophy

The design philosophy aimed at delivering the following..


 simple but powerful instructions

 single cycle execution at a high clock speed

 intelligence in software rather than hardware

 provide greater flexibility on reducing the complexity of


instructions.

The ARM core uses a RISC architecture.

The RISC philosophy is implemented with four major


design rules:
1. Instructions – RISC processors have a reduced number of
instruction classes. These classes provide simple operations that
can each execute in a single cycle. The compiler or programmer
synthesizes complicated operations (a divide operation) by
combining several simple instructions. Each instruction is
a fixed length to allow the pipeline to fetch future instructions
before decoding the current instruction. Incontrast, in CISC
processors the instructions are often of variable size and take
manycycles to execute.
2. Pipelines —The processing of instructions is broken down
into smaller units that can beexecuted in parallel by pipelines.
Ideally the pipeline advances by one step on each cyclefor
maximum throughput. There isno need for an instruction to be
executed by a miniprogram called microcode as onCISC
processors.
3. Registers—RISC machines have a large general-purpose
register set. Any register cancontain either data or an address. In
contrast, CISC processors have dedicated registers for
specificpurposes.
A S S I G N M E N T - 1 | 24

4. Load-store architecture—The processor operates on data held


in registers. Separate loadand store instructions transfer
data between the register bank and external memory.In contrast,
with a CISC design thedata processing operations can act on
memory directly.

RISC ARCHITECTURE

Q10) Design 8051 based LCD display system with data lines of LCD connected
to the port 0, control signals to port 1. Also develop ALP for the same system
to display “YES”.

(NOTE: 38H-LCD 2 LINES 5x7 Matrix; OEH-display on cursor on; 01H-clear LCD;
06H-Shift cursor right)

Program: Comment section:


ORG 0000H

MOV A,#38H //initializing LCD

ACALL COMMAND

ACALL DELAY

MOV A,#0EH //Display on cursor on

ACALL COMMAND
A S S I G N M E N T - 1 | 25

ACALL DELAY

MOV A,#01H //CLR LCD

ACALL COMMAND

ACALL DELAY

MOV A,#06H //SHIFT CURSOR RIGHT

ACALL COMMAND

ACALL DELAY

MOV A,#80H //1ST ROW FIRST POSITION

ACALL COMMAND

ACALL DELAY

DELAY:MOV R0,#0FFH

XX:DJNZ R0,XX

RET

COMMAND:MOV P1,A

CLR P2.0

CLR P2.1

SETB P2.2

CLR P2.2

RET

MOV A,#'Y' //FOR DATA DISPLAY

ACALL DATA

ACALL DELAY

MOV A,#'E'
A S S I G N M E N T - 1 | 26

ACALL DATA //CALLING THE DATA

ACALL DELAY //CALLING THE DELAY

MOV A,#'S'

ACALL DATA

ACALL DELAY

SJMP YY

DATA:MOV P1,A

SETB P2.0

CLR P2.1

SETB P2.2

CLR P2.2

RET

S-ar putea să vă placă și