Timer1 of PIC16F877

Publisher:caoxians4589Latest update time:2015-12-21 Source: eefocusKeywords:PIC16F877  Timer1 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The Timer1 module is a 16-bit timer/counter consisting of two readable and writable 8-bit registers (TMR1H and TMR1L). The TMR1 register pair (TMR1H:TMR1L) increments from 0000h to FFFFh and rolls over to 0000h. If the Timer1 interrupt is enabled, a Timer1 interrupt will be generated on overflow. The interrupt can be enabled/disabled by setting/clearing the TMR1IE bit.

Timer1 can operate in three modes:
• Synchronous Timer Mode
• Synchronous Counter Mode
• Asynchronous Counter Mode

Timer1 of PIC16F877

Timer1 in timer mode
Clear TMR1CS (T1CON<1>) to select TMR1 in timer mode. In this mode, the input clock of the timer is the internal clock frequency divided by 4 (FOSC/4). Because the internal clock is always synchronized, the synchronization control bit T1SYNC (T1CON<2>) has no effect at this time.


Timer1 in Synchronous Counter Mode
Set TMR1CS (T1CON<1>) to 1 to select TMR1 in counter mode. In this mode, the counter increments on every rising edge of the input clock at pin T1OSI (when T1OSCEN is set to 1) or T1OSO/T1CK (when T1OSCEN is cleared to 0). If the T1SYNC bit is cleared to 0, the external clock input is synchronized with the internal phase clock, and the synchronization is done after the prescaler. The prescaler is an asynchronous ripple counter. In synchronous counter mode, when operating in sleep mode, even if an external clock is used, Timer1 will not increment because the synchronization circuit is turned off, but the prescaler continues to increment. When Timer1 operates in synchronous counter mode, the external input clock signal must meet certain requirements, mainly because it must be synchronized with the internal phase clock (TOSC). After synchronization, there will be a certain delay between the actual increment count of Timer1 and the external clock edge. When the prescaler ratio is 1:1, the external input clock and the prescaler output are the same. T1CKI is synchronized with the internal phase clock by sampling the prescaler output at two adjacent Tosc internal phase clocks. Therefore, the high and low levels of the signal on the T1CKI pin are required to be at least 2Tosc (plus a small RC delay) respectively. When the prescaler ratio is other than 1:1, the external input clock signal must first be divided by the asynchronous ripple counter prescaler to make the prescaler output symmetrical. In order for the external clock to meet the sampling requirements, the ripple counter must be taken into account
. Therefore, the signal on the T1CKI pin is required to be at least 4Tosc (plus a small RC delay) for the prescaler to divide. In addition, the clock signal on the T1CKI pin must also meet the minimum pulse width requirements for the high and low levels.

 

Timer1 in Asynchronous Counter Mode
When T1SYNC (T1CON<2>) is set, the external clock input is not synchronized. Timer1 continues to count up asynchronously to the internal phase clock. In sleep mode, Timer1 will continue to run and generate an interrupt when it overflows to wake up the processor. However, special attention should be paid to the reading and writing of Timer1 in software. The asynchronous counter can work when the device is in sleep mode, so Timer1 can be used to implement a real-time clock. In asynchronous counter mode, Timer1 cannot be used as a working time base for capture or comparator.

 

Timer1 Oscillator
The crystal oscillator circuit is internally connected between the T1OSI (amplifier input) and T1OSO (amplifier output) pins and is enabled by setting the T1OSCEN control bit (T1CON<3>). This oscillator is a low power oscillator with a frequency of up to 200kHz. It can continue to operate in sleep mode. The generally recommended frequency is 32kHz, which is an ideal frequency for generating a real-time clock. Table 12-1 shows the external capacitors required for different crystal oscillator frequencies. The Timer1 oscillator is a low speed low power (LP) oscillator. The user should use a
certain software delay when the Timer1 oscillator starts to work to ensure that the oscillator starts reliably first.
Table 12-1: Capacitor selection table for Timer1 oscillator                     
Note: This allows the counter to continue to work (increment) in sleep mode, so Timer1 can be used to generate a real-time clock.
Oscillator Type    Frequency       C1      C2
  LP      32 kHz      33 pF   33 pF
          100 kHz     15 pF   15 pF
         200 kHz      15 pF   15 pF
Tested crystals:
32.768 kHz Epson C-001R32.768K-A ± 20 PPM
100 kHz Epson C-2 100.00 KC-P ± 20 PPM
200 kHz STD XTL 200.000 kHz ± 20 PPM
Note 1: Increasing the capacitance improves the stability of the oscillator, but also increases the start-up time of the oscillator.
2: Since each resonator/crystal has its own characteristics, the user should consult the resonator/crystal manufacturer for appropriate external component values.

 

Registers related to Timer1

 

Timer1 of PIC16F877

 

Keywords:PIC16F877  Timer1 Reference address:Timer1 of PIC16F877

Previous article:PIC16F877 Timer2 and CCP module PWM
Next article:Timer0 of PIC16F877

Recommended ReadingLatest update time:2024-11-16 15:23

PIC16F877 drives KS0066U LCD program
For the electronic design competition, I have to learn microcontrollers again! Now let's summarize the experience and experience of learning MCU before: 1. Microcontrollers are not difficult to use. They are nothing more than a few modules. What is really difficult is: the working timing and accurate delay of a peri
[Microcontroller]
PIC16F877 drives KS0066U LCD program
Identification of PIC16F877 Matrix Keyboard
The identification method of the matrix keyboard has been discussed in the 51 matrix keyboard identification. Now let's talk about the difference between the PIC microcontroller and the 51 microcontroller. The main difference is that the input and output of the PIC microcontroller port requires the TRISn register sett
[Microcontroller]
Identification of PIC16F877 Matrix Keyboard
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号