Professional Documents
Culture Documents
TECH
Theory Examination (Semester-VI) 2015-16
MICROCONTROLLER & ITS APPLICATIONS
(NEC 022)
Solution Paper
Section A
1.
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.
Microprocessor is a single chip CPU, microcontroller contains, a CPU and much of the remaining
circuitry of a complete microcomputer system in a single chip.
Microcontroller includes RAM, ROM, serial and parallel interface, timer, interrupt schedule
circuitry (in addition to CPU) in a single chip.
Microprocessors are most commonly used as the CPU in microcomputer systems. Microcontrollers
are used in small, minimum component designs performing control-oriented activities.
Microprocessor instruction sets are processing intensive, implying powerful addressing modes with
instructions catering to large volumes of data. Their instructions operate on nibbles, bytes, etc.
Microcontrollers have instruction sets catering to the control of inputs and outputs. Their instructions
operate also on a single bit.
When a microcontroller has an instruction set that supports many addressing modes for the arithmetic
and logical instructions, data transfer and memory accesses instructions, the microcontroller is said to
be of CISC architecture.
The typical CISC microcontroller has well over 80 instructions, many of them very powerful and very
specialized for specific control tasks.
The advantages of the CISC architecture are that many of the instructions are macro like, allowing the
programmer to use one instruction in place of many simpler instructions.
An example of CISC architecture microcontroller is Intel 8096 family.
8 bit registers of the 8051 are:
Acc,B,R0,R1,R2,R3,R4,R5,R6,R7,PSW,P0,P1,TCON,TMOD,SCON,SBUF,PCON,TH0,TL0,TH1,T
L1,IE,IP
16 bit registers of the 8051 are:
DPTR,PC
Immediate Addressing mode.
Port 0
Moves content of the address pointed by A+DPTR to A.
Timer frequency = 12MHz/12 = 1MHz
Time Period= 1/1MHz= 1us.
Memory =16KB
Port P2
PSEN is connected to CS and OE pins of external program memory. CS pin is used for chip selection
and OE pin is used to enable output buffer for read operation.
Section B
2. A.
Next:
MOV B, A
MUL AB
MOV P2, A
MOV P2, B
SJMP Next
END
2. B. The 8051 has a flag register to indicate arithmetic conditions such as the carry bit. The flag
register in the 8051 is called the program status word (PSW) register.
PSW (program status word) register
The PSW register is 8 bits wide, only 6 bits of it are used by the 8051. The two unused bits are userdefinable flags. Four of the flags are called conditional flags, meaning that they indicate some conditions
that result after an instruction is executed. These four are CY (carry), AC (auxiliary carry), P (parity), and
OV (overflow).
As seen from Figure, the bits PSW.3 and PSW.4 are designated as RSO and RSI, respectively, and are
used to change the bank registers. The PSW.5 and PSW.l bits are general-purpose status flag bits and can
be used by the programmer for any purpose.
The following is a brief explanation of four of the flag bits of the PSW register.
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. It can also be set to 1 or 0 directly by an instruction such as SETB C and CLR
C where SETB C stands for set bit carry and CLR C for clear carry.
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.
P, the parity flag
The parity flag reflects the number of 1 s in the A (accumulator) register only. If the A register contains an
odd number of Is, then P = 1. Therefore, P = 0 if A has an even number of Is.
OV, the overflow flag
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.
2.C.
(A).
(B).
(C).
(D).
(E).
28H
28H
21H
25H
22H
2. D.
2.E.
5. Activate OE (output enable) to read data out of the ADC chip. An L-to-H pulse
to the OE pin will bring digital data out of the chip. Also notice that the OE is
the same as the RD pin in other ADC chips.
2.G.
This Digital Thermometer Design can be integrated by using the 8051 microcontroller and analog to
digital converter IC ADC 804 and interfaced with any microcontroller AT8051, AT8052, AT89C51,
AT89C52, AT89S51, AT89s52 and the output can be displayed on any output device may be computer
monitor or any LCD display. A circuit amplification is done between the LM35 and the microcontroller.
The ADC0804 is an analog to digital converter which is used to convert analog signals to digital so that
any microcontroller can sense the signal and works accordingly. Resolution of this IC is 8 bits and works
with +5V. If input voltage 5V then converted digital output is FF.
Pin description of ADC0804 :
CS : Chip Select:
It is an active low input used to activate the ADC0804 IC. To activate ADC0804, this pin must be low.
RD : Read:It is an active low input used to get the converted data out of the ADC chip. The ADC
converts the analog input to its binary equivalent and holds in an internal register. When a CS = 0 and
high-to-low pulse is applied to the RD pin, then 8-bit digital output is available at the D0-D7 data pins.
WR : Write:
This is an active low input used to inform the ADC to start the conversion process. ADC starts converting
analog input to digital, when CS = 0 and a low-to-high pulse is applied to WR pin. The amount it takes to
convert varies depending on the CLK IN and CLK R values. When the data conversion is complete, the
INTR pin is forced low by the ADC804.
Interfacing Circuit ADC 804 Analog To Digital Converter with 8051 Microcontroller
Here ADC 0804 is connected to port1 of 8051. WR and INTR of ADC is connected to P3.4 and P3.5
respectively. Analog input is applied to pin 6 of ADC. Here WR is the start of conversion and INTR is the
end of conversion.
2.H.
LCD INTERFACING:
Section C
3.A.
3.B.
Programming model of 8051:
All registers are accessed through Special Function Registers (SFRs) except for the PC. SFRs are
accessed in the low addresses of data space. All peripherals like a timer or UART are also accessed via
SFRs. In the new derivatives, the original SFRs are left at their original addresses for software
compatibility. The memory maps for all 8051 devices are really close to the original 8051. For reference,
here is a memory map for the SFRs of the original 8051.
3.C.
4.A.
4.B.
The stack is a section of RAM used by the CPU to store information temporarily. This information could
be data or an address. The register used to access the stack is called the SP (stack pointer) register. The
stack pointer in the 8051 is only 8 bits wide, which means that it can take values of 00 to FFH. When the
8051 is powered up, the SP register contains value 07. This means that RAM location 08 is the first
location used for the stack by the 8051. The storing of a CPU register in the stack is called a PUSH, and
pulling the contents off the stack back into a CPU register is called a POP.
Pushing onto the stack
In the 8051 the stack pointer (SP) points to the last used location of the stack. As we push data onto the
stack, the stack pointer (SP) is incremented by one. we see that as each PUSH is executed, the contents of
the register are saved on the stack and SP is incremented by 1. Notice that for every byte of data saved on
the stack, SP is incremented only once. Notice also that to push the registers onto the stack we must use
their RAM addresses.
Popping from the stack
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.
4.C.
SFRs are accessed as if they were normal Internal RAM. The only difference is that Internal
RAM is from address 00h through 7Fh whereas SFR registers exist in the address range of 80h through
FFh.
Name
Function
RAM Address
F0H
ACC
E0H
P0
80H
SP
81H
DPL/DPH
The SFRs DPL and DPH work together to represent a 16-bit value
called the Data Pointer.
82h/83h
PCON
The Power Control SFR is used to control the 8051's power control
modes.
87h
TCON
The Timer Control SFR is used to configure and modify the way in
which the 8051's two timers operate.
88h
TMOD
89H
TL0/TH0
8AH/8CH
TL1/TH1
8BH/8DH
P1
90H
SCON
The Serial Control SFR is used to configure the behavior of the 8051's
on-board serial port.
98H
SBUF
The Serial Buffer SFR is used to send and receive data via the on-board
serial port.
99H
P2
A0H
IE
A8H
P3
B0h
IP
B8h
PSW
D0h
5.A.
8031 based system with 8Kbyte of program ROM and 8Kbyte of data ROM:
5.B.
(i)The 256K8 NV-RAM has 18 address pins (A0 A17) and 8 data lines. A0 A15 go directly
to the memory chip while A16 and A17 are controlled by P1.0 and P1.1, respectively. Chip select
of external RAM is connected to P1.2 of the 8051.
(ii) The 256K bytes of memory are divided into four blocks, and each block is accessed as
follows:
Chip select A17 A16
P1.2 P1.1 P1.0 Block address space
0 0 0 00000H - 0FFFFH
0 0 1 10000H - 1FFFFH
0 1 0 20000H - 2FFFFH
0 1 1 30000H - 3FFFFH
1 x x External RAM disabled
For example, to access the 20000H 2FFFFH address space we need
the following :
CLR P1.2
;enable external RAM
MOV DPTR,#0 ;start of 64K memory block
CLR P1.0
;A16 = 0
SETB P1.1
;A17 = 1 for 20000H block
MOV A,SBUF ;get data from serial port
MOVX @DPTR,A
INC DPTR
5.C.
;next location