You are on page 1of 18

BOARD EXAMINATION – OCTOBER 2019

142 – MICROCONTROLLER & PIC

PART A (Each question carries two marks)

1. How many states and clocks are in one machine cycle of 8051?
6 states and 12 clock cycles are in one machine cycle of 8051.

2. Write Mul ab instruction.

The content of accumulater is multiplied with the content of B register.After


multiplication, the lower byte of result is stored in accumulater and upper byte of result is
stored in B register.
OV is cleared, if the top half of the result is zero. OV is set,if the top half of the result
is non zero.CY is always cleared and AC is unaffected.

3. List the registers related to timers with 8051.


 TMOD
 TCON

4. What is meant by machine language?

A computer programming language consisting of binary or hexadecimal


instructions which a computer can respond to directly is called machine language.

5. What are the hardware interrupts in 8051?

Maskable interrupts are those hardware interrupts. Which can be delayed when a much
highest priority interrupt has occurred to the processor.

There are two external hard ware interrupt INT0&INT1

6. State the various modes of operation of 8255 IC.

 I/O Mode
 Bit set / Reset mode(BSR Mode)

7. What is meant by ADC and DAC?


ADC – Analog to Digital converter is a device widely used to convert analog signal to
digital signal.
DAC – Digital to Analog converter is a device widely used to convert digital signals to
analog signal.
8. Define WREG register in PIC 18.
The 8 bit WREG register is the most widely used register in the PIC micro-
controllers. WREG stands for working register, as there is only one. The WREG register
is the same as the accumulator in other microprocessors. The WREG register is used for
all arithmetic and logic instructions. To understand the use of WREG register, we will
show it in the context of two simple instructions: MOVE and ADD in the next sections.

PART – B (Each question carries three marks)

9. List the bank registers of 8051.How it is selected?

Bits 3 and 4 of the PSW are used for selecting the register bank. Since there are
four register banks, two bits are required for selecting a bank, as detailed below.

10. Compare microcontroller and microprocessor. (any three)

S.NO MICROPROCESSOR MICROCONTROLLER


It is suited for general purpose
1. It is suited for special purpose system.
system.
Memory, Timer/Counter, I/O Ports Memory, Timer/Counter, I/O Ports are
2.
are not inbuilt in this chip. inbuilt in this chip.
It has one or two bit handling
3. It has many bit handling instructions.
instructions.
Time taken to complete a process is
4. Time taken to complete a process is less.
more.
Microprocessors based system requires
Microprocessors based system
5. less hardware reducing PCB size and
requires more hardware.
increasing the reliability.
11. What are the addressing modes of the following instructions?
MOVA,@RO, - Indirect addressing modes
MOVA, R1 -Register addressing modes
MOVA,#20H - Immediate addressing modes

12. List the interrupt priority of 8051.

13. How will you set the timer 0 to be operated as external event counter?

When set to 1 the counter/timer function as a Counter, counting pulses from


external inputs. Timer 0 from pin 4 on port 3.

14. Explain signal conditioning.

Signal conditioning is widely used in the world of data acquisition. The most
common transducer produces an output in the form of voltage, current, charge,
capacitance and resistance. We need to convert these sequences in to voltage in order to
send input to an A to D converter. This conversion is called signal conditioning. Signal
conditioning can be a current to voltage conversion.

15. Give the flag register format of PIC 18.


16. What is the advantage of using call instruction than jump instruction while a subroutine
is called?
CALL Instruction is used to call subroutine. After the” call” instruction, program
counter push its memory address in SP and take the address of the subroutine called by
the call instruction. After executing the subroutine program, the pc pops its main
program address from sp continue its process, where the program is stopped.
But jump instruction is only transfer the control within the main program. No
continuation is exit.

PART C

17.(a) Explain the various SFRs of 8051.

SPECIAL FUNCTION REGISTERS (SFR) 10 Marks

Locations 80H to FFH contain the special function registers. As we can see from the
diagram above, not all location are used by the 8051 these extra locations are used by
other family members (8052, etc.) for the extra features those microcontrollers possess.
Also note that not all SFRs are bit-addressable. We progress through the course, but for
the moment you should take note of the accumulator (ACC) at address 0E0H and the four
port registers at addresses 80H for P0, 90h for P1, 0A0 for P2 and 0B0 for P3.
Special Function Registers (SFRs) are registers used for special functions and the
Operation of the microcontroller. Each one has its own name and address. Only 21SFR’s
in 8051are available to user. Among the 21 registers, 11 registers are bit and byte
addressable. The remaining 10 are bit addressable. Each one are 8 bit registers.
TMOD, TCON, TH1, TL0, TH1and TH0 are used for Timer operation. SCON and
SBUF are the SFR’s used for serial communication. P0, P1, P2 andP3 are used for I/O
port. PCON is used for power control. IE and IP are used as SFR used for interrupt
control.DPH and DPL are the 8bit SFR,s in DPTR . A and B registers are also the SFR’s
used in instruction
Or

17.(b) Explain the internal memory map of 8051 for both RAM and ROM.

(diagram- 5marks theory-5 marks)

The 8051 has two types of memory. They are Program Memory and Data Memory.
Program Memory (ROM) is used to save the program permanently .This will be executed
.The Data Memory (RAM) is used for storing data and intermediate results temporarily
.This results are created and used during the operation of the microcontroller. In the 8051
microcontroller family, at most a 4 Kb of ROM and 128 or 256 bytes of RAM is used. All
8051 microcontrollers have a 16-bit addressing bus and are capable of addressing 64 kb
memory. Arranging the available memory for programmer use is called memory
organization.

INTERNAL ROM

The first models of the 8051 microcontroller family did not have internal program
memory. It was added as an external separate chip. These models are recognizable by their
label beginning with 803X (for example 8031 or 8032). All later models have a few Kbyte
ROM inbuilt. Sometimes it is necessary to use additional memory if the amount of inbuilt
memory is not sufficient for writing most of the programs. To access external ROM,
the pin EA must be connected to Vss (GND). If EA connected to Vss, the addresses
0000h to 0FFF h are directed to external ROM. The addresses 1000 h to FFFF h are always
directed to external ROM irrespective of EA.
Internal 0FFF

(EA=1)
0000

INTERNAL RAM
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. In these 210 locations, 128 are
at the address 20H to 2FH in internal RAM. 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. In the general purpose RAM from 30H to 7FH and the
register banks from 00H to 1FH are only byte addressable locations. In this
locations as byte can be read and/ or write as byte. However, with bit-addressable RAM
(20H to 2FH) read or write any single bit in this region by using the unique address for that
bit.
17.(A) Explain the various addressing modes of 8051 with one example of each case.

DIFFERENT ADDRESSING MODES (Each addressing modes carry 2 marks)

The method of specifying the data in instruction is called Addressing

Types of Addressing Modes

1. Register Addressing
2. Indirect Addressing
3. Direct Addressing
4. Immediate Addressing
5. Index Addressing

1. Register Addressing
In this Addressing mode, the registers (R0…R7, A, B, DPTR, CARRY) are used as
operands. R0…R7 can be selected in any one of four banks. The banks can be selected in
PSW register.
Ex. MOV A, R1

In this mode, the content of R1 is moved to A

2. Indirect Addressing
In this Addressing mode, the operand’s address is specified in register R0, R1or
DPTR to access the address register, the symbol ‘@’ is preceded with above register. Both
internal and external RAM can be accessed in this mode. 8 bit address is specified in R0
an R1 registers. 16 bit address is specified in DPTR

Ex. MOV A,@R1

In this mode, the content of address specified in R1 is moved to A

3. Direct Addressing

In this mode of addressing, 8 bit address of operand is specified in instruction.


Address of internal RAM is specified.

Ex. MOV A, 34h

In this mode, the content of address 34h is moved to A

4. Immediate Addressing

In this addressing mode, the operand is data. The actual data is specified in the
instruction itself. The symbol ‘#’ is preceded with data. The data is accessed
immediately.

Ex. MOV A, #67h


In this mode, the hexadecimal data 67 is moved to A

5. Index Addressing

This addressing mode is used access lookup table in program memory.

Ex. MOVC A, @A+DPTR

or

18.(b) Explain the concept of time delay routine with a delay program in 8051.

(Theory 5 marks program-5 marks)

Delay routines are subroutines used for maintaining the timing of various operations
in microcontroller. In control applications, certain equipment is need to be on/off after
specified time delay.

A delay subroutine is generally written as a subroutine. In delay routine a count is


loaded in a register or a direct byte location of microcontroller. Then it is decremented by
one and its value is checked to verify, whether the content of register is zero or not. This
process is continued until the content of register is zero. When it is zero, the time delay is
over and the control is transferred to main program to carry out the decision operation.

The delay time is given by the total time taken to execute the delay subroutine.

Example

Main Program

Back SETB P1.4

LCALL delay

CLR P1.4

LCALL delay

SJMP BACK

Sub program:

DELAY MOV R5, #FFH

AGAIN DJNZ R5, AGAIN

RET
The delay period of delay subroutine can be increased to increase the number of
loops. For changing the initial value loaded in the registers, we can able to change the
delay period of time delay sub routines.

19. (a) Explain 8051 serial data transmission with program.

[Theory - 6marks; Program - 4marks]

To Program 8051, to transfer data Serially we have to perform following sequence of actions.

1. Load the TMOD register with the value 20H to use timer 1 in mode 2 (8- bit auto – reload)
to set the band rate.

2. Load TH1 to set the desire band rate for serial data transfer.

3. Load SCON registers with the value 50H, to use serial mode 1, where an 8-bit data is
framed with start and stop bits.

4. Set TR1 to 1 to Start Timer 1.

5. Clear TI with “ CLR TI ” instructions.

6. Write a character to be sent in to the SBUF register.

7. Check the TI flag bit with instruction “JNB TI , XXXX ” to see if an entire character has

been transferred completely.

8. Go to Step 5 to transfer the next character.

Importance of the TI flag

1. The byte character to be transmitted is written in to SBUF register.

2. The start bit is transferred.

3. The 8 bit character is transferred one bit at a time.

4. When the stop bit is transferred, the TI flag goes to set condition.

Example 1

Write an 8051 assembly language program to transfer letter “c“ Serially at 9600
band rate Continuously.
19.(b) Explain single bit addressability of ports with an example.
[Theory - 6marks; Program - 4marks]
Sometimes we need to access only 1 or 2 bits of the port instead of the entire
8 bits. A powerful feature of 8051 I/O ports in their capability to access individual bits of
the port. Of the four 8051 ports, we can access either the entire 8 bits or any single bit
without altering the rest. When accessing a port in single bit manner, we use the syntax
“SETB X.Y” where X is the port number 0, 1, 2, or 3, and Y is the desired bit number
from 0 to 7 for data bits D0 TO D7. For example, “SETB P1.5” sets high bit 5 of port 1.
Remember that D0 is the LSB and D7 is the MSB.For example the following code
toggles bit P1.2 continuously.

Back: CPL P1.2 ; Complement P1.2 only

ACALL DELAY
SJMP BACK

another variation of the above program follows

AGAIN: SETB P1.2 ; change only P1.2 = high


ACALL DELAY
CLR P1.2 ; change only P1.2 = low
ACALL DELAY
SJMP AGAIN

Notice that P1.2 is the third bit of P1, since the first bit is P1.0, The second bit is
P1.1, and so on. This single bit addressability of I/O ports is one of the most powerful
features of the 8051 microcontroller.
20.(a) Draw the functional block diagram of 8255 IC with its control register format.

(Diagram-5 marks theory 5 marks)

The functional block diagram of 8255 is shown in fig .It contains Data bus
buffer, Read/ Write control Logic Unit and I/O Ports.

i) Input/ Output ports

The 8255 consists of three numbers of ports namely A,B and C. Each one of
them is an 8 bit port. However port C can be divided into two 4 bit ports (port C
upper, port C Lower) and used separately.

For the convenience of Programming the ports are grouped as GroupA and Group B

Group A = Port (PA7 – PA0)

Port C Upper (PC7 – PC4)

Group B = Port B (PB7 – PB0)

Port C Lower (PC3- PC0)

ii) Data bus Buffer

It is a bidirectional 8 bit buffer. It is used to interface the 8255 with the


system data bus. The data, control world and status information signal in between
the microcontroller and 8255 are communicated only through data bus buffer.
iii) Control Logic:

RD (Read) : When this signal in low, the microcontroller

reads data from the selected I/O ports of 8255

WR (Write) : When this signal is low, the microcontroller Writes data into
the selected I/O port or the control register

Reset : Reset the all: all ports in the input mode. It is an active high
signal

CS (chip select) : It enables the Communication between the8255 and


Mrocontror

A1-A0 : These lines are used to address the three ports and control
word Register (CWR)

Control word register

It is a 8 bit Register. An 8 bit binary word present in the control register is called control
word. The control word specifies the function for each I/O Port.

Modes of 8255

The operation of the ports can be classified into two broad groups.

• I/O Mode

• Bit set/ reset mode (BSR)


Control register format

I/O MODE

BSR MODE

or

20.(b) Explain ADC interfacing with its program.(Dia-4 marks,Theory-3marks,Pro-3marks)

Digital computers (or) microcontrollers use binary values, but we get electrical
signal from sensor (Transducers) are Analog signal. The Transducers convert the physical
Quantifies like Temperature, Pressure, speed etc, into electrical signal. So whenever we want
binary values the Analog to digital converters widely used.

One of the Analog to digital converters IC is ADC 0808. It is a Parallel analog to


digital converter. The pin diagram of ADC 0808 are shown in fig
The interfacing diagram of ADC 0808 with microcontroller 8051 in shown in fig

The analog signal is applied to the any input pin INO – IN7. The digital output terminals
(D0 – D7) of ADC 0808 are directly connected to port 0 in 8051. Port 3 in micro
controller are connected different control signals in ADC 0808. P3.0 – ALE, P3.1 – SOC
P3.2 – OE, P 3.3 – EOC respectively. Port 2 in micro controllers are connected to the
address lines of A, B and C in ADC 0808. The Address lines A, B, C are used to select
the particular input Lines.

21. (a) Explain Harvard architecture in PIC with diagram.(Dia-5 marks Theory -5 marks)

 The PIC Processor has Harvard architecture –i.e. separate instruction memory and data
memory.
 For the 18F452: – 32KByte Program Memory on chip, (Flash) – 1792 bytes of Data
Memory on chip
 1536 bytes of static RAM
 256 bytes of EEPROM
 Data RAM serves the role of registers and main memory – i.e. there is no distinction
between data accesses to registers and memory – Can think of the processor as having
lots of registers and no additional data memory.

PIC Program Memory

 215 = 32K = 32768 program memory locations (bytes).


 Most PIC instructions occupy two bytes (a few occupy 4 bytes)
 CPR can read two bytes at a time from Program memory
 This is non-volatile flash memory in the 18F452. – Can be read (in 8 or 16 bit units) at
processor speed

PIC (RAM) Data Memory

• 12 data address bits allow for 212 = 4K = 4096 data memory locations (bytes). – PIC
18F452 implements only 1536 bytes of data memory
• This is volatile static RAM memory which can both be read and written.
• The non-volatile EEPROM data memory is accessed via a separate mechanism. –
EEPROM can be read at near processor speed
or

21.b Explain RISC architecture in PIC (Diagram-5 marks theory- 5 marks)

 Reduced instruction set computer


 Simplified instructions taking 1 clock cycle
 Large number of general purpose registers.
 Circuit is much simpler.
 Fast to decode
 Fast to execute.
 Pipe lining – fetching of next instruction while previous instruction executes.
 Complex operations are implemented as a sequence of instructions
 Many instructions can access memory.
 Instructions are of fixed number bytes.
 Operations are register to register, but also memory to register and memory to memory.

Prepared by
Nagarani. A
Lecturer
Department of Electronics(Robotics)
222, APPC, Palani.

You might also like