0% found this document useful (0 votes)
60 views

Final Micro

printf( " %d " ,anum[n]); (A) print(anum[n]); (B) print("%d", anum[n]); (C) print(anum[n], "%d"); (D) print(" %d ", anum[n]); (E) All of the above (F) None of the above 25. Based on the Above Code, what is the maximum size of character array "astring"? (A) 10 (B) 16 (C) 255 (D) 65535 (E) Depends on microcontroller (F) None of the above 26. Based on the Above

Uploaded by

Fatima Aldrweesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Final Micro

printf( " %d " ,anum[n]); (A) print(anum[n]); (B) print("%d", anum[n]); (C) print(anum[n], "%d"); (D) print(" %d ", anum[n]); (E) All of the above (F) None of the above 25. Based on the Above Code, what is the maximum size of character array "astring"? (A) 10 (B) 16 (C) 255 (D) 65535 (E) Depends on microcontroller (F) None of the above 26. Based on the Above

Uploaded by

Fatima Aldrweesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

‫‪1|Page‬‬

‫امأل جميع‬ ‫ضع دائرة مصمتة لالجابة المختارة في الورقة األخيرة المخصصة لإلجابة‪.‬‬
‫بياناتك والتزم بطريقة اإلجابة‪ .‬عدم تقيدك بهذه التعليمات سيؤدي إلى إنقاص عالمتك‬

‫العالمة‬
2|Page

Question 1: Please select the most appropriate answer for the following questions:

#include " 16F877A.h "


#use delay(clock =
4000000)
#INT_EXT
void F1()
{ output_D(255);
delay_ms(1000);}
void F2()
{ output_D(15);
delay_ms(500);}

#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);}
}

1. When function F1 will be executed?


(A) When switch S1 connected to (B) When switch S1 connected to RB0 (C) When switch S4 connected to RB7 is
RB0 is opened is closed opened
(D) When switch S4 connected to (E) All of the above (F) None of the above
RB7 is closed
2. When function F2 will be executed?
(A) When switch S1 connected to (B) When switch S1 connected to RB0 (C) When switch S4 connected to RB7 is
RB0 is opened is closed opened
(D) When switch S4 connected to (E) All of the above (F) None of the above
RB7 is closed
3. When function F3 will be executed?
(A) When switch S3 connected to (B) When switch S3 connected to RB6 (C) When switch S4 connected to RB7 is
RB6 is opened is closed opened
(D) When switch S4 connected to (E) All of the above (F) None of the above
RB7 is closed
3|Page

4. When Function F3 is executed, which led will light ON


(A) RD0-RD7 (B) RD0-RD3 (C) RD3-RD7
(D) No led will be lighted (E) All of the above (F) None of the above
5. Microcontroller µC is better than Microprocessor µP, because
(A) µC have all components on (B) µp requires additional components (C) µC has many programmable pins
the same chip
(D) µC has many bit handing (E) A+C (F) All of the above
instructions
6. Microcontroller Quartz Crystal oscillator, has the following characteristics:
(A) Has a precise and stable (B) Generate pulses with the same (C) Cheaper than RC method
frequency width
(D) A+C (E) A+B (F) All of the above
7. After executing the following code segment
ADDWF PCL
Where W = 0x10 , PCL = 0xF7 , , PCH = 0x08 , C = X
What is the content of the registers?
(A) PCL = 0x07 (B) PCL = 0xF7 (C) PCL = 0x07
PCH = 0x08 PCH = 0x08 PCH = 0x08
C=1 C=1 C=0
(D) PCL = 0x07 (E) All of the above (F) None of the above
PCH = 0x08
C=X
8. Which of the followings Execute ProcessA subroutine until ‘w’ contains the value decimal 99
(A) NXT: sublw d ’99’ (B) NXT: call ProcessA (C) NXT: sublw d ’99’
btfsc STATUS,Z sublw d ’99’ btfss STATUS,Z
goto DONE btfss STATUS,Z goto DONE
call ProcessA goto NXT call ProcessA
goto NXT DONE goto NXT
DONE … DONE
… …
(D) A+B (E) All of the above (F) None of the above
CLR2070: movlw 0x20
movwf FSR
NXT1: clrf INDF
incf FSR,F
movlw 0x70
subwf FSR,W
btfss STATUS,Z
goto NXT1
return
9. What is the function of the above code?
(A) Clear 70 memory location (B) Clear 20 memory location starting (C) Clear memory from location 0x20 to
starting from address 0x20 from address 0x70 0x70
(D) Clear memory from location (E) All of the above (F) None of the above
0x20 to 0x6F
10. Which instructions take 2 instruction cycles to execute:
4|Page

(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

13. for ( n = 0; n < 10; n + + ) printf( " %d " ,anum[n]);


14. putc(254); putc(192);
15. delay_ms(10);
16. puts(astring);
17. while(1); }

22. Based on the Above Code, what is the function of line 9?


(A) Go to LCD line 1 (B) Go to LCD line 2 (C) Clear LCD Screen
(D) Switch to LCD control mode (E) All of the above (F) None of the above
23. Based on the Above Code, what is the function of line 14?
(A) Go to LCD line 1 (B) Go to LCD line 2 (C) Clear LCD Screen
(D) Switch to LCD control mode (E) All of the above (F) None of the above
24. Based on the Above Code, which code may be used instead of line 16 without changing the program run?
(A) for ( n = 0; n < 16; n + + ) (B) for ( n = 0; n < 6; n + + ) (C) for ( n = 0; n < 10; n + +
printf( " %c " , astring [n]); printf( " %c " , astring [n]); printf( " %d " , astring [n]);
(D) for ( n = 0; n < 6; n + + ) (E) All of the above (F) None of the above
printf( " %X " , astring [n]);
25. Based on the Above Code, what is the function of line 17?
(A) Execute code endless times (B) Execute code and wait 1 Second (C) Execute code and exit the program
(D) Execute code once and wait (E) None of the above (F) None of the above
26. Based on the Above Code, what is the function of line 3?
(A) It is instruction used to set (B) It is directive used to set data(baud) (C) It is directive used to set data(baud)
data(baud) rate, and pins used rate, and pins used in serial sending rate, and pins used in parallel sending
in serial sending and receiving and receiving and receiving
(D) It is instruction used to set (E) All of the above (F) None of the above
data(baud) rate, and pins used
in parallel sending and
receiving
MOVLW D’150’
MOVWF TIME1
LOOP_two: MOVLW D’250’
MOVWF TIME
LOOP_ONE: NOP
DECFSZ TIME,F
GOTO LOOP_ONE
DECFSZ TIME1,F
GOTO LOOP_two
27. Based on the above code. Assume the PIC runs with a clock frequency of 4 MHz. What is the time needed to
execute the inner loop “ loop_one”?
(A) 100µs (B) 1 s (C) 1µs
(D) 1 ms (E) All of the above (F) None of the above
28. What is the time needed to execute the above code?
(A) 100µs (B) 150 ms (C) 1µs
(D) 1 ms (E) All of the above (F) None of the above
1. MOVLW 0x30
7|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

(A) 3015 μ sec (B) 5150 μ sec (C) 15 μ sec


(D) 5015 μ sec (E) All of the above (F) None of the above
36. What is the purpose of acquiring two different bits from INTCON register for performing any interrupt
operation in PIC 16f877A ?
(A) One for enabling & one for (B) One for enabling the interrupt & (C) One for setting or clearing the RBIE bit
disabling the interrupt one for its occurrence detection 
(D) A+C (E) All of the above (F) None of the above
37. Which among the below specified combination of interrupts belong to the category of the PIC 16f877A?
(A) External , Timer/ Counter & (B) Internal , External & (C) External , Timer 0 & Port B Interrupts
serial Port Interrupts  Timer/Counter Interrupts
(D) Internal, External, Timer 0 & (E) All of the above (F) None of the above
PortA Interrupts
1. TEST equ B'00000101'
2. #define RELAY PORTD,3
3. ;******* ***** MAIN PROGRAM
4. org 0x0000
5. banksel TRISB
6. clrf TRISB
7. clrf TRISD
8. movlw B'00010000'
9. movwf TRISA
10. banksel OPTION_REG
11. bsf OPTION_REG,T0CS
12. bsf OPTION_REG,PSA ; Prescaler rate is 1:1
13. banksel PORTB ; Selects bank containing PORTB
register
14. clrf TMR0 ; Clears timer register
15. bcf PORTD,3 ; Pin PORTD,3 = 0
16. loop
17. movfw TMR0 ; Timer register is moved to W register
18. movwf PORTB ; W register is moved to PORTB
19. xorlw TEST
20. btfsc STATUS,Z
21. bsf PORTD,3
22. goto loop
23. end
38. Based on the above code. What is the function of line6+7 ?
(A) Configure Port B pins as (B) Configure Port C pins as output (C) Configure Port D pins as output
output
(D) A+C (E) All of the above (F) None of the above
39. Based on the above code. What is the function of line 8+9 ?
(A) Configure Port A as input port (B) Configure Port A as output port (C) Configure Pin RA4 as input
(D) Configure Pin RA4 as output (E) All of the above (F) None of the above
40. What is the function of the above code?
(A) Turn a device connected to a (B) Turn a device connected to a relay (C)
relay ON/OFF every time a ON/OFF every 5 times a push
push button connected to RA4 button connected to RA4 is pressed
9|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

You might also like