Download Bachelor of Engineering in Computer and Electronic

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Serial digital interface wikipedia , lookup

Index of electronics articles wikipedia , lookup

Rectiverter wikipedia , lookup

Opto-isolator wikipedia , lookup

Microcontroller wikipedia , lookup

Analog-to-digital converter wikipedia , lookup

Charlieplexing wikipedia , lookup

Immunity-aware programming wikipedia , lookup

Transcript
Bachelor of Engineering in Computer and Electronic Engineering
Computer Engineering 1
Year 2 Semester 3
Autumn ‘08
Niall O’Keeffe
Instructions to Candidates: 2 hours duration
Answer 4 out of 6 questions.
Question 1.
a) List the 4 elements required to make up any computer system.
(4 marks)
b) Explain the difference between a microcontroller and a microprocessor.
(4 marks)
c) Explain the difference between code and data memory in a computer system.
(4 marks)
d) Explain the function of interrupts in a computer system.
(6 marks)
e) Figure Q1 overleaf shows a minimum 8051 circuit schematic.
(i) What is the function of the RC circuit connected to the RST pin? (3 marks)
(ii) What is the function of the EA pin?
(2 marks)
(iii) Explain the significance of the 12MHz crystal.
(2 marks)
Question 2.
a) List 2 advantages and 2 disadvantages of programming the 8051 in C rather than
assembly language.
(6 marks)
b) How much data memory will be allocated for the following variable declarations?
(4 marks)
int array1[4];
char a,b,c,d;
unsigned char array2[] = {1,2,3,4,5,6};
bit x,y,z;
c) The C code below may not always produce the correct result. Explain the problem
with the code and provide a solution.
(5 marks)
void main()
{
char num1, num2, result;
num1 = P1;
num2 = P2;
result = num1 + num2;
}
d) Change the code of part (c) to add a bit variable called overflow. The overflow
variable should be set to ‘1’ if the addition result exceeds and ‘0’ otherwise.
(5 marks)
e) Write C code to set the upper 2 bits of Port 3 without affecting the lower 6 bits of the
port.
(5 marks)
Question 3.
An 8051 application board has 2 LEDs that are used to provide status information. The
status of the board is dependent on 2 input switches SW1 and SW2. The switch and LED
information for each state is shown in the table below.
State Switch Status
SW2 SW1
0
0
0
0
1
1
1
0
2
1
1
3
LED Status
LED2
LED1
Off
Off
Off
On
On
Off
Flash 1Hz Flash 1Hz
a) Draw a circuit diagram of the application using a 74LS244 buffer to drive the LEDs.
The pin-out for the 74LS244 buffer is shown below.
(10 marks)
b) Write a C program to implement the application.
(15 marks)
To implement the time delays your program can call a function delay(x); The
parameter x will yield a delay of x * 50msec. e.g. delay(2) will generate a 0.1 second
delay
Question 4.
Figure Q4 overleaf shows an 8051 microcontroller interface to 2 7-segment displays.
Software multiplexing is used to control the displays.
a) Explain the functionality provided by the 74LS47 I.C.
(4 marks)
b) A single 74LS47 I.C. is used to drive 2 7-segment displays. Explain why the same
number will not be displayed on both displays.
(5 marks)
c) List 2 advantages of using a 74LS47 instead of a 74LS244 buffer to interface to the 7segment displays.
(5 marks)
d) What are the advantages of software multiplexing?
(4 marks)
e) The C program below may be used by the 8051 microcontroller in figure Q4.
(i)
What does the code do?
(4 marks)
(ii)
Why is the function of the 10msec delay?
(3 marks)
sbit displaya = P3^0;
sbit displayb = P3^1;
void main()
{
unsigned char data units, tens;
for (tens = 0; tens < 10; tens++)
{
for (units = 0; units < 10; units++)
{
for (z = 0; z < 50; z++)
{
P2 = tens;
displaya = 0;
displayb = 1;
delay_10msec();
displaya = 1;
displayb = 0;
P2 = units;
delay_10msec();
}
}
}
}
Question 5.
An excerpt from the 74C922 keypad encoder datasheet is attached to the rear of the exam
paper.
a) Explain the functionality provided by the 74C922 keypad encoder chip (6 marks)
b) What is the function of the capacitors connected to the Oscillator and Key Bounce
Mask pins of the 74C922.
(4 marks)
c) The 74C922 keypad encoder is connected to the 4x4 keypad shown below. What is
the 4-bit binary code output by the 74C922 if the keys ‘2’ and ‘C’ are pressed.
(4 marks)
d) Draw a schematic diagram to connect the 4x4 keypad to an 8051 microcontroller
using the 74C922 decoder chip.
(7 marks)
e) Explain how the keypad may be interfaced to an 8051 microcontroller without the use
of the 74C922 encoder chip.
(4 marks)
Y1
Y2
Y3
Y4
1
4
7
*
2
5
8
0
3
6
9
#
A
B
C
D
X1
X2
X3
X4
Question 6.
Figure Q6 overleaf shows an 8051 connected to an ADC0804 8-bit analog to digital
converter.
a) Complete the following table for an analog to digital converter (ADC). (6 marks)
Analog Input
Voltage
1V
3V
-1V
Full Scale
Voltage
0 to +5V
-5V to +5V
-5V to +5V
No. of Output Digital Output
Bits
(Hex)
8
8
8
b) What functionality do the ADC0804 WR and INTR pins provide?
(5 marks)
c) The code below interfaces an 8051 microcontroller to an ADC0804 ADC. Draw a
timing diagram showing the interface signals between the 8051 and ADC.
(6 marks)
sbit WR = P3^0;
sbit RD = P3^1;
sbit INTR = P3^2;
void main()
{
unsigned char data adc;
WR = 1;
RD = 1;
while(1)
{
WR = 0;
//start conversion by pulsing WR pin low
WR = 1;
while(INTR); //wait for end of conversion
RD = 0;
adc = P1;
RD = 1;
}
}
d) Change the program in part C so that the maximum and minimum voltage values read
by the ADC are stored in 2 variables called max and min.
(8 marks)
74C922 Keypad Encoder Datasheet Extract