Unit 3 - Practice Quiz

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

1 Which register is primarily used to configure a GPIO pin on a PIC microcontroller as either an input or an output?

PIC GPIO Registers Easy
A. STATUS Register
B. W Register
C. PORT Register
D. TRIS Register

2 To configure pin RB3 of a PIC microcontroller as an output, what value should be written to the corresponding bit in the TRISB register?

Configuring PIC GPIO as input/output Easy
A. The register should be cleared
B. 1
C. 0
D. It depends on the voltage

3 What is the main purpose of placing a resistor in series with an LED when connecting it to a PIC microcontroller pin?

LED interfacing with PIC Easy
A. To limit the current flowing through the LED
B. To change the color of the LED
C. To store electrical charge
D. To increase the brightness of the LED

4 When interfacing a simple push-button switch to a PIC input pin, what component is used to ensure a defined logic level (HIGH or LOW) when the switch is open?

Switch interfacing with PIC Easy
A. A pull-up or pull-down resistor
B. A Zener diode
C. A capacitor
D. An inductor

5 Which register is used to read the current logic state (HIGH or LOW) of the physical pins of a GPIO port?

PIC GPIO Registers Easy
A. TRIS Register
B. PCLATH Register
C. PORT Register
D. OPTION_REG Register

6 To configure pin RA5 of a PIC microcontroller as an input, what value should be written to the corresponding bit in the TRISA register?

Configuring PIC GPIO as input/output Easy
A. TRISA5
B. RA5
C. 0
D. 1

7 In C programming for PIC, which bitwise operator is used to set a specific bit of a register to 1 without affecting the other bits?

I/O bit manipulation programming Easy
A. XOR (^)
B. AND (&)
C. NOT (~)
D. OR (|)

8 To implement a simple 4-bit binary up-counter on pins RB0-RB3, what is the most common operation performed on the PORTB register inside the main loop?

Programming PIC for multi-bit binary counter Easy
A. Inverting all its bits (e.g., PORTB = ~PORTB)
B. Decrementing its value (e.g., PORTB--)
C. Incrementing its value (e.g., PORTB++)
D. Setting it to zero (e.g., PORTB = 0)

9 If an LED is connected between a PIC I/O pin and Ground (sourcing current), what logic level must the pin be set to in order to turn the LED ON?

LED interfacing with PIC Easy
A. Logic HIGH (1)
B. Logic LOW (0)
C. It will always be on
D. High-impedance

10 A switch is connected to an input pin with a pull-up resistor. The other end of the switch is connected to Ground. What logic level will the PIC read when the switch is pressed (closed)?

Switch interfacing with PIC Easy
A. Logic LOW (0)
B. Logic HIGH (1)
C. The pin will be floating
D. A middle voltage level

11 Which C statement correctly clears bit 2 (the third bit from the right) of PORTB without changing any other bits?

I/O bit manipulation programming Easy
A. PORTB = PORTB | (1<<2);
B. PORTB = ~(1<<2);
C. PORTB = PORTB & (~(1<<2));
D. PORTB = PORTB ^ (1<<2);

12 If you want to configure all 8 pins of PORTB as outputs, what value should you load into the TRISB register?

Configuring PIC GPIO as input/output Easy
A. 0xF0
B. 0x00
C. 0x0F
D. 0xFF

13 Writing a value to the PORTB register has an immediate effect on which pins?

PIC GPIO Registers Easy
A. It has no effect on the physical pins
B. Only the pins of PORTB that are configured as outputs
C. Only the pins of PORTB that are configured as inputs
D. All pins of PORTB, regardless of configuration

14 If an LED is connected between a PIC I/O pin and VDD (sinking current), what logic level must the pin be set to in order to turn the LED ON?

LED interfacing with PIC Easy
A. High-impedance
B. Logic LOW (0)
C. Logic HIGH (1)
D. It will always be off

15 What is the function of the bitwise XOR (^) operator when used on an I/O register bit?

I/O bit manipulation programming Easy
A. It always sets the bit to 1
B. It toggles the bit (flips it from 0 to 1 or 1 to 0)
C. It performs a logical AND operation
D. It always clears the bit to 0

16 If an 8-bit binary counter is implemented on PORTB, what is the maximum decimal value it can display before it overflows (resets to 0)?

Programming PIC for multi-bit binary counter Easy
A. 128
B. 127
C. 256
D. 255

17 To read the state of a switch connected to pin RC4, which specific register and bit would you need to check in your code?

Switch interfacing with PIC Easy
A. Bit C of the PORT4 register
B. Bit 4 of the TRISC register
C. Bit 4 of the PORTC register
D. Bit C of the TRIS4 register

18 The acronym TRIS, used for the data direction register in PIC microcontrollers, stands for what?

PIC GPIO Registers Easy
A. True Register Input State
B. Timer Register Input Source
C. Transmit-Receive Input Select
D. Tri-State

19 Consider the instruction TRISB = 0b11110000;. How are the pins of PORTB configured?

Configuring PIC GPIO as input/output Easy
A. All pins are configured as inputs.
B. The upper four bits (RB7-RB4) are inputs, the lower four (RB3-RB0) are outputs.
C. The upper four bits (RB7-RB4) are outputs, the lower four (RB3-RB0) are inputs.
D. All pins are configured as outputs.

20 To start a binary counter from the beginning, what initial value should be written to the PORT register connected to the LEDs?

Programming PIC for multi-bit binary counter Easy
A. -1
B. 255
C. 1
D. 0

21 In a PIC microcontroller, after a Power-On Reset (POR), the TRISB register is typically initialized to 0xFF. If you then immediately execute the instruction PORTB = 0x55;, what will be the state of the PORTB data latch and the physical pins?

PIC GPIO Registers Medium
A. The pins will be configured as inputs, but the PORTB data latch will hold the value 0x55.
B. The pins will output the pattern 01010101.
C. The pins will be in a high-impedance state, and their voltage level will be indeterminate.
D. The instruction will be ignored because the port is configured as input.

22 Consider the following C code snippet for a PIC18F microcontroller: TRISB = 0b11110000;. Which of the following statements accurately describes the configuration of PORTB?

Configuring PIC GPIO as input/output Medium
A. All pins of PORTB are configured as outputs.
B. The lower nibble (RB0-RB3) is configured as output and the upper nibble (RB4-RB7) is configured as input.
C. The upper nibble (RB4-RB7) is configured as output and the lower nibble (RB0-RB3) is configured as input.
D. All pins of PORTB are configured as inputs.

23 Which of the following C expressions is the most efficient and standard way to toggle the state of pin RC2 (bit 2 of PORTC) without affecting any other pins on PORTC, while avoiding Read-Modify-Write issues?

I/O bit manipulation programming Medium
A. PORTC |= (1 << 2);
B. LATC ^= (1 << 2);
C. PORTC &= ~(1 << 2);
D. PORTC = ~PORTC;

24 You need to interface an LED with a forward voltage of 2.0V and a desired forward current of 15mA to a PIC GPIO pin. The PIC operates at a VDD of 5.0V and the pin's output high voltage () is guaranteed to be at least 4.2V. What is the minimum standard E24 series resistor value you should use?

LED interfacing with PIC Medium
A. 330
B. 150
C. 220
D. 120

25 A 4-bit binary counter is implemented on pins RB0-RB3 of a PIC microcontroller. The counter increments every second. If the current value displayed by the LEDs connected to these pins is 1110 (binary 14), what will be the value displayed after 3 seconds?

Programming PIC for multi-bit binary counter Medium
A. 1111
B. 0000
C. 0001
D. 0010

26 A push-button switch is connected to pin RA0 of a PIC microcontroller. A 10k pull-up resistor is connected between RA0 and VDD (5V). When the switch is not pressed, it is an open circuit. When pressed, it connects the pin to Ground. What logic level will the microcontroller read at RA0 when the switch is not pressed, and what level when it is pressed?

Switch interfacing with PIC Medium
A. Not pressed: Logic 0; Pressed: Logic 1
B. Not pressed: High-impedance; Pressed: Logic 0
C. Not pressed: Logic 1; Pressed: High-impedance
D. Not pressed: Logic 1; Pressed: Logic 0

27 When performing a read-modify-write operation (e.g., PORTBbits.RB0 = 1;) on an output pin in a PIC18F microcontroller, why is it generally recommended to write to the LATB register instead of the PORTB register?

PIC GPIO Registers Medium
A. LATB consumes less power than PORTB.
B. Writing to PORTB can cause a read-modify-write (RMW) issue if a pin's voltage has not yet reached its intended logic level.
C. LATB is faster to write to than PORTB.
D. PORTB is a read-only register for output pins.

28 You want to use pin RA0 on a PIC16F877A as a digital input. This pin is also shared with the analog function AN0. What is the correct sequence of register configuration to ensure it functions purely as a digital input?

Configuring PIC GPIO as input/output Medium
A. PORTA &= ~(1 << 0); followed by TRISA |= (1 << 0);
B. ADCON1 = 0x06; followed by TRISA |= (1 << 0);
C. TRISA &= ~(1 << 0); followed by ADCON1 = 0x06;
D. TRISA |= (1 << 0); followed by ADCON1 = 0x07;

29 A byte variable port_val representing a PORT register is initialized to 0b10101100. The following sequence of C operations is performed on it:
1. port_val &= ~(1 << 2);
2. port_val |= 0x03;
3. port_val ^= (1 << 7);
What is the final hexadecimal value of port_val?

I/O bit manipulation programming Medium
A. 0x88
B. 0x28
C. 0xAB
D. 0x2B

30 An LED is connected between a PIC's GPIO pin (RD0) and VDD (5V), with a current-limiting resistor in series. This is a "current sinking" configuration. To turn the LED ON, what value must be written to the LATD0 bit, and why?

LED interfacing with PIC Medium
A. Write 0 to LATD0 to create a path to ground, allowing current to flow from VDD through the LED.
B. Write 1 to LATD0 to source current from the pin to the LED.
C. Write 1 to LATD0 to match the VDD potential, preventing current flow.
D. Write 0 to LATD0 to put the pin in a high-impedance state.

31 An 8-bit binary counter is implemented on PORTB. The counter is incremented inside a timer interrupt service routine that executes exactly every 10 milliseconds. What is the total time it will take for the counter to cycle from 0x00 through 0xFF and back to 0x00?

Programming PIC for multi-bit binary counter Medium
A. 25.5 seconds
B. 2.55 seconds
C. 2.56 seconds
D. 25.6 seconds

32 You are implementing a software debouncing routine for a switch. A common technique involves detecting a pin state change, waiting for a short delay (e.g., 20ms), and then checking the pin state again. Why is this second check necessary?

Switch interfacing with PIC Medium
A. To filter out the brief, spurious signal transitions (bouncing) that occur when a mechanical switch is pressed or released.
B. To ensure the TRIS register is correctly configured before reading the pin.
C. To give the CPU time to complete other tasks before acting on the switch press.
D. To allow the pull-up resistor to charge the line capacitance.

33 On many modern PIC microcontrollers, what is the primary purpose of the WPUx (Weak Pull-Up) register?

PIC GPIO Registers Medium
A. To configure the slew rate of an output pin to reduce EMI.
B. To set the initial power-up state of the PORTx register.
C. To select between analog and digital functionality for a pin.
D. To enable or disable internal weak pull-up resistors on a per-pin basis for inputs.

34 You have configured the upper nibble of PORTD (RD4-RD7) as inputs and the lower nibble (RD0-RD3) as outputs. Which C code snippet correctly reads the state of the input pins and stores their 4-bit value in a variable input_val?

Configuring PIC GPIO as input/output Medium
A. input_val = PORTD << 4;
B. input_val = PORTD | 0xF0;
C. input_val = PORTD & 0x0F;
D. input_val = (PORTD & 0xF0) >> 4;

35 You want to set PORTC bits 4 and 5 to 1, and clear bits 0 and 1, without affecting any other bits (2, 3, 6, 7). Which single line of C code achieves this? Assume the initial state of PORTC is unknown.

I/O bit manipulation programming Medium
A. LATC = (LATC | 0x30) & (~0x03);
B. LATC = (LATC & ~0x03) | 0x30;
C. LATC = (LATC & 0xFC) | 0x30;
D. LATC = (LATC | 0x30) & 0xFC;

36 To drive a 7-segment display using fewer I/O pins, a technique called multiplexing is often used. This involves rapidly switching between digits while displaying the correct segments for each. What principle allows the human eye to perceive this as a steady, complete number?

LED interfacing with PIC Medium
A. Quantum Tunneling
B. Persistence of Vision (POV)
C. The Photoelectric Effect
D. The Doppler Effect

37 Consider the following C code intended to implement a simple 8-bit counter on PORTB.
c
void main() {
TRISB = 0x00;
LATB = 0;
while(1) {
PORTB = PORTB + 1;
_delay_ms(100);
}
}

What potential issue exists in this code, particularly if PORTB pins were driving capacitive loads?

Programming PIC for multi-bit binary counter Medium
A. The while(1) loop will cause the microcontroller to hang.
B. LATB should be used instead of TRISB to initialize the output value.
C. It uses PORTB for a read-modify-write operation, which can lead to errors.
D. The delay is too short for the counter to be visible.

38 A switch is connected to an external interrupt pin (e.g., INT0) to detect a button press. If no debouncing (either hardware or software) is implemented, what is the most likely consequence when the button is pressed once?

Switch interfacing with PIC Medium
A. The microcontroller will reset due to a power surge from the switch.
B. The Interrupt Service Routine (ISR) will be executed multiple times in quick succession.
C. The ISR will execute only once, but with a significant delay.
D. The interrupt will not trigger at all due to the slow rise time.

39 A PIC's PORTB pin, RB0, is configured as an output (TRISB0 = 0) and is driving a high signal (LATB0 = 1). What happens to the physical state of the pin if the program then executes TRISBbits.TRISB0 = 1; without changing LATB0?

Configuring PIC GPIO as input/output Medium
A. The pin enters a high-impedance (Hi-Z) state, and its voltage will be determined by the external circuit.
B. The pin remains in a high state (VDD), but can now be overdriven by an external source.
C. The value in LATB0 is automatically cleared to 0.
D. The pin immediately goes to a low state (0V).

40 In a PIC C program, you see the line: LATA = (sensor_val > 100) ? 0xFF : 0x00;. What does this code accomplish?

I/O bit manipulation programming Medium
A. It creates a PWM signal on PORTA with a duty cycle determined by sensor_val.
B. It turns on all outputs on PORTA if sensor_val is greater than 100, and turns them all off otherwise.
C. It sets bit 0 of PORTA if sensor_val is greater than 100.
D. It reads the value from PORTA and compares it to 100.

41 A PIC microcontroller toggles an LED on RB7 using PORTB ^= 0x80;. Pin RB0 is also configured as an output and drives a highly capacitive load, causing its voltage to rise slowly. The initial state is LATB = 0x00. The code PORTB |= 0x01; is executed to turn on RB0. Immediately after, PORTB ^= 0x80; is executed to toggle RB7. Due to the slow rise time, the voltage at pin RB0 is still logic low when the toggle instruction reads the port. What will be the final state of the LATB register?

PIC GPIO Registers Hard
A. 0x01
B. 0x81
C. 0x00
D. 0x80

42 A pin RA0 on a PIC16F887 is configured as a digital output by setting TRISAbits.TRISA0 = 0;. An LED is connected to this pin. The following code is executed: LATA = 0x01;. However, the LED does not light up, and the voltage at RA0 measures near 0V. Which register is the most likely cause of this malfunction, assuming no hardware faults?

PIC GPIO Registers Hard
A. ANSEL
B. PORTA
C. CMCON
D. WDTCON

43 Pin RC0 of a PIC is configured as a digital input (TRISCbits.TRISC0 = 1;). It is connected to a 5V source via a 1kΩ resistor. After the system stabilizes, the code reconfigures the pin to a digital output (TRISCbits.TRISC0 = 0;) without first writing to LATCbits.LATC0. What is the immediate voltage level at the RC0 pin after it is switched to an output?

Configuring PIC GPIO as input/output Hard
A. 5V (logic high)
B. 0V (logic low)
C. Undefined, depends on previous LATC state
D. High-impedance (Hi-Z)

44 You need to create a C preprocessor macro SET_NIBBLE(reg, val) that writes a 4-bit value val to the upper nibble (bits 7-4) of an I/O register reg without altering the lower nibble (bits 3-0). Which of the following implementations is both correct and avoids potential side-effects of multiple evaluations of reg?

I/O bit manipulation programming Hard
A. #define SET_NIBBLE(reg, val) reg = (reg | 0xF0) & ((val << 4) | 0x0F)
B. #define SET_NIBBLE(reg, val) reg = (reg & 0x0F) | (val << 4)
C. #define SET_NIBBLE(reg, val) reg &= 0x0F; reg |= (val << 4)
D. #define SET_NIBBLE(reg, val) reg = (reg & 0xF0) | (val & 0x0F)

45 Consider a Charlieplexing setup with 3 LEDs (L1, L2, L3) connected among three PIC I/O pins (P1, P2, P3). L1 is between P1(Anode) and P2(Cathode). L2 is between P2(Anode) and P1(Cathode). L3 is between P1(Anode) and P3(Cathode). To light up only L3, what must be the configuration of the TRIS and LAT registers for these three pins?

LED interfacing with PIC Hard
A. TRIS={P1=1, P2=0, P3=0}; LAT={P1=X, P2=1, P3=0}
B. TRIS={P1=0, P2=1, P3=0}; LAT={P1=1, P2=X, P3=1}
C. TRIS={P1=0, P2=1, P3=0}; LAT={P1=1, P2=X, P3=0}
D. TRIS={P1=0, P2=0, P3=1}; LAT={P1=1, P2=0, P3=X}

46 A 4-bit binary up-counter is to be implemented on pins RD3:RD0. However, to prevent simultaneous switching transients, the output must be a Gray code representation of the count. If the current binary count is 0110 (6), what single C expression will correctly calculate the next Gray code value to be written to LATD after the count increments to 0111 (7)?

Programming PIC for multi-bit binary counter Hard
A. gray_code = count ^ (count >> 1); where count is 7
B. gray_code = ~count; where count is 7
C. gray_code = count & (count - 1); where count is 7
D. gray_code = (count << 1) | (count >> 3); where count is 7

47 A switch is monitored on pin RB0. A software debouncing routine is implemented within a 1ms timer ISR. The routine uses a static 8-bit counter, debounce_count. If RB0 is low, the counter increments; if high, it resets. The switch is considered "pressed" only when debounce_count reaches 50. Ignoring counter overflow, what is the minimum duration the switch must be held stable in the low state for a press to be registered?

Switch interfacing with PIC Hard
A. 50 ms
B. 1 ms
C. 49 ms
D. 51 ms

48 On a PIC16F690, pins RA0 and RA1 are configured as digital outputs (TRISA<1:0> = 0b00). You observe that writing LATA = 0x03 fails to make RA1 high. The ANSEL register has been correctly cleared for these pins. What is the most probable cause related to another peripheral?

PIC GPIO Registers Hard
A. The Watchdog Timer (WDT) is enabled.
B. The SPI module is enabled, using RA1 as SDO.
C. The Comparator C1 module is enabled and its output is mapped to RA1.
D. The Timer1 oscillator is enabled, using RA0 and RA1.

49 You are driving eight high-efficiency LEDs, each requiring 15 mA, directly from the 8 pins of PORTB on a PIC18F45K22. The datasheet specifies a maximum current sourced by any I/O pin as 25 mA, and a maximum total current sourced by PORTB as 100 mA. What is the most likely outcome of this design?

Configuring PIC GPIO as input/output Hard
A. The design will work flawlessly as the per-pin limit of 25 mA is not exceeded.
B. The PIC microcontroller will be immediately damaged due to excessive current draw.
C. All LEDs will light up, but their brightness will be significantly lower than expected, and the PIC may overheat.
D. Only the first six LEDs will light up due to the port current limit.

50 An application uses an interrupt service routine (ISR) to toggle an LED on RC0 every 1ms. The main loop independently sets pin RC1 high to indicate a status. Which code implementation presents the highest risk of a race condition leading to incorrect I/O behavior?

I/O bit manipulation programming Hard
A. Main loop: LATCbits.LATC1=1; / ISR: LATCbits.LATC0 ^= 1;
B. Main loop: LATCbits.LATC1=1; / ISR: PORTCbits.RC0 ^= 1;
C. Main loop: PORTCbits.RC1=1; / ISR: PORTCbits.RC0 ^= 1;
D. Main loop: PORTCbits.RC1=1; / ISR: LATCbits.LATC0 ^= 1;

51 You are multiplexing a 4-digit, common-cathode 7-segment display. The segments (a-g) are connected to PORTD and the digit select lines (D1-D4) are connected to RA0-RA3. To display the number '2' on the 3rd digit (D3), what must be the state of PORTD and PORTA<3:0>? (Assume segment 'a' is bit 0, 'g' is bit 6, and the hex code for '2' is 0x5B).

LED interfacing with PIC Hard
A. PORTD = 0x5B; PORTA<3:0> = 0b1011;
B. PORTD = ~0x5B; PORTA<3:0> = 0b0100;
C. PORTD = 0x5B; PORTA<3:0> = 0b0100;
D. PORTD = ~0x5B; PORTA<3:0> = 0b1011;

52 The following C code is intended to implement a simple 8-bit binary counter on PORTB. What is the subtle error in this code that will lead to incorrect counting behavior, especially on older PICs or with noisy I/O?
c
TRISB = 0x00;
LATB = 0x00;
while(1) {
PORTB++;
delay_ms(100);
}

Programming PIC for multi-bit binary counter Hard
A. delay_ms(100) is too short for the port to stabilize.
B. The LATB register should be used instead of PORTB for the increment operation.
C. The counter will overflow from 255 to 1 instead of 0.
D. The TRISB register is cleared inside the loop, causing issues.

53 In a 4x4 keypad matrix, rows (R1-R4) are connected to RB0-RB3 and columns (C1-C4) to RB4-RB7. To detect if the key at R2 and C3 is pressed, which scan step is correct? (Assume rows are outputs, columns are inputs with pull-ups, and a '0' is driven to activate a row).

Switch interfacing with PIC Hard
A. Set TRISB=0b11110000. Write LATB so RB1=0. Read RB6. If low, key is pressed.
B. Set TRISB=0b11110000. Write LATB so RB2=0. Read RB5. If low, key is pressed.
C. Set TRISB=0b00001111. Write LATB so RB6=0. Read RB1. If low, key is pressed.
D. Set TRISB=0b11110000. Write LATB so RB1=1. Read RB6. If low, key is pressed.

54 Immediately after a Power-on Reset (POR) on most PIC microcontrollers, what is the default state of the TRIS registers, and what is the primary reason for this design choice?

PIC GPIO Registers Hard
A. The state is undefined and must be initialized by software immediately.
B. The lower nibble is set (1) and the upper nibble is cleared (0) for mixed-mode operation.
C. All bits are cleared (0), configuring pins as outputs to ensure a known starting state.
D. All bits are set (1), configuring pins as inputs to prevent contention with external circuitry.

55 A standard PIC I/O pin does not have a true open-drain output mode, but it can be simulated to achieve a wired-AND logic function with another device. How can this be accomplished using the TRIS and LAT registers with an external pull-up resistor?

Configuring PIC GPIO as input/output Hard
A. Set LAT bit to 1 and toggle TRIS bit: TRIS=0 for logic high, TRIS=1 for logic low.
B. Set LAT bit to 0 and toggle TRIS bit: TRIS=0 for logic high, TRIS=1 for logic low.
C. Set TRIS bit to 0 and toggle the LAT bit between 0 and 1.
D. Keep the LAT bit cleared (0) and toggle TRIS bit: TRIS=0 to drive low, TRIS=1 to release high.

56 In a time-critical application, you need to set RB7, clear RB6, and toggle RB5 of PORTB as close to a single atomic operation as possible. Given the initial LATB value is 0b11010101, which C instruction correctly performs this action?

I/O bit manipulation programming Hard
A. LATB = (LATB & 0x9F) | 0x80;
B. LATB = (LATB & 0xDF) ^ 0x80;
C. LATB = (LATB | 0x80) & (~0x40) ^ 0x20;
D. LATB ^= 0xE0;

57 You are controlling an LED's brightness using software PWM. The PWM period is 10ms. To make the LED appear at 25% of its maximum brightness to the human eye, what should the approximate ON-time (duty cycle) be?

LED interfacing with PIC Hard
A. 0.63 ms (6.3% duty cycle)
B. 2.50 ms (25% duty cycle)
C. 1.25 ms (12.5% duty cycle)
D. 5.00 ms (50% duty cycle)

58 A 16-bit counter is implemented using count_L for the low byte (on PORTB) and count_H for the high byte (on PORTC), both are unsigned char. Which C code snippet correctly and most compactly handles the carry-over when incrementing?

Programming PIC for multi-bit binary counter Hard
A. count_L++; if(count_L == 0) count_H++;
B. count_L++; count_H++;
C. count_L++; if(count_L > 255) count_H++;
D. count_L++; count_H += (count_L == 0);

59 A switch with a pull-up resistor is connected to pin RB4 on a PIC18F, which is configured for Interrupt-on-Change (IOC). You want to trigger an interrupt only when the switch is pressed (pin goes from high to low). How should the IOCBP (positive edge) and IOCBN (negative edge) registers be configured for bit 4?

Switch interfacing with PIC Hard
A. IOCBP4 = 1; IOCBN4 = 0;
B. IOCBP4 = 1; IOCBN4 = 1;
C. IOCBP4 = 0; IOCBN4 = 0;
D. IOCBP4 = 0; IOCBN4 = 1;

60 When defining a pointer to a GPIO register like PORTB in C (e.g., #define PORTB_p ((unsigned char*)0xF81)), why is it critically important to include the volatile keyword in the pointer's type declaration (e.g., volatile unsigned char*)?

I/O bit manipulation programming Hard
A. It tells the compiler that the pointer address can change during execution.
B. It ensures the register access is an atomic operation.
C. It automatically adds a small delay after accessing the register to allow pin voltages to stabilize.
D. It prevents the compiler from performing optimizations that might reorder access to the register or cache its value.