Unit5 - Subjective Questions

ECE227 • Practice Questions with Detailed Answers

1

Describe the essential steps involved in configuring PIC18's Timer 0 module to generate a precise time delay using C programming. Focus on register settings and the flow of operations.

2

Provide a C code snippet to configure PIC18's Timer 0 in 16-bit mode, using a 1:8 prescaler, to generate a 10ms delay (assuming a 4MHz crystal). Calculate the initial TMR0H:TMR0L value required.

3

Compare and contrast the 8-bit and 16-bit operating modes of Timer 0 in PIC18 microcontrollers, highlighting their respective advantages and typical applications.

4

Explain how to configure PIC18's Timer 1 module to operate as an external event counter using C programming. What specific registers and bits are crucial for this configuration?

5

Write a C code snippet to initialize PIC18's Timer 1 to count external events on its input pin (T1CKI, assuming it's configured as RC0) without a prescaler. The count should be readable from TMR1H:TMR1L.

6

Differentiate between Timer 0 and Timer 1 modules in PIC18 microcontrollers based on their features, operating modes, and typical usage scenarios.

7

Define the concept of interrupts in the context of PIC18 microcontrollers. Why are interrupts essential in embedded system design, and what advantages do they offer over polling?

8

Explain the role of the Global Interrupt Enable (GIEH/GIE) and Peripheral Interrupt Enable (PEIE/GIEL) bits in controlling the interrupt system of PIC18 microcontrollers. How must they be configured for any interrupt to be processed?

9

Describe the general structure of an Interrupt Service Routine (ISR) in C for PIC18 microcontrollers. What critical actions must be performed within an ISR, and why?

10

Discuss the interrupt priority levels available in PIC18 microcontrollers. How are interrupts assigned to high or low priority, and what are the implications of using a priority scheme?

11

Outline the steps required to enable and program the Timer 0 overflow interrupt in a PIC18 microcontroller using C.

12

Write a C code snippet to initialize Timer 1 to generate an interrupt every 50ms, assuming a 4MHz crystal and a 1:4 prescaler. Include the setup for enabling the Timer 1 interrupt.

13

Design a C function to serve as an Interrupt Service Routine (ISR) for a Timer 0 overflow. The ISR should toggle an LED connected to PORTBbits.RB0 and reset the timer flag.

14

Describe a real-world application where a timer interrupt is crucial for the proper functioning of an embedded system. Explain how the timer interrupt contributes to the system's operation.

15

Detail the configuration steps for enabling and utilizing an external hardware interrupt (e.g., INT0) on a PIC18 microcontroller using C programming.

16

Provide a C code snippet for an ISR that responds to an external interrupt on the INT0 pin. The ISR should increment a global counter variable eventCount and then clear the interrupt flag. Assume INT0 is configured for falling edge detection.

17

Explain the difference between edge-triggered and level-triggered external interrupts in PIC18 microcontrollers. Which type is generally preferred for simple button presses, and why?

18

Compare and contrast polling and interrupt-driven I/O methods for interacting with external hardware in an embedded system. Discuss the advantages and disadvantages of each approach.

19

List and briefly explain the purpose of the key Special Function Registers (SFRs) involved in managing interrupts in PIC18 microcontrollers. (e.g., INTCON, PIEx, PIRx, IPRx).

20

Imagine an embedded system that needs to measure the duration of an external pulse and also perform a periodic task every 10ms. Outline how you would combine Timer 1 (as a counter) and Timer 0 (for periodic tasks) with appropriate interrupts to achieve this functionality.