Vous êtes sur la page 1sur 8

Question 1

a. Perform manually (show all your work) the following conversions;

[8 marks]

 

Base-10

Base-2

Base-16

 

593

(i)

(ii)

(iii)

(iv)

C6A

b. By using 2’s complement, perform the following operations;

i. 120 (10) – 56 (10)

 

ii. 43 (10) – 90 (10)

[9 marks]

c. Figure 1 shows internal registers of 8051 CPU. Explain the function of the following registers;

i. ACC

ii. P0, P1, P2, and P3

iii. DPTR

iv. PSW

[8 marks]

of the following registers; i. ACC ii. P0, P1, P2, and P3 iii. DPTR iv. PSW

Figure 1: Core register of 8051 CPU

Question 2

CONFIDENTIAL

a.

Explain the functions of stack area and stack pointer.

[5 marks]

b.

Referring to the assembly programming shown in program Listing 1, answer the following questions;

.

i. State the addressing mode of lines 1, 2, 3, and 4.

[8 marks]

ii. State the content (value) of the following registers after the program is executed.

Register

A

R0

45H

46H

47H

55H

Value

           

[8 marks]

iii. State the value of Carry and Auxiliary Flags when instruction SUBB A,#88H is

executed.

[4 marks]

Line No.

 

Assembly

   

ORG 0H

1.

 

MOV R0,#45H

   

MOV A,#3

2.

 

MOV R1,A

   

MOV A,#4

.

AGAIN:

ADD A,#3

3.

 

MOV @R0,A

   

INC R0

   

DJNZ R1,AGAIN

   

SUBB A,#88H

4.

 

MOV 55H,A

   

END

Program Listing 1

2

CONFIDENTIAL

Question 3

a. Referring to Figure 2, explain the functions of the following 8051 CPU pins;

i. PSEN

ii.

ALE

[6 marks]

of the following 8051 CPU pins; i. PSEN ii. ALE [6 marks] Figure 2 b. Referring

Figure 2

b. Referring the memory map shown in Figure 3, design the memory interfacing by using 74LS138 decoder. The design should include;

i. Produce the truth table

ii. Produce the complete memory interfacing circuit with all buses (control, address and data

[6 marks]

buses) labeled accordingly.

[13 marks]

0000H

A000H

FFFFH

2K x 8 ROM (off chip)

Not used

Not Used

2K x 8 RAM

2K x 8 RAM

Not Used

Data Memory

Program Memory

Figure 3: Memory Map

3

CONFIDENTIAL

Question 4 Referring to the diagram shown in Figure 4, answer the following questions;

a. Explain the function of pins A0 and A1 of the 8255A (PPI).

i.

[3 marks]

ii.

Describe the mode 2 I/O operation of the 8255A (PPI).

[3 marks]

b. Find the I/O port addresses assigned to ports A, B, C, and the control port.

[7 marks]

c. Find the control word used to configure the 8255A operation.

i.

[3 marks]

ii.

Write an assembly program which will display ‘37’ when the switch (SW2) is pressed. [9 marks]

ii. Write an assembly program which will display ‘37’ when the switch (SW2) is pressed. [9

Figure 4

4

CONFIDENTIAL

Question 5 Referring to Figure 5 and Table 1, write an assembly program which will perform the following procedure;

a. As the PB1 is pressed, MV1 opens and the water begins to fill the tank. At the same time, the

stirring motor M starts operations.

[6 marks]

b. When the water level passes TLB2 and reaches TLB1, the MV1 closes and the stirring motor

stops.

[6 marks]

c. Next, MV2 opens and starts draining the water. When the water level drops below TLB2, MV2

closes.

[6 marks]

d. When the cycle of operation has repeated four times, the operation END indicator illuminates,

and the filling and draining operation will not restart even if PB1 is pressed.

[7 marks]

operation will not restart even if PB1 is pressed. [7 marks] Figure 5: Filling/draining control operation

Figure 5: Filling/draining control operation

Table 1: I/O Assignments

Input

Device

Output

Device

P0.1

Start Button (PB1)

P1.0

Water Supply Valve (MV1)

P0.2

Stop Button (PB2)

P1.1

Drain Valve (MV2)

P0.3

Reset (PB3)

P1.2

Stirring Motor (M)

P0.4

Upper Level Switch (TLB1)

P1.3

End Indicator

P0.5

Lower Level Switch (TLB2)

   

(M)

5

RESET
RESET

Appendix

1. 8051 – Special Function Register

CONFIDENTIAL

Appendix 1. 8051 – Special Function Register CONFIDENTIAL 2. 8255 Mode Word Format 6

2. 8255 Mode Word Format

Appendix 1. 8051 – Special Function Register CONFIDENTIAL 2. 8255 Mode Word Format 6

6

3. Interfacing Components Schematic Diagram

CONFIDENTIAL

3. Interfacing Components Schematic Diagram CONFIDENTIAL 7

7

4. 8051 Instruction Sets

CONFIDENTIAL

4. 8051 Instruction Sets CONFIDENTIAL 8

8