Professional Documents
Culture Documents
Q. No Sub Q.No Answer: (Autonomous)
Q. No Sub Q.No Answer: (Autonomous)
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Fout = 1 KHz
Tout = 1/ 1X 103
Tout = 1000μ sec
Consider half of it = Tout = 500μ sec
Count Value for 500μ sec
(65536 – count) * Tin =Tout
(65536 – count) * 1μ sec = 500μ sec
(65536 – count) = 500/1 = 500
Count = 65536-500= (65036)10 = (FE0C)16
Program: -
ORG 0000H
MOV TMOD, # 01H ; Set timer 0 in Mode 1, i.e., 16 bit timer
AGAIN: SETB P1.5 ;Make P 1.5 high
ACALL DELAY ; Call Delay Program
CLR P1.5 ;Make P 1.5 low
ACALL DELAY ; Call Delay Program
SJMP AGAIN ; re-load timer with count as mode 1 is not
auto reload
DELAY: MOV TL0, # 0CH ; Load TL register with LSB of count
MOV TH0, # FEH ; Load TH register with MSB of count
SETB TR0 ; start timer 0
HERE: JNB TF0, HERE ; poll till timer roll over
CLR TR0 ; stop timer 0
CLR TF0 ;clear timer flag 0
RET
END
ORG 0000H
MOV TMOD, # 01H ; Set timer 0 in Mode 1, i.e., 16 bit timer
L2: MOV TL0, # 0CH ; Load TL register with LSB of count
MOV TH0, # FEH ; load TH register with MSB of count
SETB TR0 ; start timer 0
L1: JNB TF0, L1 ; poll till timer roll over
CLR TR0 ; stop timer 0
CPL P1.5 ;complement P 1.5 line to get high or low
CLR TF0 ;clear timer flag 0
SJMP L2 ; re-load timer with count as mode 1 is not
auto
reload
END
(Note: The above program can be considered for any frequency of square)
wave.
• The level sensor probes for the overhead tank are interfaced to the port1 of
the microcontroller i.e. P1.0 (high level sensor) and P1.1 (low level
sensor).
• We have assumed that when water is touched to sensor then logic 1 will be
available at sensor probe. When port pins p1.0 and p1.1 are high means the
tank is full and when port pins P1.0 and P1.1 are low means the tank is empty.
• We also assumed that P1.2-P1.7 are grounded.
• Port pin P2.0 is used to control the pump.
• Considering this assumptions the program will be as follows,
Funct
ion 1
Mark
each
RS: RS is the register select pin.
We need to set it to 1, if we are sending some data to be displayed on LCD. And
we will set it to 0 if we are sending some command instructions during the
initializing sequence like clear the screen etc.
VEE: VEE pin is use to adjust the display contrast, through a variable resistor.
3. Attempt any THREE of the following: 12M
a) Explain the power saving options of microcontroller 8051 with suitable 4M
diagram.
Ans Power saving modes of operation : 2 M-
diagram
8051 has two power saving modes. They are -
1M
each for
1. Idle Mode
the two
2. Power Down mode. modes
The two power saving modes are entered by setting two bits IDL and PD in the
special function register (PCON) respectively.
The structure of PCON register is as follows
Idle mode
Idle mode is entered by setting IDL bit to 1. (). The clock signal is gated off to
CPU but not to interrupt, timer and serial port functions. The CPU status is
preserved entirely. SP, PC, PSW, Accumulator and other registers maintain their
data during idle mode. The port pins hold their logical states they had at the time
Idle was initiated. ALE and PSEN are held at logic high levels
Ways to exit Idle Mode:
1. Activation of any enabled interrupt will clear PCON.0 bit and hence the Idle
Mode is exited. The program goes to the Interrupt Service Routine (ISR). After
RETI is executed at the end of the ISR, the next instruction will start from the
one following the instruction that enabled Idle Mode.
2. A hardware reset exits the idle mode. The CPU starts from the instruction
following the instruction that invoked the 'Idle' mode.
Power Down Mode:
The Power down Mode is entered by setting the PD bit to 1. The internal clock to
the entire microcontroller is stopped (frozen). However, the program is not dead.
The Power down Mode is exited (PCON.1 is cleared to 0) by Hardware Reset
only. The CPU starts from the next instruction where the Power down Mode was
invoked. Port values are not changed/ overwritten in power down mode. Vcc can
be reduced to as low as 2V in Power Down mode. However, Vcc has to be
restored to normal value before Power Down mode is exited.
b) Develop an assembly language program for 8051 to add data stored at five 4M
consecutive address location starting from 30 H. Store the result at 40 H and
carry at 41 H.
Ans ORG 0000 H ; Initialize 4 M for
MOV R0,#30H ;Source memory pointer the
MOV R2,#05 H ;Counter correct
CLR A ;Make Accumulator 0
Page No: 7/23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
The first step in the development process is to write an assembly language program.
The assembly language program can be written with an ordinary text editor such as
word star, edit and so on. The assembly language program text is an input to the
assembler.
usually known as object code. Time required to translate assembly code to object
code is called Assemble Time. During assembling process assembler checks for
syntax errors and displays them before giving object code module.
The object code module contains the information about where the program or
module to be loaded in memory. If the object code module is to be linked with other
separately assembled modules then it contains additional linkage information. At
link time, separately assembled modules are combined into one single load module,
by the linker.
The linker also adds any required initialization or finalization code to allow the
operating system to start the program running and to return control to the operating
system after the program has completed.
At load time, the program loader copies the program into the computer’s main
memory, and at execution time, program execution begins
OR
• The extension for the object file is “obj” while the extension for the list file
is “lst”
3) Assembler require a third step called linking
• The linker program takes one or more object code files and produce an
absolute object file with the extension “abs”
• This abs file is used by 8051 trainers that have a monitor program
4) Next the “abs” file is fed into a program called “OH” (object to hex converter)
which creates a file with extension “hex” that is ready to burn into ROM
• This program comes with all 8051 assemblers
• Recent Windows-based assemblers combine step 2 through 4 into one step
d) Draw and explain the configuration & internal structure of Port 1 of 8051 4M
microcontroller.
Ans Port 1 2 M for
the
It has a D type latch for each pin. The data on the port latches need not be same as diagram
that on the pins.
2 M for
The 2 data paths have entirely separate buffer circuits that read the latch or pindata. descripti
The upper buffer is enabled when the latch data is read and the lower buffer when on
the pin state is read.
• No dual function
• When used as an input, a 1 is written to the latch, turning the lower FET off,
the pin and the input to the pin buffer are pulled high by the FET load
• If used as an output, 0 is written to the latch, lower FET is on, the pull up is
off and the pin can drive the input of the ext circuitry low.
Ans 1 mark
for each
Point of Difference 8031 8052 correct
Inbuilt ROM available 0KB 8KB point
Inbuilt RAM available 128 Bytes 256 Bytes
No. of Timers/ Counters 2 3
No. of interrupts 6 8
c) Draw & explain interfacing diagram of DAC 0808 with microcontroller 8051. 4M
Ans Program:
ORG 0000H
REPEAT: MOV A, #00H ; Clear A
INCR: MOV P1, A ; Send value to P1 4 marks
INC A ; increment value for
CJNE A, #0FFH, INCR ;Compare with highest value correct
DECR: MOV P1, A program
DEC A ; Decrement value
code
CJNE A,#00H, DECR ;Compare with lowest value
SJMP REPEAT ; repeat
END
Example
Example: When executing PUSH instructions: (Refer fig 1)
of PUSH
–2M
Fig(1)
Example
of POP
–2M
Fig (2)
Progra
m-M
CLR OE ;clear OE
CLR ADDR_C ; C=0
CLR ADDR_B ; B=0
SETB ADDR_A ; A=0(select channel 0)
ACALL DELAY
SETB ALE ; latch address
ACALL DELAY
BACK: SETB SC ; start conversion
ACALL DELAY
CLR ALE
CLR SC
HERE: JB EOC,HERE ; wait
HERE1: JNB EOC,HERE1 ; wait for EOC to go high
SETB OE ; set output enable pin to make converted
data
available
ACALL DELAY
MOV A, MY_DATA ; Read converted digital data from ADC
MOV P0, A ; send read data to PORT P0
CLR OE ; Clear output enable
SJMP BACK
DELAY: MOV R3,#25 ; Delay Subroutine
L3:MOV R4,#100
L2: MOV R5,#100
L1: DJNZ R5,L1
DJNZ R4,L2
DJNZ R3,L3
RET
(Note : Marks may be given to any other program with correct logic)
4 marks
for
Progra
m
Process:
1. Allow traffic from W to E and E to W i.e. WG, EG, NR, SR lights ON and all
other lights OFF.
2. Yellow light ON i.e. WY, EY, NR, SR lights ON and all other lights OFF.
3. Allow traffic from N to S and S to N i.e. NG, SG, ER, WR lights ON and all
other lights OFF.
4. Yellow light ON i.e. NY, SY, WR, ER lights ON and all other lights OFF.
5. Repeat Process
Lane Chart:
Lane Direction 8051 Port pins Light Indicators
North P0.1 [NR] RED
P0.2 [NY] YELLOW
P0.3 [NG] GREEN
South P0.4 [SR] RED
P0.5 [SY] YELLOW
P0.6 [SG] GREEN
East P0.7 [ER] RED
P0.8 [EY] YELLOW
P3.0 [EG] GREEN
West P3.1 [WR] RED
P3.2 [WY] YELLOW
P3.3 [WG] GREEN
Timer Count:
Consider Crystal frequency= 12 MHz
I/P clock = (12*10^6 )/12= 1 MHz
Tin = 1μ sec
Required Delay = 50 msec
N = Required Delay/ Tin = 50 msec /1 μ sec = 50000
Timer Count= 65535 – 50000+1 = (15536)10 = (3CB0)16
Program:
NR EQU P1.0
NY EQU P1.1
NG EQU P1.2
SR EQU P1.3
SY EQU P1.4
SG EQU P1.5
ER EQU P1.6
EY EQU P1.7
EG EQU P3.0
WR EQU P3.1
WY EQU P3.2
WG EQU P3.3
MOV P1,#00H
MOV P3,#00H
MOV TMOD, # 11H ; Set timer 0 & timer1 in Mode 1, i.e, 16 bit timers
AGAIN: SETB NR ;North Red ON
SETB SR ; South Red ON
SETB EG ;East Green ON
SETB WG ; West Green ON
ACALL DELAY
Y_DELAY:MOV R1,#3C H ; Set counter to repeat delay 60 times to achieve delay of 30sec
AGAIN1: MOV TL1, # 0B0 H ; Load TL register with LSB of count
MOV TH1, # 3C H ; load TH register with MSB of count
SETB TR1 ; start timer 0
L2: JNB TF1, L2 ; poll till timer roll over
CLR TR1 ; stop timer 0
CLR TF1 ; clear timer flag 0
DJNZ R1, AGAIN1
RET
END
6. Implied Addressing Mode: In this addressing mode, only one operand specified in
the instruction. A specific register assigned for such instructions. These types of
instruction can work on specific registers only. These types of instructions are
also known as register specific instruction. Examples of Implied Addressing
Mode are
SWAP ; It swaps the lower nibble with higher nibble of Accumulator itself.
RLA ; It rotates the contents of accumulator by one bit position towards left.
RRA ; It rotates the contents of accumulator by one bit position towards right.