Unit 5 - Practice Quiz

ECE227 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 Which register is primarily used to configure the operation of Timer0 in PIC18 microcontrollers?

Programming Timer 0 in C Easy
A. TMR0L
B. INTCON
C. ADCON0
D. T0CON

2 When Timer0 is configured in 16-bit mode, which pair of registers holds the count value?

Programming Timer 0 in C Easy
A. TMR1L and TMR1H
B. PORTA and PORTB
C. TMR0L and TMR0H
D. T0CON and INTCON

3 What is the function of the prescaler in Timer0?

Programming Timer 0 in C Easy
A. To select the timer's mode (8-bit or 16-bit)
B. To enable the timer interrupt
C. To set the timer's initial value
D. To divide the clock frequency before it reaches the timer

4 To turn on Timer0, which bit in the T0CON register must be set to 1?

Programming Timer 0 in C Easy
A. GIE
B. TMR0ON
C. T0CS
D. PSA

5 Which register is used to control and configure Timer1 in a PIC18 microcontroller?

Programming Timer 1 in C Easy
A. T1CON
B. TMR1L
C. PIR1
D. T0CON

6 Timer1 is a 16-bit timer. Which two 8-bit registers are combined to store its value?

Programming Timer 1 in C Easy
A. T1CON and T1GCON
B. TMR1H and TMR1L
C. PIR1 and PIE1
D. TMR0H and TMR0L

7 To use the internal instruction cycle clock () as the source for Timer1, what should the TMR1CS bit in the T1CON register be set to?

Programming Timer 1 in C Easy
A. This bit does not control the clock source
B. It depends on the prescaler
C. 1
D. 0

8 What is a primary difference between Timer1 and Timer0 in many PIC18 devices?

Programming Timer 1 in C Easy
A. Timer0 is faster than Timer1
B. Only Timer1 can be used with interrupts
C. Timer0 has more prescaler options
D. Timer1 is always 16-bit, while Timer0 can be 8-bit or 16-bit

9 What is an Interrupt Service Routine (ISR)?

PIC18 interrupts Easy
A. A special function that the processor executes in response to an interrupt
B. The main loop of a program
C. A hardware register that stores interrupt flags
D. A command to reset the microcontroller

10 Which bit in the INTCON register must be set to enable all unmasked interrupts globally?

PIC18 interrupts Easy
A. INTE (External Interrupt Enable)
B. PEIE (Peripheral Interrupt Enable)
C. TMR0IE (Timer0 Interrupt Enable)
D. GIE (Global Interrupt Enable)

11 In a PIC18 microcontroller, what is an interrupt vector?

PIC18 interrupts Easy
A. A register that enables interrupts
B. A variable that stores the interrupt type
C. A specific memory address where the ISR for an interrupt is located
D. The priority level of an interrupt

12 What is the purpose of an interrupt flag bit, such as TMR0IF?

PIC18 interrupts Easy
A. To disable all interrupts globally
B. To set the priority of an interrupt
C. To enable a specific interrupt
D. To indicate that a specific interrupt event has occurred

13 To enable the Timer0 overflow interrupt, which two bits must be set?

Programming Timer Interrupt Easy
A. TMR0ON and T0CS
B. GIE and TMR0IE
C. GIE and INTE
D. PEIE and TMR1IE

14 When a Timer0 overflow interrupt occurs, which flag bit is set in the INTCON register?

Programming Timer Interrupt Easy
A. TMR0IF
B. ADIF
C. TMR1IF
D. INT0IF

15 What is a critical step that must be performed inside a timer's Interrupt Service Routine (ISR) before exiting?

Programming Timer Interrupt Easy
A. Set the timer's prescaler
B. Re-enable global interrupts
C. Clear the timer's interrupt flag bit
D. Reload the T0CON register

16 To use the Timer1 overflow interrupt, which bit must be set in the PIE1 (Peripheral Interrupt Enable) register?

Programming Timer Interrupt Easy
A. ADIE
B. TMR2IE
C. RCIE
D. TMR1IE

17 Which register contains the enable bit (INT0IE) and flag bit (INT0IF) for the external interrupt INT0?

Programming External Hardware Interrupt Easy
A. INTCON
B. PIE1
C. T0CON
D. INTCON2

18 What does an external hardware interrupt allow the microcontroller to do?

Programming External Hardware Interrupt Easy
A. Convert an analog voltage to a digital number
B. Measure the passage of time accurately
C. Communicate with a computer via USB
D. Respond to an event from an external device, like a button press

19 The INTEDG0 bit in the INTCON2 register is used to configure what aspect of the INT0 external interrupt?

Programming External Hardware Interrupt Easy
A. The interrupt's flag
B. The interrupt's priority level
C. The triggering edge (rising or falling)
D. Enabling or disabling the interrupt

20 After an external hardware interrupt is triggered and the processor jumps to the ISR, what must be done to the interrupt flag (e.g., INT0IF) before exiting the ISR?

Programming External Hardware Interrupt Easy
A. Nothing, the flag is not used for external interrupts
B. It must be cleared in software
C. It must be set to 1 in software
D. It is cleared automatically by hardware

21 A PIC18 is running with an oscillator frequency () of 20 MHz. What value should be loaded into the 8-bit TMR0 register to achieve a 1 ms delay using a 1:64 prescaler?

Programming Timer 0 in C Medium
A. 200
B. 125
C. 78
D. 178

22 In a PIC18 microcontroller with interrupt priority enabled (IPEN=1), an external interrupt INT1 (configured as high priority) and a Timer0 overflow interrupt (configured as low priority) occur at the exact same time. Which Interrupt Service Routine (ISR) will be executed first?

PIC18 interrupts Medium
A. The Timer0 ISR
B. Neither will execute until acknowledged
C. The processor will enter a debug state
D. The INT1 ISR

23 To configure Timer1 on a PIC18 to operate as a 16-bit timer using the internal clock (), with a 1:8 prescaler, and to turn it on, which hexadecimal value should be written to the T1CON register?

Programming Timer 1 in C Medium
A. 0x01
B. 0x31
C. 0x85
D. 0xB1

24 After enabling the Timer0 interrupt (TMR0IE=1 and GIE=1) and configuring Timer0, what is the most critical action to perform inside the Timer0 Interrupt Service Routine (ISR) to prevent it from being continuously re-triggered?

Programming Timer Interrupt Medium
A. Reload the TMR0 register with the initial value.
B. Clear the TMR0IF flag in the INTCON register.
C. Re-write the configuration to the T0CON register.
D. Disable and then re-enable the GIE bit.

25 You need to trigger an interrupt on the falling edge of a signal connected to the INT0 pin on a PIC18. Which register bit must be specifically configured for this purpose?

Programming External Hardware Interrupt Medium
A. Set the INT0IF bit in the INTCON register.
B. Clear the RBPU bit in the INTCON2 register.
C. Clear the INTEDG0 bit in the INTCON2 register.
D. Set the INTEDG0 bit in the INTCON2 register.

26 Consider the following C code for a PIC18: T0CON = 0b10000101;. What is the resulting configuration of Timer0?

Programming Timer 0 in C Medium
A. 8-bit mode, external clock, 1:32 prescaler
B. 16-bit mode, internal clock, 1:64 prescaler
C. 8-bit mode, internal clock, 1:64 prescaler
D. 16-bit mode, internal clock, no prescaler

27 What is the primary purpose of the PIE1 (Peripheral Interrupt Enable 1) register in a PIC18 microcontroller?

PIC18 interrupts Medium
A. To set the priority level of all peripheral interrupts.
B. To globally enable or disable all interrupts on the chip.
C. To individually enable or disable specific peripheral interrupts like Timer1 or USART.
D. To store the status flags of peripheral interrupts like TMR1IF.

28 A PIC18 uses a 16 MHz crystal. To generate a delay of 50 ms using Timer1 in 16-bit mode with a 1:8 prescaler, what initial value should be loaded into the TMR1 register pair (TMR1H:TMR1L)?

Programming Timer 1 in C Medium
A. 0xB1E0
B. 0xF858
C. 0x9E58
D. 0x3CB0

29 In a PIC18 C program, you have an ISR defined as void __interrupt(low_priority) low_isr(void). Which register configuration is required for this ISR to handle a Timer1 overflow interrupt?

Programming Timer Interrupt Medium
A. Set TMR1IE=0 in PIE1.
B. Set TMR1IP=1 in IPR1 and IPEN=1 in RCON.
C. Set TMR1IP=0 in IPR1 and IPEN=1 in RCON.
D. Set IPEN=0 in RCON.

30 Why might a 100nF capacitor be placed between an external interrupt pin (e.g., INT0) and ground when the interrupt is triggered by a mechanical switch?

Programming External Hardware Interrupt Medium
A. To act as a simple hardware debouncing filter.
B. To amplify the signal from the switch.
C. To invert the logic level of the switch.
D. To limit the current drawn by the input pin.

31 If Timer0 is configured in 8-bit mode with a 1:256 prescaler and an internal clock of , what is the maximum delay that can be generated in a single overflow cycle? Assume = 16 MHz.

Programming Timer 0 in C Medium
A. 8.192 ms
B. 16.384 ms
C. 65.536 ms
D. 32.768 ms

32 What happens if a high-priority interrupt occurs while a low-priority ISR is already executing in a PIC18 (with IPEN=1)?

PIC18 interrupts Medium
A. The low-priority ISR completes fully before the high-priority ISR is serviced.
B. The low-priority ISR is immediately preempted, and the high-priority ISR begins execution.
C. The processor resets because two ISRs cannot be active.
D. The high-priority interrupt is ignored and its flag is lost.

33 When using Timer1 as an asynchronous counter for external events (TMR1CS=1, T1SYNC=1), what is a major advantage of this mode?

Programming Timer 1 in C Medium
A. The count value can be read more quickly.
B. It synchronizes automatically with the main program execution.
C. It consumes less power than synchronous mode.
D. It can count events even while the microcontroller is in sleep mode.

34 Analyze the following PIC18 ISR code snippet. What is a potential issue with it? void __interrupt() my_isr(void) { if (PIR1bits.TMR1IF) { // Toggle an LED PORTBbits.RB0 = ~PORTBbits.RB0; // Reload Timer1 TMR1 = 0xC2F7; } }

Programming Timer Interrupt Medium
A. The TMR1 register cannot be written to inside an ISR.
B. The TMR1IF flag is not cleared.
C. The __interrupt keyword is invalid for Timer1.
D. The GIE bit should be disabled at the start of the ISR.

35 To enable both the external interrupt on pin INT2 and the "interrupt-on-change" for PORTB (pins RB7:RB4), which combination of interrupt enable bits must be set?

Programming External Hardware Interrupt Medium
A. INT2E in PIE1 and RBIE in INTCON
B. INTEDG2 in INTCON2 and RBPU in INTCON2
C. INT2IP in INTCON3 and RBIP in INTCON2
D. INT2IE in INTCON3 and RBIE in INTCON

36 A programmer wants to generate a time delay by polling the TMR0IF flag instead of using an interrupt. Which C code snippet correctly implements this blocking delay?

Programming Timer 0 in C Medium
A. if(INTCONbits.TMR0IF) { INTCONbits.TMR0IF = 0; }
B. while(INTCONbits.GIE);
C. while(!INTCONbits.TMR0IF); INTCONbits.TMR0IF = 0;
D. while(1) { if (TMR0IF == 1) break; } TMR0IF = 0;

37 What are the memory addresses for the high-priority and low-priority interrupt vectors in a standard PIC18 microcontroller?

PIC18 interrupts Medium
A. 0x0004 (reset) and 0x0008 (general)
B. 0x0008 (high) and 0x0018 (low)
C. 0x0018 (high) and 0x0008 (low)
D. 0x0000 (reset) and 0x0004 (interrupt)

38 In a C program for a PIC18, how would you read the entire 16-bit value of a running Timer1 into an unsigned int variable named timer_value in a single, atomic operation provided by the XC8 compiler?

Programming Timer 1 in C Medium
A. T1CONbits.TMR1ON = 0; timer_value = TMR1; T1CONbits.TMR1ON = 1;
B. timer_value = TMR1L; timer_value |= (TMR1H << 8);
C. timer_value = TMR1H; timer_value = (timer_value << 8) | TMR1L;
D. timer_value = TMR1;

39 An application uses a Timer1 interrupt every 10ms to increment a counter. The main loop must perform an action every 1 second. What is the most robust and efficient way to implement this logic?

Programming Timer Interrupt Medium
A. Inside the ISR, if the counter reaches 100, set a global flag and reset the counter. The main loop polls this flag.
B. In the main loop, create a 1-second software delay and then check the value of the counter.
C. Inside the ISR, if the counter reaches 100, perform the 1-second action directly inside the ISR.
D. In the main loop, continuously check if counter >= 100. If so, perform the action and reset the counter.

40 You have configured the INT0 external interrupt for a rising edge. In the ISR, you clear the INT0IF flag. However, the interrupt triggers again immediately upon exit. Assuming no switch bounce, what is a likely cause?

Programming External Hardware Interrupt Medium
A. The priority bit INT0IP was set incorrectly.
B. The INT0IE bit was accidentally cleared in the ISR.
C. The signal on the INT0 pin remained high after the initial rising edge.
D. The GIE bit was not cleared inside the ISR.

41 A PIC18F running at MHz is configured with Timer0 in 16-bit mode with a 1:64 prescaler. To generate a precise interrupt every 500 ms, an ISR reloads Timer0 with a value TMR0_PRELOAD and uses a software counter that triggers an event after N interrupts. Which combination of TMR0_PRELOAD and N achieves this target?

Programming Timer 0 in C Hard
A. TMR0_PRELOAD = 64286, N = 25
B. TMR0_PRELOAD = 62411, N = 10
C. All of the above are valid combinations.
D. TMR0_PRELOAD = 59286, N = 5

42 Consider the following PIC18 C code snippet intended to configure Timer0 in 16-bit mode.
c
T0CON = 0b00000011; // 16-bit, FOSC/4, Prescaler 1:16
TMR0H = 0x0B;
TMR0L = 0xDC;
T0CONbits.TMR0ON = 1;

According to the PIC18 datasheet, when writing to TMR0H, the value is held in a temporary register until TMR0L is written. What is the potential issue if a high-priority interrupt occurs between the TMR0H write and the TMR0L write, and the ISR also modifies Timer0?

Programming Timer 0 in C Hard
A. The TMR0H write will be lost, and Timer0 will start counting from 0x00DC.
B. The temporary holding register for TMR0H is overwritten by the ISR, leading to an incorrect starting count when the main code resumes and writes to TMR0L.
C. A write to TMR0L in the ISR will incorrectly load the TMR0H with the value from the main code's temporary register, corrupting the ISR's intended timer value.
D. There is no issue, as the hardware protocol for 16-bit timer writes is inherently atomic and protected from interrupts.

43 A developer configures Timer0 as an 8-bit external event counter using the T0CKI pin. They set T0CON = 0b01101000;. However, they observe that the timer is not incrementing on events at T0CKI, but is instead incrementing at a rate related to the system clock. What is the most likely cause of this misbehavior?

Programming Timer 0 in C Hard
A. The TRIS direction for the T0CKI pin was not set to input.
B. The PSA (Prescaler Assignment) bit is set to 1, which assigns the prescaler to the Watchdog Timer, causing Timer0 to use the raw FOSC/4 clock.
C. The TMR0ON bit was not set, so the timer is disabled.
D. The T0CS bit is set incorrectly; it should be 0 for counter mode.

44 Given T0CON = 0b10000101;, and a PIC18 running at MHz. The timer is running. At a certain point, a read of the 16-bit timer value is performed using this sequence: low_byte = TMR0L; high_byte = TMR0H;. What is a potential critical flaw in this reading method?

Programming Timer 0 in C Hard
A. Reading TMR0H first is required to latch the low byte.
B. If TMR0L overflows to 0x00 after it is read but before TMR0H is read, the captured high_byte will be one higher than it should have been relative to the low_byte, resulting in an incorrect time value.
C. This method is correct and has no flaws.
D. 16-bit reads must be disabled by setting RD16 in T1CON before reading TMR0.

45 A PIC18 is configured with Timer1 in 16-bit Asynchronous Counter mode to count external events while the CPU is in SLEEP mode. The configuration is T1CON = 0b00000111;. The oscillator for Timer1 is a low-power 32.768 kHz watch crystal connected to T1OSI and T1OSO. What happens to the TMR1 register value if the main CPU is put to sleep using the SLEEP() instruction?

Programming Timer 1 in C Hard
A. Timer1 continues to count events from its independent oscillator, allowing the PIC to wake up on a Timer1 overflow interrupt.
B. Timer1 resets to 0x0000 upon entering sleep mode and resumes counting on wakeup.
C. Timer1's behavior is undefined in sleep mode and depends on the specific PIC18 derivative.
D. Timer1 stops counting because the main oscillator is turned off during sleep.

46 A scenario where Timer1 is used with the CCP module in Capture mode to measure the period of an incoming signal. Configuration: Timer1 is free-running, clocked by , with MHz. An engineer observes that for a high-frequency input signal, the captured values (CCPR1H:CCPR1L) occasionally seem to give a very large period measurement instead of a small one. What is the most plausible cause?

Programming Timer 1 in C Hard
A. The period of the input signal is slightly longer than the overflow period of Timer1, causing a Timer1 overflow (TMR1IF) to occur between two consecutive captures.
B. The input signal frequency is higher than the Nyquist rate, causing aliasing.
C. The prescaler for Timer1 is set too high, reducing the resolution and causing measurement errors.
D. An interrupt for the CCP capture event is not being serviced fast enough, causing the CCP1IF flag to be missed before the next capture event occurs.

47 Timer1 is configured with T1CON = 0b10010001; and MHz. What is the maximum resolution (i.e., the time duration of a single timer tick) of Timer1 in this configuration, and what is its total overflow period if it starts from 0x0000?

Programming Timer 1 in C Hard
A. Resolution: 4.0 µs, Period: 262.144 ms
B. Resolution: 0.5 µs, Period: 32.768 ms
C. Resolution: 1.0 µs, Period: 65.536 ms
D. Resolution: 0.25 µs, Period: 16.384 ms

48 A developer is using Timer1's Gate Control feature (T1GCON) to measure the width of a high pulse on the T1G pin. The configuration is: T1GCON = 0b10010001;, Timer1 is on and clocked internally. What does this specific T1GCON configuration imply about how the measurement is performed?

Programming Timer 1 in C Hard
A. Timer1 is toggled on/off by each successive falling edge on the T1G pin.
B. Timer1 runs only when the T1G pin is high; the gate event is level-sensitive.
C. Timer1 starts counting on a rising edge detected by the CCP2 module and stops counting on a falling edge.
D. A single rising edge on T1G starts Timer1, and it runs until manually stopped.

49 A PIC18 has interrupt priority enabled (IPEN = 1). A low-priority Timer0 interrupt (TMR0IP = 0) and a high-priority external interrupt (INT0IP = 1) have their flags set at the exact same time. The high-priority ISR for INT0 takes 20 instruction cycles. Global interrupts are enabled. What is the execution flow?

PIC18 interrupts Hard
A. Only the high-priority ISR executes; the low-priority interrupt flag is ignored until the next polling cycle.
B. Both ISRs execute sequentially, with the high-priority ISR running first, followed immediately by the low-priority ISR.
C. The low-priority ISR starts first, is preempted by the high-priority ISR, and then resumes.
D. The processor vectors to the high-priority interrupt vector (0x0008), executes the high-priority ISR, returns, and then immediately vectors to the low-priority interrupt vector (0x0018) to execute the low-priority ISR.

50 In a PIC18 system with interrupt priorities enabled (IPEN=1), an engineer writes a low-priority ISR. To ensure atomicity of a certain operation within this ISR, they decide to temporarily disable high-priority interrupts. What is the correct and safest way to achieve this inside the low-priority ISR?

PIC18 interrupts Hard
A. Use a software flag (semaphore) that the high-priority ISR must check before proceeding.
B. GIEH = 0; at the start of the critical section and GIEH = 1; at the end.
C. This is not possible; a low-priority ISR can never block a high-priority interrupt.
D. INTCONbits.GIE = 0; at the start and INTCONbits.GIE = 1; at the end.

51 A developer is debugging a PIC18 system. After a brown-out event, they find the device is stuck in a loop. Upon examining the RCON register, they find its value is 0b00001001. What can be concluded about the sequence of reset events?

PIC18 interrupts Hard
A. A Watchdog Timer timed out, followed by a software reset.
B. A Brown-out Reset occurred, followed by a Watchdog Timer time-out.
C. A Brown-out Reset occurred, but the NOT_POR bit indicates a MCLR reset happened before that.
D. A Power-on Reset occurred, followed by a Brown-out Reset.

52 A system has two active interrupts: a high-priority ADC interrupt (ADIP=1) and a low-priority UART receive interrupt (RCIP=0), with IPEN=1. The UART ISR is currently executing a critical section where it has temporarily disabled high-priority interrupts by clearing GIEH. During this critical section, an ADC conversion completes, setting the ADIF flag. What happens immediately after GIEH is set back to 1 at the end of the critical section?

PIC18 interrupts Hard
A. The high-priority ADC ISR immediately preempts the low-priority UART ISR at the instruction right after GIEH is set.
B. The low-priority UART ISR completes its execution fully, and then the high-priority ADC ISR is serviced.
C. The processor completes the current instruction in the UART ISR and then vectors to the ADC ISR.
D. The ADIF flag is ignored because it was set while GIEH was 0.

53 In a PIC18 Timer0 ISR, the following C code is used to reload the timer. The system clock is MHz, Timer0 is in 8-bit mode with a 1:256 prescaler.
c
void interrupt tc_int(void) {
if (TMR0IF) {
// ... toggle LED ...
TMR0L = 100;
TMR0IF = 0;
}
}

What is the primary issue with this ISR code that will lead to significant cumulative timing error (jitter and drift)?

Programming Timer Interrupt Hard
A. The TMR0IF flag is cleared after reloading the timer, which is the wrong order.
B. TMR0L = 100; is the wrong value for a 10 ms delay.
C. An 8-bit timer cannot produce a 10 ms delay with the given clock and prescaler.
D. The time taken for the ISR to execute before TMR0L is reloaded is not accounted for, causing the actual period to be longer than intended.

54 To create a software PWM signal, a developer uses a single Timer1 overflow interrupt. To achieve a 25% duty cycle on a 20ms period, the pin must be high for 5ms and low for 15ms. What is the most efficient and accurate interrupt-driven method?

Programming Timer Interrupt Hard
A. In the Timer1 ISR, alternate the Timer1 reload value to create a 5ms interval, then a 15ms interval.
B. Use a second timer (e.g., Timer0) to fire a one-shot interrupt in 5ms to set the pin low.
C. Inside the Timer1 ISR, use a software delay loop for 5ms before setting the pin low.
D. In the main loop, continuously poll the TMR1 register and set the pin low when it reaches the 5ms count value.

55 A developer sets up Timer0 and Timer1 interrupts, with Timer0 as high priority and Timer1 as low priority (IPEN=1). Timer0 ISR takes 15 µs and interrupts every 25 µs. Timer1 ISR takes 40 µs and interrupts every 100 µs. At time t=0, both events occur. What percentage of CPU time is spent executing the main (non-interrupt) code? Assume no other tasks.

Programming Timer Interrupt Hard
A. 40%
B. 10%
C. 60%
D. 0%

56 An external interrupt INT1 is configured as edge-triggered. The ISR for INT1 takes 50 µs to execute. The external signal connected to the INT1 pin is a square wave with a period of 40 µs (25 kHz frequency). What will be the observed behavior of the system?

Programming External Hardware Interrupt Hard
A. The first interrupt will be serviced, but subsequent interrupts occurring during the ISR execution will be missed entirely.
B. The ISR will execute for every edge of the input signal, and the main program will run very slowly.
C. The first interrupt is serviced. Any subsequent valid edges that occur while the ISR is running will set the INT1IF flag again, causing the ISR to be re-entered immediately after it finishes.
D. The system will crash due to a stack overflow.

57 A project uses Interrupt-on-Change for port B (RBIE). Pin RB4 is for a button input, and RB5 is an LED output controlled by writing to LATB in the main loop. The ISR is intended only for RB4. The ISR code is:
c
void interrupt low_priority isr(void) {
if (RBIF) {
if (PORTBbits.RB4 == 0) { / handle button / }
RBIF = 0; // Clear interrupt flag
}
}

Why might this ISR be triggered unexpectedly?

Programming External Hardware Interrupt Hard
A. The code does not handle contact bounce from the button.
B. The RBIF flag should be cleared before checking the pin state.
C. The ISR must read from the PORTB register to clear the mismatch condition before clearing the RBIF flag.
D. A write to LATB in the main loop to control RB5 can cause RBIF to be set.

58 The INT0 external interrupt is configured with INTCONbits.INT0E = 1;, INTCONbits.INT0IF = 0;, and INTCON2bits.INTEDG0 = 0; (falling edge). The main program enters SLEEP mode. A single, clean 100 ns negative pulse occurs on the RB0/INT0 pin. The PIC's instruction cycle time is 250 ns ( MHz). What is the expected outcome?

Programming External Hardware Interrupt Hard
A. The device wakes up, but the INT0IF flag is not set, so the ISR is not executed.
B. The pulse is too short to be detected by the interrupt logic, and the device remains in sleep.
C. The device's behavior is unpredictable, as the pulse width is shorter than one instruction cycle.
D. The device wakes up from sleep and immediately executes the INT0 ISR.

59 In a PIC18 system using high-priority interrupts, what is the primary purpose of the RETFIE FAST instruction compared to the standard RETFIE?

PIC18 interrupts Hard
A. It restores the WREG, STATUS, and BSR registers from shadow registers instead of the stack, but does not re-enable global interrupts.
B. It restores key working registers (WREG, STATUS, BSR) from dedicated shadow registers and re-enables global high-priority interrupts (GIEH) in a single, atomic instruction.
C. It executes in fewer clock cycles than RETFIE.
D. It automatically clears the interrupt flag of the serviced interrupt.

60 A PIC18's INT0 interrupt is configured for a falling-edge trigger from a 1 kHz square wave. The INT0 ISR increments a 16-bit volatile integer count. The main loop toggles an LED and resets count to 0 when count >= 1000. The LED toggles approximately every 2 seconds instead of the expected 1 second. What is the most probable cause?

Programming External Hardware Interrupt Hard
A. Compiler optimization is removing the volatile qualifier.
B. The INT0 interrupt is triggering on both rising and falling edges.
C. The ISR is taking too long, causing it to miss every other interrupt.
D. The main loop's check and reset of count is not an atomic operation. An interrupt can occur after count is read but before it is reset, causing increments to be lost.