What are the special functoin register?
The special function register are stack pointer, index pointer (DPL and DPH),
I/O port addresses, status(PSW) and accumulator.
What is PSW?
Program status word (PSW) is the set of flags that contains the status
information and is considered as one of the special function register.
What is stack pointer (sp)?
Stack pointer (SP) is a 8 bit wide register and is incremented before the data is
stored into the stack using PUSH or CALL instructions.
It contains 8-bit stack top address. It is defined anywhere in the on-chip 128-
byte RAM. After reset, the SP register is initialized to 07.
After each write to stack operation, the 8-bit contents of the operand are stored
onto the stack, after incrementing the SP register by one.
It is not a top-down data structure. It is allotted an address in the special
function register bank
What is data pointer (DTPR)?
It is a 16-bit register that contains a higher byte (DPH) and lower byte (DPL) of
a 16-bit external data RAM address.
It is accessed as a 16-bit register or two 8-bit registers. It has been allotted two
addresses in the special function register bank, for its two bytes DPH and DPL.
Give the purpose of ale/prog signal.
ALE/PROG is an address latch enable output pulse and indicates that valid
address bits available on the respective pins.
The ALE pulses are emitted at a rate of one-sixth of the oscillator frequency.
The signal is valid only for external memory accesses.
MOV R4, R7 is invalid. Why?
The movement of data between the accumulator and Rn (for n = 0 to 7) is valid.
But movement of data between Rn register is not allowed. That is why MOV
R4, R7 is invalid.
Write a program to save the accumulator in r7 of bank 2.
CLR PSW – 3
SETB PSW – 4
MOV R7, A.
What is mean by microcontroller?
A device which contains the microprocessor with integrated peripherals like memory, serial ports,
parallel ports, timer/counter, interrupt controller, data acquisition interfaces like ADC, DAC is called
microcontroller.
What are the advantages of microcontroller over microprocessor?
The overall system cost is low , as the peripherals are integrated in a single chip. The size is very
small The system is easy to troubleshoot and maintain. If required additional RAM , ROM and I/O
ports may be interfaced. The system is more reliable.
List the features of 8051 microcontroller?
Single supply +5 volt operation using HMOS technology. 4096 bytes program memory on chip (not
on 8031) 128 data register banks Four register mode, 16-bit timer/ counter. Extensive Boolean
processing capabilities. 64 KB external RAM size 32 bi-directional individually addressable I/O lines. 8
bit CPU optimized for control applications.
List the on-chip peripherals of 8051 microcontroller.
4KB on chip RAM
128 B RAM
2 Timers
32 I/O pins
1 serial port
6 Interrupt sources
Explain DJNZ instruction of Intel 8051 microcontroller?
a) DJNZ Rn, rel Decrement the content of the register Rn and jump if not zero. b) DJNZ direct,
rel Decrement the content of direct 8- bit address and jump if not zero.
Explain the function of the pins PSEN and EA of 8051.
PSEN: PSEN stands for program store enable. In 8051 based system in which an external ROM holds
the program code, this pin is connected to the OE pin of the ROM.
EA: EA stands for external access. When the EA pin is connected to Vcc, program fetched to address
0000H through 0FFFH are directed to the internal ROM and program fetches to addresses 1000H
through FFFFH are directed to external ROM/EPROM. When the EA pin is grounded, all addresses
fetched by program are directed to the external ROM/EPROM.
Explain the 16-bit registers DPTR and SP of 8051.
DPTR stands for data pointer. DPTR consists of a high byte (DPH) and a low byte (DPL). Its function is
to hold a 16-bit address. It may be manipulated as a 16- bit data registers.
It serves as a base register in indirect jumps, lookup table instructions and external data transfer. SP
stands for stack pointer.
SP is a 8-bit wide register. It is incremented before data is stored during PUSH and CALL instructions.
The stack array can reside anywhere in-chip RAM.
The stack pointer is initialised to 07H after a reset. This causes the stack to begin at location. 08H.
What is the difference between MOV and MOVX instruction?
MOVX and MOVC instructions are used for accessing external
memory. Whereas MOV instruction used for accessing internal
memory.
Recall the interrupts in 8051 with their priority order.
Interpret the meaning for Resolution and conversion time.
Stepper motor:
(REVOLUTION PER MINUTE) RPM=(360/step angle)* 60
Recall the formula to convert digital value to analog using
DAC.
Which of the following signal s of 8051 must be used in accessing external
data RAM?
Only PSEN is used to access external ROM containing program code, but when
accessing external data memory we must use RD and WR signals.
XCHG, which stands for eXCHanGe. This is an instruction to exchange
contents of HL register pair with DE register pair. This instruction uses
implied addressing mode. After execution of this instruction, the content
between H and D registers and L and E registers will get swapped
respectively.
SWAP A interchanges the low-and high-order nibbles (four-bit
fields) of the Accumulator (bits 3-0 and bits 7-4). The operation can
also be thought of as a four-bit rotate instruction. No flags are
affected.
List few registers which are bit addressable.
The SFR register is implemented by bit-address registers and byte-
address registers. The accumulator, B register, Po, P1, P2, P3, IE
registers are bit-addressable register remaining all are byte-
addressable registers.
The format for TMOD register.
few applications of stepper motor.
What is SoC and EOC in ADC?
SOC [Start of conversion]: When High to low signal is appears to this pin of ADC,
ADC then starts conversion. EOC [End of conversion]: ADC sends this high EOC
signal to Micro-Controller to indicate completion of conversion.
Few points to remember while using timers.
Once timer flag (TF) is set, the programmer must clear it
before it can be set again.
The timer does not stop after the timer flag is set. The
programmer must clear the TR bit in order to stop the
timer.
Once the timer overflows, the programmer must reload the
initial start values to the TH and TL registers to begin
counting up from.
We can configure the desired timer to create an interrupt
when the TF flag is set.
If interrupt is not used, then we have to check the timer
flag (TF) is set using some conditional branching
instruction.
Maximum delay possible using a single 8051 timer is
65536µS and minimum is 1µS provided that you are using
a 12MHz crystal for clocking the microcontroller.
Program for generating 1mS delay using 8051 timer.
The program shown below can be used for generating 1mS delay
and it is written as a subroutine so that you can call it anywhere in
the program. Also you can put this in a loop for creating longer time
delays (multiples of 1mS). Here Timer 0 of 8051 is used and it is
operating in MODE1 (16 bit timer).
DELAY: MOV TMOD,#00000001B // Sets Timer 0 to MODE1 (16
bit timer). Timer 1 is not used
MOV TH0,#0FCH // Loads TH0 register with FCH
MOV TL0,#018H // LOads TL0 register with 18H
SETB TR0 // Starts the Timer 0
HERE: JNB TF0,HERE // Loops here until TF0 is set
(ie;until roll over)
CLR TR0 // Stops Timer 0
CLR TF0 // Clears TF0 flag
RET
1KHz Square wave using 8051 timer.
MOV P1,#00000000B
MOV TMOD,#00000001B
MAIN: SETB P1.0
ACALL DELAY
CLR P1.0
ACALL DELAY
SJMP MAIN
DELAY: MOV TH0,#0FEH
MOV TL0,#00CH
SETB TR0
HERE: JNB TF0,HERE
CLR TR0
CLR TF0
SETB P1.0
RET
END
LCD with 8051 and provide the code to display “NO”.
(Similary you can display any letter using the same program)
COMNWRT: ;send command to LCD