Unit3 - Subjective Questions

ECE227 • Practice Questions with Detailed Answers

1

Define the primary functions of the TRIS, PORT, and LAT registers in a PIC microcontroller's General Purpose Input/Output (GPIO) module.

2

Explain the step-by-step process of configuring a specific PIC GPIO pin, say RB0, as an output pin and then setting its logic state to HIGH.

3

Explain the step-by-step process of configuring a specific PIC GPIO pin, say RC7, as an input pin and then reading its current logic state.

4

Differentiate between the PORT register and the LAT register when used with PIC microcontroller output pins. Explain why using the LAT register for writing is generally preferred.

5

Describe the circuit diagram for interfacing a single LED with a PIC microcontroller. Explain the role of the current-limiting resistor.

6

Write a C program for a PIC microcontroller (assuming __delay_ms() is available) to blink an LED connected to RB0 with a 500 ms ON time and 500 ms OFF time.

7

Explain the concept of I/O bit manipulation programming in PIC microcontrollers. Provide C code examples for setting, clearing, and toggling a specific bit (e.g., RB5) without affecting other bits in the same port.

8

Describe the logic and steps involved in programming a PIC microcontroller to implement a 4-bit binary counter, where the count is displayed on four LEDs connected to a specific port (e.g., RD0-RD3).

9

Explain the importance of delays in the context of programming a multi-bit binary counter for visual observation. What would happen without proper delays?

10

Describe the two common methods for interfacing a push-button switch with a PIC microcontroller: pull-up configuration and pull-down configuration. Include simple circuit diagrams for each.

11

Explain the concept of switch debouncing and why it is necessary when interfacing mechanical switches with PIC microcontrollers.

12

Write a C program for a PIC microcontroller that detects a press of a push-button switch connected to RB0 (active-low with internal pull-up) and, upon detection, toggles the state of an LED connected to RD0.

13

Compare and contrast software debouncing and hardware debouncing techniques for mechanical switches, highlighting their advantages and disadvantages.

14

Explain how to configure an entire GPIO port (e.g., Port C) as an output port. Provide a C code snippet.

15

Explain how to configure an entire GPIO port (e.g., Port A) as an input port. Provide a C code snippet.

16

Write a C code snippet to toggle the state of pin RC2 on a PIC microcontroller without affecting other pins on Port C. Assume RC2 is configured as an output.

17

Write a C code snippet to set pin RA3 to a HIGH state and clear pin RA0 to a LOW state on a PIC microcontroller, without affecting other pins on Port A. Assume both are configured as outputs.

18

What are the common memory locations or registers associated with GPIO functionality in a typical PIC microcontroller?

19

Describe how to implement a simple LED chase (or running light) sequence using four LEDs connected to RB0 to RB3 of a PIC microcontroller. Provide the basic logic flow.

20

Discuss the impact of not properly initializing GPIO registers (TRIS, ANSEL, LAT) at the beginning of a PIC microcontroller program. What problems might arise?