مايكرو نصفي 2020

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

College of Electronic Technology - Tripoli CE223: Microcomputer Systems

.......................... :‫ القسم‬...................... :‫رقم القيد‬ ........................................................ :‫إسم الطالب‬

Midterm I Date: 06 / 02 / 2020


Important Notes:

 This paper contains FIVE questions in TWO pages.


 Attempt ALL questions.
 Total time allowed 75 MINUTES. Total Marks: 30
 Enhance your answers with proper sketches whenever applicable.

Q.1 [10 Marks] Multiple Choice Questions (MCQ):


1. Which of the following is not a data transfer instruction.
c. SBC. (√) a. POP. ( )
d. LDI. ( ) b. MOV. ( )

2. To configure all pins of port D as inputs, we must


c. Clear all bits of PIND. ( ) a. Set all bits of PIND. ( )
d. Clear all bits of DDRD. ( √ ) b. Set all bits of DDRD. ( )

3. ........ of ATmega328 is used to hold the address of instruction to be fetched.


c. Z register. ( ) a. Instruction register. ( )
d. PC register. (√) b. PORT register. ( )

4. In which addressing mode data is addressed by a 16 bit pointer register.


c. Register. ( ) a. Immediate. ( )
d. Indirect. (√) b. Direct. ( )

5. The microprocessor is a microcomputer system in a single chip.


b. False. (√) a. True. ( )
Reason (if false):
The microprocessor is NOT a microcomputer system it is part of the system, whereas
microcontroller is an example of a microcomputer system.

6. The C flag is set whenever the result is too large.


b. False. (√) a. True. ( )
Reason (if false):
The C flag is set whenever a carry out is generated by the last operation. The V flag is
set whenever the result is too large.

Examiner: Eng. Abdulbaset Ashour 1


College of Electronic Technology - Tripoli CE223: Microcomputer Systems

.......................... :‫ القسم‬...................... :‫رقم القيد‬ ........................................................ :‫إسم الطالب‬

7. DDRD is used to hold data read from port D.


b. False. (√) a. True. ( )
Reason (if false):
DDRD is used to configure port D pins as digital inputs or outputs. PIND is used to
hold data read from port D.

Q.2 [4 Marks] Explain the purpose of the following:


a) Data pointer registers.
b) Signal conditioning circuits.
Q.3 [4 Marks] Briefly explain the following:
a) The main advantage of parallel over sequential processor.
b) Microcontroller bandwidth.
Q.4 [4 Marks] Referring to ATmega328 instruction set and addressing modes,
translate the following code extracts to equivalent ATmega328 instructions once
in direct addressing mode then using indirect addressing mode.

Variable Address
Sum = 0;
A 0x100
A=5;
B 0x101
B=7;
Sum 0x102
Sum=A+B;

Using DIRECT addressing mode:


LDI R16 , 0; or CLR R16
STS [0x102] , R16; Sum=0
LDI R16 , 5
STS [0x100] , R16; A=5
LDI R16 , 7
STS [0x101] , R16; B=7

Examiner: Eng. Abdulbaset Ashour 2


College of Electronic Technology - Tripoli CE223: Microcomputer Systems

.......................... :‫ القسم‬...................... :‫رقم القيد‬ ........................................................ :‫إسم الطالب‬

LDS R16 , [0x100]; Loading A from SRAM to R16


LDS R17 , [0x101]; Loading B from SRAM to R17
ADD R16 , R17; R16=A+B
STS [0x102] , R16; Sum=A+B

Using INDIRECT addressing mode:


LDI R26 , 0;
LDI R27 , 0x01; Data pointer register X = 0x100
LDI R28 , 0x01;
LDI R29 , 0x01; Data pointer register Y = 0x101
LDI R30 , 0x01;
LDI R31 , 0x02; Data pointer register Z = 0x102
CLR R16 ;
ST Z, R16; Sum=0
LDI R16 , 5;
ST X, R16; A=5
LDI R16 , 7;
ST Y, R16; B=7
LD R20 , X
LD R21 , Y
ADD R20 , R21; R20=A+B
ST Z , R20; Sum=A+B

Examiner: Eng. Abdulbaset Ashour 3


College of Electronic Technology - Tripoli CE223: Microcomputer Systems

.......................... :‫ القسم‬...................... :‫رقم القيد‬ ........................................................ :‫إسم الطالب‬

Q.5 [8 Marks] Referring to figure 1 below, carry out the following tasks:

a)Classify the 7-segmend display as analog or digital, input or output device.


7-segmend display as a digital output device.

b)Can ATMega328p control the two displays directly? Elaborate your answer.
Yes it can drive the display directly because it consists of 7 LEDs and the
microcontroller can provide the power requirement of LEDs.

c)Draw a circuit diagram connecting 7-seg. A to port B and 7-Seg. B to port D of


ATMega328p.

d)Write ATmega328 instructions to show the last two digits of your matric number
on 7-seg. A and B and 7-Seg. B respectively.

Displaying 73 on 7-Seg. A and 7-Seg. B respectively

Examiner: Eng. Abdulbaset Ashour 4


College of Electronic Technology - Tripoli CE223: Microcomputer Systems

.......................... :‫ القسم‬...................... :‫رقم القيد‬ ........................................................ :‫إسم الطالب‬

LDI R16 , 0xFF; or CLR R16


OUT DDRB , R16; Port B set as digital output
OUT DDRD , R16; Port D set as digital output
LDI R16 , 0x07; 0b00000111 (a b c ON)
OUT PORTB , R16;
LDI R16 , 0x30; 0b00110000 (a b c d g ON)
OUT PORTD , R16;

Examiner: Eng. Abdulbaset Ashour 5

You might also like