Important Instructions To Examiners:: Subject Code: Page No: 1/ 26
Important Instructions To Examiners:: Subject Code: Page No: 1/ 26
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
WINTER– 14 EXAMINATION
Subject Code: 17509 Model Answer Page No: 1/ 26
Important Instructions to examiners:
1) The answers should be examined by key words and not as word-to-word as given in the
model answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try
to assess the understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more
Importance (Not applicable for subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in the
figure. The figures drawn by candidate and model answer may vary. The examiner may give credit for any
equivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed constant
values may vary and there may be some difference in the candidate‟s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant answer based on
candidate‟s understanding.
7) For programming language papers, credit may be given to any other program based on equivalent concept.
_______________________________________________________________________________________________
Q. 1
1
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
ii) Draw the pin diagram of 20 × 4 LCD display .what is the function of RS,EN and R/W pins.
Ans) (Diagram 1 mark, function 1 mark each)
Diagram:
4 line X 20 character
Functions:
RS(register select)
If RS=0, the instruction command code register is selected , allowing the user to send the command such as
clear display, cursor at home, etc.
If RS=1, the data register is selected ,allowing the user to send data to be displayed on the LCD.
R/W (read/write)
R/W input allows the user to write information to the LCD or read information from it.
EN(enable)
The enable pin is used by the LCD to latch information presented to its data pin.
When data is supplied to its data pin, a high-to-low pulse must be applied to this in order for the LCD to latch in
the data presented at the data pins.
This pulse must be a minimum of 450 ns wide
2
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
iii) What are the different data types used in C? Also give their value range.
Ans) (any FOUR data types 1 mark each)
Data types used in C:
i)Unsigned character
range :– 0-255
2)Signed character
range :- (-128+0+127)
3)Unsigned integer
Range :- 0-65535(0000-FFFFH)
4)signed integer
range ;- (-32768 to 32767)
5) Bit
Range RAM bit addressable only
6)SFR
Range RAM addresses 80 –FFH only
7) Sbit
Range SFR bit addressable only
3
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
iv) Draw and explain reset circuit used for 8051 microcontroller
Ans) (Diagram 1 mark ,Explanation 3 mark)
Diagram:
4
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
5
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
.Timer 1 is stopped in mode 3 but can be started by switching it into one of the other modes. The only
limitation is that the usual Timer I overflow flag, TF1, is not affected by Timer 1
overflows, since it is connected to TH0.
• The 8051 appears to have a third timer.
6
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
• Timer 1 can be turned on and off by switching it out of and into its own mode 3. It can
still be used by the serial port as a baud rate generator.
ii) List the addressing modes of 8051 microcontroller with examples each.
a) Classify the instruction set of microcontroller 8051 Give one example of each.
Ans) (Classification 1 mark each ,Example 1 mark each, Any four type )
b) Draw the interfacing diagram of ADC 0809 with microcontroller 8051. Write C language program
7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
to generate 50 Hz sq. wave with crystal freq.=12MHz.
Note:( Any other program logic to generate square wave should be given marks )
Diagram:
#include<reg51.h>
Void T0Delay(void);
Void main(void)
While(1)
P1=0x55;
T0Delay();
P1=0xAA;
T0Delay();
8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
}
Void T0Delay()
TMOD=0x01;
TL0=0x0F0;
TH0=0x0D8;
TR0=1;
While(TF0==0);
TR0=0;
TF0=0;
C. Draw the interfacing diagram of stepper motor with 8051 microcontroller. Draw the flow chart for rotating
stepper motor in clockwise direction. (Program not expected)
Diagram:
9
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
„OR‟
Flow chart:
10
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
a) Draw the format of PSW SFR and Describe the function of each bit
PSW register –
Format:-
D7 D0
Cy AC F0 RSI RS0 0V X P
Bit7: Carry/Borrow bit: When two 8-bit operands are added, the result may exceed 8-bit and the 9th bit is copied in the
carry bit. During subtraction, if the borrow occurs, the carry bit is set and otherwise, it is cleared.
Bit 6: Auxiliary carry/borrow bit: This bit indicates a carry from lower nibble during 8 bit addition. If AC flag is set, it
means there is a carry from 3rd to 4th bit position.
0 0 Register Bank 0
0 1 Register Bank 1
1 0 Register Bank 2
1 1 Register Bank 3
Bit 2: OV: Over flow flag is used to detect errors in signed arithmetic operations. When two signed numbers are added,
it the result exceeds the destination, overflow flag is set, else it is reset.
Bit 0: Parity Flag: P flag is set, if the result contains an odd number of 1 bit, else it is reset, if the result contains an even
number of 1 bit.
11
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
c) Write C program to continuously toggle all bits of port O with same delay.
#include <reg51.h>
Void main(void)
{
While(1) //repeat forever
P0=0x55;
MSDelay(250) ;
P0=0xAA;
MSDelay(250);
}
}
{
Unsigned int i, j;
For(i=0;i<itime;i++)
12
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
For(j=0;j<itime;j++) ;
d) Compare between
RISC CISC
RISC and CISC
machines. Reduced instruction set computer Complex instruction set computer.
Ans) (any 4 Instruction set is simple and Instruction set is very large. points each 1
mark) limited.
Instruction set is not flexible, Instruction set is flexible, hence the program is
hence the program is long. short
Instruction are shorter, hence Instructions are lengthy hence execution speed
execution speed is fast. is slow.
Each instruction required few bus Each instruction requires many bus cycle.
cycle.
13
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
e) Draw the interfacing diagram of four common cathode 7 segment display connected in
Ans) Diagram :
i) Draw the interfacing diagram of temperature measurement using LM35, ADC0808 with microcontroller 8051.
Diagram:
14
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
15
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
iv) List the alternate function of port 3.
1. SWAP A
2. DIV AB
3. RLA
4. XCH A,RO
5. SETB C
6. DA A
1) SWAP A
SWAP nibbles within the accumulator .This instruction interchanges the low order and high order nibbles of the
accumulator.
EG. A = 05H
SWAP A
A = 50H
2) DIV AB
This instruction divides the content of Register A by the contents of register B. Quotient is stored in register A &
remainder is stored in register B .
4) XCH A, R0.
(A) (R0)
5) SETBC
6) DA A
Only after the addition of two BCD numbers this instruction can be used. Result stored in Accumulator is converted
into equivalent BCD form.
17
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
ii) With suitable diagram describe the memory organization of internal program and data memory.
Ans) (1 mark for ROM explanation, 3 marks for RAM explanation, 2 marks for Internal RAM diagram)
1) Working registers
First 32 bytes from address 00H to 1FH are organized as four register banks.
The four register banks are named as Bank 0, Bank 1, Bank 2 & Bank 3.
Each register bank consist of eight register denoted as R0 to R7. each register is of 8-bits.
The register bank is selected by setting or resetting bits. RSO & RS1 of PSW register.
2) bit / byte addressable
The memory location area from 20H – 2FH, total 1B memory locations are used for bit-bytes addresses. One
memory location as 8-bits.Each bit has its own address. Therefore one memory location has 8- addresses. Hence 16-
memory location that is 16×8=128 addresses. Therefore bit addresses of this area varies from OOH-7FH.Thus single
128 bits can be stored in this area.
4) general purpose
18
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
the remaining memory location of RAM from 30H-7F can be used as general purpose data memory where data results
are stored. These area can be used as stack memory.
8051 also consists of 4KB of internal ROM from the address 000h to FFFh where codes can be stored.
a)Write ‟C‟ program to transfer message “INDIA” serially at baud rate 4800bps, 8-bit data, 1 stop bit, assume
crystal frequency 11.0592 MHz.
Ans) ( Baud rate calculation : 2 marks , Correct program with comments : 6 marks )
TH1= FA H = -6
„C‟ PROGRAM :
#include<reg51.h>
void main(void)
{
unsigned char msg[]= "INDIA";
int i;
TMOD=0X20;// timer 1,mode 2
TH1= - 6 ;// count for 4800 BAUD
SCON=0x50; // 8 bit ,1 stop bit (serial mode 1)
TR1=1;//start timer 1
for (i=0;i<5;i++)
{
SBUF = msg[i];//send message “INDIA” serially
while(TI==0);//wait for transmission to complete
TI=0;//clear TI flag for next transmission
}
}
19
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
NOTE: ( ANY OTHER CORRECT PROGRAM LOGIC SHOULD ALSO BE CONSIDERED AND GIVEN
MARKS)
b) Write assembly language program to transfer array of ten numbers stored in memory location 50H to
memory location 70H.
Ans) (ALGORITHM/FLOWCHART : 4 MARKS
PROGRAM : 4 MARKS
Algorithm:
1. Start
2. Initialize count R2=0AH
3. Initialize source pointer R0 with starting address 50h
4. Initialize destination pointer R1 with starting address 70h
5. Move number pointed by R0 to accumulator
6. Move number from accumulator to destination address pointed by R1
7. Increment source pointer R0
8. Increment destination pointer R1
9. Decrement count & if count not equal to zero repeat step 5 to step 9
10. Else stop
20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
FLOW CHART:
yes
stop
21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
Note: ( ANY OTHER CORRECT PROGRAM LOGIC SHOULD ALSO BE CONSIDERED AND
GIVEN MARKS)
c) Draw interfacing diagram to connect 8 LED‟s on port 2 and 8 switches on port 0. Write C program to read
the status of switches and send to port 2.
Interfacing diagram
22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
„C‟ PROGRAM
#include<reg51.h>
void main(void)
{
unsigned char MYBYTE;
P0=0XFF; //SET PORT0 AS INPUT
While(1)
{
MYBYTE=P0; //GET SWITCH STATUS FROM PORT 0
P2=MYBYTE; //SEND DATA BYTE TO PORT 2
}
}
MSB LSB
DESCRIPTION:
IP.7 - Reserved
IP.6 - Reserved
IP.5 - Reserved
23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
Priority bit =1 , assigns higher priority , Priority bit 0 = assigns lower priority
i. ORG
ii. DB
iii. EQU
iv. END
1. ORG : ORIGIN
The ORG directive is used to indicate the beginning of the address. The number that comes after ORG is the
address from where program will begin. The number can be either in hex and decimal
e.g. ORG 1000H
It indicates that program shall start from memory address 1000h
2. DB : Define Byte
It is used to define the 8-bit data. It is used to write the value after DB , into the program memory. When DB
is used to define data, the numbers can be in decimal, binary, hex, ASCII formats
e.g. ORG 1000H
MYDATA: DB 20,21
After execution of this , location 1000h=20 & 1001h = 21
3. EQU: EQUATE
It is used to define a constant without occupying a memory location The EQU directive assigns a constant
value to a label. When the label appears in the program, its constant value will be substituted for the label.
e.g. COUNT EQU 10
MOV R2, #COUNT
24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
When the instruction is executed , register R2 is loaded with value 10.
4. END: This indicates to the assembler the end of the source (asm) file . The END directive is the last line of an
8051 program. Means that in the program anything after the END directive is ignored by the assembler
25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
__________________________________________________________________________________________________
„OR‟
26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________________________
Important Instructions to examiners:
1) The answers should be examined by key words and not as word-to-word as given in the
model answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try
to assess the understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more
Importance (Not applicable for subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in the
figure. The figures drawn by candidate and model answer may vary. The examiner may give credit for any
equivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed constant
values may vary and there may be some difference in the candidate‟s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant answer based on candidate‟s
understanding.
7) For programming language papers, credit may be given to any other program based on equivalent concept.
______________________________________________________________________________________________
1
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________________________
Oscillator and clock circuits.
4. INTO
It is external interrupt 0, active low pin.
It is external hardware interrupt I/P signal. Through this user, programmer or peripheral interrupts to
microcontroller. This is connected to port pin p3.2
(c) Describe ‘sbit’ and ‘sfr’ data types used in C programming for 8051.
Ans: (2 Mark each)
sbit
With typical 8051 applications, it is often necessary to access individual bits within an SFR. The C51 compiler
makes this possible with the sbit data type. The sbit data type allows you to access bit-addressable SFRs. For
example:
sbit EA = 0xAF;
This declaration defines EA to be the SFR bit at address 0xAF. On the 8051, this is the enable all bit in the
interrupt enable register.
2
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________________________
sfr Types:
Names for sfr types are defined using the same method as other C variables. In the above
example, P0 and P1are the SFR name declarations. Any symbolic name may be used in an sfr declaration.
The address specification after the equal sign ('=') must be a numeric constant.
sbit 1 0 or 1
sfr 8 1 0.255
2) R/W: Reading and writing data to the LCD for reading the data R/W pin should be high (R/W=1) to write the
data to LCD R/W pin should be low (R/W=0)
3) EN: Enable pin is for starting or enabling the module. A high to low pulse of about 450ns pulse is given to this
pin.
3
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________________________
B) Attempt any ONE of the following: 6M
(a) Draw the organization of data memory(RAM) of 8051 and describe in brief.
Ans: (Diagram 4 Mark(1 M for working register, 1 M for General purpose, 2 M for bit Addressable)
Explanation 2 Mark)
Diagram:
Thirty-two bytes from address 00h to 1Fh that make up 32 working registers organized as four banks of eight
registers each. The four register banks are numbered 0 to 3 and are made up of eight registers named R0 to R7.
A bit-addressable area of 16 bytes occupies RAM byte addresses 20h to 2Fh, forming a total of 128 addressable
bits.an addressable bit may be specified by its bit address 00h to7Fh.
A general-purpose RAM area above the bit area, from 30h to 7Fh.
A general-purpose RAM area above the bit area, from 30h to 7 Fh, addressable as bytes.
4
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________________________
(b) Describe following instructions with reference to their function and addressing mode:
1) ADD A,R1
2) SUBB A,R0
3) ORL A, # 30H
Ans: (Each instruction 2 Mark, 1 M for function, 1 M for addressing mode)
1) ADD A,R1
Add contents of R1 to Accumulator and store the results into accumulator
OR
(A) + (R1) A
Addressing mode: Register
2) SUBB A,R0
Subtract contents of R0,contents of carry flag from accumulator and store the results into accumulator.
(A)- (R0)-cy A
Addressing mode: Register
3) ORL A, # 30H
Logically Or contents of accumulator with given data and store the results in accumulator.
Addressing mode: Immediate
5
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________
Q2. Attempt any Two of the following: 16M
a) Write assembly language program to find largest number of an array containing 16 numbers. Store this
number in the internal RAM location 50H. write appropriate comments.
PROGRAM :
To find largest number of an array containing 16 numbers
; 16 numbers are stored from 40H internal RAM location
CHECK_BIG:
JNC EXCHANGE ;FIND THE BIG NUMBER
SJMP UP1
NOTE: Program may change. Student can also use the other logic.
Please check the logic and understanding of students.
6
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________
b) Draw interfacing diagram of 7 segment display with Port 1 of 8051 micro controller. Write C program to
display BCD numbers from 0 to 9.
Interfacing Diagram:
7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________
Program:
#include <Intel\8052.h>
#include <standard.h>
DP G F E D C B A
NO D7 D6 D5 D4 D3 D2 D1 D0
0 0 1 0 0 0 0 0 0 =40H
1 0 1 1 1 1 0 0 1 =79H
2 0 0 1 0 0 1 0 0 =24H
3 0 0 1 1 0 0 0 0 =30H
4 0 0 0 1 1 0 0 1 =19H
5 0 0 0 1 0 0 1 0 =12H
6 0 0 0 0 0 0 1 0 =02H
7 0 1 1 1 1 0 0 0 =78H
8 0 0 0 0 0 0 0 0 =00H
9 0 0 0 1 0 0 0 0 =10H
*/
void main ()
while(1)
8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________
P1 = 0x40; //DISPLAY 0
delay_ms(1000);
P1 = 0x79; //DISPLAY 1
delay_ms(1000);
P1 = 0x24; //DISPLAY 2
delay_ms(1000);
P1 = 0x30; //DISPLAY 3
delay_ms(1000);
P1 = 0x19; //DISPLAY 4
delay_ms(1000);
P1 = 0x12; //DISPLAY 5
delay_ms(1000);
P1 = 0x02; //DISPLAY 6
delay_ms(1000);
P1 = 0x78; //DISPLAY 7
delay_ms(1000);
P1 = 0x00; //DISPLAY 8
delay_ms(1000);
P1 = 0x10; //DISPLAY 9
delay_ms(1000);
NOTE: Program may change. Student can also use the other logic.
Please check the logic and understanding of students.
9
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________
c) Draw interfacing diagram where P1.0 pin of 8051 microcontroller is used to control relay contact in turn;
controls the fan connected to 230V. Describe operation of this circuit.
Interfacing Diagram :
Operation of circuit:
We can‟t connect FAN directly to microcontroller; therefore we have to connect RELAY in between FAN and
Microcontroller.
RELAY is electromechanical switch. It operates on 12Vdc. Therefore we can‟t connect RELAY directly to the
microcontroller.
To drive the relay we are using relay driver i.e transistor BC547.
10
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________
Microcontroller will operate transistor, Transistor will operate relay and relay will operate fan.
When P1.0 is logic HIGH i.e 5V, transistor turns ON, Relay turns ON. The NO contact will become NC. And
FAN will turns ON.
When P1.0 is logic LOW i.e 0V, transistor turns OFF, Relay turns OFF. The NO contact remains NO. And
FAN will turns OFF.
Functions:
CY, the carry flag-
This flag is set whenever there is a carry out from the D7 bit. This flag bit is affected after an 8-bit addition or
subtraction.
AC, the auxiliary carry flag-
If there is a carry from D3 to D4 during an ADD or SUB operation, this bit is set; otherwise, it is cleared. This flag
is used by instructions that perform BCD (binary coded decimal) arithmetic.
11
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________
P, the parity flag-
The parity flag reflects the number of 1s in the A (accumulator0 register only. If the A register contains an odd
number of 1s, then P=1. Therefore, P=0 if A has an even number of 1s.
12
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________
(c) Describe the following C program for 8051.
Ans: (4 marks comments )
1.Data is erased using electric current 1.The erasure is caused by flower- nordheium tunneling in
which electrons pierce through a thin dielectric material
which remove an electronic charge from a floating gate
associated with each memory cell.
2.Data is within/ programmed at the byte level. 2.It is done at the block (group of bytes) level.
4.Program / erase cycle refers to the no. of times that chip 4.Flash 100,000 times.
can be erased and programmed before it becomes
unusable EPROM 1000 times.
5.No. of cells / unit is less package density is less. 5. No. of cells / unit is less package density is more.
13
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________
(e) Draw interfacing diagram of 8 key connected to P0 of 8051 and label it.
Ans: (4 Mark for correct diagram)
14
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________
Q4. A) Attempt any three of the following: 12M
a) Draw the interfacing diagram of stepper motor to Port 1. Use ULN2003 driver IC.
b) Describe bitwise Left / Right Shift operator used in 8051 C programming with example.
Ans:(Left Shift operator with example – 2 Marks And Right Shift operator with example – 2 Marks )
4) It is denoted by <<
5) Bit Pattern of the data can be shifted by specified number of Positions to Left
6) When Data is Shifted Left , trailing zero‟s are filled with zero.
7) Left shift Operator is Binary Operator [Bi – two]
15
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________
Example:
P0=0x3C << 2
It is denoted by >>
Bit Pattern of the data can be shifted by specified number of Positions to Right
When Data is Shifted Right , leading zero‟s are filled with zero.
Right shift Operator is Binary Operator [Bi – two]
Example:
Syntax : Bitwise Right Shift Operator
[variable]>>[number of places]
P0=0x3C >> 2
After execution of this instruction
Shift number 2 times to Right:
3C=0011 1100
0F=0000 1111
So,
P0=0x0F
NOTE: Example May change. Please check the logic and understanding of students.
16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________
c) Compare microprocessor and micro controller(any 4 points).
Sr.No
Microprocessor Microcontroller
1 Microprocessor don‟t have inbuilt Micro controller has inbuilt ROM and
ROM and RAM RAM
2 Microprocessor don‟t have inbuilt Micro controller has inbuilt Timer and
Timer and Counter Counter
6 It has one or two bit handling It has many bit handling instructions.
instructions.
7 Access times for memory and I/O Less access times for built-in memory
devices are more. and I/O devices.
17
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________
d) Draw the format of TMOD and describe each bit.
TMOD format:
TMOD
(89h) SFR :
Bit Name Explanation of Function Timer
When this bit is set the timer will only run when INT1 (P3.3) is high.
7 GATE1 1
When this bit is clear the timer will run regardless of the state of INT1.
When this bit is set the timer will count events on T1 (P3.5). When this
6 C/T1 1
bit is clear the timer will be incremented every machine cycle.
5 T1M1 Timer mode bit 1
4 T1M0 Timer mode bit 1
When this bit is set the timer will only run when INT0 (P3.2) is high.
3 GATE0 0
When this bit is clear the timer will run regardless of the state of INT0.
When this bit is set the timer will count events on T0 (P3.4). When this
2 C/T0 0
bit is clear the timer will be incremented every machine cycle.
1 T0M1 Timer mode bit 0
0 T0M0 Timer mode bit 0
The
modes of operation are:
18
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________
Q4. B) Attempt any one : 6M
a) Describe following branching instructions:
1) DJNZ R0,UP
3) JB P1.5,Here
DJNZ instruction decrements the value of register R0 by 1. If the new value of register is not 0 the
program will branch to the address indicated by relative address UP. If the new value of register is 0 program
flow continues with the instruction following the DJNZ instruction.
Compare the data (indirectly Pointed by R1) with immediate number 80H. If both numbers are not equal
then jump to LOOP label
CJNE compares the value of operand1i.e the data (indirectly Pointed by R1) and operand2, i.e 80H and
branches to the indicated relative address LOOP, if operand1 and operand2 are not equal.
If the two operands are equal program flow continues with the instruction following the CJNE
instruction.
3) JB P1.5, Here
If port pin P1.5 is set then jump to the address pointed by label Here.
JB branches to the address indicated by reladdr-Here if the bit indicated by bit addrP1.5 is set. If the bit
is not set program execution continues with the instruction following the JB instruction.
19
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________
b) Compare 8051 micro controller with 8052, with reference to
1) On chip ROM
2) On chip RAM
3) Timers
4) Interrupt Sources.
1 On chip ROM 4 KB 8 KB
3 Timers 2 3
4 Interrupt Sources 5 6
a) Draw the format of SCON register and describe function of each bit. State the importance of SMOD bit
when it is set. If XTAL =12 MHZ, Calculate baud rate for
ANS: ( SCON format:2 marks , SCON bit explanation :2 marks , Significance of SMOD bit :2 marks , Baud
rate calculation: 2 marks )
20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________
SM2 enables the multiprocessor communication feature in Modes 2 and 3. In Modes 2 or 3, if SM2 is set to 1 than RI will not be activated if the
received 9th date bit(RB8) 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
SMOD is PCON.7 bit , which when set to 1 doubles the serial communication baud rate. When 8051 is powered up,
SMOD is 0.
(b) Write assembly language program for 8051 to generate square wave of 10 KHZ on port pin P1.7 Assume
XTAL =12MHZ , use Timer0 to generate delay.( show delay calculation with comments)
ANS: (delay calculation: 2 marks , Program : 6 marks)
Frequency = 10 khz
Therefore Time period T = 1 / 10KHZ = 0.1 ms
Therefore TON = TOFF = 0.1ms / 2 = 0.05 ms = 50 usec
ORG 0000H
Program:
MOV TMOD,#02H ;Timer0, Mode 2
MOV TH0,#0CEh ;Load higher byte of count
SETB TR0 ; start timer0
HERE:JNB TF0,HERE ;Check if TF0 is set
CPL P1.7 ;COMPLEMENT P1.7
CLR TF0 ; CLEAR TF0
SJMP HERE ;REPEAT
END
Note: ( Any other correct program logic can be used)
22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________
#include <reg51.h>
void main(void)
{
unsigned char mybyte;
P0=0xFF; //make Port0 input port
P1=0X00; // make Port1 output port
while (1)
{
mybyte=P0; //get a byte from P0
P1= ~ mybyte; //send compliment of it to P1
}
}
Note: When switch is not pressed port pin of P0 status is logic 1 and when switch is pressed port pin of P0 is
logic 0. So we have to complement the status of P0 i.e mybyte variable.
23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________
a) Draw diagram of port 0 of 8051 and label it. Write the process to read port 0 pin status.
24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________
C) State addressing modes of 8951. Describe any two addressing modes with example
ANS: Stating addressing modes: 1 mark , explanation of any two addressing modes with one example each : 3
marks ( one example each :1/2 mark )
MOV A,@R0
ANL A,@R1
ADD A,@R0
Some instructions are specific to a certain register. For example, some instructions always operate on the
Accumulator, or Data Pointer, etc., so no address byte is needed to point to it. The opcode itself does that.
Instructions that refer to the Accumulator as A assemble as accumulator specific opcodes.
RLC A
RRC A
SWAP A
DAA
26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SUMMER-15 EXAMINATION
Subject Code:17509 Model Answer Page No: 27/ N
__________________________________________________________________________________________________
d) Draw format of IE register and describe each bit
ANS: format : 2 marks , bit explanation: 2 marks
e) Assuming temperature control system using LM35 as temperature sensor and ADC 0809. Draw flow chart of
this system to keep temperature within
25 ◦ C to 35◦ C
ANS: correct flow chart : 4 marks
( Note: Any other correct logic can be used)
27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Subject Code: 17509
Model Answer
WINTER – 15 EXAMINATION Page No:1/ 13
Important Instructions to examiners:
1) The answers should be examined by key words and not as word-to-word as given in the
model answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try
to assess the understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more
Importance (Not applicable for subject English and Communication Skills).
4) While assessing figures, examiner may give credit for principal components indicated in the
figure. The figures drawn by candidate and model answer may vary. The examiner may give
credit for anyequivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed constant
values may vary and there may be some difference in the candidate’s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant
answer based on candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on equivalent concept.
Q1-A. Atempt any Three : 12
i) Draw the block diagram of Von-Neumann and Harvard architectures 4
2+2
ii) Draw the interfacing of two seven segment display with 8051 microcontroller. 4
iii) Wri te C language program for 8051 microcontroller to toggle all 8 lines of port 0 with delay. 4
#include <REG51.H>
void delay(void);
void main(void)
{
while(1)
{
P0= 0xaa;
delay();
P0 =0x55;
delay();
}
}
Pages 1/13
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Subject Code: 17509
Model Answer
WINTER – 15 EXAMINATION Page No:2/ 13
void delay(void)
{
unsigned int count;
for(count =0;count<1000;count++);
}
iv) Describe the function of PC and DPTR 4
PC: Program counter 2+2
It is a 16 bit register in 8051. It points to the address of the next instruction to be executed. As the cpu
fetches the opcode, contents of PC are incremented to point to next opcode fetch location. PC is not part of
any instruction in 8051.
DPTR: Data Pointer
It is a 16 bit register. It is used to hold address of the internal and external program memeory and external
data memory. It consists of two 8 bit registers: DPH(high order byte) and DPL(low order byte)
Q1 B) Attempt any one 6
i) Draw and describe the internal RAM memory organisation of 8051 microcontroller 4+2
The internal RAM of 8051 is of 128 bytes (00-7F). It is divided in following sections:
1) Four register banks: Each register bank has eight registers(R0-R7) of 8bits each. Any one register bank is
active at a given time. A register bank can be selected by using RS0,RS1 registers in PSW register.
2) Bit addressable memory area: Memory address 20H-2FH is called as bit addrresable memory. There are
128 addressable bits. The bit address ranges from 00H-7FH.
3) General purpose area: Memory address 30H to 7FH is general purpose scratch pad area of the RAM. This
area is used to store temporary variables, for initializing stack pointer etc.
ii) Write an assembly language program to find largest number out of five numbers. Data is stored in internal 6
RAM memory location 10 H onwards. Store the result at 20 H. (Credit to any suitable and logical program)
ORG 0000h SKIP: INC R0 ;point to next address
LJMP MAIN DJNZ R1,LOOP ; decr r1 and loop back
ORG 0030H MOV 20H,0F0H ;transfer largest to 20h
MAIN: MOV R0,#10h ; intialize start address END
MOV R1,#05h ; init counter to 5
MOV 0F0H,#00H ;initialize B reg as largest
LOOP: MOV A,@R0 ; transfer data to acc
CJNE A,0F0H,CHK ; compare with B register
SJMP SKIP ; if equal do nothing
CHK: JC SKIP ; if less do nothing
MOV 0F0H,0E0H ;if ACC is greater then transfer to B
Pages 2/13
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Subject Code: 17509
Model Answer
WINTER – 15 EXAMINATION Page No:3/ 13
Q2. Attempt any two: 16
a. Describe the addressing modes of 8051 microcontroller with one example. 8
1) Immediate addressing mode: Data is provided as part of the instruction. The data follows the instruction 1
each
opcode
Example: MOV A,#0AH
2) Register addressing mode: It involves use of registers to hold the data.
Example: MOV A,R0
3) Direct adrresing mode: 8 bit direct address of the internal RAM of 8051 is specified in the instruction.
Example: MOV A, 40H
4) Indirect addressing mode: It uses registers to hold the address of the memory location to access. Registers
R0, R1 are used to point to internal memory and DPTR is used to point to external data memory.
Example: MOV A, @R0, MOVX A, @DPTR
5) Indexed addressing mode: It uses 16bit registers PC and DPTR to hold the base address. And accumulator
to hold the offset which is relative to the base address.
Example: MOVC A,@A+DPTR
6) Relative addresing Mode: It is used with conditional jump instructions.
Example: SJMP NEXT (NEXT is calculated relative to preset location)
7) Absolute Adressing mode: It is used by ACALL and AJMP instructions. They are two byte instructions with
11bit address specified in instruction opcode. The upper 5 bits are taken from PC. It can branch to
anywhere in 2Kbyte page of the program memory. Example: ACALL LOOP1
8) Long addressing mode: It is used by LCALL LJMP instruction. These are 3 byte instructions in which 16 bit
direct address is specified. It can jump any where in the entire 64K program memory.
Example: LJMP MAIN
b. Draw the interfacing of DAC 0808 with 8051 microcontroller. Write C language program to generate 8
triangular waveform by using DAC 0808. 4+4
Pages 3/13
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Subject Code: 17509
Model Answer
WINTER – 15 EXAMINATION Page No:4/ 13
/* Program to generate triangular wave */
#include <REG51.H>
sfr DACDATA = P1;
void main(void)
{
unsigned char wavevalue[12] = { 0, 8,16,32,64,128,255,128,64,32,16,8};
unsigned char x;
while(1)
{
for(x=0;x<12;x++)
{
DACDATA = wavevalue[x];
}
}
}
Assume that :
The stepper motor is uniploar type. The four leads of motor
are controlled by P1.0 to P1.3 of 8051.
Motor Step angle = 20
Steps per revolution = 180
Four step sequence for anticlock wise movment as shown in folllwing table:
Step A B C D
1 0 0 1 1
2 0 1 1 0
3 1 1 0 0
4 1 0 0 1
0
One four step sequence = 8 .
No of four step sequneces required for 3600 = 45 i.e. 180 steps
Pages 4/13
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Subject Code: 17509
Model Answer
WINTER – 15 EXAMINATION Page No:5/ 13
Q3. Attempt any Four
16
a. Draw the block diagram of internal architecture of 8051 microcontroller. 4
b. Describe the four timer modes of8051 microcontroller with suitable diagram. 4
Timer mode 0: 13 bit timer mode 1
each
Internla clock pulses are counted by (THx-8bits and TLx-5bits). When the count rolls over to 0 after 8191 counts
(213), TFx bit is set.
Timer mode 1: 16 bit timer mode
Internal clock pulses are counted by (THx-8bits and TLx-8bits). When the count rolls over to 0 after 65535 counts
(216), TFx bit is set.
Timer mode 2: 8 bit auto reload mode
Pages 5/13
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Subject Code: 17509
Model Answer
WINTER – 15 EXAMINATION Page No:6/ 13
Pages 6/13
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Subject Code: 17509
Model Answer
WINTER – 15 EXAMINATION Page No:7/ 13
TLx acts as 8 bit timer. The reload value is stored in THx register. When TLx register rolls over from FF to 0, the
reload value stored in THx is loaded into TLx register.
Timer Mode 3: split timer mode
void main(void)
{
Unsigned char portdata;
While(1)
{
portdata = P1;
P3 = portdata;
}
}
A mircoprocessor does not have on-chip memory Has program as well as data memory on-chip
A microprocessor does not have on-chip timer, I/O Timers, I/O ports, serial ports are on-chip.
ports
It is mainly used for computing purpose. Use of microcontroller is for mainly for device control.
Memeory and other peripheral deveices need to be It is a computer on-chip with small computing power
connected externally to make complete computer required for device control
Cost of the system is higher as compared to Results into a cheaper solution for the given
microcontroller . application
Pages 7/13
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Subject Code: 17509
Model Answer
WINTER – 15 EXAMINATION Page No:8/ 13
e. Draw the interfacing of 8 LEDs to port 2 of8051 microcontroller. Write C language program to (turn ON and 4
OFF LEDs of port 2 with delay. 2+2
#include <REG51.H>
void delay(void);
void main(void)
{ void delay(void)
while(1) {
{ unsigned int cnt;
P2 = 0xff; for(cnt=0;cnt<2000;cnt++);
delay(); }
P2 = 0x00;
delay();
}
}
ii) What is bus ? Describe the function of address, data and control bus. 4
Bus is bunch of wires running from one device to other for communicating information.
Address Bus: It holds binary address of the device connected in system.
Data Bus: It carries data from device toCPU or vice versa
Control Bus: It carries control signals such as clock signals, chip select signals, Read/Write signals, interrrupt
request signals
Pages 8/13
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Subject Code: 17509
Model Answer
WINTER – 15 EXAMINATION Page No:9/ 13
iii) Write the instruction for following using C operator: 4
a) Bit wise shift data left 4 times. 2+2
b) Bit wise shift data right 4 times.
Parity Flag: It is set when number of 1s in ACC are odd and reset when number of 1s are even
Carry Flag: This flag is set whenever there is a carry out from the D7 bit. This flag bit is affected after an 8-bit
addition or subtraction. It can be also set or reset by using SETB C, CLR C instructions.
Auxiliary carry flag: If there is a carry from D3 to D4 during an ADD or SUB operation, this bit is set; otherwise,
it is cleared.
OV flag: It is overflow flag. It is set when there is carry from D6 to D7 but no carry from D7 or carry from D7
but no carry from D6 to D7.
B. Attempt any one: 6
i) Write an assembly language program for 8051 microcontroller to find average of ten 8-bit numbers stored in 6
internal RAM location 20 H onwards. Store the result at 30 H.
ORG 0000h
LJMP MAIN
ORG 0030H
MAIN: MOV R1,#0AH ;LOAD COUNTER OF 10
MOV R0,#20H
XRA A ; CLEAR ACC AND CY FLAG
NEXT: ADD A,@R0 ;ADD NUMBAR TO ACC AND STORE SUM IN ACC
INC R0
DJNZ R1,NEXT
MOV B,#0AH
DIV A,B
MOV 30H,A
RET
ii) Draw the format of TMOD register of 8051 microcontroller. Describe the function of each bit. 6
3+3
Pages 9/13
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Subject Code: 17509
Model Answer
WINTER – 15 EXAMINATION Page No:10/ 13
TMOD register is divided in two sections lower 4 bits are for timer T0 and upper 4 bits are for timer T1
GATE: Gating control when set. Timer/counter is enabled only while the INTx pin is high and the TRx control pin
is set. When cleared, the timer is enabled whenever the TRx control bit is set.
C/T : Timer or counter selected cleared for timer operation (input from internal system clock). Set for counter
operation (input from Tx input pin).
M1 : Mode bit 1
M0 : Mode bit 0
Pages 10/13
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Subject Code: 17509
Model Answer
WINTER – 15 EXAMINATION Page No:11/ 13
b. Describe the following assembler directives with example. 8
i) DB ii) ORG iii) EQU iv) END. 2
each
DB: The DB directive is the most widely used data directive in the assembler. It is used to define the 8-bit data.
When DB is used to define data, the numbers can be in decimal, binary, hex, or ASCII formats.
Example:
DATA1 DB 28 (decimal data stored as 1C hex)
DATA2 DB 01010101B (Binary data)
DATA3 DB 5Fh
Text DB “ABCDE” ASCII character array named as Text
ORG: The ORG directive is used to indicate the beginning of the address. The number that comes after ORG can be
either in hex or in decimal. If the number is not followed by H, it is decimal and the assembler will convert it to hex.
Example:
ORG 0000H
LJMP main
ORG 0030H
MAIN: ….
EQU: This is used to define a constant without occupying a memory location. When the label appears in the
program, constant value will be substituted for the label.
Example:
NUMBER EQU 25H
END: This indicates to the assembler the end of the source (asm) file. The END directive is the last line of an 8051
program, meaning that in the source code anything after the END directive is ignored by the assembler
c.
i)Write C language program for 8051 microcontroller to add five 8-bit numbers 8
#include <REG51.H> 4+4
void main(void)
{
unsigned char num [5], i; // declare five element array and counter i
unsigned int sum; // to store result;
for(i=0;i<5;i++)
{
sum = sum + num[i];
}
}
iii) State any four C data types with their range of value.
1) unsigned char 0 -255 2) char -128 to 127 3) unsigned int 0 -65535 4) int 32767 to -32768
Pages 11/13
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Subject Code: 17509
Model Answer
WINTER – 15 EXAMINATION Page No:12/ 13
Q6. Attempt any Four 16
a. Distinguish between 8051 and 8052 microcontrollers (any four points). 4
8051 8052
4 KB program memory 8 KB program memory
128 bytes internal RAM 256 bytes internal RAM
Two timers Three timers
Five interrupt sources Six interrupt sources
b. Write C language program for 8051 microcontroller to transmit message'WELCOME'serially at baud rate 4
9600,8-bit data, 1 -stop bit Assume crystal frequency is 11.0592 MHz.
#include <REG51.H>
void main(void)
{
unsigned char text[] = “WELCOME”;
unsigned char i;
TMOD = 0x20;
TH1 = 0xFD;
SCON = 0x50;
TR1 = 1;
while(1)
{
for(i =0;i<7;i++)
{
SBUF= text[i];
while(TI ==0);
TI = 0;
}
}
}
c. Write an assembly language program for 8051 microcontroller to transfer 10 bytes starting from 20 H 4
onwards to 30 H onwards.
ORG 0000H
LJMP MAIN
ORG 0030H
MAIN: MOV R0,#20H
MOV R1,#30H
MOV B,#0AH
NEXT: MOV A,@R0
MOV @R1,A
INC R0
INC R1
DJNZ B,NEXT
END
Pages 12/13
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Subject Code: 17509
Model Answer
WINTER – 15 EXAMINATION Page No:13/ 13
d. Describe alternative functions of port 3 of8051 microcontroller. 4
e. Draw the interfacing diagram for temperature measurement using 8051 microcontroller and adc 0809. 4
Pages 13/13
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
Summer 2016 EXAMINATIONS
1) The answers should be examined by key words and not as word-to-word as given in
the answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner
may try to assess the understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more
Importance (Not applicable for subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated
in the figure. The figures drawn by candidate and model answer may vary. The
examiner may give credit for any equivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed
constant values may vary and there may be some difference in the candidate’s
answers and model answer.
7) For programming language papers, credit may be given to any other program based on
equivalent concept.
1
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
2
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
REN: The REN (receive enable) bit is D4 of the SCON register. The REN bit is also referred to as
SCON.4 since SCON is a bit addressable register.
When the REN =1, it allows the 8051 to receive data on the RxD pin of the 8051. As a result if we
want the 8051 to both transfer and receive data, REN must be set to 1.
By making REN=0, the receiver is disabled. Making REN=1 or REN=0 can be achieved by the
instructions “SETB SCON.4” and “CLR SCON.4”, respectively.
This bit can be used to block any serial data reception and is an extremely important bit in the
SCON register.
TB8: TB8 (transfer bit 8) is bit D3 of SCON. It is used for serial modes 2 and 3. We make TB8=0
since it is not used in our applications.
RB8: RB8 (receive bit 8) is bit D2 of the SCON register. In serial mode 1, this bit gets copy of the
stop bit when an 8 bit data is received. This bit (as is the case for TB8) is rarely used anymore. In all
our applications we will make RB8=0. Like TB8, the RB8 bit is also used in serial modes 2 and 3.
3
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
RI: RI(receive interrupt) is the D0 bit of the SCON register. This is another extremely important
flag in the SCON register. When the 8051 receives data serially via RxD, it gets rid of the start and
stop bits and places the byte in the SBUF register. Then it raises the RI flag bit to indicate that a
byte has been received and picked up before it is lost. RI is raised halfway through the stop bit.
c) Write ‘C’ language program to toggle all bits of Port 1 of 8051 continuously with some delay.
Ans: (4M-correct program)
#include <reg51.h>
Void MSDelay(unsigned int) ;
Void main(void)
{
While(1) //repeat forever
{
P0=0x55;
MSDelay(250) ;
P0=0xAA;
MSDelay(250);
}
}
Void MSDelay(unsigned int itime)
{
Unsigned int i, j;
For(i=0;i<itime;i++)
For(j=0;j<itime;j++) ;
}
OR
Internal ROM The 8051 has 4K (4096 locations) of on-chip ROM. This is used for storing the
system program. 212 = 4096, therefore the internal ROM address bus is 12 bits wide and internal
ROM locations go from 000H to FFFH.
Internal RAM
There are 256 bytes of internal RAM on the 8051. 28 = 256, therefore the internal RAM address
5
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
bus is 8 bits wide and internal RAM locations go from 00H to FFH.
Register Banks
There are four register banks from 00H to 1FH. On power-up, registers R0 to R7 are located at
00H to 07H. However, this can be changed so that the register set points to any of the other three
banks (if you change to Bank 2, for example, R0 to R7 is now located at 10H to 17H).
Bit-addressable Locations
The 8051 contains 210 bit-addressable locations of which 128 are at locations 20H to 2FH while
the rest are in the SFRs. Each of the 128 bits from 20H to 2FH have a unique number (address)
attached to them, as shown in the table above. The 8051 instruction set allows you to set or reset
any single bit in this section of RAM. With the general purpose RAM from 30H to 7FH and the
register banks from 00H to 1FH, you may only read or write a full byte (8 bits) at these locations.
However, with bit-addressable RAM (20H to 2FH) you can read or write any single bit in this
region by using the unique address for that bit. We will later see that this is a very powerful
feature.
General Purpose RAM
These 80 bytes of Internal RAM memory are available for general-purpose data storage. The general
purpose RAM can be accessed using direct or indirect addressing mode instructions.
Special Function Registers (SFRs)
Locations 80H to FFH contain the special function registers. As you can see from the diagram
above, not all locations are used by the 8051 (eleven locations are blank). These extra locations are
used by other family members (8052, etc.) for the extra features these microcontrollers possess.
Not all SFRs are bit-addressable. Those that are have a unique address for each bit.
The ORG directive is used to indicate the beginning of the address. The number that comes after
ORG can be either in hex or in decimal. If the number is not followed by H, it is decimal and the
assembler will convert it to hex. Some assemblers use “.ORG” (notice the dot) instead of “ORG” for
the origin directive.
ii) DB:- (Data Byte)
Syntax: Label: DB Byte
Where byte is an 8-bit number represented in either binary, Hex, decimal or ASCII form. There should
be at least one space between label & DB. The colon (:) must present after label. This directive can be
used at the beginning of program. The label will be used in program instead of actual byte. There should
be at least one space between DB & a byte. Following are some DB examples:
6
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
iii)EQU: Equate
It is used to define constant without occupying a memory location.
Syntax:
Name EQU Constant
By means of this directive, a numeric value is replaced by a symbol.
For e.g. MAXIMUM EQU 99 After this directive every appearance of the label “MAXIMUM” in the
program, the assembler will interpret as number 99 (MAXIMUM=99).
iv) END:
This directive must be at the end of every program.meaning that in the source code anything after the
END directive is ignored by the assembler.
This indicates to the assembler the end of the source file(asm).
Once it encounters this directive, the assembler will stop interpreting program into machine code.
e.g. END ; End of the program.
Program:-
MOV TMOD, # 10H ; Set timer 1 in Mode 1, i.e., 16 bit timer
L2: MOV TL1, # 1AH ; Load TL register with LSB of count
MOV TH1, # FFH ; load TH register with MSB of count
SETB TR1 ; start timer 1
L1: JNB TFO, L1 ; poll till timer roll over
CLR TR1 ; stop timer 1
CPL P3.0 ; complement port 1.5 line to get high or low
CLR TF1 ; clear timer flag 1
SJMP L2 ; re-load timer with count as mode 1 is not
auto reload
b) Interface 8 bit DAC 0808 to 8051 and write ‘C’ language program to generate staircase waveform.
Ans: (4m-diagram, 4M-correct program)
7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
#include<reg51.h>
Void Delat2(unsigned int );
Void main(void)
{
While(1)
{
P2=0x00;
Delay2(10);
P2=0x33;
Delay2(10);
P2=0x66;
Delay2(10);
P2=0x99;
Delay2(10);
P2=0xCC;
Delay2(10);
P2=0xFF;
Delay2(10);
}
}
Void Delay2 (unsigned int t)
{
Unsigned int x,y;
For(x=0;x<=t;x++);
8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
For(y=0;y<=t;y++);
}
c) Draw and explain interfacing diagram for DC motor speed control using 8051.Also develop flowchart for
the same operation.
Ans: (4M-diagram,4M-flowchart)
9
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
OR
b) State the function of Program counter (PC) and Data Pointer (DPTR) registers of 8051.
Ans: (2M-each function)
The Data Pointer (DPTR)
The Data Pointer (DPTR) is the 8051s only user-accessible 16-bit (2-byte) register. The
Accumulator, "R" registers, and "B" register are all 1-byte values.
DPTR, as the name suggests, is used to point to data. It is used by a number of commands which
allow the 8051 to access external memory. When the 8051 accesses external memory it will access
external memory at the address indicated by DPTR.
10
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
While DPTR is most often used to point to data in external memory, many programmers often take
advantage of the fact that it is the only true 16-bit register available. It is often used to store 2-byte
values which have nothing to do with memory locations.
The Program Counter (PC)
The Program Counter (PC) is a 2-byte address which tells the 8051 where the next instruction to
execute is found in memory. When the 8051 is initialized PC always starts at 0000h and is
incremented each time an instruction is executed. It is important to note that PC isnt always
incremented by one. Since some instructions require 2 or 3 bytes the PC will be incremented by 2 or
3 in these cases.
The Program Counter is special in that there is no way to directly modify its value. That is to say,
you cant do something like PC=2430h. On the other hand, if you execute LJMP 2430h you have
effectively accomplished the same thing.
c) State any four ‘C’ data types with their range of values.
Ans: (1M-each)
Data types used in C:
i)Unsigned character
range :– 0-255
2)Signed character
range :- (-128+0+127)
3)Unsigned integer
Range :- 0-65535(0000-FFFFH)
4)signed integer
range ;- (-32768 to 32767)
5) Bit
Range RAM bit addressable only
6)SFR
Range RAM addresses 80 –FFH only
7) Sbit
Range SFR bit addressable only)
e) Draw neat interfacing diagram of 20x4 LCD display with 8051 in 8 bit mode
11
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
a)Draw the interfacing diagram for temperature measurement using LM 35 temperature sensor with8051
microcontroller.
b)Write ‘C” language program to send out the value 44H serially one bit at a time via P1.0 pin of
8051.TheLSB should go out first.
#include<reg51.h>
sbit=P1^o;
sbit reg_bdata=Acc^0;
12
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
Void main(void)
{
Unsigned char a=0x44,I;
ACC=a;
For(i=1;I<=8,i++)
{
t_bit=reg_bdata;
ACC=ACC<<1;
}
}
c)Compare Von –Neumann and Harvard architecture
Any 4 difference points --4 marks .
d)List interrupts of 8051 mic with their vector address and priority upon reset and explain SFR used to
enable interrupt of 8051
13
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
External Interrupt 0 –INT0 0003H 1
Timer 0 Interrupt 000BH 2
External Interrupt 1 –INT1 0013H 3
Timer 1 Interrupt 001BH 4
Serial Interrupt 0023H 5
a) Explain the operation of following instruction of 8051 with suitable example each.
i) MOVX A,@DPTR
Description: This instruction moves the contents of the external RAM memory pointed by (or
stored in) DPTR to accumulator.
No of bytes: 1 byte
Addressing mode: register
Example: MOV DPTR, # 2000H ; DPTR = 2000H(external RAM address)
ii). SWAP A
Description: This instruction exchanges bits 0-3 of the Accumulator with bits 4-7 of the
Accumulator. This instruction is identical to executing "RR A" or "RL A" four times.
No of bytes: 1 byte
Addressing mode: register specific
Example: MOV A, #59H ;A= 59H
SWAP A ; A= 95H
14
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
b) Draw and explain format of TMOD and TCON registers of microcontroller 8051.
TMOD format:
TMOD
(89h) SFR:
15
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
TR0 TCON. 4 Timer 0 run control bit. Set/cleared by software to turn Timer/Counter 0
ON/OFF.
IE1 TCON. 3 ExternalInterrupt 1 edge flag. Set byhardware when External
Interruptedgeis detected. Cleared by hardware when interrupt is processed.
a)Draw interfacing diagram of 3x3 matrix keyboard with 8051 and write ‘C” language program to read key
status
16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
# define ROW P1
unsigned char keypad [3] [3] = { ‘0’ , ‘1’ ,’2’ ,’3’ , ’4’, ‘5’ ,’6’ ,’7’ ,’8’};
void main()
17
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
{
do
do
Do
While(1)
If ( colloc = = 0X0E)
TI = 0; // clear flag
unsigned int x, y;
for ( x= 0; x<1275;x++ )
b)Write algorithm and assembly language program to add two BCD numbers stored at internal RAM
locations 40 H and 41H .store the result at internal RAM location 42H.
ALgorithm
Program
MOV A,40H ;Load the contents of mem location 40H into accumulator
Sjmp $
20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
c)Draw the diagram to interface 8 switches to Port 1 and 8 LED’s to Port 2 of 8051.Write “C” language
program to display switch status on LED’s
21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
Ans: Operating modes of Timer: The timer may operate in any of the four modes that
aredeterminedbyM1 and M0 bit in TMOD register.
Mode0:
In mode0 the register THX is used as 8 bit counterand TLX is used as5 bitcounter.Thepulse i/p
isdivided by(32)10so that TH counts. Henceoriginal oscillatorfrequencyis divided
by(384)10.Thetimer flagis setwhenTHXrolls over fromFFto 00H.
Mode1:
It is similarto Mode0 except TLX is configured as a full8-bit counter. Hencepulse inputis divided
by25610so that TH counts the timer flagis set when THX rolls over fromFFto 00H
22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
In this modeonlyTLX isused as 8-bitcounter. THXis used to hold the value which is
loadedin TLX initially.EverytimeTLX overflows from FFH to 00H thetimer flagis set
and thevalue from THX is automaticallyreloaded in TLXregister.
Mode 3
In this mode, timer0 becomes two completed separate 8-bittimers. TL0 is controlled
bygatearrangement oftimer0and sets timer 0 flag when itoverflows.TH0 receives the timerclock
under the control of TR1 bit and sets TF1 flagwhen itoverflows. Timer 1 maybeused in mode 0, 1
and 2 with oneimportant exception that no interrupt will be generated bythe timer when the timer 0
is usingTF1 overflow flag
Draw circuit diagram to interface common anode 7 segment display to 8051 and write „C‟ language
program to display number 0.
8
0
5
1
OR
23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
Program:
NO D7 D6 D5 D4 D3 D2 D1 D0
0 0 1 0 0 0 0 0 0 =40H
A = P1.0 B = P1.1 C = P1.2 D = P1.3
E = P1.4 F = P1.5 G = P1.6 DP= P1.7
*/
void main ()
{
P1 = 0xFF; //DISPLAY OFF
while(1)
{
P1 = 0x40; //DISPLAY 0
24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
delay_ms(1000);
}
}
NOTE: Program may change. Student can also use the other logic.
Please check the logic and understanding of students.
c)List any four addressing modes of 8051 with one example each.
There are a number of addressing modes available to the 8051 instruction set, as follows:
1. Immediate Addressing mode
2. Register Addressing mode
3. Direct Addressing mode
4 Register Indirect addressing mode
5. Relative Addressing mode
6. Absolute addressing mode
7. Long Addressing mode
8. Indexed Addressing mode
25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
This is a special addressing mode used with certain jump instructions. The relative address, often
referred to as an offset, is an 8-bit signed number, which is automatically added to the PC to make
the address of the next instruction. The 8-bitsigned offset value gives an address range of + 127 to –
128 locations.
Consider the following example:
SJMP LABEL_X
An advantage of relative addressing is that the program code is easy to relocate in memory in that
the addressing is relative to the position in memory.
CY AC F0 RS1 RS0 OV -- P
CY PSW.7 CarryFlag.
AC PSW.6 Auxiliarycarryflag.
F0 PSW.5 Available to the userforgeneral purpose.
RS1 PSW.4 Register bank selector bit 1.
26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
-- PSW.1 User-definable bit.
P PSW.0 Parity flag. Set/cleared by hardware each instruction cycle to
2. AC:the auxiliary carry flag If there is a carry from D3 and D4 during an ADD or SUB operation,
this bit is set; it is cleared. This flag is used by instructions that perform BCD (binarycoded
decimal)arithmetic.
4. RS0, RS1: register bank selects bits These two bits are used to select one of the four register
banks n internal RAM in the table. By writing zeroes and ones to these bits, a group of registers R0-
R7can be used out off our registers banks in internal RAM.
.OV:
Overflow
flag
This flag is set whenever the result of a signed number operation is too large, causing thehigh-
order bit to overflow into the sign bit. In general, the carry flag is used to detect errors in
unsigned arithmetic operations. The over flow flag is only used to detect errors in signed
arithmetic operations.
6.P:Parity
flag
The parity flag reflects the number of 1sin the A(accumulator) register only.If the A register
contains an odd number of 1s, then P=1.P=0 if A has an even number of 1s.
27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_____________________________________________________________________________________________
e)Draw interfacing diagram to interface relay to port pin P3.0 and opto isolator to port pin P3.7 of 8051
microcontroller
28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION 17509
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
_________________________________________________________________________________________________________________
WINTER– 16 EXAMINATION (Subject Code: 17509)
Model Answer
Important Instructions to examiners:
1. The answers should be examined by key words and not as word-to-word as given in the model answer
scheme.
2. The model answer and the answer written by candidate may vary but the examiner may try to assess the
understanding level of the candidate.
3. The language errors such as grammatical, spelling errors should not be given more Importance (Not
applicable for subject English and Communication Skills.
4. While assessing figures, examiner may give credit for principal components indicated in the figure. The
figures drawn by candidate and model answer may vary. The examiner may give credit for any equivalent
figure drawn.
5. Credits may be given step wise for numerical problems. In some cases, the assumed constant values may
vary and there may be some difference in the candidate’s answers and model answer.
6. In case of some questions credit may be given by judgement on part of examiner of relevant answer based
on candidate’s understanding.
7. For programming language papers, credit may be given to any other program based on equivalent concept.
Ans: Format:
2M
Significa
nce:2M
PSW register is one of the most important SFRs. It contains several status bits that reflect the
current state of the CPU. Besides, this register contains Carry bit, Auxiliary Carry, two
register bank select bits, Overflow flag, parity bit and user-definable status flag.
P - Parity bit. If a number stored in the accumulator is even then this bit will be
automatically set (1), otherwise it will be cleared (0). It is mainly used during data transmit
and receive via serial communication.
OV Overflow This flag is set whenever the result of a signed number operation is too large,
causing the high-order bit to overflow into the sign bit. In general, the carry flag is used to
detect errors in unsigned arithmetic operations. The overflow flag is only used to detect
errors in signed arithmetic operations
RS0, RS1 - Register bank select bits. These two bits are used to select one of four register
banks of RAM. By setting and clearing these bits, registers R0-R7 are stored in one of four
banks of RAM.
AC - Auxiliary Carry Flag is used for BCD operations only. If there is a carry from D3 and
D4 during an ADD or SUB operation, this bit is set.
CY - Carry Flag is set whenever there is a carry out from D7 bit. It is affected after all
arithmetical operations and shift instructions.
Ans: Diagram
:2M
Explanat
ion:2M
1M
Each
a) Draw internal RAM organization of microcontroller 8051 and show address areas for 6M
each Section.
Ans: 6M
Program:
# include <reg51.h>
sbit CS =P2^0;
sbit DOUT=P2^3;
void main( )
Unsigned char x;
Delay( );
SCLK=0;
SCLK=1
Delay( );
SCLK=0;
Delay ( )
//pin to DO of Reg A
c) Draw interfacing diagram of stepper motor control with 8051 microcontroller. Draw 8M
flow chart to rotate a stepper motor clockwise through 360°.Assume step angle of 1.8 ° .
Ans: Diagram
:4M,
Flowcha
rt:4M
The high byte (THx) is cascaded with the low byte (TLx) to produce a 16-bit timer. This
timer counts from 0000H to FFFFH - it has 216 (65,536) states. An overflow occurs during
the FFFFH to 0000H transition, setting the overflow flag.This is a very commonly used
mode to generate time delay using 16bit count.
The timer low byte (TLx) operates as an 8-bit timer (counting to FFH) while the high-byte (THx) holds a re
value. When the timer overflows from FFH, rather than starting again from 00H, the value in THx is loaded
TLx and the count continues from there. The auto-reload mode is very commonly used for generating baud r
.which is used for Serial Communication.
POP Operation
Popping the contents of the stack back into a given register is the opposite process of
pushing. With every pop, the top byte of the stack is copied to the register specified by the
instruction and the stack pointer is decremented once.
OR
The address can be given in either hex or decimal there should be a space of at least
one character between ORG & address fields. Some assemblers use ORG should not
begin in label field.
i v ) END:
This directive must be at the end of every program. meaning that in the source code
anything after the END directive is ignored by the assembler.
This indicates to the assembler the end of the source file (asm).
Once it encounters this directive, the assembler will stop interpreting program into
machine code.
e.g. END ; End of the program
Program:-
Provides Windows on the screen for the detailed information of source code part
with labels, registers as the execution continues, status of peripheral devices, status of
RAM and ports etc.
Verifies the performance of a target system that an emulator built into the
development system, which remains independent of a particular targeted system
Includes a logic analyzer for up to 256 or 512 transactions on the address and data
buses after triggering
Simulates on a host system (PC), the hardware unit like emulator, peripherals, and
I/O devices.
Debug by single stepping.
Features of Keil:
The µVision IDE combines project management, run-time environment, build
facilities, source code editing, and program debugging in a single powerful
environment.
µVision is easy-to-use and accelerates your embedded software development.
µVision supports multiple screens and allows you to create individual window
layouts anywhere on the visual surface.
The µVision Debugger provides a single environment in which you may test, verify,
and optimize your application code.
The debugger includes traditional features like simple and complex breakpoints,
watch windows, and execution control and provides full visibility to device
- IE.6 (Reserved)
- IE.5 (Reserved)
ADC808 Chip with 8 analog channels. This means this kind of chip allows to monitor 8
different transducers.
• ALE: Latch in the address
• Start : Start of conversion
• OE: output enable
• EOC: End of Conversion
Select an analog channel by providing bits to A, B, and C addresses.
2. Activate the ALE pin. It needs an Low-to-High pulse to latch in the address.
3. Activate SC (start conversion) by an High-to-Low pulse to initiate conversion.
4. Monitor EOC (end of conversion) to see whether conversion is finished.
5. Activate OE (output enable) to read data out of the ADC chip. A High-to-Low pulse to the
OE pin will bring digital data out of the chip.
c) Write an ALP for 16 bit multiplication. Assume numbers to be stored in internal RAM. 4M
Ans: (Assume first 16-bit number is stored in 40H and 41H and second 16-bit number is 4M
stored in 42H and 43H.;Result is in 20H,21H,22H & 23H)
MOV R1,41H
MOV R2,43H
MOV R3,40H
MOV R4,42H
MOV A,R3
MOV B,R4
MUL AB
MOV 20H,A
MOV 21H,B
MOV A,R3
MOV B R2
MUL AB
MOV 22H,B
ADDC A,21H
MOV 21H,A
MOV A,R1
MOV B,R4
MUL AB
MOV A,R1
MOV B,R2
MUL AB
ADDC A,22H
MO 22H,A
MOV A,B
ADDC A,#00H
MOV 23H,A
END
( Program with any other relevant logic can be given full marks)
d) State and explain the interrupts used in 8051 microcontroller. 4M
Ans: The 8051 provides five interrupt sources. These are listed below as per their default priority 4M
are:
1. Timer 0 (TF0)
2. External hardware interrupt, INT0
3. Timer 1 (TF1)
4. External hardware interrupt, INT1
5. Serial communication interrupt TI and RI
EXTERNAL INTERRUPTS:
Pins INT0 and INT1are used by external circuitry. Inputs on these pins can set the
Interrupt flags IE0 and IE1 in TCON register to 1 by two different method. The IEX
flags may be set when the INTX pin signal reaches a low level, or the flags may be set
when a high-to-low transition takes place on the INTX pin. Bits IT0 and IT1 in TCON
program the INTX pin for low level interrupt when set to 0 and program the INTX pins
for transition interrupt when set to 1.
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: Microcontroller and Applications Subject Code: 17509
I m p o r t a n t In str uc ti o ns t o ex a m i n ers:
1) The answers should be examined by key words and not as word-to-word as given
in the model answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner
may try to assess the understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more
Importance (Not applicable for subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components
indicated in the figure. The figures drawn by candidate and model answer may
vary. The examiner may give credit for any equivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the
assumed constant values may vary and there may be some difference in the
candidate’s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner
of relevant answer based on candidate’s understanding.
7) For programming language papers, credit may be given to any other program
based on equivalent concept.
Page 1 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
ii) Draw the interfacing diagram of four 7-segment display with 8051
microcontroller.
Ans: 4M- correct diagram
Page 2 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
iii) What are the different data types used in ‘C’? Give their value range.
Ans:2M- datatypes, 2M-range
Data types in C Language
Data types specify how we enter data into our programs and what type of data we enter.
C language has some predefined set of data types to handle various kinds of data that we
use in our program. These datatypes have different storage capacities.
C language supports 2 different type of data types,
Primary data types
These are fundamental data types in C namely integer(int), floating(float), charater(char)
and void.
Derived data types
Derived data types are like arrays, functions, stuctures and pointers. These are dicussed in
detail later.
Integer type
Integers are used to store whole numbers.
Size and range of Integer type
Page 3 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
Page 4 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
Register Banks
There are four register banks from 00H to 1FH. On power-up, registers R0 to R7 are
located at 00H to 07H. However, this can be changed so that the register set points to any
of the other three banks (if you change to Bank 2, for example, R0 to R7 is now located
at 10H to 17H).
Bit-addressable Locations
The 8051 contains 210 bit-addressable locations of which 128 are at locations 20H to
2FH while the rest are in the SFRs. Each of the 128 bits from 20H to 2FH have a unique
number (address) attached to them, as shown in the table above. The 8051 instruction set
allows you to set or reset any single bit in this section of RAM.
With the general purpose RAM from 30H to 7FH and the register banks from 00H to
1FH, you may only read or write a full byte (8 bits) at these locations.
However, with bit-addressable RAM (20H to 2FH) you can read or write any single bit in
this region by using the unique address for that bit. We will later see that this is a very
powerful feature.
Special Function Registers (SFRs)
Locations 80H to FFH contain the special function registers. As you can see from the
diagram above, not all locations are used by the 8051 (eleven locations are blank). These
extra locations are used by other family members (8052, etc.) for the extra features these
microcontrollers possess.
Page 5 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
Also note that not all SFRs are bit-addressable. Those that are having a unique address
for each bit.
The ORG directive is used to indicate the beginning of the address. The number that
comes after ORG can be either in hex or in decimal. If the number is not followed by H,
it is decimal and the assembler will convert it to hex. Some assemblers use “. ORG”
(notice the dot) instead of “ORG” for the origin directive.
ii) DB:- (Data Byte)
Syntax: Label: DB Byte
Where byte is an 8-bit number represented in either binary, Hex, decimal or ASCII form.
There should be at least one space between label & DB. The colon (:) must present after
label. This directive can be used at the beginning of program. The label will be used in
program instead of actual byte. There should be at least one space between DB & a byte.
Following are some DB examples:
Page 6 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
Page 7 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
SJMP LABEL_X
An advantage of relative addressing is that the program code is easy to relocate in
memory in that the addressing is relative to the position in memory.
6) Absolute addressing Mode:
Absolute addressing within the 8051 is used only by the AJMP (Absolute Jump) and
ACALL (Absolute Call) instructions.
7) Long Addressing Mode: The long addressing mode within the 8051 is used with the
instructions LJMP and LCALL. The address specifies a full 16 bit destination address so
that a jump or a call can be made to a location within a 64KByte code memory space
(216 = 64K).
An example instruction is:
LJMP 5000h; full 16 bit address is specified in operand
8) Indexed Addressing Mode:
With indexed addressing a separate register, either the program counter, PC, or the data
pointer DTPR, is used as a base address and the accumulator is used as an offset address.
The effective address is formed by adding the value from the base address to the value
from the offset address. Indexed addressing in the 8051 is used with the JMP or MOVC
instructions. Look up tables are easy to implement with the help of index addressing.
Consider the example instruction:
MOVC A, @A+DPTR
MOVC is a move instruction, which moves data from the external code memory space.
The address operand in this example is formed by adding the content of the DPTR
register to the accumulator value. Here the DPTR value is referred to as the base address
and the accumulator value us referred to as the index address.
b) Draw neat diagram to interface 8 bit DAC 0808 with 8051.Write ‘C’ language
program to generate staircase waveform.
Ans: 4M- diagram,4M –correct program
Page 8 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
DAC interfacing:
#include<reg51.h>
void Delay(); // delay for frequency
{
int c;
for(c=0;c<1000;c++);
}
void main()
{
P1=0x00; // P1 as output port
while(1)
{
P1=0x00; // step by step increment
Delay();
P1=0x20; // values sent to P2
Delay();
P1=0x40;
Delay();
P1=0x80;
Delay();
}
}
Page 9 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
a) Draw the format of PSW SFR and describe the function of each bit.
Page 10 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
Page 11 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
Page 12 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
Page 13 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
e) Draw the interfacing diagram to connect 8 LEDs to port 2 of 8051 microcontroller. Also write ‘C’
language program to turn ON and OFF LEDs with some delay.
NOTE: Program may change. Student can also use the other logic.
#include <reg51.h>
Page 14 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
Unsignedintx,y;
for(x=0;x<i; x++)
for (y=0;y<1275;y++);
a) Draw the interfacing of stepper motor with 8051 microcontroller. Also draw the flow chart to rotate
the motor through 360 degree in the clockwise
Page 15 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
OR
Page 16 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
b) Write ‘C’ language program for 8051 microcontroller to toggle port 1.0 with some delay.
Program:
# include <reg51.h>
sbit sw=P1^0;
void delay(int) // delay function
void main (void)
{
while (1) // infinite while loop
{
{
sw=1; //port pin is on
delay (100); //delay
sw= 0 ; //port pin is off
delay (100); //delay
}
}
void delay(int k)
{
int i,j;
for(i=0;i<k;i++);
for(j=0;j<100;j++);
}
}
c) Compare between Von-Neumann and Harvard architecture with neat diagram.
Page 17 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
d) List the interrupts of 8051 microcontroller with their vector address and priority upon rest. Explain
SFR used to enable interrupts.
Page 18 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
a) Write an assembly language program for 8051 microcontroller to find the average of ten 8 bit
numbers stored in internal RAM location 20H onwards. Store the result in 31H.
Page 19 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
i) Onchip ROM
iv) Interrupts
Onchip RAM 4 KB 8 KB
a) Draw the interfacing diagram to interface 8 switches to port 0 and 8 LEDs to port 1.
Write „C‟ language program to read switch status and display the same on the LEDs.
Ans:- ( Interfacing diagram- 4 mks, program – 4 mks)
Page 20 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
b) Write and assembly language program to transfer array of ten numbers stored in memory
location 50 H to memory location 60 H.
Page 21 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
Program
c) Write an assembly language program for 8051 to generate square ware of 1 KHZ on port
pin P1.1. User timer 1 and assume crystal frequency to be 12 MHZ. Clearly show the necessary
calculation with comments.
Page 22 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
Program
SJMP L2 ; Reload timer with count as mode 1,is not auto reload
a) Draw the internal structures of port 0 of 8051. Label the same. Describe the process to
ready port 0 pin status.
Page 23 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
b) Write „c‟ language program for 8051 to transmit message “MSBTE” serially a 9600
baud, 8 bit data, 1 stop bit, assuming crystal frequency to be 11,0592 MHZ.
Page 24 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
While (1)
{
For (i=0: i<5;i++)
{
SBUF=text[I];
While)T1==0);
T1=0;
}
}
}
c) With neat algorithm, write an assembly language program to add two BCD
numbers stored at internal RAM location 30 H and 31 H. Store the result in internal RAM
location 40 H.
Algorithm
Program
Page 25 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
END ; Stop
e) Draw interfacing diagram to interface relay at P1.0 and opto-isolator at P1.7 of 8051
microcontroller.
Ans:- ( Proper interfacing diagram- 4 mks)
Page 26 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
____________________________________________________________________________________________
Page 27 of 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
Page1/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
c) List any four C-data types with its range and size. 4M
Ans: Any 4
points-1M
each
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
6M
(OR)
Page3/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
Page4/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
Page5/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
Program:
MOV R3,#09H
L2:MOV R2,#09H
MOV R0,#30H
L1:MOV A,@R0
INC R0
SUBB A,@R0
JC L0
MOV A,@R0
DEC R0
XCH A,@R0
INC R0
MOV @R0,A
L0:DJNZ R2,L1
DJNZ R3,L2
END
(b) Interface ADC 0809 to 8051 and write c program to read analog data at CH7 and 8M
convert it to digital
Ans: Interfacing of ADC with 8051: Diagram
4M
Program
4M
Page6/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
(OR)
Program:
#include <reg 51.h>
sbit ALE = P2^4;
sbit OE = P2^5;
Page7/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
sbit SC = P2^6;
sbit EOC = P2^7;
sbit ADDR_A = P2^0;
sbit ADDR_B = P2^1;
sbit ADDR_C = P2^2;
Sfr MYDATA = P1;
Void MSdelay(void);
void main()
{
unsigned char value;
MYDATA = OxFF;
EOC = 1;
ALE = 0;
OE = 0;
SC = 0;
while(1)
{ADDR_C = 1;
ADDR_B = 1;
ADDR_A = 1;
MSDelay(1);
ALE = 1;
MSDelay(1);
SC = 1;
MSDelay (1);
ALE = 0;
SC = 0;
while(EOC==1);
while(EOC==0);
OE = 1;
MSDelay(1);
value = MYDATA;
OE = 0;
}}
Void Msdelay(unsigned int itime)
{
Int i,j;
for(i=0;i<itime;i++)
{
for (j=0;j<1275;j++);
}
}
(c) Interface stepper motor with 8051 and explain logic to rotate it clockwise by 360. 8M
Assume step angle 1.8.(No program).
Ans: Stepper motor interfacing- Diagram
4M
Page8/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
Logic 4M
(OR)
Page9/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
Page10/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
• Compiler
• Cross assembler
• Cross compiler
• Linker/ Locators
• Loaders
• Simulators
• Debugger
Function: ( Any four component)
Compiler:
It is a computer program that transforms the source code written in a programming or
source language into another computer language i.e. target language i.e. binary code
known as object code. Each
Cross assembler: Function-
It is useful to convert object codes for microcontrollers or processor to other codes for ½M
another microcontrollers or processor and vice versa.
Cross compiler:
It is used to create executable code other than one on which the compiler is run.
They are used to generate executable for embedded systems or multiple platforms.
Linker/Locator:
It is used for relocation process.
It is done during compilation also it can be done at run time by a relocating loader.
It is a program that takes one or more objects generated by compiler and combines them
into a single executable program.
Simulators:
A simulator is the software that simulates an hardware unit like emulator, peripheral,
network and I/O devices on a PC. It defines a processor or processing device as well
as various versions for the target system. It also monitors the detailed information as
source code part with labels and symbols during the execution for each single step.
It provides the detailed information of the status of memory RAM and simulated ports,
simulated peripheral devices of the defined target system.
Page11/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
Debugger:
It is a program that is used to test and debug the target program. Debugger allows to
download code to the Emulator’s memory and then control from PC. It also allows the
programmer to examine and modify the On-chip register and program memory data
1 mark for
Page12/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
0 0 Mode 0 f/12
Mode 3
In mode 3, 11 bits are transmitted through the TXD pin or received through the RXD
pin: a START bit (always 0), 8 data bits (LSB first), a programmable 9th data bit and a
STOP bit (always 1). On transmit, the 9th data bit is actually the TB8 bit of the SCON
register. This bit usually has a function of parity bit. On receive, the 9th data bit goes
into the RB8 bit of the same register (SCON).
The baud rate is decided by Timer1 Overflow time
TRANSMIT – Data transmit is initiated by writing data to the SBUF register. End of
data transmission is indicated by setting the TI bit of the SCON register.
Page13/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
RECEIVE – The START bit (logic zero (0)) on the RXD pin initiates data receive.
The following two conditions must be met: bit REN=1 and bit RI=0. Both of them are
stored in the SCON register. The RI bit is automatically set upon data reception is
complete.
Page14/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
Page15/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
Page16/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
= FE0C H
(OR)
Page17/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
Page18/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
a) Interface DAC0808 with 8051and write C-program to generate saw tooth wave on 8M
P2.1
Ans: 4M
#include<reg51.h>
unsigned char d;
void main(void)
while(1)
Page19/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
{ 4M
P1 = d;
b) Write an ALP to multiply content of internal RAM location 50h and 51h. Store 8M
the result at 2000h(LSB) and 2001(MSB) in external RAM.
Ans: FLOWCHART: 2M
Page20/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
PROGRAM:
MOVX @DPTR,A ; Move the LSB to the External Memory pointed by DPTR
c) Explain bitwise shift operation for right shift and left shift with suitable examples. 8M
P0=0x3C<< 2
So, P0=0xF0
Bitwise Right Shift Operator in C:
• It is denoted by >>
Page21/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
Example:
Syntax : Bitwise Right Shift Operator
[variable]>>[number of places]
P0=0x3C >> 2
After execution of this instruction
Shift number 2 times to Right:
3C=0011 1100
0F=0000 1111
So, P0=0x0F
NOTE: Example May change. Please check the logic and understanding of
students.
Ans: 1. The stack memory is part of RAM used by the CPU to store information Stack
temporarily. explanation
:2M
2. This information may be either data or address.
3. The CPU needs this storage area as there are only a limited amount of registers.
Page22/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
PUSH Instruction:
This instruction increments Stack pointer by 1 and then copies the data at the PUSH:1M
POP: 1M
POP Instruction:
This instruction copies the data at the location pointed by Stack Pointer to the
direct address given in the instruction and then decrements Stack pointer by 1.
Ans: 1. RS: RS is the register select pin used to write display data to the LCD RS: 2M
(characters), this pin has to be high when writing the data to the LCD. During R/W: 1M
the initializing sequence and other commands this pin should low.
EN: 1M
2. R/W: Reading and writing data to the LCD for reading the data R/W pin
should be high (R/W=1) to write the data to LCD R/W pin should be low
(R/W=0).
3. EN: Enable pin is for starting or enabling the module. A high to low pulse of
about 450ns pulse is given to this pin.
Ans: DB :The DB directive is the most widely used data directive in the assembler. It is 1M each
used to define the 8-bit data. When DB is used to define data, the numbers can be in
decimal, binary, hex, or ASCII formats.
Page23/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
ORG: The ORG directive is used to indicate the beginning of the address. The number
that comes after ORG can be either in hex or in decimal. If the number is not followed
by H, it is decimal and the assembler will convert it to hex.
LJMP main
ORG 0030H
MAIN: ….
EQU: This is used to define a constant without occupying a memory location. When
the label appears in the program, constant value will be substituted for the label.
END: This indicates to the assembler the end of the source (asm) file. The END
directive is the last line of an 8051 program, meaning that in the source code anything
after the END directive is ignored by the assembler.
Page24/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
• It is a 16-bit register.
• It is used to hold the address of the external and internal data memory.
• It is used to store a 16-bit data.
• It is also divided into two 8-bit registers viz. DPH and DPL.
• Each registers can be used to hold a 8-bit data.
e) Explain the logic to measure temperature using LM35. Draw interfacing diagram. 4M
Ans: 2M-
DIAGRAM
2M -
EXPLANA
TION
Page25/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
WINTER– 17 EXAMINATION
Subject Title: Microcontroller and applications Subject Code: 17509
ADC converts the analog output voltage of LM35 to corresponding digital value.
Page26/26
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
i Draw the format of TCON and state the function of each bit in it. 4M
Ans Format-2
: marks
Function-
2marks
7 TF1 Timer 1 Overflow flag. Set when timer rolls from all 1's to 0. Cleared
when processor vectors to execute interrupt service routine located at
program address 001Bh.
6 TR1 Timer 1 run control bit. Set to 1 by program to enable timer to count;
cleared to 0 by program to halt timer.
5 TF0 Timer 0 Overflow flag. Set when timer rolls from all 1's to 0. Cleared
when processor vectors to execute interrupt service routine located at
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
program address 000Bh.
4 TR0 Timer 0 run control bit. Set to 1 by program to enable timer to count;
cleared to 0 by program to halt timer.
3 IE1 External interrupt 1 Edge flag. Set to 1 when a high-to-low edge signal is
received on port 3.3 (INT1). Cleared when processor vectors to interrupt
service routine at program address 0013h. Not related to timer
operations.
2 IT1 External interrupt 1 signal type control bit. Set to 1 by program to enable
external interrupt 1 to be triggered by a falling edge signal. Set to 0 by
program to enable a low-level signal on external interrupt 1 to generate
an interrupt.
1 IE0 External interrupt 0 Edge flag. Set to 1 when a high-to-low edge signal is
received on port 3.2 (INT0). Cleared when processor vectors to interrupt
service routine at program address 0003h. Not related to timer
operations.
0 IT0 External interrupt 0 signal type control bit. Set to 1 by program to enable
external interrupt 1 to be triggered by a falling edge signal. Set to 0 by
program to enable a low-level signal on external interrupt 0 to generate
an interrupt.
ii Compare between RISC and CISC machines (any four points). 4M
Ans Any 4
: points –
1mark
each
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
iii Write a program in 'C' to read a byte of data from Port 1 if it is greater than 99 send it to 4M
Port 0 otherwise send it to Port 2.
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
P2=x; //send it to P0
}
}
iv Define Baud rate. State the Baud rate of each mode in UART. 4M
Ans Baud rate :Baud rate is defined as the number of bits transmitted per sec.
: OR
Baud rate is defined as the number of signal changes per second.
I Describe the function of following instructions in terms of length of bytes and operation. 6M
a) RRC A
b) DIV AB
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
A7 = C
C = A0
Bytes:1
.
b)DIV AB
The DIV instruction divides the unsigned 8-bit integer in the accumulator by the unsigned 8-bit
integer in register B. After the division, the quotient is stored in the accumulator and the
remainder is stored in the B register. The carry and OV flags are cleared.
AB = A / B
Bytes:1
The JNB instruction branches to the specified address (DOWN) if the bit P1.3 has a value of 0.
Otherwise, execution continues with the next instruction. No flags are affected by this instruction.
JNB
PC = PC + 3
IF (bit) = 0
PC = PC + offset
Bytes:3
Ans Correct
: labelled
diagram-4
marks
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
(OR)
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
a Write assembly language program to find largest number from the array of ten 8M
numbers stored in external memory RAM. Assume suitable data.
Ans: Assumptions: Array of ten numbers are stored from memory location 3000H onwards and Correct
program-8
result is stored in memory location 6000H
marks
Program:
CLR PSW.3 ; Select Bank 0 PSW.3
MOV R1, 0AH ; Initialize byte counter
MOV DPTR, # 3000H ; Initialize memory pointer
DEC R1 ; Decrement byte counter by 1
MOV X A, @DPTR ; Load number in accumulator
MOV 40 H, A ; Store number in memory location
UP: INC DPTR ; Increment memory pointer by 1
MOVXA, @DTPR ; Read next number
CJNE A, 40 H, DN ; if number≠ next number, and then go to NEXT
DN: JNC NEXT ; If next number < number then go to NEXT
MOV 40H, A ; Else replace NEXT number with number
NEXT: DJNZ R1, UP ; Decrement byte counter by 1, if byte counter≠ 0 then go to UP
MOV DPTR,#6000H ; Increment memory pointer by 1
MOV A, 40H
MOVX@ DPTR, A ; Store result t external memory location
LOOP: AJMP LOOP ; Stop
b Draw interface diagram of ADC 0809 with 8051. Write 'C' language program to generate 8M
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
50 Hz sq. wave with crystal freq = 12 MHz.
Ans: Diagram-4
marks
Program-4
marks
'C' language program to generate 50 Hz sq. wave with crystal freq = 12 MHz.:
Square wave Frequency = 50Hz
Therefore Time period T = 1 / 50HZ = 0.02s
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
}
}
void delay()
{
TMOD=0X01; //set timer 0 in mode 1 i.e. 16 bit number
TL0=0X0F0; //load TL register with LSB of count
TH0=0X0D8 ; //Load TH register with MSB of count
TR0 =1; //Start timer 0
While(TF0==0); //wait until timer rolls over
TR0=0; //Stop timer 0
TF0=0; //Clear timer flag 0 }
}
c Draw interfacing diagram for stepper motor with 8051. Draw flow chart for rotating 8M
stepper motor in clockwise direction.
Ans: Diagram 4
marks
Flowchart-
4 marks
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
Q. Sub Answers Marking
No. Q. Scheme
N.
Ans 2M EACH
:
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
b ̅ = 0 ii) E 𝐀
Draw program memory organization for i) E𝐀 ̅ = 1. 4M
Ans 2M each
:
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
c Compare between 8051 and 8052 microcontroller. 4M
Ans 1M each
:
d Describe the standard data types in 'C' for 8051 with suitable example. 4M
RAM addresses
sfr 8-bit Sfr P1= 0x90;
80-FFH only
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
e Draw interlacing diagram of DAC 0808 with 8051 microcontroller. 4M
Ans 4M
:
Ans ½ M each
: point
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
Ans 1M each
:
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
iii Write 'C' program to toggle only bit P1.2 continuously with 200 ms delay. 4M
void main()
while(1)
LED=0;
delay(200);
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
LED=1;
delay (200);
for(i=0;i<=t;i++)
for(j=0;j<=1275;j++);
Ans 4M
:
Note:(Diagrams drawn using any other ADC (0808,0848 etc.) also to be considered)
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
b Attempt any ONE: 6- Total
Marks
i Write assembly language program to count time period of square wave using 8051 6M
counter. Assume suitable data.
Explanation: If we count the number of pulses applied to P3.4 in 1 ms, we will directly get
the time period in milliseconds. Timer0 is used to count the pulses and Timer1 is used to
generate a delay of 1ms.
Program:
MOV TMOD,#15H //LOAD 15H TO TOMOD REGISTER
SETB P3.4 //P3.4 AS INPUT
MOV TL0,#00H
MOV TH0,#00H //LOAD INITIAL VALUE FOR COUNTING
SETB TR0 //START COUNTER
MOV TL1,#18H
MOV TH1,#0FCH //LOAD COUNT VALUE FOR 1ms DELAY
SAME: JB P3.4,SAME //WAIT FOR FIRST FALLING EDGE OF SQUARE WAVE
SETB TR1 //START TIMER1
BACK: JNB TF1,BACK //CHECK FOR 1ms DELAY
CLR TF1 //CLEAR TF1
CLR TR1 //STOP TIMER1
CLR TR0 //STOP COUNTER0
MOV A,TL0
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
MOV P1,A //LOWER BYTE OF COUNT IN P1
MOV A,TH0 //HIGHER BYTE OF COUNT IN P2
MOV P2,A
SJMP $
ii Draw the diagram to interface external RAM and ROM with 8051 microcontroller and 6M
explain the function of ALE and ̅̅̅̅̅̅̅̅
𝐏𝐒𝐄𝐍 pins of 8051.
Ans 4M
: (drawing)
1M each
(function)
PSEN pin stands for Program Store Enable. It is used to read a signal from the external
program memory.
ALE/PROG: Address Latch Enable output pulse for latching the low byte of the address
during accesses to external memory. This pin is also the program pulse input (PROG)
during EPROM programming.
Ans There are a number of addressing modes available to the 8051 instruction set, as follows: Any four, 2
: marks
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
1. Immediate Addressing mode each (1
mark for
2. Register Addressing mode explanatio
3. Direct Addressing mode n and 1
mark for
4 Register Indirect addressing mode example)
1) Immediate Addressing mode: Immediate addressing simply means that the operand
(which immediately follows the Instruction op. code) is the data value to be used.
For example the instruction: MOV A, #25H ; Load 25H into A Moves the value 25H into
the accumulator. The # symbol tells the assembler that the immediate addressing mode
is to be used.
3) Direct Addressing Mode: Direct addressing means that the data value is obtained
directly from the memory location specified in the operand.
For example consider the instruction: MOV R0, 40H; Save contents of RAM location 40H
in R0. The instruction reads the data from Internal RAM address 40H and stores this in
theR0. Direct addressing can be used to access Internal RAM, including the SFR registers.
An example instruction, which uses indirect addressing, is as follows: MOV A, @R0; move
contents of RAM location whose address is held by R0 into A Note the @ symbol
indicated that the indirect addressing mode is used. If the data is inside the CPU, only
registers R0 & R1 are used for this purpose.
5) Relative Addressing Mode: This is a special addressing mode used with certain jump
Page No: 21/31
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
instructions. The relative address, often referred to as an offset, is an 8-bit signed
number, which is automatically added to the PC to make the address of the next
instruction. The 8-bitsigned offset value gives an address range of + 127 to –128
locations.
6) Absolute addressing Mode: Absolute addressing within the 8051 is used only by the
AJMP (Absolute Jump) and ACALL (Absolute Call) instructions.
7) Long Addressing Mode: The long addressing mode within the 8051 is used with the
instructions LJMP and LCALL. The address specifies a full 16 bit destination address so
that a jump or a call can be made to a location within a 64KByte code memory space (216
= 64K). An example instruction is: LJMP 5000h; full 16 bit address is specified in operand
8) Indexed Addressing Mode: With indexed addressing a separate register, either the
program counter, PC, or the data pointer DTPR, is used as a base address and the
accumulator is used as an offset address. The effective address is formed by adding the
value from the base address to the value from the offset address. Indexed addressing in
the 8051 is used with the JMP or MOVC instructions. Look up tables are easy to
implement with the help of index addressing.
MOVC A, @A+DPTR
MOVC is a move instruction, which moves data from the external code memory space.
The address operand in this example is formed by adding the content of the DPTR register
to the accumulator value. Here the DPTR value is referred to as the base address and the
accumulator value us referred to as the index address.
b Write 'C' language program to transfer the message "AICTE" serially at baud rate 9600. 8M
Assume crystal frequency 11.0592 MHz.
Ans Calculatio
: Normally Serial communication MODE 1 is used (8 bit UART with variable baud rate). For n of count
setting baud rate, TIMER 1 to be programmed in Mode 2 – Auto reload mode. – 1M
Following formula is used for calculation of Count to be given to Timer 1 register, TH1 to
set standard baud rate. Program :-
7M
𝑓 2𝑠𝑚𝑜𝑑 𝑓
𝑜𝑠𝑐
𝑏𝑎𝑢𝑑= 32
𝑋 12 𝑋 (256−𝑇𝐻1)
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
20 11059200
Hence for 9600 baud, 9600 = 𝑋
32 12 𝑋 (256−𝑇𝐻1)
From this formula we get value to be loaded to TH1 as FD H
(Any other logically similar method may also be used for calculation)
Program:
#include <REG51.H>
void main(void)
{
unsigned char text[] = “AICTE”;
unsigned char i;
TMOD = 0x20;
TH1 = 0xFD;
SCON = 0x50;
TR1 = 1;
while(1)
{
for(i =0;i<5;i++)
{
SBUF= text[i];
while(TI ==0);
TI = 0;
}
}
}
c Draw and explain the interfacing of seven segment LED display in common cathode 8M
with 8051 microcontroller. Write 'C' language program to display digit 0 to 9.
Ans 4 marks
: diagram
4 marks
program
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
void main ()
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
{
while(1)
P1 = 0x3F; //DISPLAY 0
delay_ms(1000);
P1 = 0x06; //DISPLAY 1
delay_ms(1000);
P1 = 0x5B; //DISPLAY 2
delay_ms(1000);
P1 = 0x4F; //DISPLAY 3
delay_ms(1000);
P1 = 0x66; //DISPLAY 4
delay_ms(1000);
P1 = 0x6D; //DISPLAY 5
delay_ms(1000);
P1 = 0x7D; //DISPLAY 6
delay_ms(1000);
P1 = 0x07; //DISPLAY 7
delay_ms(1000);
P1 = 0x7F; //DISPLAY 8
delay_ms(1000);
P1 = 0x6F; //DISPLAY 9
delay_ms(1000);
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
}
NOTE: Program may change. Student can also use the other logic. Please check the logic
and understanding of students.
a Draw the format of IE register of 8051 and state the function of each bit. 4M
Ans 2 mark
: format 2
marks
function
i) ORG
ii) DB
iii) EQU
iv) END
Ans 1 mark
: each
( Each directive explanation with example : 1 mark each)
1. ORG : ORIGIN The ORG directive is used to indicate the beginning of the address. The
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
number that comes after ORG is the address from where program will begin. The number
can be either in hex and decimal
2. DB : Define Byte It is used to define the 8-bit data. It is used to write the value after
DB , into the program memory. When DB is used to define data, the numbers can be in
decimal, binary, hex, ASCII formats
MYDATA: DB 20,21
4. END: This indicates to the assembler the end of the source (asm) file . The END
directive is the last line of an 8051 program. Means that in the program anything after
the END directive is ignored by the assembler
ADD A , #10
END
Ans 4 marks
Pin Name: Description
: Pin
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
No:
2 Vdd (+5 Volt) Powers the LCD with +5V (4.7V – 5.3V)
7 Data Pin 0
8 Data Pin 1
9 Data Pin 2 Data pins 0 to 7 forms a 8-bit data line. They can be connected
to Microcontroller to send 8-bit data.
10 Data Pin 3
These LCD’s can also operate on 4-bit mode in such case Data
pin 4,5,6 and 7 will be left free.
11 Data Pin 4
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
12 Data Pin 5
13 Data Pin 6
14 Data Pin 7
Ans 2 marks
: diagram 2
marks
explainati
on
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
damage input side electrical components.
The output of opto coupler is given to relay which further operates the output device
Ans 2 marks
: each
An 8051
clock circuit is shown above. In general cases, a quartz crystal is used to make the clock
circuit. The connection is shown in figure (a) and note the connections to XTAL 1 and XTAL
2. In some cases external clock sources are used and you can see the various connections
above. Clock frequency limits (maximum and minimum) may change from device to
device. Standard practice is to use 12MHz frequency. If serial communications are
involved then its best to use 11.0592 MHz frequency.
SUMMER– 18 EXAMINATION
Subject Name: Microprocessor & Applications Model Answer Subject Code: 17509
__________________________________________________________________________________________________
One machine cycle has 6 states. One state is 2 T-states. Therefore one machine cycle is 12
T-states. Time to execute an instruction is found by multiplying C by 12 and dividing
product by Crystal frequency.
T=(C*12d)/crystal frequency
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
1
1) (69)2 – (34)2
2) (18)2 – (27)2
Page 1/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
2
Ans: 2M EACH
i) ̅̅̅̅̅̅̅̅
𝑷𝑺𝑬𝑵
ii) ̅̅̅̅
𝑬𝑨
iii) RST
iv) ALE
Page 2/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
3
Ans: 1. ̅̅̅̅̅̅̅̅
𝑷𝑺𝑬𝑵 − It is active low output control signal used to activate enable signal of external 1M each
ROM/ EPROM .it is activated every six oscillator periods while reading the external
memory.
2. ̅̅̅̅
𝑬𝑨 − It is active low output control signal. When EA = 1, µc accesses internal and
external program memory when EA =0, µc accesses only external program memory.
3. RST: It is a RESET pin, which is used to reset the microcontroller to its initial values.
4. ALE: There are two ALE pulses per machine cycle. The ALE pulse, which is primarily used
as a timing pulse for external memory access, indicates when every instruction byte is
fetched.
Ans: 1.) Direct Addressing Mode: Direct addressing means that the data value is 1M each
obtained directly from the memory location specified in the operand.
For example: ADD A, 40H- ADD the content of Acumulator and the content of
memory location 40H and store the result in A.
2.) Indirect Addressing Mode: Indirect addressing means that the data value is
obtained from the memory location pointed by the register specified in the
operand.
Eg: ADD A, @R0 - ADD the content of A and the content of memory location
pointed by R0 and store the result in A.
Note the @ symbol indicated that the indirect addressing mode is used. If the
data is inside the CPU, only registers R0 & R1 are used for this purpose.
3.) Register Addressing Mode: One of the eight general-registers, R0 to R7, can be
Page 3/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
4
Ans: Mode 0 – 8 bit shift Register- In this mode, the serial port works like a shift register 1M each
and the data transmission works synchronously with a clock frequency of fosc /12.
Serial data is received and transmitted through RXD. 8 bits are transmitted/ received
at a time. Pin TXD outputs the shift clock pulses of frequency fosc /12, which is
connected to the external circuitry for synchronization In Mode 0, the baud rate is
fixed at Fosc. / 12.
Mode 1 : 8-bit UART 10 bits are transmitted through TXD or received through
RXD. The 10 bits consist of one start bit (which is usually '0'), 8 data bits (LSB is
sent first/received first), and a stop bit (which is usually '1'). Once received, the stop
bit goes into RB8 in the special function register SCON. The baud rate is variable.
Mode 2 : 9-bit UART- In this mode 11 bits are transmitted through TXD or received
through RXD.The various bits are as follows: a start bit (usually '0'), 8 data bits (LSB
Page 4/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
5
first), a programmable 9 th (TB8 or RB8)bit and a stop bit (usually '1'). While
transmitting, the 9 th data bit (TB8 in SCON) can be assigned the value '0' or '1'. For
example, if the information of parity is to be transmitted, the parity bit (P) in PSW
could be moved into TB8.On reception of the data, the 9 th bit goes into RB8 in
'SCON', while the stop bit is ignored.
2SMOD X OSCILLATOR FREQ
BAUD RATE=
64
Mode 3: 9-Bit UART with Variable Baud Rate- In this mode 11 bits are
transmitted through TXD or received through RXD. The various bits are: a start bit
(usually '0'), 8 data bits (LSB first), a programmable 9th bit and a stop bit (usually
'1'). Mode-3 is same as mode-2, except the fact that the baud rate in mode-3 is
variable (i.e., just as in mode-1).
(a) Write ALP to find smallest number in an array of 10 numbers stored in Internal RAM. 6M
Page 5/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
6
equal
AJMP SMALL ; if equal jump to small label
DOWN: JNC SMALL ; jump to small label if no carry
MOV 60H, A ; move the content of A to 60h
SMALL: DJNZ R1,UP ; decrement R1 and jump to up label if not equal
END
Ans: 3M
diagram,
3M
program
PROGRAM:
ORG 0000H
MOV A,#33H
L1: MOV P1,A
ACALL DELAY
RR A
SJMP L1
Page 6/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
7
DELAY:
MOV R1,#0FH
L2: MOV R2, # 0FFH
L: DJNZ R2, L
DJNZ R1, L2
RET
END
a) Draw and explain internal RAM organization of microcontroller 8051, and show address 8M
areas for each section.
Ans: 4M
diagram,4
M
explanati
on
OR
Page 7/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
8
Internal ROM- The 8051 has 4K (4096 locations) of on-chip ROM. This is used for storing the system
program. 212 = 4096, therefore the internal ROM address bus is 12 bits wide and internal ROM
locations go from 000H to FFFH.
Internal RAM -There are 256 bytes of internal RAM on the 8051. 28 = 256, therefore the internal
RAM address bus is 8 bits wide and internal RAM locations go from 00H to FFH.
Register Banks- There are four register banks from 00H to 1FH. On power-up, registers R0 to R7 are
located at 00H to 07H. However, this can be changed so that the register set points to any of the
other three banks (if you change to Bank 2, for example, R0 to R7 is now located at 10H to 17H).
Bit-addressable Locations-The 8051 contains 210 bit-addressable locations of which 128 are at
locations 20H to 2FH while the rest are in the SFRs. Each of the 128 bits from 20H to 2FH have a
unique number (address) attached to them, as shown in the table above. The 8051 instruction set
allows to set or reset any single bit in this section of RAM. With the general purpose RAM from 30H
Page 8/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
9
to 7FH and the register banks from 00H to 1FH, you may only read or write a full byte (8 bits) at
these locations. However, with bit-addressable RAM (20H to 2FH) you can read or write any single
bit in this region by using the unique address for that bit. We will later see that this is a very
powerful feature.
General Purpose RAM- These 80 bytes of Internal RAM memory are available for general-purpose
data storage. The general purpose RAM can be accessed using direct or indirect addressing mode
instructions.
Special Function Registers (SFRs)-Locations 80H to FFH contain the special function registers. As
you can see from the diagram above, not all locations are used by the 8051 (eleven locations are
blank). These extra locations are used by other family members (8052, etc.) for the extra features
these microcontrollers possess. Not all SFRs are bit-addressable. Those that are have a unique
address for each bit.
b) Write ALP for 8051 microcontroller to generate a delay 0f 3μs using timer 1. Draw flow 8M
chart also. Assume crystal frequency 12MHz.
Calculations: 1M
Calculatio
Formula to calculate count n, 4M
Crystal freq. = 12MHz program,
3M
Timer freq. – 12/12 =1MHz flowchart
TH1= 0FFH
TL1=0FDH
Program:
Page 9/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
10
SJMP UP ; repeat
c) Draw and explain interfacing diagram for DC motor speed control using 8051 μc. Also 8M
develop flow chart for same operation.
Page
10/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
11
Ans: 3M
diagram,
3M
Explainati
on,
2M
flowchart
Explanation:
1. The maximum current which can be sunk from 89C51 is upto 15mA at 5V.
2. But DC motor needs more current depending on its type. Hence DC motor cannot
be connected directly to the microcontroller.
3. L293D motor driver stops the back emf produced by the motor from affecting the
microcontroller.
4. Port pins P1.0 and P1.1 are connected to the input pins 2 and 7 of L293D motor
driver.
5. The output pins of the L293D ,pin 3 and 6 are connected to the DC motor.
6. Direction of the rotation of the motor can be changed by inverting the output
terminals
Page
11/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
12
Page
12/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
13
Ans: Diagram-
4M
i) DB
ii) ORG
iii) EQU
iv) END
Page
13/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
14
Example:
DATA1: DB 28 ; (decimal data stored as 1C hex)
DATA2: DB 01010101B ;(Binary data stored as 35 in hex)
DATA3: DB 5FH ;(Hex)
DATA4: DB “ABCDE” ; ASCII characters
The ORG directive is used to indicate the beginning of the address. The number that comes
after ORG is the address from where program will begin. The number can be either in hex
and decimal.
EQU: This is used to define a constant without occupying a memory location. When
the label appears in the program, constant value will be substituted for the label.
Page
14/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
15
Example:
NUMBER EQU 25H
MOV R3,#NUMBER ;
R3 = 25H as 25H will be substituted for NUMBER
iv) END
This indicates to the assembler the end of the source (asm) file. The END directive is the
last line of an 8051 program, meaning that in the source code anything after the END
directive is ignored by the assembler.
d) State any four ‘C’ data types with their range of values. 4M
Page
15/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
16
Ans: Interfacin
g
diagram-
2M
&
Explainati
on-2M
Explanation:
• It is the function of the microcontroller to scan the keyboard continuously to detect and
identify the key pressed
• First microcontroller checks whether all keys are open before the start of operation, by
grounding all the rows and ensuring that the input port has 111.
• To detect a pressed key, the microcontroller again grounds all rows by providing 0 to the
output latch, then it reads the columns
• If the data read from columns is D2 – D0 = 111, no key has been pressed and the process
continues till key press is detected
• If one of the column bits has a zero, this means that a key press has occurred
• Then the program waits for 20ms (debounce time) and check for the key pressed again. If
still the key pressed is detected, it proceeds.
• After detecting a key press, microcontroller will go through the process of identifying the
key
• Starting with the top row, the microcontroller grounds it by providing a low to row D0
only
Page
16/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
17
• It reads the columns, if the data read is all 1s, no key in that row is activated and the
process is moved to the next row
• It grounds the next row, reads the columns, and checks for any zero
• This process continues until the row is identified
• After identification of the row in which the key has been pressed Find out which column
the pressed key belongs to
• Upon finding the row that the key press belongs to, it sets up the starting address for the
look-up table holding the scan codes (or ASCII) for that row
• To identify the key press, it rotates the column bits, one bit at a time, into the carry flag
and checks to see if it is low
• Upon finding the zero, it pulls out the ASCII code for that key from the look-up table
• Otherwise, it increments the pointer to point to the next element of the look-up table
Timers 2 3
I/O pins 32 32
Serial port 1 1
Page
17/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
18
Interrupts 6 8
Watchdog No No
timer
(b) Draw format of PSW register of 8051 μc and explain function of any two flag. 4M
Ans: Format-
2M
&
Function
of any
two flag-
2M(1M
each)
PSW register is one of the most important SFRs. It contains several status bits that reflect
the current state of the CPU. Besides, this register contains Carry bit, Auxiliary Carry, two
register bank select bits, Overflow flag, parity bit and user-definable status flag.
P - Parity bit- If a number stored in the accumulator is even then this bit will be
automatically set (1), otherwise it will be cleared (0). It is mainly used during data transmit
Page
18/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
19
1) MOVX A,@DPTR
2) SWAP A
3) MUL AB
4) MOV A, R0
Page
19/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
20
MOVX instruction allows access to external data memory space. This instruction is n-1M
used for general purpose access of data memory. This instruction will read the byte
of data pointed to by register DPTR and store it in the accumulator.
Operation: A (DPTR)
2) SWAP A
3) MUL AB
Operation: BA A * B
In byte by byte multiplication, one of the operand must be in register A, and second
Page
20/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
21
operand must be in register B. after multiplication, the 16 bit result is held by A and
B registers as lower byte is in A, and upper byte is in B.
Addressing mode: Register addressing mode
4) MOV A,R0
No. of bytes – 1byte
Operation: A˂--- R0
Load the contents of R0 in the accumulator.
Addressing mode: Register addressing mode
(d) Write a program to send “ WELCOME” serially on 8051 μc, use baud rate of 2400. 4M
(OR)
Page
21/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
22
Program:
#include <REG51.H>
void main(void)
{
unsigned char text[] = “WELCOME”;
unsigned char i;
TMOD = 0x20;
TH1 = 0XF4;
SCON = 0x50;
TR1 = 1;
while(1)
{
for(i =0;i<7;i++)
{
SBUF= text[i];
while(TI ==0);
TI = 0;
}
}
}
(a) List all I/O ports of 8051 μc and describe alternative functions of each ports. 6M
Page
22/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
23
Ans: 8051 Microcontroller provides 4 I/O ports as P0,P1, P2 & P3 each as 8 bit port. List-1M
Page
23/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
24
(b) With necessary interfacing diagram, write a ‘C’ program to generate a triangular wave 6M
using DAC.
Ans: Interfacin
g
diagram-
3M
&
Program-
3M
Page
24/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
25
#include<reg51.h>
void main(void)
{
unsigned char d;
while(1)
{
for(d=0; d<=255; d++)
{
P1 = d;
}
for(d=255; d>=0; d--)
{
Page
25/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
26
P1 = d;
}
}
}
a) Write ALP to exchange 10 bytes of data from source location 20H to destination location 8M
60 H for 8051 μc.
Ans: ( Program with any other relevant logic can be considered) ( Correct
program
logic= 6
ORG 0000H marks,
MOV R0,#20H ; source pointer R0 = 20H Comment
s =2 marks
MOV R1,#60H ; Destination pointer R1= 60H )
MOV R2,# 0AH ; count = 10
UP: MOV A,@R0 ; Read first data byte
MOV B,@R1 ; Read second data byte
MOV @R0,B ; exchange numbers
MOV @R1,A ;
INC R0 ; increment source pointer
INC R1 ; increment destination pointer
DJNZ R2,UP ; decrement count and if count not equal to 0 jump UP
END ; end of program
b) Write ‘C’ language program to toggle all bits of port 1 of 8051 μc continuously with 5 ms 8M
delay.
Page
26/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
27
Ans: ( Correct
program
( Program with any other relevant logic can be considered)
logic= 6
marks,
#include < reg 51.h> Comment
s =2 marks
void delay (unsigned int); )
void main (void)
{
while(1) //repeat loop
{
P1=0xff; //toggle all bits of port1
delay (5); //add 5ms delay
P1=0x00; //toggle all bits of port1
delay (5); //add 5ms delay
}
}
void delay (unsigned inti)
{
Unsigned int x,y;
for(x=0; x<i ; x++)
for(y =0 ; y <1275 ; y++);
}
c) Draw neat labeled interfacing diagram to control lamp at pin 1.0, by using opto isolator 8M
with 8051 μc.
Page
27/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
28
Ans: ( CORRECT
DIAGRAM
: 8M)
Ans: (Diagram
: 2 marks
explainati
on : 2
marks)
The Von Neumann architecture uses single memory for storing instructions and
data.
It requires single bus for instructions and data.
Width of address and data bus for program and data memory are same
Instructions and data have to be fetched in sequential order limiting the
Page
28/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
29
operation bandwidth
For e.g. general purpose microprocessors
b) With the help of neat diagram, describe timer modes of 8051 μc. 4M
Page
29/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
30
Page
30/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
31
This program typically provides many features for authoring, modifying, compiling,
deploying and debugging software.
Page
31/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
32
Page
32/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
WINTER– 18 EXAMINATION
Subject Name: Microcontroller and Applications Model Answer Subject Code: 17509
33
{
if ( SW == 0) // check if switch is closed
{
LED =1;// turn LED ON
}
Else
{
LED = 0;// turn LED OFF
}
}// End of while loop
}// End of program
e) Draw interfacing diagram for temperature measurement using LM 35 sensor with 8051 4M
μc.
Ans: ( Correct
diagram :
4M)
Page
33/33
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
Page 1/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
(b) Draw the format of PSW of 8051 and state the function of each bit 4M
Function
2M
P - Parity bit. If a number stored in the accumulator is even then this bit will be automatically
set (1), otherwise it will be cleared (0). It is mainly used during data transmit and receive via
serial communication.
OV: Overflow This flag is set whenever the result of a signed number operation is too large,
causing the high-order bit to overflow into the sign bit. In general, the carry flag is used to
detect errors in unsigned arithmetic operations. The overflow flag is only used to detect
Page 2/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
RS0, RS1 - Register bank select bits. These two bits are used to select one of four register
banks of RAM. By setting and clearing these bits, registers R0-R7 are stored in one of four
banks of RAM.
AC - Auxiliary Carry Flag is used for BCD operations only. If there is a carry from D3 and D4
during an ADD or SUB operation, this bit is set.
CY - Carry Flag is set whenever there is a carry out from D7 bit. It is affected after all
arithmetical operations and shift instructions. It also can be set to 1 or 0 using instructions
SETB c and CLR c
(c) Describe the following assembler directive with one example each: 4M
(i) ORG
(ii)DB
(iii)EQU
(iv) END
Page 3/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
Where byte is an 8-bit number represented in either binary, Hex, decimal or ASCII
form. There should be at least one space between label & DB. The colon (:) must
present after label. This directive can be used at the beginning of program. The label
will be used in program instead of actual byte. There should be at least one space
between DB & a byte. Following are some DB examples:
Page 4/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
Each data
type with
value:1M
(e) Draw the pin diagram of 20 X 4 LCD display and state the function of RS,EN & R/W
pins
Ans: Pin
Diagram:
2M
Function
of RS:1M
EN: ½M
R/W: ½ M
Page 5/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
RS: RS is the register select pin used to write display data to the LCD (characters), this pin has
to be high when writing the data to the LCD. During the initializing sequence and other
commands this pin should low.
R/W: Reading and writing data to the LCD for reading the data R/W pin should be high
(R/W=1) to write the data to LCD R/W pin should be low (R/W=0).
EN: Enable pin is for starting or enabling the module. A high to low pulse of about 450ns
pulse is given to this pin.
Page 6/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
No of bytes: 1 byte
2. DAA
If the auxiliary carry bit is set or if the value of bits 0-3(lower nibble) exceed 9, 0x06 is added
to the accumulator. If the carry bit is set or if the value of bits 4-7 (higher nibble) exceeds 9,
0x60 is added to the accumulator.
No of bytes: 1 byte
Ans: Each
Point:1M
Sr. Parameter Microprocessor Microcontroller
No.
1 No. of Many instructions to Few instruction to read/ write
instruction read/write data to/ from data to/ from external memory
s used external memory
Page 7/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
Ans Each
Mode:1M
1. Mode 0 : 13 bit timer/counter
In mode 0, the timer/counter is configured as a 13-bit timer/counter. The upper 8 bits of the
count are in TH .The lower 5 bits are in the lower 5 bits of TL. The upper 3 bits of TL are not
used. The TFx flag will be set when the timer /counter Overflows from all 1’s to all 0’s. The
Page 8/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
In mode 1, the timer/counter is configured as a 16-bit timer/counter. The upper 8 bits of the
count are in TH & The lower 8 bits are in TL. The TFx flag will be set when the timer / counter
overflows from all 1’s to all 0’s. The timer continues to count.
TL operates as an 8-bit Timer / counter.TH holds a reload value. When TL overflows (reached
FFH), the TFx flag is set, TL is reloaded from the value in TH and counting continues.
Timer 0 is split into two independent 8-bit timers.TL0 acts as 8 bit Timer / Counter When TL0
overflows, it sets the TF0 flag.TH0 acts as 8 bit Timer, When TH0 overflows, it sets the TF1
flag. Timer 1 is stopped in mode 3. It can be switched independently to a different mode.
However, when it overflows it will NOT set the TF1 flag.
Page 9/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
10
c) Write an assembly language program to transfer the external memory location content of 4M
address 2400 H to internal RAM location42 H
Ans Program:
3M
(Consider Any other Correct Logic)
Comment
ORG 0000 :1M
MOV DPH, #24H; Move higher byte of external memory address to DPH
MOV DPL, #00H; Move lower byte of external memory address to DPL
MOV @R0, A; Move content of Accumulator into memory location pointed by register
END
Ans Each
instructio
(i) P0= 0x56 >>3; shift 3 times to right n: 2M
Page
10/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
11
Ans: Format:1
M
SM0 SCON.7 Serial port mode specifier AND SM1 SCON.6 Serial port mode specifier.
Each pin
Descriptio
n: 1/2 M
REN SCON.4 Set/ cleared by software to enable/ disable reception. When the REN =1, it
allows the 8051 to receive data on the RxD pin of the 8051. As a result if we want the 8051
to both transfer and receive data, REN must be set to 1. By making REN=0, the receiver is
disabled.
TB8 SCON.3 TB8 (transfer bit 8) is bit D3 of SCON. It is used for serial modes 2 and 3. We
make TB8=0 since it is not used in our applications.
RB8 SCON.2 Not widely used. RB8 (receive bit 8) is bit D2 of the SCON register. In serial
mode 1, this bit gets copy of the stop bit when an 8 bit data is received.
TI SCON.1 Transmit interrupt flag. Set by hardware at the beginning of the stop Bit in
mode 1. Must be cleared by software. This is an extremely important flag bit in the SCON
register. When the 8051 finishes the transfer of the 8 bit character, it raises the T1 flag to
indicate that it is ready to transfer another byte. The TI bit is raised at the beginning of the
stop bit.
RI SCON.0 Receive interrupt flag. Set by hardware halfway through the stop bit time in
mode 1. Must be cleared by software. When the 8051 receives data serially via RxD, it gets
rid of the start and stop bits and places the byte in the SBUF register. Then it raises the RI
flag bit to indicate that a byte has been received and picked up before it is lost. RI is raised
Page
11/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
12
(f) Write any four assembly language instructions to make accumulator contents to zero 4M
Ans: Each
instructio
1. MOV A, #00H
n: 1M
2. ANL A, A
3. XRL A, A
4. SUB A, A
a) Convert : 4M
(i)(542)10into Hex
(ii)(4FDA)16into Binary
=(21E)16
(ii)(4FDA)16into Binary
(4 F D A)16
=(0100 1111 1101 1010)2
b) List interrupts in 8051 microcontroller with their priorities and vector address 4M
Page
12/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer Subject Code:17509
13
Ans: l
Interrupt Source Vector address Interrupt priority l
i
External Interrupt 0 –INT0 0003H 1 u
u
Timer 0 Interrupt 000BH 2
i
External Interrupt 1 –INT1 0013H 3 s
t
Timer 1 Interrupt 001BH 4
-
Serial Interrupt 0023H 5
1
c) List any four addressing modes of 8051 microcontroller with one example of each 4M
Ans: There are a number of addressing modes available to the 8051 instruction set, as follows: 1M—Each
1. Immediate Addressing mode addressin
2. Register Addressing mode g mode
3. Direct Addressing mode with
4 Register Indirect addressing mode example
5. Relative Addressing mode
6. Absolute addressing mode
7. Long Addressing mode
8. Indexed Addressing mode
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
14
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
15
d) Write a “C” language program to toggle pin PI 2 continuously with some delay 4M
Page
15/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
16
Ans 4M-
correct
interfacin
g diagram
f) Draw the format of IP register of 8051 microcontroller and state the function of each bit 4M
Ans: 2M-
format,
2M –
explanati
on
Page
16/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
17
(a) Write an assembly language program to find smallest number from the array of ten 8M
numbers stored in internal RAM 50 H onwards
(b) Write an assembly language program to generate square wave of 5 kHz , on port pin P2.4 8M
using timer 1. Assume XTAL = 12 MHz ( show delay calculation )
Ans: Solution : 1M –
Frequency = 5 KHZ delay
calculatio
Time period T = 1 / 5 KHZ = 0.2 ms
n, 6M—
Required time delay = TON = TOFF = T / 2 = 0.2ms / 2 = 0.1 ms = 100usec
correct
program
Required time delay = ( 12 / Fosc ) x number of increments (N) 1M:
100 us = ( 12 / 12MHZ ) x number of increments (N) comment
100 us = 1.0 usec. x N s
N = 100
Page
17/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
18
Program is as follows :
MOV TMOD, #10H ; timer 1, mode 1
AGAIN : MOV TL1, #9CH ; TL1 = 1A, low byte of timer
MOV TH1, #0FFH ; TH1 = FF, higher byte of timer
SETB TR1 ; Start the timer 1
BACK : JNB TF1, BACK ; stay until timer rolls over
CLR TR1 ; Stop timer 1
CPL P2.4 ; Complement P2.4 to get high, low
CLR TF1 ; Clear timer flag 1
SJMP AGAIN ; reload the timer
(c) Draw the interfacing diagram where P2.3 pin of 8051 microcontroller is used to control 8M
relay which in turn controls the fan connected to 230 V. Describe operations of this circuit.
Ans: Microcontroller are intelligent devices but they can’t switch ON or OFF your room fan as they 4 M—
can’t handle heavy current so we use relays to do so. correct
diagram,4
Microcontroller can power ON or OFF an Relay’s Electromagnet. M—
When Electromagnet is turned on or off you can easily hear a sound of ‘tick’ just like a Operation
practical room switch. However, there is a glitch here: Relays electromagnet requires heavy of the
current to operate which Microcontroller can’t possible handle. circuit
The current sinking cability of each port pin of 8052 is only 20mA.
Hence port pin to which relay is connected may get damaged.To avoid this problem
ULN2003/ULN2803 driver is used.
In the figure Port 2 pin P2.3 is connected to in1pin of ULN2803.The out1 pin of ULN2803 is
connected to the relat which is connected to the fan.
Page
18/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
19
a) Draw the interfacing diagram of stepper motor to Port 1 pins of 8051. Use ULN 2003 driver 4M
IC
Ans: 4M
Page
19/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
20
(i)
(ii)ALE
(iii)
(iv)RST
Ans (i) : It is active low output control signal used to activate enable signal of external 1M- EACH
ROM/ EPRM . it is activated every six oscillator periods while reading the external memory.
(ii)ALE : There are two ALE pulses per machine cycle. The Ale pulse, which is primarily
used as a timing pulse for external memory access, indicates when every instruction byte is
fetched.
(iii) : It is active low output control signal. When EA = 1, μc accesses internal and external
program memory when EA =0, μc accesses only external program memory.
(iv)RST : It is a RESET pin, which is used to reset the microcontroller to its initial values.
Page
20/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
21
C) Draw the labelled interfacing diagram of ADC 0809 with 8051 microcontroller 4M
Ans 4M
Page
21/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
22
When the control is '0', the port can be used as a normal bidirectional I/O port. When the port
is used as an input port, '1' must be written to the latch and to output 0 on the pin „0‟ must be
written to the latch. When the control is '1', the port can be used as address/data bus(AD0 –
AD7)for external data transfer.
e) Describe any four tools of IDE 4M
Page
22/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
23
They are used to generate executable for embedded systems or multiple platforms.
Linker/Locator:
It is used for relocation process.
It is done during compilation also it can be done at run time by a relocating loader.
It is a program that takes one or more objects generated by compiler and combines them
into a single executable program.
Simulators:
A simulator is the software that simulates an hardware unit like emulator, peripheral,
network and I/O devices on a PC. It defines a processor or processing device as well
as various versions for the target system. It also monitors the detailed information as
source code part with labels and symbols during the execution for each single step.
It provides the detailed information of the status of memory RAM and simulated ports,
simulated peripheral devices of the defined target system.
Debugger:
It is a program that is used to test and debug the target program. Debugger allows to
download code to the Emulator’s memory and then control from PC. It also allows the
programmer to examine and modify the On-chip register and program memory data.
Ans: 4M
Page
23/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
24
Ans: 2M
DIAGRAM,
1M STACK,
Page
24/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
25
1M
stackpointer
Stack: The stack is a section of a RAM used by the CPU to store information such as data or
memory address on temporary basis. The CPU needs this storage area considering limited
number of registers. The register used to access the stack is known as the stack pointer
register.
Stack pointer: The 8-bit stack pointer (SP) register is used to hold an internal RAM address
that is called the top of stack. The address held in the SP register is the location in internal
RAM where the last byte of data was stored by a stack operation.
Page
25/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
26
Ans: 4M
d) Write “C” language program to transfer the character “A” serially at baud rate 9600 , 8 bit 4M
data. 1 stop bit. Assume crystal frequency 11.0592 MHz
Ans: ( For any other relevant logic, marks can be given) 3M-
PROGRAM,
#include<reg51.h> 1M-
COMMENTS
void main(void)
{
TMOD=0x20; //use timer1, mode 2
TH1=0xfd; // 9600 baudrate
Page
26/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
27
SCON=0x50h;
tr1=1;
while(1)
{
SBUF=’A’; // place value in buffer
while(TI==0);
TI=0;
}
}
Ans: 4M
Ans 4M
Page
27/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
SUMMER– 19 EXAMINATION
Subject Name : Microcontroller and Application Model Answer 17509
Subject Code:
28
Page
28/28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
WINTER – 19EXAMINATIONS
Subject Name:Microcontroller and ApplicationsModel AnswerSubject Code: 17509
Important Instructions to examiners:
1) The answers should be examined by key words and not as word-to-word as given in themodel answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try to assess the understanding
level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given moreImportance (Not applicable for
subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in thefigure. The figures drawn by
candidate and model answer may vary. The examiner may give credit for anyequivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed constant values may vary and there
may be some difference in the candidate’s answers and model answer.
6) In case of some questions credit may be given by judgment on part of examiner of relevant answer based on candidate’s
understanding.
7) For programming language papers, credit may be given to any other program based on equivalent concept.
Ans: RS: RS is the register select pin used to write display data to the LCD (characters), this pin 1M
hasto be high when writing the data to the LCD. During the initializing sequence and other each
commands this pin should be low.
R/W: Reading and writing data to the LCD, for reading the data R/W pin should be high
(R/W=1) to write the data to LCD R/W pin should be low (R/W=0).
EN: Enable pin is for starting or enabling the module. A high to low pulse of about 450ns
Pulse is given to this pin. Sends data to data pins when a high to low pulse is given at this
pin.
Page 1 / 17
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
iv)LED+
It is pin no 15, inputpin. Backlight LED pin positive terminal.
c) List any four C data types with its size and ranges. 4M
Ans: 1M
each
Page 2 / 17
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans:
Page 3 / 17
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
The CPU, only registers R0 & R1 are used for this purpose.
5) Indexed Addressing Mode:
With indexed addressing a separate register, either the program counter, PC, or the data
pointer DTPR, is used as a base address and the accumulator is used as an offset address.
The effective address is formed by adding the value from the base address to the value from
the offset address. Indexed addressing in the 8051 is used with the JMP or MOVC
instructions. Look up tables are easy to implement with the help of index addressing.
Consider the example instruction: MOVC A, @A+DPTR
MOVC is a move instruction, which moves data from the external code memory space. The
address operand in this example is formed by adding the content of the DPTR register to the
accumulator value. Here the DPTR value is referred to as the base address and the
accumulator value us referred to as the index address.
b) Draw interfacing diagram of DAC 0808 with 8051µC and write C program to generate 8M
triangular wave.
Ans Diagram:
: 4M
Page 4 / 17
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
#include<reg51.h>
void main(void)
{
unsigned char d;
while(1) Program
{ :4M
for(d=0; d<255; d++)
{
P1 = d;
}
for(d=255; d>0; d--)
{
P1 = d;
}
}
}
c) Draw the interfacing diagram of stepper motor with 8051. Write excitation code to rotate 8M
it in clockwise direction.
Ans Diagram:
: 6M
Code:2M
Page 5 / 17
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans 2 marks:
: circuit
diagram
Application:
To generate baud rate in serial communication
c) 4M
Write C program to toggle bits of P2. Use software delay.
Ans #include <reg51.h>
: void delay(unsigned int);
void main(void)
{
4M for
P2=0X00; // PORT 2 as output port
correct
while(1) program)
{ Any
P2=0X00; amount
delay(200); of delay
P2=0XFF; can be
delay (200); considere
d
}
}
void delay(unsigned int t)
{
Page 6 / 17
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
unsigned inti,j;
for(i=0;i<=t;i++)
for(j=0;j<=1275;j++);
}
OR
#include <reg51.h>
void delay(unsigned int);
void main(void)
{
P2=0X00; // PORT 2 as output port
while(1)
{
P2= ~ P2;
delay(200);
}
}
void delay(unsigned int t)
{
unsigned inti,j;
for(i=0;i<=t;i++)
for(j=0;j<=1275;j++);
}
ANY OTHER CORRECT PROGRAM LOGIC SHOULD BE GIVEN MARKS
d) Convert (59)10 = (?)16 = (?)2. 4M
Ans
:
Page 7 / 17
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Q.4 (A) Attempt any THREE of the following : 12- M
a) Draw interfacing diagram for temperature measurement using LM 35, ADC 0808 4M
with 8051 microcontroller.
Ans Correct
: diagram
4M
Page 8 / 17
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans
:
Page 9 / 17
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans Explanat
: ion: 2
marks
each.
One T-state is the time period of one clock signal. It is the reciprocal of system clock
frequency.
Machine cycle is the minimum time taken by microcontroller to perform an operation.
One machine cycle has 6 states. One state is 2 T-states. Therefore one machine cycle is
12 T-states.
Time to execute an instruction, called instruction cycle is found by multiplying C by 12 and
dividing product by Crystal frequency.
T=(C*12)/crystal frequency
Where C is number of machine cycles
b) Explain stack memory. Write any two stack related instruction. 6M
Ans 1. The stack memory is part of RAM used by the CPU to store information temporarily. 4 marks:
: 2. This information may be either data or address. Stack
3. The CPU needs this storage area as there are only a limited amount of registers. memory
4. The register used to access stack memory is called stack pointer. explanati
5. Upon reset SP contains 07H; this causes the stack to begin to location 08H. So, Register
on
banks 2, 3, 4 (08H to 1FH) form the default stack area.
6. The stack is generally placed in the general-purpose area (30H to 7FH) of the internal Writing
RAM. Any two
Stack Related Instructions: (any two ) instructio
a) PUSH ns: 2
b) POP marks:
c) CALL ( ACALL, LCALL ) (1 mark
d) RET
each
instructio
n)
Ans 2Marks
: Baud Rate Calculation: for
Timer Value = 2SMOD Oscfreq
Calculati
12 32 Re quired Baud rate
Considering SMOD = 1 on
Page 10 / 17
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
20 Oscfreq
Timer Value = 12 32 Re quired Baud rate
Oscfreq = 11.0592Mhz
11.059Mhz
Timer Value =
12 32 Re quired baud rate
Case – 1 ) Required Baud rate = 4800
28,800
Time value =
4800
Timer value = 6
- 6 must be loaded in Timer for Required Delay.
Case – 2) Required Baud rate =9600
Timer value = 28,800 / 9600
Timer value = 3
-3 must be loaded in Timer for Required Delay
C Program: 1 Mark
#include <REG51.h> for
void Trans(unsigned char x); calculatio
void main(void) n and 5M
{ For
TMOD = 0X20; Program
TH1 = -3; // for 9600 Baud rate
SCON = 0X50;
TR1 = 1;
while(1)
{
Trans(‘ ‘);
Trans(‘M');
Trans(‘S');
Trans(‘B');
Trans(‘T');
Trans(‘E’);
}
void Trans(unsigned char x)
{
SBUF = x;
while(TI = = 0)
{ }
TI=0;
}
b) Write an ALP to generate square wave of 1kHz frequency on p2.3, Use timer 1 in 8M
model1. fOSC= 12 MHz
Page 11 / 17
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans 2Marks
: for
TMOD
Page 12 / 17
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans 2Marks
:
Diagram
In Embedded systems Code generation tools are used for creating and compiling. Then 6Marks
codes are tested using simulators and a number of latest software tolls like simulators ,
Logic Analyzers, profiler, Emulators etc. Explanat
When all of these programs are integrated in one software package then it is called as ion
Integrated Development environment (IDE)
Integrated Development Environment ( IDE ) consists of simulators with editors ,
compilers, assemblers, emulators, logic analyzers .
IDE Components:
Editor:
You can type your assembly program-using editor.
An editor is a program which helps you to construct your assembly language program in
right format so that the assembler will translate it correctly to machine language. This
form of your program is called as source program.
The assembly program written using DOS Editor is stored as .asm extension &The C
Program written using DOS Editor is stored as .C extension.
Cross Assembler:
An Cross Assembler is program that allows an Assembly program written on one type of
microcontroller to be used on another type.
Simulator:
Simulator Simulates (Duplicates) the behavior of Target Hardware (Microcontroller) in
Software.
Provides the detailed information of the status of RAM and ports (simulated) of the
defined target system and can execute each instruction in Single step mode.
Emulation:
An emulator in computer sciences duplicates (provides an emulation of) the functions of
one system using a different system, so that the second system behaves like (and appears
to be) the first system.
Logic Analyzer:
A logic analyzer is an electronic instrument that captures and displays multiple signals
from a digital system or digital circuit. A logic analyzer may convert the captured data
into timing diagrams.
RTOS:
RTOS are used in system to execute any task in defined time limits. It has following
functions.
1. Memory Management
2. File Management
3. Port Management
Page 13 / 17
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
4. Process Management
5. I/O Management
Target Process Evaluator:
Target Evaluation is the systematic process of gathering and analyzing data and other
objective information on processes and outcomes to determine the quality, value, and
effectiveness of coding & performance improvement.
Q.6 16-M
Attempt any FOUR of the following:
a) Draw structure of Interrupt and explain it. 4M
Page 14 / 17
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans 2Marks
: for
Diagram
Page 15 / 17
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Example program
Address Hex
Org 0000h becomes 0000 74
Fredequ 12h 0001 12
Mov a, #fred
EQU turns numbers into names; it makes the program much more readable because the name
chosen for the label can have some meaning in the program, whereas the number will not.
(3) DB(Define Byte)
db xx Define a byte: Place the 8 bit number xx next in memory.
Example program
Address Hex
Org 0100h becomes 0100 34
db 34h 0101 56
db 56h
DB xx takes the number xx (from 0 to 255) and converts it to hex in the next memory location.
DB permits the programmer to place any hex byte anywhere in memory.
(4) DW ( Define word ):
dwxxxx Define aword: place the 16bit number xxxx in memory.
Example program
Address Hex
org 0abcdh becomes abcd 12
dw 1234h abce 34
DW is a 16 bit version of db.
(5) End:
The End: Tells the assembler to stop assembling
d) Draw the structure of internal RAM of 8051. 4M
Ans 4 Marks
: for
Correct
Diagram
e) Draw the interfacing diagram of relay connected at P2.1 with 8051 microcontroller. 4M
Page 16 / 17
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans 4Marks
: for
Correct
Diagram
Page 17 / 17