Podcast
Questions and Answers
What must be set to choose Timer mode for Timer 0?
What must be set to choose Timer mode for Timer 0?
How many prescaler options are available for Timer 0?
How many prescaler options are available for Timer 0?
What clock source allows the timer to operate asynchronously to the microcontroller?
What clock source allows the timer to operate asynchronously to the microcontroller?
What does the TMR0IF bit in the INTCON register indicate?
What does the TMR0IF bit in the INTCON register indicate?
Signup and view all the answers
Which timer in the PIC16F877 is responsible for both timing and counting functions?
Which timer in the PIC16F877 is responsible for both timing and counting functions?
Signup and view all the answers
Which register is used to enable the prescaler for Timer 0?
Which register is used to enable the prescaler for Timer 0?
Signup and view all the answers
What is the main advantage of postscaling in timer operation?
What is the main advantage of postscaling in timer operation?
Signup and view all the answers
Which of the following describes the clock source used by Timer 0?
Which of the following describes the clock source used by Timer 0?
Signup and view all the answers
Which of the following is NOT a special function register associated with the timers in the PIC16F877?
Which of the following is NOT a special function register associated with the timers in the PIC16F877?
Signup and view all the answers
What is the function of the TMR0SE bit in the OPTION_REG register?
What is the function of the TMR0SE bit in the OPTION_REG register?
Signup and view all the answers
In which mode does the timer count according to the external signals?
In which mode does the timer count according to the external signals?
Signup and view all the answers
The feature that allows Timer 0 to count based on external signals is facilitated by which pin?
The feature that allows Timer 0 to count based on external signals is facilitated by which pin?
Signup and view all the answers
What is a limitation when using a standard timer to measure a KHz frequency signal?
What is a limitation when using a standard timer to measure a KHz frequency signal?
Signup and view all the answers
What is the operation mode of Timer 0 when no action is taken to stop it?
What is the operation mode of Timer 0 when no action is taken to stop it?
Signup and view all the answers
Which timer in the PIC16F877 is best suited for slow signal timing?
Which timer in the PIC16F877 is best suited for slow signal timing?
Signup and view all the answers
What term is used to describe the mechanism that allows for programmable counting cycles in timers?
What term is used to describe the mechanism that allows for programmable counting cycles in timers?
Signup and view all the answers
What is the starting point of Timer 0's counting functionality after the microcontroller powers on?
What is the starting point of Timer 0's counting functionality after the microcontroller powers on?
Signup and view all the answers
Which bit in the OPTION_REG register is responsible for selecting the clock source for Timer 0?
Which bit in the OPTION_REG register is responsible for selecting the clock source for Timer 0?
Signup and view all the answers
In Timer 0, what happens when the TMR0 register overflows?
In Timer 0, what happens when the TMR0 register overflows?
Signup and view all the answers
How can the speed of Timer 0 be reduced?
How can the speed of Timer 0 be reduced?
Signup and view all the answers
Which of the following statements about Timer 0 is NOT correct?
Which of the following statements about Timer 0 is NOT correct?
Signup and view all the answers
What is the maximum prescaler option available for Timer 0?
What is the maximum prescaler option available for Timer 0?
Signup and view all the answers
Which special function register is used specifically to control Timer 1 operations?
Which special function register is used specifically to control Timer 1 operations?
Signup and view all the answers
How is the edge transition determined for the clock source in Timer 0?
How is the edge transition determined for the clock source in Timer 0?
Signup and view all the answers
What is the primary purpose of the independent timers and counters in a microcontroller?
What is the primary purpose of the independent timers and counters in a microcontroller?
Signup and view all the answers
Why might an external oscillator be required for a timer operating in asynchronous mode?
Why might an external oscillator be required for a timer operating in asynchronous mode?
Signup and view all the answers
How does postscaling enhance the functionality of the timers?
How does postscaling enhance the functionality of the timers?
Signup and view all the answers
What feature of the PIC16F877 timers allows for modular programming and flexibility during operation?
What feature of the PIC16F877 timers allows for modular programming and flexibility during operation?
Signup and view all the answers
Which timers are specifically available in the PIC16F877 microcontroller?
Which timers are specifically available in the PIC16F877 microcontroller?
Signup and view all the answers
In what situation is it typically advisable to use an external KHz range oscillator for clocking the timer?
In what situation is it typically advisable to use an external KHz range oscillator for clocking the timer?
Signup and view all the answers
What type of signals does the timer/counter typically count in asynchronous mode?
What type of signals does the timer/counter typically count in asynchronous mode?
Signup and view all the answers
Which of the following best describes the timers' role in measuring periods of time effectively?
Which of the following best describes the timers' role in measuring periods of time effectively?
Signup and view all the answers
Study Notes
Design Problem
- We need a way to measure 1 second exactly, count pulses from an infrared sensor, send the counts to 7-segment displays, and perform these actions simultaneously.
Timers/Counters
- Timer/counters are important microcontroller features for timing and counting.
Timers/Counters - Clock Source
- External Crystal (Asynchronous Mode): The timer gets its clock from an external oscillator.
- Counter increments asynchronously to the microcontroller, and works best for timing slow signals.
- A separate KHz range oscillator can be used for timing KHz signals.
Timers and Prescaler
- Postscaling allows counting multiple counter loops before setting the flag.
- The flag indicates counter completion.
- Postscaling allows longer time measurement using the same counter.
The PIC16F877 Timers
- PIC16F877 has three timers/counters (Timer0, Timer1, Timer2).
PIC16F877 Timers
- The three timers reside in the SFR (Special Function Register) area
- Timer0: Address 0x01
- Timer1: Addresses 0x0E and 0x0F
- Timer2: Address 0x11
- We can read and write to these locations to access the current count value and set the starting count value.
Timer-related Special Function Registers
- INTCON (Interrupt Control Register) controls the timer's behavior.
- OPTION_REG (Options Register) configures timer properties.
- T1CON (Timer 1 Control Register) configures Timer 1 specifically.
- T2CON (Timer 2 Control Register) configures Timer 2 specifically.
INTCON
- The INTCON (Interrupt Control Register) is used to configure Timer 0's interrupt flags, enabling or disabling the timer's behavior.
Timer 0 Block Diagram
- The T0CKI pin can be used for external clock input.
- In timer mode, it increments on every instruction clock pulse unless a prescaler is used.
Timer 0 Features
- 8-bit timer/counter.
- Readable and writeable via the TMR0 register in SFR.
- 3-bit software programmable prescaler.
- Internal or external clock selection.
- Interrupt on overflow.
- Programmable external clock edge selection (rising or falling).
Timer 0 Operation
- The OPTION Register controls Timer 0's operation.
- Timer 0 is a free-running counter, starting immediately upon powering on.
Steps to Configure Timer 0
- Select Timer mode using the T0CS bit in the OPTION_REG register (0=timer, 1=counter).
- Configure the Prescaler Assignment and Prescaler Rate Select bits of the OPTION_REG register.
- The TMR0IF flag in the INTCON register is automatically set when TMR0 overflows.
Timer 0 Configuration: OPTION Register
- Selecting timer mode is determined by clearing the TMR0CS bit in the OPTION_REG register.
Timer 0 Configuration: OPTION Register
- The direction of the incrementing edge (rising or falling) for external clock input is determined by the TMR0SE bit in the OPTION_REG register.
Timer 0 Configuration: OPTION Register
- The prescaler is enabled by clearing the PSA bit in the OPTION_REG register.
- Eight prescaler options are available, ranging from 1:2 to 1:256.
- The prescale value is selectable via the PS bits in the OPTION_REG register.
Timer Locations
- Timer0 is located at memory address 0x01.
- Timer1 is located at memory addresses 0x0E and 0x0F.
- Timer2 is located at memory address 0x11.
- These addresses are available for both reading and writing.
Timer Operations
- The current count value can be read from the timer registers.
- The starting count value can be set by writing to the timer registers.
- Other Special Function Registers (SFRs) are required to configure and control these timers, including INTCON, OPTION_REG, T1CON, and T2CON.
Timer0 Block Diagram
- The T0CKI pin can be used for an external clock.
- In timer mode, Timer0 increments with each instruction clock pulse, unless a prescaler is used to reduce the speed.
Timer0 Features and Operation
- Timer0 is an 8-bit timer/counter.
- It is readable and writeable through the TMR0 register in SFR.
- It has a 3-bit software programmable prescaler.
- It can use an internal or external clock.
- It can generate an interrupt on overflow.
- It can be programmed to use rising or falling edges of the external clock.
Timer0 Configuration
- Timer 0 operation is controlled using the OPTION register.
- Timer 0 is a free-running timer and doesn't have a start/stop signal.
- It begins counting immediately after the microcontroller is powered on.
Steps to Configure Timer0
- Select the timer mode by setting the T0CS bit of the OPTION_REG register to 0.
- Configure the Prescaler Assignment and Prescaler Rate Select bits within the OPTION_REG register.
- The TMR0IF flag bit in the INTCON register is automatically set when the TMR0 register overflows.
Timer0 Configuration: OPTION Register
- The Timer mode is selected by clearing the TMR0CS bit of the OPTION_REG register.
- The rising or falling edge of the clock input (T0CKI) is determined by the TMR0SE bit in the OPTION_REG register.
- The prescaler is enabled by clearing the PSA bit of the OPTION_REG register.
- There are eight prescaler options for Timer0, ranging from 1:2 to 1:256, which are selected using the PS bits in the OPTION_REG register.
PIC16F877 Timers
- The PIC16F877 has three timers/counters: Timer0, Timer1, and Timer2.
Special Function Registers
- Some high-usage Special Function Registers (SFRs) from bank0 are mirrored in the other banks (e.g., INDF, PCL, STATUS, FSR, PCLATH, INTCON).
Timer-related Special Function Registers
- The three timers in the PIC16F877 are located in the SFR area.
Timers/Counters - Clock Source
- Internal Clock (Synchronous Mode): The timer receives its clock from the microcontroller's internal oscillator. The counter is incremented synchronously with the controller's operation.
- External Clock (Asynchronous Mode): The timer receives its clock from an external oscillator. The counter operates asynchronously to the controller. This mode is used for timing very slow signals and can use independent oscillators with a different frequency than the microcontroller.
Timers and Prescaler
- Prescaling: A technique that divides the timer's clock input frequency by a programmable value before the signal reaches the counter. This allows the counter to measure longer time intervals while preserving the resolution of the counter.
Postscaling
- Postscaling: The count is scaled after the counter completes its cycle. This involves setting a “flag” bit after a programmable number of cycles. This allows longer time intervals to be measured using the same counter.
Timer/Counters Design Problem
- A design problem may require a way to measure a 1-second interval precisely, count pulses from an infrared sensor, send the results to 7-segment displays at the end of the second, and perform these operations simultaneously.
- This can be achieved by using the independent timers and counters found in the microcontroller.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Test your knowledge on the functioning of timers and counters in microcontrollers, specifically focusing on the PIC16F877. This quiz will cover clock sources, counting mechanisms, and the specific functionalities of the timers in the PIC16F877. Prepare to assess how well you understand the timing and counting features essential for precise measurements.