=========================preview======================
(ELEC254)MiniExam03Fall.pdf
Back to ELEC254 Login to download
======================================================
The Hong Kong University of Science and Technology
Department of Electrical and Electronic Engineering
ELEC254 Mini Exam 9 Oct. 2003
Name: Answer
Student Number: (also fill in your student no. at the bottom of each page)
Time: 19:00-20:00 (One-hour open-book examination)
Do ALL the problems in this examination paper
Question Your Mark Mark of question
Q1 1
Q2 1
Q3 2
Q4 3
Q5 3
Total 10
Q1. To setup interrupt priority, there are two approaches. One is Daisy-Chaining of the acknowledge line. State two main disadvantages of this approach.
Ans.:
1.
Slow when there are many devices. (0.5 mark)
2.
Devices with higher priority must be always turned on. (0.5 mark)
Q2. A 8051 microcontroller is used to measure how long a key is pressed by the embedded 8-bit counter with auto reload (Mode 2).
Given that the oscillator is 12MHz and one machine cycle is composed of 12 clock periods. The preset value is 124, and the reading from the counter is 255 in decimal. How long the key is pressed in the unit of second?
Ans.: (255 .124) 12 = 131s (no mark for other answer)
12 106
Q3. A 8051 microcontroller is used for detecting 8 switches and controlling 8 LEDs.
Assume all LEDs are turned on initially, write a simple 8051 program such that only LED7 will be turned off when sw1 is closed.
Ans.: MOV A, P1 ANL A, #02H JZ SomeWhereElse MOV P2, #80H
Q4. Given that an 8051 microcontroller is connected to an external memory. Write a COMPLETE 8051 program to do the following. No need to infinitely loop the program. Meaningful comments are required.
Data in internal RAM 30H will be added with the data at external memory at address 0100H. The result will be stored in internal at address 50H.
Data in internal RAM 31H will be added with the data at external memory at address 0101H. The result will be stored in internal at address 51H.
Data in internal RAM 32H will be added with the data at external memory at address 0102H. The result will be stored in internal at address 52H.
until
Data in internal RAM 4FH will be added with the data at external memory at address 011FH. The result will be stored in internal at address 6FH.
During the addition process, you should count how many times there is a carry out from the addition and store it in R7 of Bank 0 (This value should be less than or equal to 20H).
Ans.:
ORG 00
LOOP: NOC: MOV R7, #0H MOV R0, #30H MOV R1, #50H MOV R3, #20H MOV DPTR, #0100H MOVX A, @DPTR ADD A, @R0 JNC NOC INC R7 MOV @R1, A NC DPTR INC R0 INC R1 DJNZ R3, LOOP
END
Q5. A system for analog signal processing is shown below.
The input-output relationship is given by
vo A
=
vi 1+ A . f It is known that the above system in analog domain may be unstable and is noise sensitive. Many circuit designers prefer to achieve the same idea in digital domain. One of the solutions is using a microprocessor along with two analog-to-digital converters