Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

1

 Course Archive Course Management Teaching Assessment ePortfolio Mahara Course search Helpdesk   GOH KANG HOW

  
EEE226 MICROPROCESSOR I
SECTIONS
Dashboard / My courses / EEE226 MICROPROCESSOR I / 7 June - 13 June / EEE226 Test 1
Quiz navigation
1
Show one page at a time

2 Started on Tuesday, 8 June 2021, 8:30 PM Finish review

1 2 3 4 5

3
State Finished

4
Completed on Tuesday, 8 June 2021, 9:30 PM

5
Time taken 59 mins 56 secs

6
Grade Not yet graded
7

Question 1
8 Figure 1 shows a block diagram of 8051. It consists of 4 ports which are Port 0, Port 1, Port 2 and Port 3.
Complete
Explain the function of AD0-AD7 on Port 0 and A8-A15 on Port 2. (3%)
Marked out of 3.00
9

10 

Figure 1

For AD0 to AD7, it is used for both address and data. Port 0 will provide both address and data when
connecting an 8051 to an external memory. Port 2 is also used as input and output. Upon reset, port 2 is
con gured as an input port. Port 2 along with Port 0 will provide the 16-bit address for the external
memory. Then, AD0-A7 pins from Port 0 and A8-A15 pins from port 2 are combined in which port 2
contains higher order byte and port 0 contains the lower order byte.

Question 2
Figure 2 shows registers of 8051. It consists of four register banks which are bank 0, bank 1, bank3 and
Complete
bank3. Each bank has eight registers, which are R0, R1, R2, R3, R4, R5, R6 and R7. Explain how 8051 will
Marked out of 3.00 di erentiate between these registers and write instruction to explain your answer. (3%)

Figure 2

The 8051 microcontroller will di erentiate between these 8 registers by selecting the register bank. These
banks are selected from Program Status Word (PSW) register. When both PSW.3 and PSW.4 are zero, the
program will select register bank 0. However, if PSW.3 is one and PSW.4 is zero, the register bank 1 will be
selected. If PSW.3 is zero and PSW.4 is one, then the register bank 2 is selected. If both PSW registers are
one, then register bank 3 will select.

Program:

SETB PSW.4 ; select bank 2


MOV R0, #99H ; load R0 with 99H
MOV R1, #95H ; load R1 with 95H

This program shows that the register bank 2 is selected since PSW.4 is one and PSW.3 is zero. Then, the
RAM location 10H will have 99H value and RAM location 11H will have 95H value.

Question 3
Figure 1 shows T0 and T1 at pin number of 14 and 15 respectively. Explain the function of both of these
Complete
pins. Write a program to explain your answer. (3%)
Marked out of 3.00

Figure 1

Pin 14 and 15 are used as Timer 0 and Timer 1 respectively which are 16 bit timer. It is accessed as two
separate register, low byte (TLO or TL1) and high byte (TH0 or TH1). These registers can be accessed like
other register, MOV TL0, #4FH.

Program:

MOV TMOD, #20H


MOV TH1, #5
SETB TR1
BACK: JNB TF1, BACK
CPL P1.0
CLR TF1
SJMP BACK

This is a program of a timer in mode 2. First, load the TNOD value register and TH register. Then, timer is
started and kept monitoring the TF. Get out of the loop when TF is HIGH. Then, TF is cleared and went back
to step 4 since mode 2 is an auto reload timer.

Question 4
Figure 1 shows INT0 and INT1 at pin number of 12 and 13 respectively. Explain the function of these
Complete pins. Write a program to explain your answer. (3%)

Marked out of 3.00

Figure 1

Pin 12 and 13 are used as external interrupt hardware 0 and external interrupt hardware 1 respectively.
The interrupt vector table locations 0003H and 0013H are set aside for INT0 and INT1 respectively. They
are enabled and disabled using the IE register. There are two types of activation for the external hardware
interrupts: (1) level triggered, and (2) edge triggered.

Program:
ORG 000H
LJMP MAIN
ORG 0013H
SETB P1.3
MOV R3, #225
BACK: DJNZ R3, BACK
CLR P1.3
RETI
ORG 30H
MAIN: MOV IE, #10000100B
HERE: SJMP HERE
END

This is a program that assumed the INT1 pin is connected to a switch that is normally high. Whenever it
goes low, it should turn on LED. The LED is connected to P1.3 and is normally o . WHen it is turned on it
should stay on for a fraction of a second. As long as the switch is pressed low, the LED stay on.

Question 5
Write a program to clear 16 RAM location starting at RAM address 60H. ( 3%)
Complete

Marked out of 3.00


CLR A
MOV R1, #60H
MOV R7, #16
LOOP: MOV @R1, A
INC R1
DJNZ R7, AGAIN

Finish review

Previous Activity Jump to... Next Activity

Useful Link Reference Link


O cial USM Website Moodle Docs (v3.9)
Campus Online Panopto Support
CDAE Website Contact Us Form

Copyright © 2020 - Universiti Sains Malaysia Powered by Edwiser RemUI


You are logged in as GOH KANG HOW (Log out)
Get the mobile app

You might also like