Final Micro
Final Micro
امأل جميع ضع دائرة مصمتة لالجابة المختارة في الورقة األخيرة المخصصة لإلجابة.
بياناتك والتزم بطريقة اإلجابة .عدم تقيدك بهذه التعليمات سيؤدي إلى إنقاص عالمتك
العالمة
2|Page
Question 1: Please select the most appropriate answer for the following questions:
#INT_RB
void F3()
{ output_D(00);
delay_ms(1000);}
void main() {
int x;
enable_interrupts(int_ext);
enable_interrupts(global);
ext_int_edge(L_TO_H);
while(1){ output_D(x);
x++;
delay_ms(100);}
}
(A) Instructions that modify the (B) Instruction with test condition that (C) Program control instruction
PC is logic one
(D) A+B (E) All of the above (F) None of the above
1. unsigned cnt;
2. void interrupt() {
3. cnt++;
4. TMR0 = 96;
5. INTCON = 0x20;
6. }
7. void main() {
8. OPTION_REG = 0x84;
9. ANSEL = 0;
10. ANSELH = 0;
11. TRISB = 0;
12. PORTB = 0x0;
13. TMR0 = 96;
14. INTCON = 0xA0;
15. cnt = 0;
16. do {
17. if (cnt == 400) {
18. PORTB = PORTB++;
19. cnt = 0;
20. }
21. } while(1);
22. }
11. Based on the above code. What is the purpose of line 9 and 10?
(A) All I/O pins are configured as (B) All I/O pins are configured as (C) All I/O pins have an output of 0
analog digital
(D) All I/O pins have an output of (E) All of the above (F) None of the above
1
12. Based on the above code. What is the purpose of line 11?
(A) Send an output of 0 to PortB (B) Send an output of 1 to PortB (C) Configure PortB as output port
(D) Configure PortB as input port (E) All of the above (F) None of the above
13. Based on the above code. What is the purpose of line 5?
(A) Set T0IE (B) Clear T0IF (C) A+B
(D) Initialize TMR0 (E) All of the above (F) None of the above
14. Based on the above code. When line 18 will be executed?
(A) Once (B) 400 times (C) After 400 interrupt
(D) When cnt=0 (E) All of the above (F) None of the above
15. Based on the above code. What is the range of timer0?
(A) From 255 to 96 (B) From 96 to 255 (C) From 0 to 255
(D) From 255 to 0 (E) All of the above (F) None of the above
16. Harvard Architecture Compared to von-Neumann architecture is
5|Page
(A) Use two separate memories (B) Both Having the same performance (C) Harvard Have one data, address, and
control bus
(D) Harvard can execute only one (E) All of the above (F) None of the above
instruction at a time
17. Which of the following is true regarding STACK memory
(A) Has STATUS bit to indicate (B) Have 13 registers (C) Register Size is 8 Bits
stack overflow
(D) It is used to store PC after (E) All of the above (F) None of the above
CALL instruction
1. # include " 16F877A.H "
2. int8 outbyte = 1;
3. int16 n;
4. void out()
5. {
6. while (outbyte! = 0)
7. { output_C(outbyte);
8. outbyte ++ ;
9. for(n = 1;n < 500;n++ ); }
10. }
11. main( )
12. { out( );
13. while(1); }
18. Based on the Above Code. What is the Maximum value that variable “outbyte” can have?
(A) 1 (B) 255 (C) +127
(D) 65535 (E) +32767 (F) None of the above
19. Based on the Above Code. What is the Maximum value that variable “n” can have?
(A) 1 (B) 255 (C) +127
(D) 65535 (E) +32767 (F) None of the above
20. What is the function of the above code?
(A) Print from 0xFF to 0x01 on (B) Print from 0x01 to 0xFF on PortC (C) Print from 0x01 to 0xFF on PortD
PortC
(D) Print from 0xFF to 0x01 on (E) All of the above (F) None of the above
PortD
21. Based on the Above Code. What is the function of line 9 ?
(A) Generate 500 ms delay (B) Generate 500 µs delay (C) Generate delay to make output visible
(D) Print from 00 to 500 on PortC (E) All of the above (F) None of the above
1. # include " 16F877A.h"
2. # use delay(clock=4000000)
3. # use rs232(baud = 9600, xmit = PIN_D0, rcv = PIN_D1)
4. main()
5. { int8 aval = 0, n; // Declare single variables
6. int8 anum[10]; // Declare integer array
7. char astring[16]; // Declare character array
8. delay_ms(1000);
9. putc(254); putc(1);
10. delay_ms(10);
11. for ( n = 0; n < 10; n + + ) { anum[n] = aval; aval + + ; }
12. strcpy(astring, " Hello! " );
6|Page
2. MOVWF FSR
3. MOVLW D’16’
4. MOVWF COUNTER
5. LOOP:
6. CLRF INDF
7. INCF FSR,F
8. DECFSZ COUNTER,F
9. GOTO LOOP
29. What is the function of the above code?
(A) Clear an array from address (B) Clear an array with size of 15 bytes (C) Clear an array from address 0x30 to
0x30 to 0x3f from address 0x30 0x46
(D) Clear an array from address (E) All of the above (F) None of the above
0x30 to 0x3f
30. Assume the PIC runs with a clock frequency of 4MHz. What is the approximate time needed to execute the
above code?
(A) 100 µs (B) 800 µs (C) 84 µs
(D) 8 µs (E) All of the above (F) None of the above
1. MOVWF TEMP1
2. MOVWF TEMP2
3. BCF STATUS,C
4. RLF TEMP2,F
5. RLF TEMP2,W
6. ADDWF TEMP1,F
7. BCF STATUS,C
8. RLF TEMP1,W
31. What is the function of the above code. What is the result of line 4 ?
(A) W=2*W (B) TEMP2 = 2*W (C) TEMP2 = 4*W
(D) W=4*W (E) All of the above (F) None of the above
32. What is the function of the above code. What is the result of line 5 ?
(A) W=2*W (B) TEMP2 = 2*W (C) TEMP2 = 4*W
(D) W=4*W (E) All of the above (F) None of the above
33. What is the function of the above code. What is the result of line 8 ?
(G) W=2*W (H) W = 4*W (I) W = 8*W
(J) W=10*W (K) All of the above (L) None of the above
34. When start executing ISR, which of the followings is True
(A) Disable the interrupt at the (B) Enable the interrupt at the end of (C) Clear the interrupt flag at the end of
beginning of ISR ISR ISR
(D) A+B (E) All of the above (F) None of the above
35. The following subroutine executes on a 16F877 system with a crystal of 800 KHz. How long does it take to
execute in μ sec ?
delay: movlw D’200’
movwf count
delx: nop
nop
decfsz count,1
goto delx
return
8|Page
is pressed
(D) (E) All of the above (F) None of the above
41. Three microcontrollers (A, B & C) have maximum clock speeds 10MHz, 20MHz, 24MHz respectively.
Microcontroller A divides its clock by 4 to give one machine cycle, microcontroller B by 8, and microcontroller
C by 12. Microcontrollers A & C take 2 machine cycles to perform an instruction, while microcontroller B
takes three cycles. Place the microcontrollers in order of the speed in which they can perform that instruction?
(A) A then B then C (B) C then B then A (C) B then C then A
(D) A then C then B (E) All of the above (F) None of the above
Question # 2 : ( 10 points): Indicate whether the following statements are True or False. Explain the true one and
correct the faulty one. Answer by Guessing will give you minus grade.
1. Look-up table is essentially a list of retlw instructions, each with its two byte of data. one
2. Inside the look-up table which is written as a subroutine, at least three instructions are executed. two
3. The size of the addressable look-up table is 512 words at MAX. 256
4. When using variables in loops, counting variables up is easier than counting down. difficult
5. Bank 0 is used to control the actual operation of the PIC, for example to tell the PIC which bits of Port A are input
and which are output. Bank 1 is used to manipulate the data. 0 and 1 are reversed.
6. A subroutine is a section of code, which can be called when you need it. It increases the size of the memory used by
the program. Decrease
7. In indirect addressing, registers’ addresses are specified in the INDF register, and their contents are stored in the
FSR register. INDF & FSR are reversed
8. A High-speed crystal can be used in PIC Clock to reduce power consumption, and A low-speed crystal can be used
to increase power consumption. (High / Low) ( increase/reduce) are reverse
9. When enabled, the watchdog timer (WDT) automatically resets the processor after a given period. This allows, for
example, an application to escape from an endless loop caused by a program bug. TRUe
10. Basic digital input and output (I/O) in the microcontroller uses a unidirectional port pin. Bidirectional
11. Total digital I/O available is 35 pins. 33
12. The program memory ROM contains the machine code, in locations numbered from 0000 h to 1FFFh. True
13. Interrupt source (INT_RTCC) and (INT_TIMER0) are the same. True
14. This directive (#int_ext) tells the compiler that the code immediately following is the service routine for GLOBAL
interrupt. EXT(RB0)
15. Contact bounce in a mechanical switches happen when the switch goes from close to open state. Open to close
16. #INT_EXT directive is used to specify the interrupt function used with any change on PortB (RB4-RB7). RB0
17. Enable_interrupts(int_ext) is equivalent to set the bit INTE in INTCON register. True
18. Enable_interrupts(global) is equivalent to set the bit GIE in INTCON register. True
19. Enable_interrupts(INT_RB) is equivalent to set the bit RBIE in INTCON register. True
20. Disable_interrupts(INT_timer0) is equivalent to reset the bit T0IE in INTCON register. True
10 | P a g e
.........................………………اسم المدرس
P1 circle T or F
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
T T T T T T T T T T T T T T T T T T T T
F F F F F F F F F F F F F F F F F F F F
P2 circle your choice and fill the circle completely with ink
1. A B C D E F 21. A B C D E F
2. A B C D E F 22. A B C D E F
3. A B C D E F
23. A B C D E F
4. A B C D E F
24. A B C D E F
5. A B C D E F
6. A B C D E F 25. A B C D E F
7. A B C D E F 26. A B C D E F
8. A B C D E F
27. A B C D E F
9. A B C D E F
28. A B C D E F
10. A B C D E F
29. A B C D E F
11. A B C D E F
12. A B C D E F 30. A B C D E F
13. A B C D E F 31. A B C D E F
14. A B C D E F
32. A B C D E F
11 | P a g e
15. A B C D E F 33. A B C D E F
16. A B C D E F 34. A B C D E F
17. A B C D E F
35. A B C D E F
18. A B C D E F
36. A B C D E F
19. A B C D E F
20. A B C D E F 37. A B C D E F
38. A B C D E F
39. A B C D E F
40. A B C D E F