PIC16F7X7
Data Sheet
                                   28/40/44-Pin, 8-Bit CMOS Flash
                                   Microcontrollers with 10-Bit A/D
                                          and nanoWatt Technology
 2003 Microchip Technology Inc.        Preliminary            DS30498B
Note the following details of the code protection feature on Microchip devices:
•    Microchip products meet the specification contained in their particular Microchip Data Sheet.
•    Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
     intended manner and under normal conditions.
•    There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
     knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip's Data
     Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
•    Microchip is willing to work with the customer who is concerned about the integrity of their code.
•    Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
     mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Information contained in this publication regarding device               Trademarks
applications and the like is intended through suggestion only            The Microchip name and logo, the Microchip logo, Accuron,
and may be superseded by updates. It is your responsibility to           dsPIC, KEELOQ, MPLAB, PIC, PICmicro, PICSTART,
ensure that your application meets with your specifications.
                                                                         PRO MATE and PowerSmart are registered trademarks of
No representation or warranty is given and no liability is
                                                                         Microchip Technology Incorporated in the U.S.A. and other
assumed by Microchip Technology Incorporated with respect
                                                                         countries.
to the accuracy or use of such information, or infringement of
patents or other intellectual property rights arising from such          AmpLab, FilterLab, microID, MXDEV, MXLAB, PICMASTER,
use or otherwise. Use of Microchip’s products as critical                SEEVAL and The Embedded Control Solutions Company are
components in life support systems is not authorized except              registered trademarks of Microchip Technology Incorporated
with express written approval by Microchip. No licenses are              in the U.S.A.
conveyed, implicitly or otherwise, under any intellectual                Application Maestro, dsPICDEM, dsPICDEM.net, ECAN,
property rights.                                                         ECONOMONITOR, FanSense, FlexROM, fuzzyLAB,
                                                                         In-Circuit Serial Programming, ICSP, ICEPIC, microPort,
                                                                         Migratable Memory, MPASM, MPLIB, MPLINK, MPSIM,
                                                                         PICkit, PICDEM, PICDEM.net, PowerCal, PowerInfo,
                                                                         PowerMate, PowerTool, rfLAB, rfPIC, Select Mode,
                                                                         SmartSensor, SmartShunt, SmartTel and Total Endurance are
                                                                         trademarks of Microchip Technology Incorporated in the
                                                                         U.S.A. and other countries.
                                                                         Serialized Quick Turn Programming (SQTP) is a service mark
                                                                         of Microchip Technology Incorporated in the U.S.A.
                                                                         All other trademarks mentioned herein are property of their
                                                                         respective companies.
                                                                         © 2003, Microchip Technology Incorporated, Printed in the
                                                                         U.S.A., All Rights Reserved.
                                                                             Printed on recycled paper.
                                                                         Microchip received QS-9000 quality system
                                                                         certification for its worldwide headquarters,
                                                                         design and wafer fabrication facilities in
                                                                         Chandler and Tempe, Arizona in July 1999
                                                                         and Mountain View, California in March 2002.
                                                                         The Company’s quality system processes and
                                                                         procedures are QS-9000 compliant for its
                                                                         PICmicro® 8-bit MCUs, KEELOQ® code hopping
                                                                         devices, Serial EEPROMs, microperipherals,
                                                                         non-volatile memory and analog products. In
                                                                         addition, Microchip’s quality system for the
                                                                         design and manufacture of development
                                                                         systems is ISO 9001 certified.
DS30498B-page ii                                          Preliminary                                  2003 Microchip Technology Inc.
                                                                                          PIC16F7X7
      28/40/44-Pin, 8-Bit CMOS Flash Microcontrollers with
              10-Bit A/D and nanoWatt Technology
Low-Power Features:                                                       Peripheral Features:
• Power Managed modes:                                                    • High Sink/Source Current: 25 mA
  - Primary Run (XT, RC oscillator, 76 µA,                                • Two 8-bit Timers with Prescaler
    1 MHz, 2V)                                                            • Timer1/RTC module:
  - RC_RUN (7 µA, 31.25 kHz, 2V)                                            - 16-bit timer/counter with prescaler
  - SEC_RUN (9 µA, 32 kHz, 2V)                                              - Can be incremented during Sleep via
  - Sleep (0.1 µA, 2V)                                                        external 32 kHz watch crystal
• Timer1 Oscillator (1.8 µA, 32 kHz, 2V)                                  • Master Synchronous Serial Port (MSSP) with
• Watchdog Timer (0.7 µA, 2V)                                               3-wire SPITM and I2CTM (Master and Slave) modes
• Two-Speed Oscillator Start-up                                           • Addressable Universal Synchronous
                                                                            Asynchronous Receiver Transmitter (AUSART)
Oscillators:                                                              • Three Capture, Compare, PWM modules:
                                                                            - Capture is 16-bit, max. resolution is 12.5 ns
• Three Crystal modes:
                                                                            - Compare is 16-bit, max. resolution is 200 ns
  - LP, XT, HS (up to 20 MHz)
                                                                            - PWM max. resolution is 10 bits
• Two External RC modes
                                                                          • Parallel Slave Port (PSP) – 40/44-pin devices only
• One External Clock mode:
  - ECIO (up to 20 MHz)                                                   Special Microcontroller Features:
• Internal Oscillator Block:
  - 8 user-selectable frequencies (31 kHz,                                • Fail-Safe Clock Monitor for protecting critical
     125 kHz, 250 kHz, 500 kHz, 1 MHz, 2 MHz,                               applications against crystal failure
     4 MHz, 8 MHz)                                                        • Two-Speed Start-up mode for immediate code
                                                                            execution
Analog Features:                                                          • Power-on Reset (POR), Power-up Timer (PWRT)
                                                                            and Oscillator Start-up Timer (OST)
• 10-bit, up to 14-channel Analog-to-Digital Converter:                   • Programmable Code Protection
  - Programmable Acquisition Time                                         • Processor Read Access to Program Memory
  - Conversion available during Sleep mode                                • Power Saving Sleep mode
• Dual Analog Comparators                                                 • In-Circuit Serial Programming (ICSP) via
• Programmable Low Current Brown-out Reset                                  two pins
  (BOR) Circuitry and Programmable Low-Voltage                            • MPLAB® In-Circuit Debug (ICD) via two pins
  Detect (LVD)
                                                                          • MCLR pin function replaceable with input only pin
                                                                            Comparators
                                                                                                    MSSP
                                                 Interrupts
                 Program
                               Data
                  Memory                                        10-bit                     CCP                          Timers
   Device                     SRAM        I/O                                                             I2C    AUSART
              (# Single-Word                                   A/D (ch)                   (PWM)   SPI                   8/16-bit
                             (Bytes)                                                                    (Master)
               Instructions)
 PIC16F737          4096           368    25     16              11          2              3     Yes     Yes     Yes      2/1
 PIC16F747          4096           368    36     17              14          2              3     Yes     Yes     Yes      2/1
 PIC16F767          8192           368    25     16              11          2              3     Yes     Yes     Yes      2/1
 PIC16F777          8192           368    36     17              14          2              3     Yes     Yes     Yes      2/1
 2003 Microchip Technology Inc.                              Preliminary                                        DS30498B-page 1
PIC16F7X7
Pin Diagrams
     PDIP, SOIC, SSOP (28-pin)
              MCLR/VPP/RE3           1                                28       RB7/PGD
                   RA0/AN0           2                                27       RB6/PGC
                   RA1/AN1           3                                26       RB5/AN13/CCP3
                                     4                                25       RB4/AN11
                                               PIC16F737/767
        RA2/AN2/VREF-/CVREF
              RA3/AN3/VREF+          5                                24       RB3/CCP2(1)/AN9
          RA4/T0CKI/C1OUT            6                                23       RB2/AN8
    RA5/AN4/LVDIN/SS/C2OUT           7                                22       RB1/AN10
                        VSS          8                                21       RB0/INT/AN12
              OSC1/CLKI/RA7          9                                20       VDD
             OSC2/CLKO/RA6          10                                19       VSS
          RC0/T1OSO/T1CKI           11                                18       RC7/RX/DT
            RC1/T1OSI/CCP2          12                                17       RC6/TX/CK
                  RC2/CCP1          13                                16       RC5/SDO
               RC3/SCK/SCL          14                                15       RC4/SDI/SDA
                                                                                                     RB5/AN13/CCP3
                                                                                                     MCLR/VPP/RE3
                                                                                                     RB4/AN11
                                                                                                     RB7/PGD
                                                                                                     RB6/PGC
                                                                                                     RA1/AN1
                                                                                                     RA0/AN0
                                                                    QFN (28-pin)
                                                                                                     28 27 26 25 24 23 22
                                                                   RA2/AN2/VREF-/CVREF           1                       21    RB3/CCP2(1)/AN9
                                                                         RA3/AN3/VREF+           2                       20    RB2/AN8
                                                                     RA4/T0CKI/C1OUT             3     PIC16F737 19            RB1/AN10
                                                               RA5/AN4/LVDIN/SS/C2OUT            4                       18    RB0/INT/AN12
                                                                                   VSS           5     PIC16F767 17            VDD
                                                                       OSC2/CLKO/RA6             6                       16    VSS
                                                                        OSC1/CLKI/RA7            7                       15    RC7/RX/DT
                                                                                                      8 9 10 11 12 13 14
                           RC0/T1OSO/T1CKI
      QFN (44-pin)
                           RC1/T1OSI/CCP2
                                                                                                            RC2/CCP1
                                                                                                      RC1/T1OSI/CCP2
                                                                                                         RC3/SCK/SCL
                                                                                                             RC5/SDO
                                                                                                     RC0/T1OSO/T1CKI
                                                                                                         RC4/SDI/SDA
                                                                                                           RC6/TX/CK
                           RC3/SCK/SCL
                           RC4/SDI/SDA
                           RC6/TX/CK
                           RC2/CCP1
                           RD3/PSP3
                           RD2/PSP2
                           RD1/PSP1
                           RD0/PSP0
                           RC5/SDO
                           44
                           43
                           42
                           41
                           40
                           39
                           38
                           37
                           36
                           35
                           34
       RC7/RX/DT         1                                     33          OSC2/CLKO/RA6
        RD4/PSP4         2                                     32          OSC1/CLKI/RA7
        RD5/PSP5         3                                     31          VSS
        RD6/PSP6         4                                     30          VSS
        RD7/PSP7         5
                               PIC16F747                       29          NC
              VSS        6                                     28          VDD
              VDD        7     PIC16F777                       27          RE2/CS/AN7
              VDD        8                                     26          RE1/WR/AN6
     RB0/INT/AN12        9                                     25          RE0/RD/AN5
        RB1/AN10         10                                    24          RA5/AN4/LVDIN/SS/C2OUT
          RB2/AN8        11                                    23          RA4/T0CKI/C1OUT
                           20
                           21
                           22
                           13
                           14
                           15
                           16
                           17
                           18
                           19
                           12 RB3/CCP2(1)/AN9
                                     RB4/AN11
                               RB5/AN13/CCP3
                                MCLR/VPP/RE3
                                      RA0/AN0
                                      RA1/AN1
                          RA2/AN2/VREF-/CVREF
                                           NC
                                     RB6/PGC
                                     RB7/PGD
                                RA3/AN3/VREF+
    Note 1:   RB3 is the alternate pin for the CCP2 pin multiplexing.
DS30498B-page 2                                                     Preliminary                                  2003 Microchip Technology Inc.
                                                                                                          PIC16F7X7
Pin Diagrams (Continued)
    PDIP (40-pin)
                               MCLR/VPP/RE3              1                    40        RB7/PGD
                                    RA0/AN0              2                    39        RB6/PGC
                                    RA1/AN1              3                    38        RB5/AN13/CCP3
                         RA2/AN2/VREF-/CVREF             4                    37        RB4/AN11
                               RA3/AN3/VREF+             5                    36        RB3/CCP2(1)/AN9
                           RA4/T0CKI/C1OUT               6                    35        RB2/AN8
                     RA5/AN4/LVDIN/SS/C2OUT              7                    34        RB1/AN10
                                                              PIC16F747/777
                                 RE0/RD/AN5              8                    33        RB0/INT/AN12
                                 RE1/WR/AN6              9                    32        VDD
                                 RE2/CS/AN7              10                   31        VSS
                                         VDD             11                   30        RD7/PSP7
                                         VSS             12                   29        RD6/PSP6
                               OSC1/CLKI/RA7             13                   28        RD5/PSP5
                              OSC2/CLKO/RA6              14                   27        RD4/PSP4
                           RC0/T1OSO/T1CKI               15                   26        RC7/RX/DT
                             RC1/T1OSI/CCP2              16                   25        RC6/TX/CK
                                   RC2/CCP1              17                   24        RC5/SDO
                                RC3/SCK/SCL              18                   23        RC4/SDI/SDA
                                   RD0/PSP0              19                   22        RD3/PSP3
                                   RD1/PSP1              20                   21        RD2/PSP2
                                                       RC1/T1OSI/CCP2
      TQFP (44-pin)
                                                       RC3/SCK/SCL
                                                       RC4/SDI/SDA
                                                       RC6/TX/CK
                                                       RC2/CCP1
                                                       RD3/PSP3
                                                       RD2/PSP2
                                                       RD1/PSP1
                                                       RD0/PSP0
                                                       RC5/SDO
                                                       NC
                                                     44
                                                     43
                                                     42
                                                     41
                                                     40
                                                     39
                                                     38
                                                     37
                                                     36
                                                     35
                                                     34
                            RC7/RX/DT             1                                33             NC
                             RD4/PSP4             2                                32             RC0/T1OSO/T1CKI
                             RD5/PSP5             3                                31             OSC1/CLKI/RA7
                             RD6/PSP6             4                                30             OSC2/CLKO/RA6
                             RD7/PSP7             5       PIC16F747                29             VSS
                                   VSS            6                                28             VDD
                                   VDD            7       PIC16F777                27             RE2/CS/AN7
                         RB0/INT/AN12             8                                26             RE1/WR/AN6
                             RB1/AN10             9                                25             RE0/RD/AN5
                              RB2/AN8             10                               24             RA5/AN4/LVDIN/SS/C2OUT
                       RB3/CCP2(1)/AN9            11                               23             RA4/T0CKI/C1OUT
                                                       12
                                                       13
                                                       14
                                                       15
                                                       16
                                                       17
                                                       18
                                                       19
                                                       20
                                                       21
                                                       22
                                                                  RB4/AN11
                                                            RB5/AN13/CCP3
                                                             MCLR/VPP/RE3
                                                                   RA0/AN0
                                                                   RA1/AN1
                                                       RA2/AN2/VREF-/CVREF
                                                                        NC
                                                                        NC
                                                                  RB6/PGC
                                                                  RB7/PGD
                                                             RA3/AN3/VREF+
    Note 1:   RB3 is the alternate pin for the CCP2 pin multiplexing.
 2003 Microchip Technology Inc.                         Preliminary                                                DS30498B-page 3
PIC16F7X7
Table of Contents
1.0 Device Overview ......................................................................................................................................................................... 5
2.0 Memory Organization................................................................................................................................................................ 15
3.0 Reading Program Memory........................................................................................................................................................ 31
4.0 Oscillator Configurations........................................................................................................................................................... 33
5.0 I/O Ports.................................................................................................................................................................................... 49
6.0 Timer0 Module .......................................................................................................................................................................... 73
7.0 Timer1 Module .......................................................................................................................................................................... 77
8.0 Timer2 Module .......................................................................................................................................................................... 85
9.0 Capture/Compare/PWM Modules ............................................................................................................................................. 87
10.0 Master Synchronous Serial Port (MSSP) Module..................................................................................................................... 93
11.0 Addressable Universal Synchronous Asynchronous Receiver Transmitter (USART) ............................................................ 133
12.0 Analog-to-Digital Converter (A/D) Module .............................................................................................................................. 151
13.0 Comparator Module ................................................................................................................................................................ 161
14.0 Comparator Voltage Reference Module ................................................................................................................................. 167
15.0 Special Features of the CPU .................................................................................................................................................. 169
16.0 Instruction Set Summary......................................................................................................................................................... 193
17.0 Development Support ............................................................................................................................................................. 201
18.0 Electrical Characteristics......................................................................................................................................................... 207
19.0 DC and AC Characteristics Graphs and Tables ..................................................................................................................... 237
20.0 Packaging Information ............................................................................................................................................................ 239
Appendix A: Revision History ........................................................................................................................................................... 249
Appendix B: Device Differences........................................................................................................................................................ 249
Appendix C: Conversion Considerations........................................................................................................................................... 250
Index .................................................................................................................................................................................................. 251
On-Line Support................................................................................................................................................................................ 259
Systems Information and Upgrade Hot Line ..................................................................................................................................... 259
Reader Response ............................................................................................................................................................................. 260
PIC16F7X7 Product Identification System ........................................................................................................................................ 261
                                                               TO OUR VALUED CUSTOMERS
  It is our intention to provide our valued customers with the best documentation possible to ensure successful use of your Microchip
  products. To this end, we will continue to improve our publications to better suit your needs. Our publications will be refined and
  enhanced as new volumes and updates are introduced.
  If you have any questions or comments regarding this publication, please contact the Marketing Communications Department via
  E-mail at docerrors@mail.microchip.com or fax the Reader Response Form in the back of this data sheet to (480) 792-4150.
  We welcome your feedback.
  Most Current Data Sheet
  To obtain the most up-to-date version of this data sheet, please register at our Worldwide Web site at:
          http://www.microchip.com
  You can determine the version of a data sheet by examining its literature number found on the bottom outside corner of any page.
  The last character of the literature number is the version number, (e.g., DS30000A is version A of document DS30000).
  Errata
  An errata sheet, describing minor operational differences from the data sheet and recommended workarounds, may exist for current
  devices. As device/documentation issues become known to us, we will publish an errata sheet. The errata will specify the revision
  of silicon and revision of document to which it applies.
  To determine if an errata sheet exists for a particular device, please check with one of the following:
  • Microchip’s Worldwide Web site; http://www.microchip.com
  • Your local Microchip sales office (see last page)
  • The Microchip Corporate Literature Center; U.S. FAX: (480) 792-7277
  When contacting a sales office or the literature center, please specify which device, revision of silicon and data sheet (include
  literature number) you are using.
  Customer Notification System
  Register on our web site at www.microchip.com/cn to receive the most current information on all of our products.
DS30498B-page 4                                                                        Preliminary                                                      2003 Microchip Technology Inc.
                                                                                               PIC16F7X7
1.0          DEVICE OVERVIEW                                     • The Timer1 module current consumption has
                                                                   been greatly reduced from 20 µA (previous PIC16
This document contains device specific information                 devices) to 1.8 µA typical (32 kHz at 2V), which is
about the following devices:                                       ideal for real-time clock applications. Refer to
• PIC16F737                    • PIC16F767                         Section 7.0 “Timer1 Module” for further details.
• PIC16F747                    • PIC16F777                       • Extended Watchdog Timer (WDT) that can have a
                                                                   programmable period from 1 ms to 268s. The WDT
PIC16F737/767 devices are available only in 28-pin
                                                                   has its own 16-bit prescaler. Refer to Section 15.17
packages, while PIC16F747/777 devices are available
                                                                   “Watchdog Timer (WDT)” for further details.
in 40-pin and 44-pin packages. All devices in the
PIC16F7X7 family share common architecture with the              • Two-Speed Start-up: When the oscillator is
following differences:                                             configured for LP, XT or HS, this feature will clock
                                                                   the device from the INTRC while the oscillator is
• The PIC16F737 and PIC16F767 have one-half of                     warming up. This, in turn, will enable almost
  the total on-chip memory of the PIC16F747 and                    immediate code execution. Refer to
  PIC16F777.                                                       Section 15.17.3 “Two-Speed Clock Start-up
• The 28-pin devices have 3 I/O ports, while the                   Mode” for further details.
  40/44-pin devices have 5.                                      • Fail-Safe Clock Monitor: This feature will allow the
• The 28-pin devices have 16 interrupts, while the                 device to continue operation if the primary or
  40/44-pin devices have 17.                                       secondary clock source fails, by switching over to
• The 28-pin devices have 11 A/D input channels,                   the INTRC.
  while the 40/44-pin devices have 14.                           The available features are summarized in Table 1-1.
• The Parallel Slave Port is implemented only on                 Block diagrams of the PIC16F737/767 and
  the 40/44-pin devices.                                         PIC16F747/777 devices are provided in Figure 1-1 and
• Low-Power modes: RC_RUN allows the core and                    Figure 1-2, respectively. The pinouts for these device
  peripherals to be clocked from the INTRC, while                families are listed in Table 1-2 and Table 1-3.
  SEC_RUN allows the core and peripherals to be                  Additional information may be found in the PICmicro®
  clocked from the low-power Timer1. Refer to                    Mid-Range      MCU Family        Reference Manual
  Section 4.7 “Power Managed Modes” for                          (DS33023), which may be obtained from your local
  further details.                                               Microchip Sales Representative or downloaded from
• Internal RC oscillator with eight selectable                   the Microchip web site. The Reference Manual should
  frequencies, including 31.25 kHz, 125 kHz,                     be considered a complementary document to this data
  250 kHz, 500 kHz, 1 MHz, 2 MHz, 4 MHz and                      sheet and is highly recommended reading for a better
  8 MHz. The INTRC can be configured as a primary                understanding of the device architecture and operation
  or secondary clock source. Refer to Section 4.5                of the peripheral modules.
  “Internal Oscillator Block” for further details.
TABLE 1-1:         PIC16F7X7 DEVICE FEATURES
              Key Features                   PIC16F737          PIC16F747             PIC16F767           PIC16F777
Operating Frequency                          DC – 20 MHz       DC – 20 MHz           DC – 20 MHz         DC – 20 MHz
Resets (and Delays)                           POR, BOR          POR, BOR              POR, BOR            POR, BOR
                                             (PWRT, OST)       (PWRT, OST)           (PWRT, OST)         (PWRT, OST)
Flash Program Memory (14-bit words)               4K                 4K                   8K                   8K
Data Memory (bytes)                              368                368                  368                  368
Interrupts                                        16                 17                   16                   17
I/O Ports                                    Ports A, B, C   Ports A, B, C, D, E     Ports A, B, C     Ports A, B, C, D, E
Timers                                            3                  3                    3                    3
Capture/Compare/PWM Modules                       3                  3                    3                    3
Master Serial Communications             MSSP, USART          MSSP, USART           MSSP, USART         MSSP, USART
Parallel Communications                           —                 PSP                   —                   PSP
10-bit Analog-to-Digital Module         11 Input Channels    14 Input Channels     11 Input Channels   14 Input Channels
Instruction Set                          35 Instructions       35 Instructions      35 Instructions      35 Instructions
Packaging                                    28-pin PDIP       40-pin PDIP           28-pin PDIP         40-pin PDIP
                                             28-pin SOIC        44-pin QFN           28-pin SOIC         44-pin QFN
                                             28-pin SSOP       44-pin TQFP           28-pin SSOP         44-pin TQFP
                                              28-pin QFN                              28-pin QFN
 2003 Microchip Technology Inc.                       Preliminary                                      DS30498B-page 5
PIC16F7X7
FIGURE 1-1:                PIC16F737 AND PIC16F767 BLOCK DIAGRAM
                                                                                                          PORTA
                                            13                                                    8                     RA0/AN0
                                                                                   Data Bus
                                                   Program Counter                                                      RA1/AN1
                          Standard                                                                                      RA2/AN2/VREF-/CVREF
                            Flash                                                                                       RA3/AN3/VREF+
                          Program                                                                                       RA4/T0CKI/C1OUT
                           Memory                                                    RAM
                                                    8-Level Stack                    File                               RA5/AN4/LVDIN/
                         4K/8K x 14                    (13-bit)                                                         SS/C2OUT
                                                                                   Registers
                                                                                                                        OSC2/CLKO/RA6
                                                                                    368 x 8
               Program                                                                                                  OSC1/CLKI/RA7
                          14
                 Bus                                                   RAM Addr(1)         9              PORTB
                                                                                                                        RB0/INT/AN12
                                                                                   Addr MUX
                   Instruction Register                                                                                 RB1/AN10
                                                                   7                           Indirect                 RB2/AN8
                                                  Direct Addr
                                                                                           8     Addr                   RB3/CCP2(1)/AN9
                                                                                                                        RB4/AN11
                                                                                        FSR reg
                                                                                                                        RB5/AN13/CCP3
                                                                                                                        RB7/PGD:RB6/PGC
                                                                                          Status reg
                                            8                                                             PORTC
                                                                                                                        RC0/T1OSO/T1CKI
                                                                                                                        RC1/T1OSI/CCP2(1)
                                                                               3           MUX
                                                    Power-up                                                            RC2/CCP1
                                                     Timer                                                              RC3/SCK/SCL
                         Instruction                Oscillator                                                          RC4/SDI/SDA
                         Decode &                 Start-up Timer                                                        RC5/SDO
                                                                                    ALU
                           Control                                                                                      RC6/TX/CK
                                                    Power-on
                                                     Reset                 8                                            RC7/RX/DT
                          Timing                    Watchdog
                         Generation                   Timer                        WREG
       OSC1/CLKI                                    Brown-out
       OSC2/CLKO                                      Reset
                                                                                                          PORTE
                                                VDD, VSS
                                                                                                                        MCLR/VPP/RE3
      Timer0                    Timer1                      Timer2                      10-bit A/D
                                                            MSSP                      Addressable         BOR/LVD
   Comparators                 CCP1, 2, 3
                                                                                        USART
  Note 1: Pin location of CCP2 is determined by CCPMX in Configuration Word Register 1.
DS30498B-page 6                                                        Preliminary                            2003 Microchip Technology Inc.
                                                                                                               PIC16F7X7
FIGURE 1-2:                PIC16F747 AND PIC16F777 BLOCK DIAGRAM
                                                                                                          PORTA
                                            13                                                    8                 RA0/AN0
                                                                                   Data Bus
                                                  Program Counter                                                   RA1/AN1
                          Standard
                                                                                                                    RA2/AN2/VREF-/CVREF
                            Flash
                          Program                                                                                   RA3/AN3/VREF+
                           Memory                                                    RAM                            RA4/T0CKI/C1OUT
                         4K/8K x 14                 8-Level Stack                                                   RA5/AN4/LVDIN/
                                                                                     File
                                                       (13-bit)                    Registers                        SS/C2OUT
                                                                                                                    OSC2/CLKO/RA6
                                                                                    368 x 8                         OSC1/CLKI/RA7
               Program
                          14
                 Bus                                                   RAM Addr(1)         9              PORTB
                                                                                                                    RB0/INT/AN12
                                                                                   Addr MUX
                     Instruction Register                                                                           RB1/AN10
                                                                   7                           Indirect             RB2/AN8
                                                 Direct Addr
                                                                                           8     Addr               RB3/CCP2(1)/AN9
                                                                                                                    RB4/AN11
                                                                                        FSR reg
                                                                                                                    RB5/AN13/CCP3
                                                                                                                    RB7/PGD:RB6/PGC
                                                                                          Status reg
                                            8                                                             PORTC
                                                                                                                    RC0/T1OSO/T1CKI
                                                                                                                    RC1/T1OSI/CCP2(1)
                                                                               3                                    RC2/CCP1
                                                    Power-up                               MUX
                                                                                                                    RC3/SCK/SCL
                                                     Timer
                                                                                                                    RC4/SDI/SDA
                         Instruction                Oscillator                                                      RC5/SDO
                         Decode &                 Start-up Timer                                                    RC6/TX/CK
                                                                                    ALU
                           Control                                                                                  RC7/RX/DT
                                                    Power-on
                                                     Reset                 8                              PORTD
                          Timing                    Watchdog
                         Generation                   Timer                        WREG
       OSC1/CLKI                                    Brown-out
       OSC2/CLKO                                      Reset                                                         RD7/PSP7:RD0/PSP0
                                                                                    Parallel Slave Port
                                                VDD, VSS                                                  PORTE
                                                                                                                    RE0/RD/AN5
                                                                                                                    RE1/WR/AN6
      Timer0                    Timer1                     Timer2                       10-bit A/D                  RE2/CS/AN7
                                                                                                                    MCLR/VPP/RE3
    Comparators                                            MSSP                       Addressable         BOR/LVD
                               CCP1, 2, 3
                                                                                        USART
  Note 1: Pin location of CCP2 is determined by CCPMX in Configuration Word Register 1.
 2003 Microchip Technology Inc.                                       Preliminary                                     DS30498B-page 7
PIC16F7X7
TABLE 1-2:          PIC16F737 AND PIC16F767 PINOUT DESCRIPTION
                            PDIP
                            SSOP      QFN      I/O/P     Buffer
         Pin Name                                                                           Description
                            SOIC      Pin #    Type      Type
                            Pin #
OSC1/CLKI/RA7                 9         7              ST/CMOS(3) Oscillator crystal or external clock input.
  OSC1                                           I                   Oscillator crystal input or external clock source input. ST
                                                                     buffer when configured in RC mode; otherwise CMOS.
   CLKI                                          I                   External clock source input. Always associated with pin
                                                                     function OSC1 (see OSC1/CLKI, OSC2/CLKO pins).
   RA7                                          I/O        ST        Digital I/O.
OSC2/CLKO/RA6                 10        6                   —       Oscillator crystal or clock output.
  OSC2                                           O                     Oscillator crystal output.
                                                                       Connects to crystal or resonator in Crystal Oscillator
                                                                       mode.
   CLKO                                          O                     In RC mode, OSC2 pin outputs CLKO, which has 1/4 the
                                                                       frequency of OSC1 and denotes the instruction cycle rate.
   RA6                                          I/O        ST          Digital I/O.
MCLR/VPP/RE3                  1        26                  ST       Master Clear (input) or programming voltage (output).
  MCLR                                           I                     Master Clear (Reset) input. This pin is an active-low
                                                                       Reset to the device.
   VPP                                           P                     Programming voltage input.
   RE3                                           I                     Digital input only pin.
                                                                    PORTA is a bidirectional I/O port.
RA0/AN0                       2        27                  TTL
   RA0                                          I/O                     Digital I/O.
   AN0                                            I                     Analog input 0.
RA1/AN1                       3        28                  TTL
   RA1                                          I/O                     Digital I/O.
   AN1                                            I                     Analog input 1.
RA2/AN2/VREF-/CVREF           4         1                  TTL
   RA2                                          I/O                     Digital I/O.
   AN2                                            I                     Analog input 2.
   VREF-                                          I                     A/D reference voltage input (low).
   CVREF                                         0                      Comparator voltage reference output.
RA3/AN3/VREF+                 5         2                  TTL
   RA3                                          I/O                     Digital I/O.
   AN3                                            I                     Analog input 3.
   VREF+                                          I                     A/D reference voltage input (high).
RA4/T0CKI/C1OUT               6         3                  ST
   RA4                                          I/O                     Digital I/O – Open-drain when configured as output.
   T0CKI                                          I                     Timer0 external clock input.
   C1OUT                                         O                      Comparator 1 output bit.
RA5/AN4/LVDIN/SS/C2OUT        7         4                  TTL
   RA5                                          I/O                     Digital I/O.
   AN4                                            I                     Analog input 4.
   LVDIN                                        I/O                     Low-voltage detect input.
   SS                                             I                     SPI slave select input.
   C2OUT                                         O                      Comparator 2 output bit.
Legend:    I = input                 O = output                  I/O = input/output              P = power
           — = Not used              TTL = TTL input             ST = Schmitt Trigger input
Note 1:    This buffer is a Schmitt Trigger input when configured as the external interrupt.
     2:    This buffer is a Schmitt Trigger input when used in Serial Programming mode.
     3:    This buffer is a Schmitt Trigger input when configured in RC Oscillator mode and a CMOS input otherwise.
DS30498B-page 8                                        Preliminary                              2003 Microchip Technology Inc.
                                                                                                  PIC16F7X7
TABLE 1-2:         PIC16F737 AND PIC16F767 PINOUT DESCRIPTION (CONTINUED)
                            PDIP
                            SSOP      QFN      I/O/P     Buffer
        Pin Name                                                                            Description
                            SOIC      Pin #    Type      Type
                            Pin #
                                                                    PORTB is a bidirectional I/O port. PORTB can be software
                                                                    programmed for internal weak pull-up on all inputs.
RB0/INT/AN12                  21       18               TTL/ST(1)
   RB0                                          I/O                     Digital I/O.
   INT                                            I                     External interrupt.
   AN12                                           I                     Analog input channel 12.
RB1/AN10                      22       19                  TTL
   RB1                                          I/O                     Digital I/O.
   AN10                                           I                     Analog input channel 10.
RB2/AN8                       23       20                  TTL
   RB2                                          I/O                     Digital I/O.
   AN8                                            I                     Analog input channel 8.
RB3/CCP2/AN9                  24       21                  TTL
   RB3                                          I/O                     Digital I/O.
   CCP2                                         I/O                     CCP2 capture input, compare output, PWM output.
   AN9                                            I                     Analog input channel 9.
RB4/AN11                      25       22                  TTL
   RB4                                          I/O                     Digital I/O.
   AN11                                           I                     Analog input channel 11.
RB5/AN13/CCP3                 26       23                  TTL
   RB5                                          I/O                     Digital I/O.
   AN13                                           I                     Analog input channel 13.
   CCP3                                         I/O                     CCP3 capture input, compare output, PWM output.
RB6/PGC                       27       24               TTL/ST(2)
   RB6                                          I/O                     Digital I/O.
   PGC                                          I/O                     In-circuit debugger and ICSP programming clock.
RB7/PGD                       28       25               TTL/ST(2)
   RB7                                          I/O                     Digital I/O.
   PGD                                          I/O                     In-circuit debugger and ICSP programming data.
Legend:    I = input                 O = output                  I/O = input/output              P = power
           — = Not used              TTL = TTL input             ST = Schmitt Trigger input
Note 1:    This buffer is a Schmitt Trigger input when configured as the external interrupt.
     2:    This buffer is a Schmitt Trigger input when used in Serial Programming mode.
     3:    This buffer is a Schmitt Trigger input when configured in RC Oscillator mode and a CMOS input otherwise.
 2003 Microchip Technology Inc.                       Preliminary                                           DS30498B-page 9
PIC16F7X7
TABLE 1-2:         PIC16F737 AND PIC16F767 PINOUT DESCRIPTION (CONTINUED)
                             PDIP
                             SSOP      QFN      I/O/P     Buffer
       Pin Name                                                                               Description
                             SOIC      Pin #    Type      Type
                             Pin #
                                                                     PORTC is a bidirectional I/O port.
RC0/T1OSO/T1CKI                11        8                  ST
   RC0                                           I/O                     Digital I/O.
   T1OSO                                          O                      Timer1 oscillator output.
   T1CKI                                           I                     Timer1 external clock input.
RC1/T1OSI/CCP2                 12        9                  ST
   RC1                                           I/O                     Digital I/O.
   T1OSI                                           I                     Timer1 oscillator input.
   CCP2                                          I/O                     Capture2 input, Compare2 output, PWM2 output.
RC2/CCP1                       13       10                  ST
   RC2                                           I/O                     Digital I/O.
   CCP1                                          I/O                     Capture1 input, Compare1 output, PWM1 output.
RC3/SCK/SCL                    14       11                  ST
   RC3                                           I/O                     Digital I/O.
   SCK                                           I/O                     Synchronous serial clock input/output for SPI mode.
   SCL                                           I/O                     Synchronous serial clock input/output for I2C mode.
RC4/SDI/SDA                    15       12                  ST
   RC4                                           I/O                     Digital I/O.
   SDI                                             I                     SPI data in.
   SDA                                           I/O                     I2C data I/O.
RC5/SDO                        16       13                  ST
   RC5                                           I/O                     Digital I/O.
   SDO                                            O                      SPI data out.
RC6/TX/CK                      17       14                  ST
   RC6                                           I/O                     Digital I/O.
   TX                                             O                      USART asynchronous transmit.
   CK                                            I/O                     USART1 synchronous clock.
RC7/RX/DT                      18       15                  ST
   RC7                                           I/O                     Digital I/O.
   RX                                              I                     USART asynchronous receive.
   DT                                            I/O                     USART synchronous data.
VSS                          8, 19     5, 16      P          —       Ground reference for logic and I/O pins.
VDD                            20       17        P          —       Positive supply for logic and I/O pins.
Legend:     I = input                 O = output                  I/O = input/output              P = power
            — = Not used              TTL = TTL input             ST = Schmitt Trigger input
Note 1:     This buffer is a Schmitt Trigger input when configured as the external interrupt.
     2:     This buffer is a Schmitt Trigger input when used in Serial Programming mode.
     3:     This buffer is a Schmitt Trigger input when configured in RC Oscillator mode and a CMOS input otherwise.
DS30498B-page 10                                        Preliminary                              2003 Microchip Technology Inc.
                                                                                                    PIC16F7X7
TABLE 1-3:           PIC16F747 AND PIC16F777 PINOUT DESCRIPTION
                              PDIP     QFN     TQFP     I/O/P     Buffer
          Pin Name                                                                                 Description
                              Pin #    Pin #   Pin #    Type      Type
OSC1/CLKI/RA7                  13       32       31             ST/CMOS(4) Oscillator crystal or external clock input.
  OSC1                                                    I                   Oscillator crystal input or external clock source input.
                                                                              ST buffer when configured in RC mode; otherwise
                                                                              CMOS.
    CLKI                                                  I                   External clock source input. Always associated with
                                                                              pin function OSC1 (see OSC1/CLKI, OSC2/CLKO
                                                                              pins).
    RA7                                                  I/O        ST        Bidirectional I/O pin.
OSC2/CLKO/RA6                  14       33       30                  —       Oscillator crystal or clock output.
  OSC2                                                    O                     Oscillator crystal output. Connects to crystal or
                                                                                resonator in Crystal Oscillator mode.
    CLKO                                                  O                     In RC mode, OSC2 pin outputs CLKO, which has
                                                                                1/4 the frequency of OSC1 and denotes the
                                                                                instruction cycle rate.
    RA6                                                  I/O        ST          Bidirectional I/O pin.
MCLR/VPP/RE3                    1       18       18                 ST       Master Clear (input) or programming voltage (output).
  MCLR                                                    I                     Master Clear (Reset) input. This pin is an
                                                                                active- low Reset to the device.
    VPP                                                   P                     Programming voltage input.
    RE3                                                   I                     Digital input only pin.
                                                                             PORTA is a bidirectional I/O port.
RA0/AN0                         2       19       19                 TTL
   RA0                                                   I/O                     Digital I/O.
   AN0                                                     I                     Analog input 0.
RA1/AN1                         3       20       20                 TTL
   RA1                                                   I/O                     Digital I/O.
   AN1                                                     I                     Analog input 1.
RA2/AN2/VREF-/CVREF             4       21       21                 TTL
   RA2                                                   I/O                     Digital I/O.
   AN2                                                     I                     Analog input 2.
   VREF-                                                   I                     A/D reference voltage input (low).
   CVREF                                                   I                     Comparator voltage reference output.
RA3/AN3/VREF+                   5       22       22                 TTL
   RA3                                                   I/O                     Digital I/O.
   AN3                                                     I                     Analog input 3.
   VREF+                                                   I                     A/D reference voltage input (high).
RA4/T0CKI/C1OUT                 6       23       23                 ST
   RA4                                                   I/O                     Digital I/O – Open-drain when configured as output.
   T0CKI                                                   I                     Timer0 external clock input.
   C1OUT                                                  O                      Comparator 1 output.
RA5/AN4/LVDIN/SS/C2OUT          7       24       24                 TTL
   RA5                                                   I/O                     Digital I/O.
   AN4                                                     I                     Analog input 4.
   LVDIN                                                   I                     Low-voltage detect input.
   SS                                                      I                     SPI slave select input.
   C2OUT                                                   I                     Comparator 2 output.
Legend:     I = input                    O = output                 I/O = input/output                 P = power
            — = Not used                 TTL = TTL input            ST = Schmitt Trigger input
Note 1:     This buffer is a Schmitt Trigger input when configured as an external interrupt.
     2:     This buffer is a Schmitt Trigger input when used in Serial Programming mode.
     3:     This buffer is a Schmitt Trigger input when configured as a general purpose I/O and a TTL input when used in the Parallel
            Slave Port mode (for interfacing to a microprocessor bus).
       4:   This buffer is a Schmitt Trigger input when configured in RC Oscillator mode and a CMOS input otherwise.
 2003 Microchip Technology Inc.                        Preliminary                                               DS30498B-page 11
PIC16F7X7
TABLE 1-3:           PIC16F747 AND PIC16F777 PINOUT DESCRIPTION (CONTINUED)
                              PDIP     QFN     TQFP     I/O/P     Buffer
          Pin Name                                                                                 Description
                              Pin #    Pin #   Pin #    Type      Type
                                                                             PORTB is a bidirectional I/O port. PORTB can be
                                                                             software programmed for internal weak pull-up on all
                                                                             inputs.
RB0/INT/AN12                   33        9        8              TTL/ST(1)
   RB0                                                   I/O                     Digital I/O.
   INT                                                     I                     External interrupt.
   AN12                                                    I                     Analog input channel 12.
RB1/AN10                       34       10        9                 TTL
   RB1                                                   I/O                     Digital I/O.
   AN10                                                    I                     Analog input channel 10.
RB2/AN8                        35       11       10                 TTL
   RB2                                                   I/O                     Digital I/O.
   AN8                                                     I                     Analog input channel 8.
RB3/CCP2/AN9                   36       12       11                 TTL
   RB3                                                   I/O                     Digital I/O.
   CCP2                                                  I/O                     CCP2 capture input, compare output, PWM output.
   AN9                                                     I                     Analog input channel 9.
RB4/AN11                       37       14       14                 TTL
   RB4                                                   I/O                     Digital I/O.
   AN11                                                    I                     Analog input channel 11
RB5/AN13/CCP3                  38       15       15                 TTL
   RB5                                                   I/O                     Digital I/O.
   AN13                                                    I                     Analog input channel 13.
   CCP3                                                    I                     CCP3 capture input, compare output, PWM output.
RB6/PGC                        39       16       16              TTL/ST(2)
   RB6                                                   I/O                     Digital I/O.
   PGC                                                   I/O                     In-circuit debugger and ICSP programming clock.
RB7/PGD                        40       17       17              TTL/ST(2)
   RB7                                                   I/O                     Digital I/O.
   PGD                                                   I/O                     In-circuit debugger and ICSP programming data.
Legend:     I = input                    O = output                 I/O = input/output                 P = power
            — = Not used                 TTL = TTL input            ST = Schmitt Trigger input
Note 1:     This buffer is a Schmitt Trigger input when configured as an external interrupt.
     2:     This buffer is a Schmitt Trigger input when used in Serial Programming mode.
     3:     This buffer is a Schmitt Trigger input when configured as a general purpose I/O and a TTL input when used in the Parallel
            Slave Port mode (for interfacing to a microprocessor bus).
      4:    This buffer is a Schmitt Trigger input when configured in RC Oscillator mode and a CMOS input otherwise.
DS30498B-page 12                                        Preliminary                                2003 Microchip Technology Inc.
                                                                                                    PIC16F7X7
TABLE 1-3:           PIC16F747 AND PIC16F777 PINOUT DESCRIPTION (CONTINUED)
                              PDIP     QFN     TQFP     I/O/P     Buffer
          Pin Name                                                                                 Description
                              Pin #    Pin #   Pin #    Type      Type
                                                                             PORTC is a bidirectional I/O port.
RC0/T1OSO/T1CKI                15       34       32                 ST
   RC0                                                   I/O                     Digital I/O.
   T1OSO                                                  O                      Timer1 oscillator output.
   T1CKI                                                   I                     Timer1 external clock input.
RC1/T1OSI/CCP2                 16       35       35                 ST
   RC1                                                   I/O                     Digital I/O.
   T1OSI                                                   I                     Timer1 oscillator input.
   CCP2                                                  I/O                     Capture2 input, Compare2 output, PWM2 output.
RC2/CCP1                       17       36       36                 ST
   RC2                                                   I/O                     Digital I/O.
   CCP1                                                  I/O                     Capture1 input, Compare1 output, PWM1 output.
RC3/SCK/SCL                    18       37       37                 ST
   RC3                                                   I/O                     Digital I/O.
   SCK                                                   I/O                     Synchronous serial clock input/output for SPI mode.
   SCL                                                   I/O                     Synchronous serial clock input/output for I2C mode.
RC4/SDI/SDA                    23       42       42                 ST
   RC4                                                   I/O                     Digital I/O.
   SDI                                                     I                     SPI data in.
   SDA                                                   I/O                     I2C data I/O.
RC5/SDO                        24       43       43                 ST
   RC5                                                   I/O                     Digital I/O.
   SDO                                                    O                      SPI data out.
RC6/TX/CK                      25       44       44                 ST
   RC6                                                   I/O                     Digital I/O.
   TX                                                     O                      USART asynchronous transmit.
   CK                                                    I/O                     USART1 synchronous clock.
RC7/RX/DT                      26        1        1                 ST
   RC7                                                   I/O                     Digital I/O.
   RX                                                      I                     USART asynchronous receive.
   DT                                                    I/O                     USART synchronous data.
Legend:     I = input                    O = output                 I/O = input/output                 P = power
            — = Not used                 TTL = TTL input            ST = Schmitt Trigger input
Note 1:     This buffer is a Schmitt Trigger input when configured as an external interrupt.
     2:     This buffer is a Schmitt Trigger input when used in Serial Programming mode.
     3:     This buffer is a Schmitt Trigger input when configured as a general purpose I/O and a TTL input when used in the Parallel
            Slave Port mode (for interfacing to a microprocessor bus).
       4:   This buffer is a Schmitt Trigger input when configured in RC Oscillator mode and a CMOS input otherwise.
 2003 Microchip Technology Inc.                        Preliminary                                               DS30498B-page 13
PIC16F7X7
TABLE 1-3:           PIC16F747 AND PIC16F777 PINOUT DESCRIPTION (CONTINUED)
                              PDIP     QFN     TQFP     I/O/P     Buffer
          Pin Name                                                                                 Description
                              Pin #    Pin #   Pin #    Type      Type
                                                                             PORTD is a bidirectional I/O port or Parallel Slave Port
                                                                             when interfacing to a microprocessor bus.
RD0/PSP0                       19       38       38              ST/TTL(3)
   RD0                                                   I/O                     Digital I/O.
   PSP0                                                  I/O                     Parallel Slave Port data.
RD1/PSP1                       20       39       39              ST/TTL(3)
   RD1                                                   I/O                     Digital I/O.
   PSP1                                                  I/O                     Parallel Slave Port data.
RD2/PSP2                       21       40       40              ST/TTL(3)
   RD2                                                   I/O                     Digital I/O.
   PSP2                                                  I/O                     Parallel Slave Port data.
RD3/PSP3                       22       41       41              ST/TTL(3)
   RD3                                                   I/O                     Digital I/O.
   PSP3                                                  I/O                     Parallel Slave Port data.
RD4/PSP4                       27        2        2              ST/TTL(3)
   RD4                                                   I/O                     Digital I/O.
   PSP4                                                  I/O                     Parallel Slave Port data.
RD5/PSP5                       28        3        3              ST/TTL(3)
   RD5                                                   I/O                     Digital I/O.
   PSP5                                                  I/O                     Parallel Slave Port data.
RD6/PSP6                       29        4        4              ST/TTL(3)
   RD6                                                   I/O                     Digital I/O.
   PSP6                                                  I/O                     Parallel Slave Port data.
RD7/PSP7                       30        5        5              ST/TTL(3)
   RD7                                                   I/O                     Digital I/O.
   PSP7                                                  I/O                     Parallel Slave Port data.
                                                                             PORTE is a bidirectional I/O port.
RE0/RD/AN5                      8       25       25              ST/TTL(3)
   RE0                                                   I/O                     Digital I/O.
   RD                                                      I                     Read control for Parallel Slave Port.
   AN5                                                     I                     Analog input 5.
RE1/WR/AN6                      9       26       26              ST/TTL(3)
   RE1                                                   I/O                     Digital I/O.
   WR                                                      I                     Write control for Parallel Slave Port.
   AN6                                                     I                     Analog input 6.
RE2/CS/AN7                     10       27       27              ST/TTL(3)
   RE2                                                   I/O                     Digital I/O.
   CS                                                      I                     Chip select control for Parallel Slave Port.
   AN7                                                     I                     Analog input 7.
VSS                            —        31       —        P          —       Analog ground reference.
VSS                          12, 31    6, 30    6, 29     P          —       Ground reference for logic and I/O pins.
VDD                            —         8       —        P          —       Analog positive supply.
VDD                           11, 32   7, 28    7, 28     P          —       Positive supply for logic and I/O pins.
NC                             —       13, 29 12, 13,     —          —       These pins are not internally connected. These pins
                                              33, 34                         should be left unconnected.
Legend:     I = input                    O = output                 I/O = input/output                 P = power
            — = Not used                 TTL = TTL input            ST = Schmitt Trigger input
Note 1:     This buffer is a Schmitt Trigger input when configured as an external interrupt.
     2:     This buffer is a Schmitt Trigger input when used in Serial Programming mode.
     3:     This buffer is a Schmitt Trigger input when configured as a general purpose I/O and a TTL input when used in the Parallel
            Slave Port mode (for interfacing to a microprocessor bus).
      4:    This buffer is a Schmitt Trigger input when configured in RC Oscillator mode and a CMOS input otherwise.
DS30498B-page 14                                        Preliminary                                2003 Microchip Technology Inc.
                                                                                             PIC16F7X7
2.0      MEMORY ORGANIZATION                                       2.2      Data Memory Organization
There are two memory blocks in each of these                       The data memory is partitioned into multiple banks
PICmicro® MCUs. The program memory and data                        which contain the General Purpose Registers and the
memory have separate buses so that concurrent                      Special Function Registers. Bits RP1 (Status<6>) and
access can occur and is detailed in this section. The              RP0 (Status<5>) are the bank select bits:
program memory can be read internally by user code
(see Section 3.0 “Reading Program Memory”).                                 RP1:RP0                       Bank
Additional information on device memory may be found                            00                          0
in the PICmicro® Mid-Range MCU Family Reference                                 01                          1
Manual (DS33023).                                                               10                          2
                                                                                11                          3
2.1      Program Memory Organization
                                                                   Each bank extends up to 7Fh (128 bytes). The lower
The PIC16F7X7 devices have a 13-bit program counter                locations of each bank are reserved for the Special
capable of addressing an 8K word x 14-bit program                  Function Registers. Above the Special Function Regis-
memory space. The PIC16F767/777 devices have                       ters are General Purpose Registers, implemented as
8K words of Flash program memory and the                           static RAM. All implemented banks contain Special
PIC16F737/747 devices have 4K words. The program                   Function Registers. Some frequently used Special
memory maps for PIC16F7X7 devices are shown in                     Function Registers from one bank may be mirrored in
Figure 2-1. Accessing a location above the physically              another bank for code reduction and quicker access.
implemented address will cause a wraparound.
The Reset vector is at 0000h and the interrupt vector is           2.2.1      GENERAL PURPOSE REGISTER
at 0004h.                                                                     FILE
                                                                   The register file (shown in Figure 2-2 and Figure 2-3)
                                                                   can be accessed either directly, or indirectly, through
                                                                   the File Select Register (FSR).
FIGURE 2-1:            PROGRAM MEMORY MAPS AND STACKS FOR PIC16F7X7 DEVICES
                                        PC<12:0>
                           CALL, RETURN            13
                           RETFIE, RETLW
                                       Stack Level 1
                                       Stack Level 2
                                       Stack Level 8
                                       Reset Vector        0000h
                                      Interrupt Vector     0004h
                                                           0005h
                                          Page 0
                                                           07FFh      Memory available on all
                                                           0800h      PIC16F7X7.
                                          Page 1
                      On-Chip
                                                           0FFFh
                      Program
                      Memory                               1000h
                                          Page2                       Memory available on PIC16F767
                                                           17FFh      and PIC16F777. The memory
                                                           1800h      wraps to 000h through 0FFFh on
                                          Page 3                      the PIC16F737 and PIC16F747.
                                                           1FFFh
 2003 Microchip Technology Inc.                       Preliminary                                     DS30498B-page 15
PIC16F7X7
FIGURE 2-2:            DATA MEMORY MAP FOR PIC16F737 AND THE PIC16F767
                         File                      File                          File                       File
                       Address                   Address                       Address                    Address
       Indirect addr.(*)   00h   Indirect addr.(*)   80h   Indirect addr.(*)    100h      Indirect addr.(*)   180h
            TMR0           01h   OPTION_REG          81h       TMR0             101h      OPTION_REG          181h
             PCL           02h         PCL           82h        PCL             102h           PCL            182h
           STATUS          03h       STATUS          83h      STATUS            103h          STATUS          183h
             FSR           04h         FSR           84h       FSR              104h           FSR            184h
           PORTA           05h        TRISA          85h      WDTCON            105h                          185h
           PORTB           06h        TRISB          86h       PORTB            106h           TRISB          186h
           PORTC           07h        TRISC          87h                        107h                          187h
                           08h                       88h                        108h                          188h
            PORTE          09h        TRISE          89h      LVDCON            109h                          189h
           PCLATH          0Ah      PCLATH           8Ah      PCLATH            10Ah         PCLATH           18Ah
           INTCON          0Bh      INTCON           8Bh      INTCON            10Bh         INTCON           18Bh
             PIR1          0Ch        PIE1           8Ch      PMDATA            10Ch         PMCON1           18Ch
             PIR2          0Dh        PIE2           8Dh       PMADR            10Dh                          18Dh
            TMR1L          0Eh       PCON            8Eh      PMDATH            10Eh                          18Eh
            TMR1H          0Fh      OSCCON           8Fh      PMADRH            10Fh                          18Fh
            T1CON          10h     OSCTUNE           90h                        110h                          190h
            TMR2           11h      SSPCON2          91h
            T2CON          12h        PR2            92h
           SSPBUF          13h      SSPADD           93h
           SSPCON          14h      SSPSTAT          94h
            CCPR1L         15h     CCPR3L            95h
            CCPR1H         16h     CCPR3H            96h
                                                              General                         General
           CCP1CON         17h     CCP3CON           97h      Purpose                         Purpose
            RCSTA          18h       TXSTA           98h      Register                        Register
            TXREG          19h       SPBRG           99h      16 Bytes                        16 Bytes
            RCREG          1Ah                       9Ah
           CCPR2L          1Bh     ADCON2            9Bh
            CCPR2H         1Ch     CMCON             9Ch
           CCP2CON         1Dh     CVRCON            9Dh
           ADRESH          1Eh      ADRESL           9Eh
           ADCON0          1Fh      ADCON1           9Fh                        11Fh                          19Fh
                           20h                       A0h                        120h                          1A0h
                                    General                   General                         General
                                    Purpose                   Purpose                         Purpose
           General                  Register                  Register                        Register
           Purpose                  80 Bytes                  80 Bytes                        80 Bytes
           Register                                  EFh                        16Fh                          1EFh
                                                     F0h                        170h                          1F0h
           96 Bytes
                                    accesses                  accesses                        accesses
                                    70h-7Fh                   70h-7Fh                         70h-7Fh
                           7Fh                       FFh                        17Fh                          1FFh
           Bank 0                    Bank 1                   Bank 2                           Bank 3
           Unimplemented data memory locations read as ‘0’.
       *   Not a physical register.
DS30498B-page 16                                 Preliminary                            2003 Microchip Technology Inc.
                                                                                               PIC16F7X7
FIGURE 2-3:             DATA MEMORY MAP FOR PIC16F747 AND THE PIC16F777
                          File                           File                          File                      File
                        Address                        Address                       Address                   Address
        Indirect addr.(*)   00h    Indirect addr.(*)    80h      Indirect addr.(*)    100h     Indirect addr.(*)   180h
              TMR0          01h    OPTION_REG           81h          TMR0             101h      OPTION_REG         181h
               PCL          02h          PCL            82h           PCL             102h          PCL            182h
            STATUS          03h        STATUS           83h         STATUS            103h         STATUS          183h
               FSR          04h          FSR            84h          FSR              104h          FSR            184h
             PORTA          05h         TRISA           85h         WDTCON            105h                         185h
             PORTB          06h         TRISB           86h          PORTB            106h         TRISB           186h
             PORTC          07h         TRISC           87h                           107h                         187h
             PORTD          08h         TRISD           88h                           108h                         188h
             PORTE          09h         TRISE           89h         LVDCON            109h                         189h
           PCLATH           0Ah       PCLATH            8Ah         PCLATH            10Ah         PCLATH          18Ah
            INTCON          0Bh       INTCON            8Bh         INTCON            10Bh         INTCON          18Bh
              PIR1          0Ch         PIE1            8Ch         PMDATA            10Ch        PMCON1           18Ch
              PIR2          0Dh         PIE2            8Dh          PMADR            10Dh                         18Dh
             TMR1L          0Eh        PCON             8Eh         PMDATH            10Eh                         18Eh
             TMR1H          0Fh       OSCCON            8Fh         PMADRH            10Fh                         18Fh
             T1CON          10h      OSCTUNE            90h                           110h                         190h
             TMR2           11h       SSPCON2           91h
             T2CON          12h         PR2             92h
            SSPBUF          13h       SSPADD            93h
            SSPCON          14h       SSPSTAT           94h
             CCPR1L         15h      CCPR3L             95h
             CCPR1H         16h      CCPR3H             96h
                                                                    General                       General
            CCP1CON         17h      CCP3CON            97h         Purpose                       Purpose
             RCSTA          18h        TXSTA            98h         Register                      Register
             TXREG          19h        SPBRG            99h         16 Bytes                      16 Bytes
             RCREG          1Ah                         9Ah
            CCPR2L          1Bh      ADCON2             9Bh
             CCPR2H         1Ch      CMCON              9Ch
            CCP2CON         1Dh      CVRCON             9Dh
            ADRESH          1Eh       ADRESL            9Eh
            ADCON0          1Fh       ADCON1            9Fh                           11Fh                         19Fh
                            20h                         A0h                           120h                         1A0h
                                      General                       General                       General
                                      Purpose                       Purpose                       Purpose
            General                   Register                      Register                      Register
            Purpose                   80 Bytes                      80 Bytes                      80 Bytes
            Register                                    EFh                           16Fh                         1EFh
                                                        F0h                           170h                         1F0h
            96 Bytes
                                      accesses                      accesses                      accesses
                                      70h-7Fh                       70h-7Fh                       70h-7Fh
                            7Fh                         FFh                           17Fh                         1FFh
             Bank 0                    Bank 1                       Bank 2                         Bank 3
            Unimplemented data memory locations read as ‘0’.
        *   Not a physical register.
 2003 Microchip Technology Inc.                   Preliminary                                           DS30498B-page 17
PIC16F7X7
2.2.2         SPECIAL FUNCTION REGISTERS                                    The Special Function Registers can be classified into
                                                                            two sets: core (CPU) and peripheral. Those registers
The Special Function Registers are registers used by
                                                                            associated with the core functions are described in
the CPU and peripheral modules for controlling the
                                                                            detail in this section. Those related to the operation of
desired operation of the device. These registers are
                                                                            the peripheral features are described in detail in the
implemented as static RAM. A list of these registers is
                                                                            peripheral feature section.
given in Table 2-1.
TABLE 2-1:           SPECIAL FUNCTION REGISTER SUMMARY
                                                                                                                          Value on:   Details
Address       Name        Bit 7         Bit 6      Bit 5        Bit 4        Bit 3       Bit 2         Bit 1      Bit 0
                                                                                                                          POR, BOR    on page
  Bank 0
00h(4)     INDF         Addressing this location uses contents of FSR to address data memory (not a physical register) 0000 0000      30, 180
01h        TMR0         Timer0 Module Register                                                                            xxxx xxxx   76, 180
02h(4)     PCL          Program Counter (PC) Least Significant Byte                                                       0000 0000   29, 180
03h(4)     STATUS          IRP          RP1         RP0          TO           PD          Z            DC          C      0001 1xxx   21, 180
04h(4)     FSR          Indirect Data Memory Address Pointer                                                              xxxx xxxx   30, 180
05h        PORTA        PORTA Data Latch when written: PORTA pins when read                                               xx0x 0000   55, 180
06h        PORTB        PORTB Data Latch when written: PORTB pins when read                                               xx00 0000   64, 180
07h        PORTC        PORTC Data Latch when written: PORTC pins when read                                               xxxx xxxx   66, 180
08h(5)     PORTD        PORTD Data Latch when written: PORTD pins when read                                               xxxx xxxx   67, 180
09h(5)     PORTE           —             —          —            —           RE3         RE2           RE1        RE0     ---- x000   68, 180
0Ah(1,4) PCLATH            —             —          —      Write Buffer for the upper 5 bits of the Program Counter       ---0 0000   29, 180
0Bh(4)     INTCON         GIE           PEIE     TMR0IE        INT0IE        RBIE      TMR0IF         INT0IF      RBIF    0000 000x   23, 180
0Ch        PIR1                  (3)    ADIF       RCIF         TXIF        SSPIF      CCP1IF         TMR2IF    TMR1IF    0000 0000   25, 180
                        PSPIF
0Dh        PIR2          OSFIF          CMIF       LVDIF         —          BCLIF         —           CCP3IF    CCP2IF    000- 0-00   27, 180
0Eh        TMR1L        Holding Register for the Least Significant Byte of the 16-bit TMR1 Register                       xxxx xxxx   83, 180
0Fh        TMR1H        Holding Register for the Most Significant Byte of the 16-bit TMR1 Register                        xxxx xxxx   83, 180
10h        T1CON           —           T1RUN    T1CKPS1      T1CKPS0      T1OSCEN T1SYNC             TMR1CS TMR1ON -000 0000          83, 180
11h        TMR2         Timer2 Module Register                                                                            0000 0000   86, 180
12h        T2CON           —           TOUTPS3 TOUTPS2       TOUTPS1      TOUTPS0 TMR2ON T2CKPS1 T2CKPS0 -000 0000                    86, 180
13h        SSPBUF       Synchronous Serial Port Receive Buffer/Transmit Register                                          xxxx xxxx 101, 180
14h        SSPCON        WCOL          SSPOV       SSPEN        CKP        SSPM3       SSPM2          SSPM1     SSPM0     0000 0000 101, 180
15h        CCPR1L       Capture/Compare/PWM Register 1 (LSB)                                                              xxxx xxxx   90, 180
16h        CCPR1H       Capture/Compare/PWM Register 1 (MSB)                                                              xxxx xxxx   90, 180
17h        CCP1CON         —             —         CCP1X       CCP1Y       CCP1M3      CCP1M2        CCP1M1     CCP1M0 --00 0000      88, 180
18h        RCSTA         SPEN           RX9        SREN        CREN        ADDEN        FERR          OERR       RX9D     0000 000x 134, 180
19h        TXREG        USART Transmit Data Register                                                                      0000 0000 139, 180
1Ah        RCREG        USART Receive Data Register                                                                       0000 0000 141, 180
1Bh        CCPR2L       Capture/Compare/PWM Register 2 (LSB)                                                              xxxx xxxx   92, 180
1Ch        CCPR2H       Capture/Compare/PWM Register 2 (MSB)                                                              xxxx xxxx   92, 180
1Dh        CCP2CON         —             —         CCP2X       CCP2Y       CCP2M3      CCP2M2        CCP2M1     CCP2M0 --00 0000      88, 180
1Eh        ADRESH       A/D Result Register Byte                                                                          xxxx xxxx 160, 180
1Fh        ADCON0        ADCS1         ADCS0       CHS2        CHS1         CHS0      GO/DONE         CHS3       ADON     0000 0000 152, 180
Legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ‘0’, r = reserved.
        Shaded locations are unimplemented, read as ‘0’.
Note 1: The upper byte of the program counter is not directly accessible. PCLATH is a holding register for the PC<12:8>, whose contents are
        transferred to the upper byte of the program counter during branches (CALL or GOTO).
     2: Other (non Power-up) Resets include external Reset through MCLR and Watchdog Timer Reset.
     3: Bits PSPIE and PSPIF are reserved on the 28-pin devices; always maintain these bits clear.
     4: These registers can be addressed from any bank.
     5: PORTD, PORTE, TRISD and TRISE are not physically implemented on the 28-pin devices (except for RE3), read as ‘0’.
     6: This bit always reads as a ‘1’.
     7: OSCON<OSTS> bit resets to ‘0’ with dual-speed start-up and LP, HS or HS-PLL selected as the oscillator.
     8: RE3 is an input only. The state of the TRISE3 bit has no effect and will always read ‘1’.
DS30498B-page 18                                            Preliminary                                      2003 Microchip Technology Inc.
                                                                                                               PIC16F7X7
TABLE 2-1:            SPECIAL FUNCTION REGISTER SUMMARY (CONTINUED)
                                                                                                                           Value on:   Details
Address       Name        Bit 7          Bit 6     Bit 5        Bit 4        Bit 3          Bit 2      Bit 1      Bit 0
                                                                                                                           POR, BOR    on page
  Bank 1
80h(4)     INDF         Addressing this location uses contents of FSR to address data memory (not a physical register) 0000 0000       30, 180
81h        OPTION_REG    RBPU           INTEDG    T0CS         T0SE          PSA            PS2        PS1        PS0      1111 1111   22, 180
82h(4)     PCL          Program Counter’s (PC) Least Significant Byte                                                      0000 0000   29, 180
83h(4)     STATUS          IRP            RP1      RP0           TO           PD              Z         DC            C    0001 1xxx   21, 180
84h(4)     FSR          Indirect Data Memory Address Pointer                                                               xxxx xxxx   30, 180
85h        TRISA        PORTA Data Direction Register                                                                      1111 1111   55, 181
86h        TRISB        PORTB Data Direction Register                                                                      1111 1111   64, 181
87h        TRISC        PORTC Data Direction Register                                                                      1111 1111   66, 181
88h(5)     TRISD        PORTD Data Direction Register                                                                      1111 1111   67, 181
89h(5)     TRISE          IBF   (5)      OBF(5)   IBOV(5)   PSPMODE(5)       —(8)         PORTE Data Direction bits        0000 1111   69, 181
8Ah(1,4) PCLATH            —               —        —       Write Buffer for the upper 5 bits of the Program Counter       ---0 0000   23, 180
8Bh(4)     INTCON         GIE            PEIE     TMR0IE       INT0IE        RBIE          TMR0IF     INT0IF      RBIF     0000 000x   25, 180
8Ch        PIE1                   (3)    ADIE      RCIE         TXIE        SSPIE          CCP1IE    TMR2IE     TMR1IE     0000 0000   24, 181
                        PSPIE
8Dh        PIE2          OSFIE           CMIE     LVDIE          —          BCLIE            —        CCP3IE    CCP2IE     000- 0-00   26, 181
8Eh        PCON            —               —        —            —            —           SBOREN       POR        BOR      ---- -1qq   28, 181
8Fh        OSCCON          —             IRCF2    IRCF1        IRCF0       OSTS     (8)     IOFS       SCS1      SCS0      -000 1000   38, 181
90h        OSCTUNE         —               —      TUN5         TUN4         TUN3            TUN2       TUN1      TUN0      --00 0000   36, 181
91h        SSPCON2       GCEN           ACKSTAT   ACKDT        ACKEN        RCEN            PEN       RSEN        SEN      0000 0000    105
92h        PR2          Timer2 Period Register                                                                             1111 1111   86, 181
93h        SSPADD       Synchronous Serial Port (I2C mode) Address Register                                                0000 0000 101, 181
94h        SSPSTAT        SMP            CKE       D/A           P             S            R/W         UA            BF   0000 0000 101, 181
95h        CCPR3L       Capture/Compare/PWM Register 1 (LSB)                                                               xxxx xxxx     92
96h        CCPR3H       Capture/Compare/PWM Register 1 (MSB)                                                               xxxx xxxx     92
97h        CCP3CON         —               —      CCP3X        CCP3Y       CCP3M3         CCP3M2     CCP3M1     CCP3M0 --00 0000         92
98h        TXSTA         CSRC             TX9     TXEN         SYNC           —            BRGH       TRMT       TX9D      0000 -010 145, 181
99h        SPBRG        Baud Rate Generator Register                                                                       0000 0000 145, 181
9Ah               —     Unimplemented                                                                                          —         —
9Bh        ADCON2          —               —      ACQT2        ACQT1        ACQT0            —          —             —    --00 0---    154
9Ch        CMCON         C2OUT          C1OUT     C2INV        C1INV          CIS           CM2        CM1        CM0      0000 0111   55, 161
9Dh        CVRCON        CVREN          CVROE     CVRR           —          CVR3            CVR2      CVR1       CVR0      000- 0000   55, 167
9Eh        ADRESL       A/D Result Register Low Byte                                                                       xxxx xxxx    180
9Fh        ADCON1        ADFM           ADCS2     VCFG1        VCFG0        PCFG3          PCFG2      PCFG1      PCFG0     0000 0000 153, 181
Legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ‘0’, r = reserved.
        Shaded locations are unimplemented, read as ‘0’.
Note 1: The upper byte of the program counter is not directly accessible. PCLATH is a holding register for the PC<12:8>, whose contents are
        transferred to the upper byte of the program counter during branches (CALL or GOTO).
     2: Other (non Power-up) Resets include external Reset through MCLR and Watchdog Timer Reset.
     3: Bits PSPIE and PSPIF are reserved on the 28-pin devices; always maintain these bits clear.
     4: These registers can be addressed from any bank.
     5: PORTD, PORTE, TRISD and TRISE are not physically implemented on the 28-pin devices (except for RE3), read as ‘0’.
     6: This bit always reads as a ‘1’.
     7: OSCON<OSTS> bit resets to ‘0’ with dual-speed start-up and LP, HS or HS-PLL selected as the oscillator.
     8: RE3 is an input only. The state of the TRISE3 bit has no effect and will always read ‘1’.
 2003 Microchip Technology Inc.                            Preliminary                                                    DS30498B-page 19
PIC16F7X7
TABLE 2-1:                SPECIAL FUNCTION REGISTER SUMMARY (CONTINUED)
                                                                                                                           Value on:   Details
Address          Name         Bit 7      Bit 6         Bit 5       Bit 4        Bit 3       Bit 2       Bit 1      Bit 0
                                                                                                                           POR, BOR    on page
 Bank 2
100h(4)        INDF         Addressing this location uses contents of FSR to address data memory (not a physical register) 0000 0000   30, 180
101h           TMR0         Timer0 Module Register                                                                         xxxx xxxx   76, 180
102h(4)        PCL          Program Counter (PC) Least Significant Byte                                                    0000 0000   29, 180
103h(4)        STATUS         IRP        RP1           RP0          TO           PD           Z         DC           C     0001 1xxx   21, 180
104h(4)        FSR          Indirect Data Memory Address Pointer                                                           xxxx xxxx   30, 180
105h           WDTCON          —          —             —       WDTPS3        WDTPS2 WDTPS1 WDTPS0 SWDTEN ---0 1000                      187
106h           PORTB        PORTB Data Latch when written: PORTB pins when read                                            xxxx xxxx   64, 180
107h                  —     Unimplemented                                                                                      —         —
108h                  —     Unimplemented                                                                                      —         —
109h           LVDCON          —          —            IRVST       LVDEN       LVDL3       LVDL2       LVDL1      LVDL0    --00 0101     176
10Ah(1,4) PCLATH               —          —             —      Write Buffer for the upper 5 bits of the Program Counter    ---0 0000   23, 180
10Bh(4)        INTCON         GIE        PEIE        TMR0IE        INT0IE       RBIE      TMR0IF       INT0IF      RBIF    0000 000x   25, 180
10Ch           PMDATA       EEPROM Data Register Low Byte                                                                  xxxx xxxx   32, 181
10Dh           PMADR        EEPROM Address Register Low Byte                                                               xxxx xxxx   32, 181
10Eh           PMDATH          —          —       EEPROM Data Register High Byte                                           --xx xxxx   32, 181
10Fh           PMADRH          —          —             —            —       EEPROM Address Register High Byte             ---- xxxx   32, 181
 Bank 3
180h(4)        INDF         Addressing this location uses contents of FSR to address data memory (not a physical register) 0000 0000   30, 180
181h           OPTION_REG    RBPU      INTEDG          T0CS        T0SE         PSA         PS2         PS1         PS0    1111 1111   22, 180
182h(4)        PCL          Program Counter (PC) Least Significant Byte                                                    0000 0000   29, 180
183h(4)        STATUS         IRP        RP1           RP0          TO           PD           Z         DC           C     0001 1xxx   21, 180
184h(4)        FSR          Indirect Data Memory Address Pointer                                                           xxxx xxxx   30, 180
185h                  —     Unimplemented                                                                                      —         —
186h           TRISB        PORTB Data Direction Register                                                                  1111 1111   64, 181
187h                  —     Unimplemented                                                                                      —         —
188h                  —     Unimplemented                                                                                      —         —
189h                  —     Unimplemented                                                                                      —         —
       (1,4)   PCLATH          —          —             —      Write Buffer for the upper 5 bits of the Program Counter    ---0 0000   23, 180
18Ah
18Bh(4)        INTCON         GIE        PEIE        TMR0IE        INT0IE       RBIE      TMR0IF       INT0IF      RBIF    0000 000x   25, 180
18Ch           PMCON1          —          —             —            —           —           —           —          RD     ---- ---0   32, 181
18Dh                  —     Reserved, maintain clear                                                                       0000 0000     —
18Eh                  —     Reserved, maintain clear                                                                       0000 0000     —
18Fh                  —     Reserved, maintain clear                                                                       0000 0000     —
Legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ‘0’, r = reserved.
        Shaded locations are unimplemented, read as ‘0’.
Note 1: The upper byte of the program counter is not directly accessible. PCLATH is a holding register for the PC<12:8>, whose contents are
        transferred to the upper byte of the program counter during branches (CALL or GOTO).
     2: Other (non Power-up) Resets include external Reset through MCLR and Watchdog Timer Reset.
     3: Bits PSPIE and PSPIF are reserved on the 28-pin devices; always maintain these bits clear.
     4: These registers can be addressed from any bank.
     5: PORTD, PORTE, TRISD and TRISE are not physically implemented on the 28-pin devices (except for RE3), read as ‘0’.
     6: This bit always reads as a ‘1’.
     7: OSCON<OSTS> bit resets to ‘0’ with dual-speed start-up and LP, HS or HS-PLL selected as the oscillator.
     8: RE3 is an input only. The state of the TRISE3 bit has no effect and will always read ‘1’.
DS30498B-page 20                                               Preliminary                                    2003 Microchip Technology Inc.
                                                                                                   PIC16F7X7
2.2.2.1       Status Register                                         For example, CLRF STATUS, will clear the upper three
                                                                      bits and set the Z bit. This leaves the Status register as
The Status register contains the arithmetic status of the
                                                                      000u u1uu (where u = unchanged).
ALU, the Reset status and the bank select bits for data
memory.                                                               It is recommended, therefore, that only BCF, BSF,
                                                                      SWAPF and MOVWF instructions are used to alter the
The Status register can be the destination for any
                                                                      Status register because these instructions do not affect
instruction, as with any other register. If the Status reg-
                                                                      the Z, C or DC bits from the Status register. For other
ister is the destination for an instruction that affects the
                                                                      instructions not affecting any Status bits, see
Z, DC or C bits, then the write to these three bits is dis-
                                                                      Section 16.0 “Instruction Set Summary”.
abled. These bits are set or cleared according to the
device logic. Furthermore, the TO and PD bits are not                      Note 1: The C and DC bits operate as a borrow
writable, therefore, the result of an instruction with the                         and digit borrow bit, respectively, in sub-
Status register as destination may be different than                               traction. See the SUBLW and SUBWF
intended.                                                                          instructions for examples.
REGISTER 2-1:           STATUS REGISTER (ADDRESS 03h, 83h, 103h, 183h)
                           R/W-0         R/W-0         R/W-0           R-1           R-1       R/W-x      R/W-x       R/W-x
                            IRP           RP1           RP0            TO            PD           Z        DC           C
                         bit 7                                                                                              bit 0
             bit 7       IRP: Register Bank Select bit (used for indirect addressing)
                         1 = Bank 2, 3 (100h-1FFh)
                         0 = Bank 0, 1 (00h-FFh)
             bit 6-5     RP1:RP0: Register Bank Select bits (used for direct addressing)
                         11 = Bank 3 (180h-1FFh)
                         10 = Bank 2 (100h-17Fh)
                         01 = Bank 1 (80h-FFh)
                         00 = Bank 0 (00h-7Fh)
                         Each bank is 128 bytes.
             bit 4       TO: Time-out bit
                         1 = After power-up, CLRWDT instruction or SLEEP instruction
                         0 = A WDT time-out occurred
             bit 3       PD: Power-down bit
                         1 = After power-up or by the CLRWDT instruction
                         0 = By execution of the SLEEP instruction
             bit 2       Z: Zero bit
                         1 = The result of an arithmetic or logic operation is zero
                         0 = The result of an arithmetic or logic operation is not zero
             bit 1       DC: Digit Carry/borrow bit (ADDWF, ADDLW, SUBLW, SUBWF instructions)
                         1 = A carry-out from the 4th low order bit of the result occurred
                         0 = No carry-out from the 4th low order bit of the result
             bit 0       C: Carry/borrow bit (ADDWF, ADDLW, SUBLW, SUBWF instructions)
                         1 = A carry-out from the Most Significant bit of the result occurred
                         0 = No carry-out from the Most Significant bit of the result occurred
                           Note:      For borrow, the polarity is reversed. A subtraction is executed by adding the two’s
                                      complement of the second operand. For rotate (RRF, RLF) instructions, this bit is
                                      loaded with either the high or low order bit of the source register.
                        Legend:
                        R = Readable bit                W = Writable bit         U = Unimplemented bit, read as ‘0’
                        - n = Value at POR              ‘1’ = Bit is set         ‘0’ = Bit is cleared   x = Bit is unknown
 2003 Microchip Technology Inc.                       Preliminary                                          DS30498B-page 21
PIC16F7X7
2.2.2.2       OPTION_REG Register                                          Note:    To achieve a 1:1 prescaler assignment for
The OPTION_REG register is a readable and writable                                  the TMR0 register, assign the prescaler to
register which contains various control bits to configure                           the Watchdog Timer.
the TMR0 prescaler/WDT postscaler (single assign-
able register known also as the prescaler), the external
INT interrupt, TMR0 and the weak pull-ups on PORTB.
REGISTER 2-2:          OPTION_REG REGISTER (ADDRESS 81h, 181h)
                          R/W-1         R/W-1          R/W-1          R/W-1         R/W-1        R/W-1      R/W-1       R/W-1
                          RBPU          INTEDG         T0CS           T0SE           PSA          PS2        PS1         PS0
                        bit 7                                                                                               bit 0
            bit 7       RBPU: PORTB Pull-up Enable bit
                        1 = PORTB pull-ups are disabled
                        0 = PORTB pull-ups are enabled by individual port latch values
            bit 6       INTEDG: Interrupt Edge Select bit
                        1 = Interrupt on rising edge of RB0/INT pin
                        0 = Interrupt on falling edge of RB0/INT pin
            bit 5       T0CS: TMR0 Clock Source Select bit
                        1 = Transition on RA4/T0CKI pin
                        0 = Internal instruction cycle clock (CLKO)
            bit 4       T0SE: TMR0 Source Edge Select bit
                        1 = Increment on high-to-low transition on RA4/T0CKI pin
                        0 = Increment on low-to-high transition on RA4/T0CKI pin
            bit 3       PSA: Prescaler Assignment bit
                        1 = Prescaler is assigned to the WDT
                        0 = Prescaler is assigned to the Timer0 module
            bit 2-0     PS2:PS0: Prescaler Rate Select bits
                                Bit Value   TMR0 Rate WDT Rate
                                  000        1:2            1:1
                                  001        1:4            1:2
                                  010        1:8            1:4
                                  011        1 : 16         1:8
                                  100        1 : 32         1 : 16
                                  101        1 : 64         1 : 32
                                  110        1 : 128        1 : 64
                                  111        1 : 256        1 : 128
                        Legend:
                        R = Readable bit                W = Writable bit           U = Unimplemented bit, read as ‘0’
                        - n = Value at POR              ‘1’ = Bit is set           ‘0’ = Bit is cleared   x = Bit is unknown
DS30498B-page 22                                       Preliminary                                 2003 Microchip Technology Inc.
                                                                                                PIC16F7X7
2.2.2.3       INTCON Register                                          Note:    Interrupt flag bits are set when an interrupt
The INTCON register is a readable and writable regis-                           condition occurs regardless of the state of
ter which contains various enable and flag bits for the                         its corresponding enable bit or the global
TMR0 register overflow, RB port change and external                             enable bit, GIE (INTCON<7>). User
RB0/INT pin interrupts.                                                         software should ensure the appropriate
                                                                                interrupt flag bits are clear prior to
                                                                                enabling an interrupt.
REGISTER 2-3:          INTCON REGISTER (ADDRESS 0Bh, 8Bh, 10Bh, 18Bh)
                          R/W-0      R/W-0       R/W-0        R/W-0            R/W-0       R/W-0       R/W-0        R/W-x
                           GIE        PEIE      TMR0IE        INT0IE           RBIE       TMR0IF      INT0IF        RBIF
                        bit 7                                                                                           bit 0
            bit 7       GIE: Global Interrupt Enable bit
                        1 = Enables all unmasked interrupts
                        0 = Disables all interrupts
            bit 6       PEIE: Peripheral Interrupt Enable bit
                        1 = Enables all unmasked peripheral interrupts
                        0 = Disables all peripheral interrupts
            bit 5       TMR0IE: TMR0 Overflow Interrupt Enable bit
                        1 = Enables the TMR0 interrupt
                        0 = Disables the TMR0 interrupt
            bit 4       INT0IE: RB0/INT External Interrupt Enable bit
                        1 = Enables the RB0/INT external interrupt
                        0 = Disables the RB0/INT external interrupt
            bit 3       RBIE: RB Port Change Interrupt Enable bit
                        1 = Enables the RB port change interrupt
                        0 = Disables the RB port change interrupt
            bit 2       TMR0IF: TMR0 Overflow Interrupt Flag bit
                        1 = TMR0 register has overflowed (must be cleared in software)
                        0 = TMR0 register did not overflow
            bit 1       INT0IF: RB0/INT External Interrupt Flag bit
                        1 = The RB0/INT external interrupt occurred (must be cleared in software)
                        0 = The RB0/INT external interrupt did not occur
            bit 0       RBIF: RB Port Change Interrupt Flag bit
                        A mismatch condition will continue to set flag bit RBIF. Reading PORTB will end the mismatch
                        condition and allow flag bit RBIF to be cleared.
                        1 = At least one of the RB7:RB4 pins changed state (must be cleared in software)
                        0 = None of the RB7:RB4 pins have changed state
                        Legend:
                        R = Readable bit            W = Writable bit           U = Unimplemented bit, read as ‘0’
                        - n = Value at POR          ‘1’ = Bit is set           ‘0’ = Bit is cleared   x = Bit is unknown
 2003 Microchip Technology Inc.                   Preliminary                                            DS30498B-page 23
PIC16F7X7
2.2.2.4       PIE1 Register                                              Note:    Bit PEIE (INTCON<6>) must be set to
The PIE1 register contains the individual enable bits for                         enable any peripheral interrupt.
the peripheral interrupts.
REGISTER 2-4:          PIE1 REGISTER (ADDRESS 8Ch)
                          R/W-0       R/W-0        R/W-0        R/W-0            R/W-0       R/W-0       R/W-0        R/W-0
                               (1)
                        PSPIE          ADIE        RCIE          TXIE            SSPIE      CCP1IE      TMR2IE       TMR1IE
                       bit 7                                                                                              bit 0
           bit 7        PSPIE(1): Parallel Slave Port Read/Write Interrupt Enable bit
                        1 = Enables the PSP read/write interrupt
                        0 = Disables the PSP read/write interrupt
                          Note 1: PSPIE is reserved on 28-pin devices; always maintain this bit clear.
           bit 6        ADIE: A/D Converter Interrupt Enable bit
                        1 = Enables the A/D converter interrupt
                        0 = Disables the A/D converter interrupt
           bit 5        RCIE: USART Receive Interrupt Enable bit
                        1 = Enables the USART receive interrupt
                        0 = Disables the USART receive interrupt
           bit 4        TXIE: USART Transmit Interrupt Enable bit
                        1 = Enables the USART transmit interrupt
                        0 = Disables the USART transmit interrupt
           bit 3        SSPIE: Synchronous Serial Port Interrupt Enable bit
                        1 = Enables the SSP interrupt
                        0 = Disables the SSP interrupt
           bit 2        CCP1IE: CCP1 Interrupt Enable bit
                        1 = Enables the CCP1 interrupt
                        0 = Disables the CCP1 interrupt
           bit 1        TMR2IE: TMR2 to PR2 Match Interrupt Enable bit
                        1 = Enables the TMR2 to PR2 match interrupt
                        0 = Disables the TMR2 to PR2 match interrupt
           bit 0        TMR1IE: TMR1 Overflow Interrupt Enable bit
                        1 = Enables the TMR1 overflow interrupt
                        0 = Disables the TMR1 overflow interrupt
                        Legend:
                        R = Readable bit              W = Writable bit           U = Unimplemented bit, read as ‘0’
                        - n = Value at POR            ‘1’ = Bit is set           ‘0’ = Bit is cleared    x = Bit is unknown
DS30498B-page 24                                     Preliminary                                 2003 Microchip Technology Inc.
                                                                                          PIC16F7X7
2.2.2.5       PIR1 Register
                                                                  Note: Interrupt flag bits are set when an interrupt
The PIR1 register contains the individual flag bits for                 condition occurs regardless of the state of its
the peripheral interrupts.                                              corresponding enable bit or the global enable
                                                                        bit, GIE (INTCON<7>). User software should
                                                                        ensure the appropriate interrupt bits are clear
                                                                        prior to enabling an interrupt.
REGISTER 2-5:          PIR1 REGISTER (ADDRESS 0Ch)
                          R/W-0      R/W-0        R-0         R-0        R/W-0       R/W-0       R/W-0        R/W-0
                         PSPIF(1)    ADIF         RCIF        TXIF       SSPIF      CCP1IF       TMR2IF      TMR1IF
                        bit 7                                                                                   bit 0
             bit 7     PSPIF(1): Parallel Slave Port Read/Write Interrupt Flag bit
                       1 = A read or a write operation has taken place (must be cleared in software)
                       0 = No read or write has occurred
                         Note:    PSPIF is reserved on 28-pin devices; always maintain this bit clear.
             bit 6     ADIF: A/D Converter Interrupt Flag bit
                       1 = An A/D conversion is completed (must be cleared in software)
                       0 = The A/D conversion is not complete
             bit 5     RCIF: USART Receive Interrupt Flag bit
                       1 = The USART receive buffer is full
                       0 = The USART receive buffer is empty
             bit 4     TXIF: USART Transmit Interrupt Flag bit
                       1 = The USART transmit buffer is empty
                       0 = The USART transmit buffer is full
             bit 3     SSPIF: Synchronous Serial Port (SSP) Interrupt Flag bit
                       1 = The SSP interrupt condition has occurred and must be cleared in software before returning
                           from the Interrupt Service Routine. The conditions that will set this bit are:
                           SPI:
                           A transmission/reception has taken place.
                           I2 C Slave:
                           A transmission/reception has taken place.
                           I2 C Master:
                           A transmission/reception has taken place.
                           The initiated Start condition was completed by the SSP module.
                           The initiated Stop condition was completed by the SSP module.
                           The initiated Restart condition was completed by the SSP module.
                           The initiated Acknowledge condition was completed by the SSP module.
                           A Start condition occurred while the SSP module was Idle (multi-master system).
                           A Stop condition occurred while the SSP module was Idle (multi-master system).
                       0 = No SSP interrupt condition has occurred
             bit 2     CCP1IF: CCP1 Interrupt Flag bit
                       Capture mode:
                       1 = A TMR1 register capture occurred (must be cleared in software)
                       0 = No TMR1 register capture occurred
                       Compare mode:
                       1 = A TMR1 register compare match occurred (must be cleared in software)
                       0 = No TMR1 register compare match occurred
                       PWM mode:
                       Unused in this mode.
             bit 1     TMR2IF: TMR2 to PR2 Match Interrupt Flag bit
                       1 = TMR2 to PR2 match occurred (must be cleared in software)
                       0 = No TMR2 to PR2 match occurred
             bit 0     TMR1IF: TMR1 Overflow Interrupt Flag bit
                       1 = TMR1 register overflowed (must be cleared in software)
                       0 = TMR1 register did not overflow
                       Legend:
                       R = Readable bit             W = Writable bit     U = Unimplemented bit, read as ‘0’
                       - n = Value at POR           ‘1’ = Bit is set     ‘0’ = Bit is cleared x = Bit is unknown
 2003 Microchip Technology Inc.                   Preliminary                                       DS30498B-page 25
PIC16F7X7
2.2.2.6       PIE2 Register
The PIE2 register contains the individual enable bits for
the CCP2 and CCP3 peripheral interrupts.
REGISTER 2-6:          PIE2 REGISTER (ADDRESS 8Dh)
                          R/W-0       R/W-0        R/W-0           U-0    R/W-0         U-0        R/W-0       R/W-0
                          OSFIE        CMIE        LVDIE            —     BCLIE          —        CCP3IE      CCP2IE
                        bit 7                                                                                      bit 0
           bit 7        OSFIE: Oscillator Fail Interrupt Enable bit
                        1 = Enabled
                        0 = Disabled
           bit 6        CMIE: Comparator Interrupt Enable bit
                        1 = Enabled
                        0 = Disabled
           bit 5        LVDIE: Low-Voltage Detect Interrupt Enable bit
                        1 = LVD interrupt is enabled
                        0 = LVD interrupt is disabled
           bit 4        Unimplemented: Read as ‘0’
           bit 3        BCLIE: Bus Collision Interrupt Enable bit
                        1 = Enable bus collision interrupt in the SSP when configured for I2C Master mode
                        0 = Disable bus collision interrupt in the SSP when configured for I2C Master mode
           bit 2        Unimplemented: Read as ‘0’
           bit 1        CCP3IE: CCP3 Interrupt Enable bit
                        1 = Enables the CCP3 interrupt
                        0 = Disables the CCP3 interrupt
           bit 0        CCP2IE: CCP2 Interrupt Enable bit
                        1 = Enables the CCP2 interrupt
                        0 = Disables the CCP2 interrupt
                        Legend:
                        R = Readable bit              W = Writable bit    U = Unimplemented bit, read as ‘0’
                        - n = Value at POR            ‘1’ = Bit is set    ‘0’ = Bit is cleared    x = Bit is unknown
DS30498B-page 26                                     Preliminary                          2003 Microchip Technology Inc.
                                                                                                PIC16F7X7
2.2.2.7       PIR2 Register
                                                                       Note:    Interrupt flag bits are set when an interrupt
The PIR2 register contains the flag bits for the CCP2
                                                                                condition occurs regardless of the state of
interrupt.
                                                                                its corresponding enable bit or the global
                                                                                enable bit, GIE (INTCON<7>). User
                                                                                software should ensure the appropriate
                                                                                interrupt flag bits are clear prior to
                                                                                enabling an interrupt.
REGISTER 2-7:          PIR2 REGISTER (ADDRESS 0Dh)
                          R/W-0      R/W-0       R/W-0           U-0           R/W-0         U-0       R/W-0       R/W-0
                         OSFIF       CMIF        LVDIF            —            BCLIF          —       CCP3IF       CCP2IF
                        bit 7                                                                                          bit 0
           bit 7       OSFIF: Oscillator Fail Interrupt Flag bit
                       1 = System oscillator failed, clock input has changed to INTRC (must be cleared in software)
                       0 = System clock operating
           bit 6       CMIF: Comparator Interrupt Flag bit
                       1 = Comparator input has changed (must be cleared in software)
                       0 = Comparator input has not changed
           bit 5       LVDIF: Low-Voltage Detect Interrupt Flag bit
                       1 = The supply voltage has fallen below the specified LVD voltage (must be cleared in software)
                       0 = The supply voltage is greater then the specified LVD voltage
           bit 4       Unimplemented: Read as ‘0’
           bit 3       BCLIF: Bus Collision Interrupt Flag bit
                       1 = A bus collision has occurred in the SSP when configured for I2C Master mode
                       0 = No bus collision has occurred
           bit 2       Unimplemented: Read as ‘0’
           bit 1       CCP3IF: CCP3 Interrupt Flag bit
                       Capture mode:
                       1 = A TMR1 register capture occurred (must be cleared in software)
                       0 = No TMR1 register capture occurred
                       Compare mode:
                       1 = A TMR1 register compare match occurred (must be cleared in software)
                       0 = No TMR1 register compare match occurred
                       PWM mode:
                       Unused in this mode.
           bit 0       CCP2IF: CCP2 Interrupt Flag bit
                       Capture mode:
                       1 = A TMR1 register capture occurred (must be cleared in software)
                       0 = No TMR1 register capture occurred
                       Compare mode:
                       1 = A TMR1 register compare match occurred (must be cleared in software)
                       0 = No TMR1 register compare match occurred
                       PWM mode:
                       Unused.
                        Legend:
                        R = Readable bit            W = Writable bit           U = Unimplemented bit, read as ‘0’
                        - n = Value at POR          ‘1’ = Bit is set           ‘0’ = Bit is cleared   x = Bit is unknown
 2003 Microchip Technology Inc.                   Preliminary                                            DS30498B-page 27
PIC16F7X7
2.2.2.8     PCON Register                                             Note:    BOR is unknown on POR. It must be set
The Power Control (PCON) register contains flag bits                           by the user and checked on subsequent
to allow differentiation between a Power-on Reset                              Resets to see if BOR is clear, indicating a
(POR), a Brown-out Reset (BOR), a Watchdog Reset                               brown-out has occurred. The BOR status
(WDT) and an external MCLR Reset.                                              bit is not predictable if the brown-out circuit
                                                                               is disabled (by clearing the BOREN bit in
                                                                               the Configuration Word register).
REGISTER 2-8:          PCON REGISTER (ADDRESS 8Eh)
                          U-0         U-0         U-0           U-0            U-0         R/W-1       R/W-0        R/W-1
                           —          —           —             —               —        SBOREN         POR          BOR
                       bit 7                                                                                             bit 0
             bit 7-3   Unimplemented: Read as ‘0’
             bit 2     SBOREN: Software Brown-out Reset Enable bit
                       If BORSEN in Configuration Word 2 is a ‘1’ and BOREN in Configuration Word 1 is ‘0’, then:
                       1 = BOR enabled
                       0 = BOR disabled
             bit 1     POR: Power-on Reset Status bit
                       1 = No Power-on Reset occurred
                       0 = A Power-on Reset occurred (must be set in software after a Power-on Reset occurs)
             bit 0     BOR: Brown-out Reset Status bit
                       1 = No Brown-out Reset occurred
                       0 = A Brown-out Reset occurred (must be set in software after a Brown-out Reset occurs)
                       Legend:
                       R = Readable bit            W = Writable bit           U = Unimplemented bit, read as ‘0’
                       - n = Value at POR          ‘1’ = Bit is set           ‘0’ = Bit is cleared    x = Bit is unknown
DS30498B-page 28                                  Preliminary                                 2003 Microchip Technology Inc.
                                                                                                          PIC16F7X7
2.3        PCL and PCLATH                                                    The stack operates as a circular buffer. This means that
                                                                             after the stack has been PUSHed eight times, the ninth
The Program Counter (PC) is 13 bits wide. The low                            push overwrites the value that was stored from the first
byte comes from the PCL register, which is a readable                        push. The tenth push overwrites the second push (and
and writable register. The upper bits (PC<12:8>) are                         so on).
not readable but are indirectly writable through the
PCLATH register. On any Reset, the upper bits of the                            Note 1: There are no Status bits to indicate stack
PC will be cleared. Figure 2-4 shows the two situations                                 overflow or stack underflow conditions.
for the loading of the PC. The upper example in the
                                                                                       2: There are no instructions/mnemonics
figure shows how the PC is loaded on a write to PCL
                                                                                          called PUSH or POP. These are actions
(PCLATH<4:0> → PCH). The lower example in the
                                                                                          that occur from the execution of the
figure shows how the PC is loaded during a CALL or
                                                                                          CALL, RETURN, RETLW and RETFIE
GOTO instruction (PCLATH<4:3> → PCH).
                                                                                          instructions or the vectoring to an
                                                                                          interrupt address.
FIGURE 2-4:                         LOADING OF PC IN
                                    DIFFERENT SITUATIONS                     2.4       Program Memory Paging
            PCH                       PCL                                    PIC16F7X7 devices are capable of addressing a con-
                                                                             tinuous 8K word block of program memory. The CALL
      12                8       7                    0   Instruction with    and GOTO instructions provide only 11 bits of address to
 PC                                                      PCL as
                                                         Destination         allow branching within any 2K program memory page.
                   PCLATH<4:0>                   8                           When doing a CALL or GOTO instruction, the upper
            5                                            ALU
                                                                             2 bits of the address are provided by PCLATH<4:3>.
                                                                             When doing a CALL or GOTO instruction, the user must
                        PCLATH                                               ensure that the page select bits are programmed so
                                                                             that the desired program memory page is addressed. If
            PCH                      PCL
                                                                             a return from a CALL instruction (or interrupt) is exe-
      12   11 10    8       7                        0
                                                                             cuted, the entire 13-bit PC is POPed off the stack.
 PC                                                      GOTO,CALL
                                                                             Therefore, manipulation of the PCLATH<4:3> bits is
            PCLATH<4:3>                     11                               not required for the RETURN instructions (which POPs
      2                                                  Opcode <10:0>       the address from the stack).
                   PCLATH                                                      Note:        The contents of the PCLATH are
                                                                                            unchanged after a RETURN or RETFIE
                                                                                            instruction is executed. The user must set
                                                                                            up the PCLATH for any subsequent CALLs
2.3.1           COMPUTED GOTO
                                                                                            or GOTOs.
A computed GOTO is accomplished by adding an offset
                                                                             Example 2-1 shows the calling of a subroutine in
to the program counter (ADDWF PCL). When doing a
                                                                             page 1 of the program memory. This example assumes
table read using a computed GOTO method, care
                                                                             that PCLATH is saved and restored by the Interrupt
should be exercised if the table location crosses a PCL
                                                                             Service Routine (if interrupts are used).
memory boundary (each 256-byte block). Refer to the
Application Note, AN556, “Implementing a Table Read”
(DS00556).                                                                   EXAMPLE 2-1:             CALL OF A SUBROUTINE
                                                                                                      IN PAGE 1 FROM PAGE 0
2.3.2           STACK                                                                   ORG   0x500
The PIC16F7X7 family has an 8-level deep x 13-bit                                       BCF   PCLATH, 4
                                                                                        BSF   PCLATH, 3 ;Select page 1
wide hardware stack. The stack space is not part of
                                                                                                        ;(800h-FFFh)
either program or data space and the stack pointer is
                                                                                         CALL SUB1_P1   ;Call subroutine in
not readable or writable. The PC is PUSHed onto the                                     :               ;page 1 (800h-FFFh)
stack when a CALL instruction is executed or an                                         :
interrupt causes a branch. The stack is POPed in the                                    ORG   0x900     ;page 1 (800h-FFFh)
event of a RETURN, RETLW or a RETFIE instruction                              SUB1_P1
execution. PCLATH is not affected by a PUSH or POP                                      :                   ;called subroutine
operation.                                                                              :                   ;page 1 (800h-FFFh)
                                                                                        :
                                                                              RETURN                        ;return to Call
                                                                                                            ;subroutine in page 0
                                                                                                            ;(000h-7FFh)
 2003 Microchip Technology Inc.                                     Preliminary                                    DS30498B-page 29
PIC16F7X7
2.5      Indirect Addressing, INDF and                                   EXAMPLE 2-2:          INDIRECT ADDRESSING
         FSR Registers                                                           MOVLW      0x20   ;initialize pointer
                                                                                 MOVWF      FSR    ;to RAM
The INDF register is not a physical register. Addressing                 NEXT    CLRF       INDF   ;clear INDF register
the INDF register will cause indirect addressing.                                INCF       FSR, F ;inc pointer
                                                                                 BTFSS      FSR, 4 ;all done?
Indirect addressing is possible by using the INDF
                                                                                 GOTO       NEXT   ;no clear next
register. Any instruction using the INDF register actu-
                                                                         CONTINUE
ally accesses the register pointed to by the File Select                     :                        ;yes continue
Register, FSR. Reading the INDF register itself indi-
rectly (FSR = 0) will read 00h. Writing to the INDF reg-
ister indirectly results in a no operation (although Status
bits may be affected). An effective 9-bit address is
obtained by concatenating the 8-bit FSR register and
the IRP bit (Status<7>) as shown in Figure 2-5.
A simple program to clear RAM locations 20h-2Fh
using indirect addressing is shown in Example 2-2.
FIGURE 2-5:               DIRECT/INDIRECT ADDRESSING
                 Direct Addressing                                                             Indirect Addressing
   RP1:RP0         6       From Opcode          0                                     IRP     7         FSR Register        0
  Bank Select    Location Select                                                      Bank Select               Location Select
                                                00        01        10        11
                                          00h          80h        100h      180h
                       Data
                       Memory(1)
                                          7Fh          FFh        17Fh      1FFh
                                           Bank 0        Bank 1    Bank 2    Bank 3
   Note 1:      For register file map detail, see Figure 2-2.
DS30498B-page 30                                             Preliminary                           2003 Microchip Technology Inc.
                                                                                                 PIC16F7X7
3.0      READING PROGRAM MEMORY                                      When interfacing to the program memory block, the
                                                                     PMDATH:PMDATA registers form a two-byte word
The Flash program memory is readable during normal                   which holds the 14-bit data for reads. The
operation over the entire VDD range. It is indirectly                PMADRH:PMADR registers form a two-byte word
addressed through Special Function Registers (SFR).                  which holds the 13-bit address of the Flash location
Up to 14-bit numbers can be stored in memory for use                 being accessed. These devices can have up to
as calibration parameters, serial numbers, packed 7-bit              8K words of program Flash, with an address range
ASCII, etc. Executing a program memory location con-                 from 0h to 3FFFh. The unused upper bits in both the
taining data that forms an invalid instruction results in a          PMDATH and PMADRH registers are not implemented
NOP.                                                                 and read as ‘0’s.
There are five SFRs used to read the program and
memory. These registers are:                                         3.1      PMADR
•   PMCON1                                                           The address registers can address up to a maximum of
•   PMDATA                                                           8K words of program Flash.
•   PMDATH                                                           When selecting a program address value, the MSByte
•   PMADR                                                            of the address is written to the PMADRH register and
•   PMADRH                                                           the LSByte is written to the PMADR register. The upper
                                                                     MSbits of PMADRH must always be clear.
The program memory allows word reads. Program
memory access allows for checksum calculation and
reading calibration tables.                                          3.2      PMCON1 Register
                                                                     PMCON1 is the control register for memory accesses.
                                                                     The control bit, RD, initiates read operations. This bit
                                                                     cannot be cleared, only set, in software. It is cleared in
                                                                     hardware at the completion of the read operation.
REGISTER 3-1:           PMCON1 REGISTER (ADDRESS 18Ch)
                            R-1          U-0          U-0           U-0         U-x          U-0         U-0         R/S-0
                         reserved         —            —             —           —           —            —           RD
                        bit 7                                                                                            bit 0
           bit 7        Reserved: Read as ‘1’
           bit 6-1      Unimplemented: Read as ‘0’
           bit 0        RD: Read Control bit
                        1 = Initiates a Flash read, RD is cleared in hardware. The RD bit can only be set (not cleared)
                            in software.
                        0 = Flash read completed
                        Legend:
                        R = Readable bit                W = Writable bit       U = Unimplemented bit, read as ‘0’
                        - n = Value at POR              ‘1’ = Bit is set       ‘0’ = Bit is cleared    x = Bit is unknown
 2003 Microchip Technology Inc.                      Preliminary                                          DS30498B-page 31
PIC16F7X7
3.3      Reading the Flash Program                                   3.4           Operation During Code-Protect
         Memory                                                      Flash program memory has its own code-protect
A program memory location may be read by writing two                 mechanism. External read and write operations by
bytes of the address to the PMADR and PMADRH reg-                    programmers are disabled if this mechanism is
isters and then setting control bit, RD (PMCON1<0>).                 enabled.
Once the read control bit is set, the microcontroller will           The microcontroller can read and execute instructions
use the next two instruction cycles to read the data. The            out of the internal Flash program memory, regardless
data is available in the PMDATA and PMDATH regis-                    of the state of the code-protect configuration bits.
ters after the second NOP instruction. Therefore, it can
be read as two bytes in the following instructions. The
PMDATA and PMDATH registers will hold this value
until the next read operation.
EXAMPLE 3-1:            FLASH PROGRAM READ
               BSF        STATUS, RP1        ;
               BCF        STATUS, RP0        ;   Bank 2
               MOVF       ADDRH, W           ;
               MOVWF      PMADRH             ;   MSByte of Program Address to read
               MOVF       ADDRL, W           ;
               MOVWF      PMADR              ;   LSByte of Program Address to read
               BSF        STATUS, RP0        ;   Bank 3 Required
 Required      BSF        PMCON1, RD         ; EEPROM Read Sequence
 Sequence      NOP                           ; memory is read in the next two cycles after BSF PMCON1,RD
               NOP                           ;
               BCF        STATUS, RP0        ; Bank 2
               MOVF       PMDATA, W          ; W = LSByte of Program PMDATA
               MOVF       PMDATH, W          ; W = MSByte of Program PMDATH
TABLE 3-1:         REGISTERS ASSOCIATED WITH PROGRAM FLASH
                                                                                                                  Value on
                                                                                                     Value on:
Address     Name        Bit 7    Bit 6     Bit 5    Bit 4    Bit 3         Bit 2     Bit 1   Bit 0                all other
                                                                                                     POR, BOR
                                                                                                                   Resets
10Dh      PMADR        Address Register Low Byte                                                     xxxx xxxx uuuu uuuu
10Fh      PMADRH         —        —         —      Address Register High Byte                        ---x xxxx ---u uuuu
10Ch      PMDATA Data Register Low Byte                                                              xxxx xxxx uuuu uuuu
10Eh      PMDATH         —        —      Data Register High Byte                                     --xx xxxx --uu uuuu
18Ch      PMCON1        —(1)      —         —         —       —             —         —      RD      1--- ---0 1--- ---0
Legend: x = unknown, u = unchanged, r = reserved, - = unimplemented, read as ‘0’. Shaded cells are not used
        during Flash access.
Note 1: This bit always reads as a ‘1’.
DS30498B-page 32                                      Preliminary                              2003 Microchip Technology Inc.
                                                                                                PIC16F7X7
4.0         OSCILLATOR                                              TABLE 4-1:          CAPACITOR SELECTION FOR
            CONFIGURATIONS                                                              CRYSTAL OSCILLATOR (FOR
                                                                                        DESIGN GUIDANCE ONLY)
4.1         Oscillator Types                                                                     Typical Capacitor Values
                                                                                     Crystal              Tested:
The PIC16F7X7 can be operated in eight different oscil-              Osc Type
                                                                                      Freq
lator modes. The user can program three configuration                                                 C1             C2
bits (FOSC2:FOSC0) to select one of these eight modes
                                                                          LP         32 kHz          33 pF          33 pF
(modes 5-8 are new PIC16 oscillator configurations):
                                                                                     200 kHz         15 pF          15 pF
1.    LP     Low-Power Crystal
                                                                          XT         200 kHz         56 pF          56 pF
2.    XT     Crystal/Resonator
                                                                                     1 MHz           15 pF          15 pF
3.    HS     High-Speed Crystal/Resonator
4.    RC     External Resistor/Capacitor with                                        4 MHz           15 pF          15 pF
             FOSC/4 output on RA6                                         HS         4 MHz           15 pF          15 pF
5.    RCIO External Resistor/Capacitor with                                          8 MHz           15 pF          15 pF
             I/O on RA6                                                              20 MHz          15 pF          15 pF
6.    INTIO1 Internal Oscillator with FOSC/4                         Capacitor values are for design guidance only.
             output on RA6 and I/O on RA7
                                                                     These capacitors were tested with the crystals listed
7.    INTIO2 Internal Oscillator with I/O on RA6
                                                                     below for basic start-up and operation. These values
             and RA7
                                                                     were not optimized.
8.    ECIO External Clock with I/O on RA6
                                                                     Different capacitor values may be required to produce
                                                                     acceptable oscillator operation. The user should test
4.2         Crystal Oscillator/Ceramic
                                                                     the performance of the oscillator over the expected
            Resonators                                               VDD and temperature range for the application.
In XT, LP or HS modes, a crystal or ceramic resonator                See the notes following this table for additional
is connected to the OSC1/CLKI and OSC2/CLKO pins                     information.
to establish oscillation (see Figure 4-1 and Figure 4-2).
The PIC16F7X7 oscillator design requires the use of a                  Note 1: Higher capacitance increases the stability
parallel cut crystal. Use of a series cut crystal may give                     of oscillator but also increases the
a frequency out of the crystal manufacturer’s                                  start-up time.
specifications.
                                                                               2: Since each crystal has its own character-
                                                                                  istics, the user should consult the crystal
FIGURE 4-1:                CRYSTAL OPERATION
                                                                                  manufacturer for appropriate values of
                           (HS, XT OR LP OSC                                      external components.
                           CONFIGURATION)
                                                                               3: Rs may be required in HS mode, as well
                       OSC1               PIC16F7X7                               as XT mode, to avoid overdriving crystals
           C1(1)                                                                  with low drive level specification.
                   XTAL
                                                                               4: Always verify oscillator performance over
                                 RF(3)         Sleep
                                                                                  the VDD and temperature range that is
                       OSC2                                                       expected for the application.
                   RS(2)
           C2(1)                              To Internal
                                              Logic
     Note 1: See Table 4-1 for typical values of C1 and C2.
           2: A series resistor (RS) may be required for AT
              strip cut crystals.
           3: RF varies with the crystal chosen (typically
              between 2 MΩ to 10 MΩ).
 2003 Microchip Technology Inc.                            Preliminary                                      DS30498B-page 33
PIC16F7X7
FIGURE 4-2:                   CERAMIC RESONATOR                     4.3      External Clock Input
                              OPERATION (HS OR XT
                                                                    The ECIO Oscillator mode requires an external clock
                              OSC CONFIGURATION)
                                                                    source to be connected to the OSC1 pin. There is no
                          OSC1             PIC16F7X7                oscillator start-up time required after a Power-on Reset
                                                                    or after an exit from Sleep mode.
          C1(1)
                                                                    In the ECIO Oscillator mode, the OSC2 pin becomes
                   RES                        Sleep
                                  RF(3)                             an additional general purpose I/O pin. The I/O pin
                          OSC2                                      becomes bit 6 of PORTA (RA6). Figure 4-3 shows the
                   RS   (2)                                         pin connections for the ECIO Oscillator mode.
          C2(1)                               To Internal
                                              Logic                 FIGURE 4-3:            EXTERNAL CLOCK INPUT
                                                                                           OPERATION
   Note 1: See Table 4-2 for typical values of C1 and C2.                                  (ECIO CONFIGURATION)
          2: A series resistor (RS) may be required.
          3: RF varies with the resonator chosen (typically           Clock from                 OSC1/CLKI
             between 2 MΩ to 10 MΩ).                                  Ext. System                     PIC16F7X7
                                                                                    RA6          I/O (OSC2)
TABLE 4-2:               CERAMIC RESONATORS (FOR
                         DESIGN GUIDANCE ONLY)
             Typical Capacitor Values Used:
  Mode             Freq            OSC1            OSC2
   XT             455 kHz          56 pF           56 pF
                  2.0 MHz          47 pF           47 pF
                  4.0 MHz          33 pF           33 pF
   HS             8.0 MHz          27 pF           27 pF
                  16.0 MHz         22 pF           22 pF
Capacitor values are for design guidance only.
These capacitors were tested with the resonators
listed below for basic start-up and operation. These
values were not optimized.
Different capacitor values may be required to produce
acceptable oscillator operation. The user should test
the performance of the oscillator over the expected
VDD and temperature range for the application.
See the notes following this table for additional
information.
  Note:       When using resonators with frequencies
              above 3.5 MHz, the use of HS mode rather
              than XT mode is recommended. HS mode
              may be used at any VDD for which the
              controller is rated. If HS is selected, it is
              possible that the gain of the oscillator will
              overdrive the resonator. Therefore, a
              series resistor should be placed between
              the OSC2 pin and the resonator. As a
              good starting point, the recommended
              value of RS is 330Ω.
DS30498B-page 34                                            Preliminary                      2003 Microchip Technology Inc.
                                                                                             PIC16F7X7
4.4       RC Oscillator                                          4.5         Internal Oscillator Block
For timing insensitive applications, the “RC” and “RCIO”         The PIC16F7X7 devices include an internal oscillator
device options offer additional cost savings. The RC             block which generates two different clock signals;
oscillator frequency is a function of the supply voltage,        either can be used as the system’s clock source. This
the resistor (REXT) and capacitor (CEXT) values and the          can eliminate the need for external oscillator circuits on
operating temperature. In addition to this, the oscillator       the OSC1 and/or OSC2 pins.
frequency will vary from unit to unit due to normal man-         The main output (INTOSC) is an 8 MHz clock source
ufacturing variation. Furthermore, the difference in lead        which can be used to directly drive the system clock. It
frame capacitance between package types will also                also drives the INTOSC postscaler which can provide a
affect the oscillation frequency, especially for low CEXT        range of six clock frequencies, from 125 kHz to 4 MHz.
values. The user also needs to take into account varia-
tion due to tolerance of external R and C components             The other clock source is the internal RC oscillator
used. Figure 4-4 shows how the R/C combination is                (INTRC), which provides a 31.25 kHz (32 µs nominal
connected.                                                       period) output. The INTRC oscillator is enabled by
                                                                 selecting the INTRC as the system clock source or
In the RC Oscillator mode, the oscillator frequency              when any of the following are enabled:
divided by 4 is available on the OSC2 pin. This signal may
be used for test purposes or to synchronize other logic.         •   Power-up Timer
                                                                 •   Watchdog Timer
FIGURE 4-4:               RC OSCILLATOR MODE                     •   Two-Speed Start-up
          VDD                                                    •   Fail-Safe Clock Monitor
                                                                 These features are discussed in greater detail in
   REXT                                                          Section 15.0 “Special Features of the CPU”.
                                             Internal
                          OSC1
                                              Clock              The clock source frequency (INTOSC direct, INTRC
                                                                 direct or INTOSC postscaler) is selected by configuring
   CEXT                                                          the IRCF bits of the OSCCON register (page 38).
                                       PIC16F7X7
   VSS
                          OSC2/CLKO
                                                                     Note:     Throughout this data sheet, when referring
                 FOSC/4                                                        specifically to a generic clock source, the
  Recommended values: 3 kΩ ≤ REXT ≤ 100 kΩ                                     term “INTRC” may also be used to refer to
                      CEXT > 20 pF                                             the clock modes using the internal
                                                                               oscillator block. This is regardless of
The RCIO Oscillator mode (Figure 4-5) functions like                           whether the actual frequency used is
the RC mode, except that the OSC2 pin becomes an                               INTOSC (8 MHz), the INTOSC postscaler
additional general purpose I/O pin. The I/O pin                                or INTRC (31.25 kHz).
becomes bit 6 of PORTA (RA6).
FIGURE 4-5:               RCIO OSCILLATOR MODE
         VDD
  REXT
                          OSC1                Internal
                                               Clock
  CEXT
  VSS                                  PIC16F7X7
           RA6            I/O (OSC2)
  Recommended values: 3 kΩ ≤ REXT ≤ 100 kΩ
                      CEXT > 20 pF
 2003 Microchip Technology Inc.                         Preliminary                                    DS30498B-page 35
PIC16F7X7
4.5.1       INTRC MODES                                              4.5.2        OSCTUNE REGISTER
Using the internal oscillator as the clock source can                The internal oscillator’s output has been calibrated at the
eliminate the need for up to two external oscillator pins,           factory but can be adjusted in the application. This is
after which it can be used for digital I/O. Two distinct             done by writing to the OSCTUNE register (Register 4-1).
configurations are available:                                        The tuning sensitivity is constant throughout the tuning
• In INTIO1 mode, the OSC2 pin outputs FOSC/4,                       range. The OSCTUNE register has a tuning range of
  while OSC1 functions as RA7 for digital input and                  ±12.5%.
  output.                                                            When the OSCTUNE register is modified, the INTOSC
• In INTIO2 mode, OSC1 functions as RA7 and                          and INTRC frequencies will begin shifting to the new fre-
  OSC2 functions as RA6, both for digital input and                  quency. The INTRC clock will reach the new frequency
  output.                                                            within 8 clock cycles (approximately 8 * 32 µs = 256 µs);
                                                                     the INTOSC clock will stabilize within 1 ms. Code execu-
                                                                     tion continues during this shift. There is no indication that
                                                                     the shift has occurred. Operation of features that depend
                                                                     on the 31.25 kHz INTRC clock source frequency, such
                                                                     as the WDT, Fail-Safe Clock Monitor and peripherals,
                                                                     will also be affected by the change in frequency.
REGISTER 4-1:           OSCTUNE: OSCILLATOR TUNING REGISTER (ADDRESS 90h)
                             U-0         U-0        R/W-0         R/W-0        R/W-0         R/W-0        R/W-0        R/W-0
                              —          —          TUN5          TUN4         TUN3          TUN2         TUN1         TUN0
                         bit 7                                                                                            bit 0
           bit 7-6      Unimplemented: Read as ‘0’
           bit 5-0      TUN<5:0>: Frequency Tuning bits
                        011111 = Maximum frequency
                        011110 =
                        •
                        •
                        •
                        000001 =
                        000000 = Center frequency. Oscillator module is running at the calibrated frequency.
                        111111 =
                        •
                        •
                        •
                        100000 = Minimum frequency
                         Legend:
                         R = Readable bit              W = Writable bit        U = Unimplemented bit, read as ‘0’
                         -n = Value at POR             ‘1’ = Bit is set        ‘0’ = Bit is cleared     x = Bit is unknown
DS30498B-page 36                                      Preliminary                               2003 Microchip Technology Inc.
                                                                                         PIC16F7X7
4.6      Clock Sources and Oscillator                         the main oscillator that is selected by the FOSC2:FOSC0
         Switching                                            configuration bits in Configuration Register 1. When the
                                                              bits are set in any other manner, the system clock
The PIC16F7X7 devices include a feature that allows           source is provided by the Timer1 oscillator
the system clock source to be switched from the main          (SCS1:SCS0 = 01) or from the internal oscillator block
oscillator to an alternate low-frequency clock source.        (SCS1:SCS0 = 10). After a Reset, SCS<1:0> are
PIC16F7X7 devices offer three alternate clock sources.        always set to ‘00’.
When enabled, these give additional options for
                                                              The internal oscillator select bits, IRCF2:IRCF0, select
switching to the various power managed operating
                                                              the frequency output of the internal oscillator block that
modes.
                                                              is used to drive the system clock. The choices are the
Essentially, there are three clock sources for these          INTRC source (31.25 kHz), the INTOSC source
devices:                                                      (8 MHz) or one of the six frequencies derived from the
• Primary oscillators                                         INTOSC postscaler (125 kHz to 4 MHz). Changing the
                                                              configuration of these bits has an immediate change on
• Secondary oscillators
                                                              the internal oscillator’s output.
• Internal oscillator block (INTRC)
                                                              The OSTS and IOFS bits indicate the status of the
The primary oscillators include the External Crystal          primary oscillator and INTOSC source; these bits are
and Resonator modes, the External RC modes, the               set when their respective oscillators are stable. In par-
External Clock mode and the internal oscillator block.        ticular, OSTS indicates that the Oscillator Start-up
The particular mode is defined on POR by the contents         Timer has timed out.
of Configuration Word 1. The details of these modes
are covered earlier in this chapter.                          4.6.2       CLOCK SWITCHING
The secondary oscillators are those external sources          Clock switching will occur for the following reasons:
not connected to the OSC1 or OSC2 pins. These
sources may continue to operate even after the                • The FCMEN (CONFIG2<0>) bit is set, the device
controller is placed in a power managed mode.                   is running from the primary oscillator and the
                                                                primary oscillator fails. The clock source will be
PIC16F7X7 devices offer the Timer1 oscillator as a              31.25 kHz INTRC.
secondary oscillator. This oscillator continues to run
                                                              • The FCMEN bit is set, the device is running from
when a SLEEP instruction is executed and is often the
                                                                the T1OSC and T1OSC fails. The clock source
time base for functions, such as a real-time clock.
                                                                will be 31.25 kHz INTRC.
Most often, a 32.768 kHz watch crystal is connected           • Following a wake-up due to a Reset or a POR,
between the RC0/T1OSO/T1CKI and RC1/T1OSI/CCP2                  when the device is configured for Two-Speed
pins. Like the LP mode oscillator circuit, loading capaci-      mode, switching will occur between the INTRC and
tors are also connected from each pin to ground. The            the system clock defined by the FOSC<2:0> bits.
Timer1 oscillator is discussed in greater detail in
                                                              • A wake-up from Sleep occurs due to interrupt or
Section 7.6 “Timer1 Oscillator”.
                                                                WDT wake-up and Two-Speed Start-up is
In addition to being a primary clock source, the internal       enabled. If the primary clock is XT, HS or LP, the
oscillator block is available as a power managed                clock will switch between the INTRC and the
mode clock source. The 31.25 kHz INTRC source is                primary system clock after 1024 clocks (OST) and
also used as the clock source for several special fea-          8 clocks of the primary oscillator. This is
tures, such as the WDT, Fail-Safe Clock Monitor,                conditional upon the SCS bits being set equal
Power-up Timer and Two-Speed Start-up.                          to ‘00’.
The clock sources for the PIC16F7X7 devices are shown         • SCS bits are modified from their original value.
in Figure 4-6. See Section 7.0 “Timer1 Module” for fur-       • IRCF bits are modified from their original value.
ther details of the Timer1 oscillator. See Section 15.1
“Configuration Bits” for Configuration register details.        Note:     Because the SCS bits are cleared on any
                                                                          Reset, no clock switching will occur on a
4.6.1       OSCCON REGISTER                                               Reset unless the Two-Speed Start-up is
                                                                          enabled and the primary clock is XT, HS or
The OSCCON register (Register 4-2) controls several
                                                                          LP. The device will wait for the primary
aspects of the system clock’s operation, both in full
                                                                          clock to become stable before execution
power operation and in power managed modes.
                                                                          begins (Two-Speed Start-up disabled).
The system clock select bits, SCS1:SCS0, select the
clock source that is used when the device is operating
in power managed modes. When the bits are cleared
(SCS<1:0> = 00), the system clock source comes from
 2003 Microchip Technology Inc.                      Preliminary                                   DS30498B-page 37
PIC16F7X7
4.6.3     CLOCK TRANSITION AND WDT                             Once the clock transition is complete (i.e., new oscilla-
                                                               tor selection switch has occurred), the Watchdog
When clock switching is performed, the Watchdog
                                                               Counter is re-enabled with the Counter Reset. This
Timer is disabled because the Watchdog Ripple
                                                               allows the user to synchronize the Watchdog Timer to
Counter is used as the Oscillator Start-up Timer.
                                                               the start of execution at the new clock frequency.
  Note:   The OST is only used when switching to
          XT, HS and LP Oscillator modes.
REGISTER 4-2:        OSCCON: OSCILLATOR CONTROL REGISTER
                        U-0        R/W-0        R/W-0         R/W-0         R-0         R-0       R/W-0       R/W-0
                         —         IRCF2        IRCF1         IRCF0      OSTS(1)       IOFS       SCS1        SCS0
                     bit 7                                                                                        bit 0
           bit 7     Unimplemented: Read as ‘0’
           bit 6-4   IRCF<2:0>: Internal RC Oscillator Frequency Select bits
                     000 = 31.25 kHz
                     001 = 125 kHz
                     010 = 250 kHz
                     011 = 500 kHz
                     100 = 1 MHz
                     101 = 2 MHz
                     110 = 4 MHz
                     111 = 8 MHz
           bit 3     OSTS: Oscillator Start-up Time-out Status bit(1)
                     1 = Device is running from the primary system clock
                     0 = Device is running from T1OSC or INTRC as a secondary system clock
                       Note 1: Bit resets to ‘0’ with Two-Speed Start-up and LP, XT or HS selected as the oscillator
                               mode.
           bit 2     IOFS: INTOSC Frequency Stable bit
                     1 = Frequency is stable
                     0 = Frequency is not stable
           bit 1-0   SCS<1:0>: Oscillator Mode Select bits
                     00 = Oscillator mode defined by FOSC<2:0>
                     01 = T1OSC is used for system clock
                     10 = Internal RC is used for system clock
                     11 = Reserved
                     Legend:
                     R = Readable bit            W = Writable bit       U = Unimplemented bit, read as ‘0’
                     -n = Value at POR           ‘1’ = Bit is set       ‘0’ = Bit is cleared    x = Bit is unknown
DS30498B-page 38                                 Preliminary                             2003 Microchip Technology Inc.
                                                                                                                  PIC16F7X7
FIGURE 4-6:             PIC16F7X7 CLOCK DIAGRAM
                                                                                                           CONFIG1 (FOSC2:FOSC0)
                  Primary Oscillator
                                                                                                             SCS<1:0> (T1OSC)
     OSC2
                               Sleep
                                                                                             LP, XT, HS, RC, EC
     OSC1
                  Secondary Oscillator                                                                                           Peripherals
                                                                                                           T1OSC
                                                                                                                        MUX
   T1OSO
                               T1OSCEN                                                To Timer1
                               Enable
    T1OSI                      Oscillator                                  OSCCON<6:4>            Internal Oscillator
                                                                       8 MHz                                                           CPU
                                                                                111
                                                                       4 MHz
                              Internal                                          110
                             Oscillator                                2 MHz
                                                                                101
                               Block
                                                       Postscaler
                                                                       1 MHz
                                                                                      MUX
                                                                                100
                                                                     500 kHz
                                              8 MHz                             011
                             31.25 kHz      (INTOSC)                 250 kHz
                              Source                                            010
                                                                     125 kHz
                                                                                001
                                                                    31.25 kHz
                       31.25 kHz                                                000
                                                                                                                                WDT, FSCM
                        (INTRC)
4.6.4       MODIFYING THE IRCF BITS                                             If the IRCF bits are modified while the internal oscillator
                                                                                is running at any other frequency than INTRC
The IRCF bits can be modified at any time, regardless
                                                                                (31.25 kHz, IRCF<2:0> ≠ 000), there is no need for a
of which clock source is currently being used as the
                                                                                4 ms clock switch delay. The new INTOSC frequency
system clock. The internal oscillator allows users to
                                                                                will be stable immediately after the eight falling edges.
change the frequency during run-time. This is achieved
                                                                                The IOFS bit will remain set after clock switching
by modifying the IRCF bits in the OSCCON register.
                                                                                occurs.
The sequence of events that occur after the IRCF bits
are modified is dependent upon the initial value of the                           Note:       Caution must be taken when modifying the
IRCF bits before they are modified. If the INTRC                                              IRCF bits using BCF or BSF instructions. It
(31.25 kHz, IRCF<2:0> = 000) is running and the IRCF                                          is possible to modify the IRCF bits to a fre-
bits are modified to any other value than ‘000’, a 4 ms                                       quency that may be out of the VDD specifi-
clock switch delay is turned on. Code execution contin-                                       cation range; for example, VDD = 2.0V and
ues at a higher than expected frequency while the new                                         IRCF = 111 (8 MHz).
frequency stabilizes. Time sensitive code should wait
for the IOFS bit in the OSCCON register to become set
before continuing. This bit can be monitored to ensure
that the frequency is stable before using the system
clock in time critical applications.
 2003 Microchip Technology Inc.                         Preliminary                                                          DS30498B-page 39
PIC16F7X7
4.6.5        CLOCK TRANSITION SEQUENCE                         • Clock before switch: One of INTOSC/INTOSC
                                                                 postscaler (IRCF<2:0> ≠ 000)
The following are three different sequences for
switching the internal RC oscillator frequency:                  1. IRCF bits are modified to a different INTOSC/
                                                                    INTOSC postscaler frequency.
• Clock before switch: 31.25 kHz
                                                                 2. The clock switching circuitry waits for a falling
  (IRCF<2:0> = 000)
                                                                    edge of the current clock, at which point CLKO
  1. IRCF bits are modified to an INTOSC/INTOSC                     is held low.
     postscaler frequency.
                                                                 3. The clock switching circuitry then waits for
  2. The clock switching circuitry waits for a falling              eight falling edges of requested clock, after
     edge of the current clock, at which point CLKO                 which it switches CLKO to this new clock
     is held low.                                                   source.
  3. The clock switching circuitry then waits for eight          4. The IOFS bit is set.
     falling edges of requested clock, after which it
                                                                 5. Oscillator switchover is complete.
     switches CLKO to this new clock source.
  4. The IOFS bit is clear to indicate that the clock is       4.6.6       OSCILLATOR DELAY UPON
     unstable and a 4 ms delay is started. Time                            POWER-UP, WAKE-UP AND CLOCK
     dependent code should wait for IOFS to
                                                                           SWITCHING
     become set.
  5. Switchover is complete.                                   Table 4-3 shows the different delays invoked for
                                                               various clock switching sequences. It also shows the
• Clock before switch: One of INTOSC/INTOSC
                                                               delays invoked for POR and wake-up.
  postscaler (IRCF<2:0> ≠ 000)
  1. IRCF      bits  are     modified     to    INTRC
     (IRCF<2:0> = 000).
  2. The clock switching circuitry waits for a falling
     edge of the current clock, at which point CLKO
     is held low.
  3. The clock switching circuitry then waits for eight
     falling edges of requested clock, after which it
     switches CLKO to this new clock source.
  4. Oscillator switchover is complete.
TABLE 4-3:         OSCILLATOR DELAY EXAMPLES
 Switch From         Switch To             Frequency         Oscillator Delay                 Comments
                      INTRC                 31.25 kHz
                      T1OSC                32.768 kHz
  Sleep/POR                                                                     Following a wake-up from Sleep
                  INTOSC/INTOSC          125 kHz-8 MHz
                     Postscaler                            5 µs-10 µs (approx.) mode or POR, CPU start-up is
                                                             CPU Start-up(1)    invoked to allow the CPU to
 INTRC/Sleep           EC, RC             DC – 20 MHz
                                                                                become ready for code execution.
    INTRC
                       EC, RC             DC – 20 MHz
  (31.25 kHz)
                                                            1024 Clock Cycles    Following a change from INTRC, an
     Sleep           LP, XT, HS        32.768 kHz-20 MHz
                                                                 (OST)           OST of 1024 cycles must occur.
    INTRC         INTOSC/INTOSC                                                  Refer to Section 4.6.4 “Modifying
                                         125 kHz-8 MHz            4 ms
  (31.25 kHz)        Postscaler                                                  the IRCF bits” for further details.
Note 1:      The 5 µs-10 µs start-up delay is based on a 1 MHz system clock.
DS30498B-page 40                                      Preliminary                       2003 Microchip Technology Inc.
                                                                                                 PIC16F7X7
4.7         Power Managed Modes                                       If the system clock does not come from the INTRC
                                                                      (31.25 kHz) when the SCS bits are changed and the
4.7.1         RC_RUN MODE                                             IRCF bits in the OSCCON register are configured for a
                                                                      frequency other than INTRC, the frequency may not be
When SCS bits are configured to run from the INTRC,
                                                                      stable immediately. The IOFS bit (OSCCON<2> will be
a clock transition is generated if the system clock is not
                                                                      set when the INTOSC or postscaler frequency is stable,
already using the INTRC. The event will clear the
                                                                      after approximately 4 ms.
OSTS bit and switch the system clock from the primary
system clock (if SCS<1:0> = 00) determined by the                     After a clock switch has been executed, the OSTS bit
value contained in the configuration bits, or from the                is cleared, indicating a low-power mode and the device
T1OSC (if SCS<1:0> = 01) to the INTRC clock option,                   does not run from the primary system clock. The inter-
and shut down the primary system clock to conserve                    nal Q clocks are held in the Q1 state until eight falling
power. Clock switching will not occur if the primary                  edge clocks are counted on the INTRC oscillator. After
system clock is already configured as INTRC.                          the eight clock periods have transpired, the clock input
                                                                      to the Q clocks is released and operation resumes (see
                                                                      Figure 4-7).
FIGURE 4-7:               TIMING DIAGRAM FOR XT, HS, LP, EC, EXTRC TO RC_RUN MODE
             Q1 Q2 Q3 Q4 Q1                                                Q1   Q2    Q3    Q4    Q1    Q2       Q3   Q4   Q1
                                      TINP(1)
  INTOSC
                                                  TSCS(3)
  OSC1
               TOSC(2)
  System
  Clock
                            TDLY(4)
  SCS<1:0>
  Program
  Counter           PC                                       PC + 1                                     PC + 2             PC + 3
  Note 1:    TINP = 32 µs typical.
       2:    TOSC = 50 ns minimum.
       3:    TSCS = 8 TINP.
       4:    TDLY = 1 TINP.
 2003 Microchip Technology Inc.                      Preliminary                                            DS30498B-page 41
PIC16F7X7
4.7.2        SEC_RUN MODE
The core and peripherals can be configured to be                Note 1: The T1OSCEN bit must be enabled and it
clocked by T1OSC using a 32.768 kHz crystal. The                        is the user’s responsibility to ensure
crystal must be connected to the T1OSO and T1OSI                        T1OSC is stable before clock switching to
pins. This is the same configuration as the low-power                   the T1OSC input clock can occur.
timer circuit (see Section 7.6 “Timer1 Oscillator”).                     2: When T1OSCEN = 0, the following
When SCS bits are configured to run from T1OSC, a                           possible effects result.
clock transition is generated. It will clear the OSTS bit,                  Original Modified                 Final
switch the system clock from either the primary system                     SCS<1:0> SCS<1:0>                SCS<1:0>
clock or INTRC, depending on the value of SCS<1:0>
and FOSC<2:0>, to the external low-power Timer1                                00            01        00 – no change
oscillator input (T1OSC) and shut down the primary                             00            11        10 – INTRC
system clock to conserve power.                                                10            11        10 – no change
After a clock switch has been executed, the internal Q                         10            01        00 – OSC
clocks are held in the Q1 state until eight falling edge                                               defined by
clocks are counted on the T1OSC. After the eight clock                                                 FOSC<2:0>
periods have transpired, the clock input to the Q clocks                   A clock switching event will occur if the
is released and operation resumes (see Figure 4-8). In                     final state of the SCS bits is different from
addition, T1RUN (in T1CON) is set to indicate that                         the original.
T1OSC is being used as the system clock.
FIGURE 4-8:              TIMING DIAGRAM FOR SWITCHING TO SEC_RUN MODE
            Q1 Q2 Q3 Q4 Q1                                          Q1    Q2   Q3   Q4      Q1    Q2       Q3   Q4   Q1
                                     TT1P(1)
  T1OSI
                                                  TSCS(3)
  OSC1
              TOSC(2)
  System
  Clock
                           TDLY(4)
  SCS<1:0>
  Program
  Counter         PC                                  PC + 1                                      PC + 2             PC + 3
  Note 1:   TT1P = 30.52 µs.
       2:   TOSC = 50 ns minimum.
       3:   TSCS = 8 TT1P
       4:   TDLY = 1 TT1P.
DS30498B-page 42                                      Preliminary                         2003 Microchip Technology Inc.
                                                                                         PIC16F7X7
4.7.3       SEC_RUN/RC_RUN TO PRIMARY                         4.7.3.1        Returning to Primary Clock Source
            CLOCK SOURCE                                                     Sequence
When switching from a SEC_RUN or RC_RUN mode                  Changing back to the primary oscillator from
back to the primary system clock, following a change of       SEC_RUN or RC_RUN can be accomplished by either
SCS<1:0> to ‘00’, the sequence of events that take            changing SCS<1:0> to ‘00’ or clearing the T1OSCEN
place will depend upon the value of the FOSC bits in the      bit in the T1CON register (if T1OSC was the secondary
Configuration register. If the primary clock source is        clock).
configured as a crystal (HS, XT or LP), then the              The sequence of events that follows is the same for
transition will take place after 1024 clock cycles. This is   both modes:
necessary because the crystal oscillator has been pow-
ered down until the time of the transition. In order to       1.    If the primary system clock is configured as EC,
provide the system with a reliable clock when the                   RC or INTRC, then the OST time-out is skipped.
changeover has occurred, the clock will not be                      Skip to step 3.
released to the changeover circuit until the 1024 counts      2.    If the primary system clock is configured as an
have expired.                                                       external oscillator (HS, XT, LP), then the OST
                                                                    will be active, waiting for 1024 clocks of the
During the oscillator start-up time, the system clock
                                                                    primary system clock.
comes from the current system clock. Instruction exe-
cution and/or peripheral operation continues using the        3.    On the following Q1, the device holds the
currently selected oscillator as the CPU clock source               system clock in Q1.
until the necessary clock count has expired to ensure         4.    The device stays in Q1 while eight falling edges
that the primary system clock is stable.                            of the primary system clock are counted.
To know when the OST has expired, the OSTS bit                5.    Once the eight counts transpire, the device
should be monitored. OSTS = 1 indicates that the                    begins to run from the primary oscillator.
Oscillator Start-up Timer has timed out and the system        6.    If the secondary clock was INTRC and the
clock comes from the primary clock source.                          primary is not INTRC, the INTRC will be shut
                                                                    down to save current, providing that the INTRC
Following the oscillator start-up time, the internal Q
                                                                    is not being used for any other function, such as
clocks are held in the Q1 state until eight falling edge
                                                                    WDT or Fail-Safe Clock Monitoring.
clocks are counted from the primary system clock. The
clock input to the Q clocks is then released and              7.    If the secondary clock was T1OSC, the T1OSC
operation resumes with the primary system clock                     will continue to run if T1OSCEN is still set;
determined by the FOSC bits (see Figure 4-10).                      otherwise, the T1 oscillator will be shut down.
When in SEC_RUN mode, the act of clearing the
T1OSCEN bit in the T1CON register will cause
SCS<0> to be cleared, which causes the SCS<1:0>
bits to revert to ‘00’ or ‘10’ depending on what SCS<1>
is. Although the T1OSCEN bit was cleared, T1OSC will
be enabled and instruction execution will continue until
the OST time-out for the main system clock is com-
plete. At that time, the system clock will switch from the
T1OSC to the primary clock or the INTRC. Following
this, the T1 oscillator will be shut down.
  Note:     If the primary system clock is either RC or
            EC, an internal delay timer (5-10 µs) will
            suspend operation after exiting Secondary
            Clock mode to allow the CPU to become
            ready for code execution.
 2003 Microchip Technology Inc.                      Preliminary                                   DS30498B-page 43
PIC16F7X7
FIGURE 4-9:               TIMING FOR TRANSITION BETWEEN SEC_RUN/RC_RUN AND
                          PRIMARY CLOCK
                                                                    TT1P(1) or TINP(2)
                    Q4       Q1        Q2       Q3        Q4         Q1                           Q2 Q3 Q4 Q1 Q2 Q3 Q4
      Sec. Osc
         OSC1
                                  TOST(6)
         OSC2
                                                          TOSC(3)              TSCS(4)
  Primary Clock
  System Clock
     SCS<1:0>                                   TDLY(5)
         OSTS
      Program
      Counter       PC                      PC + 1                                       PC + 2                   PC + 3
   Note 1:   TT1P = 30.52 µs.
        2:   TINP = 32 µs typical.
        3:   TOSC = 50 ns minimum.
        4:   TSCS = 8 TINP OR 8 TT1P.
        5:   TDLY = 1 TINP OR 1 TT1P.
        6:   Refer to parameter “D032” in Section 18.0 “Electrical Characteristics”.
DS30498B-page 44                                               Preliminary                         2003 Microchip Technology Inc.
                                                                                                         PIC16F7X7
4.7.3.2           Returning to Primary Oscillator with                       no oscillator start-up time required because the pri-
                  a Reset                                                    mary clock is already stable; however, there is a delay
                                                                             between the wake-up event and the following Q2. An
A Reset will clear SCS<1:0> back to ‘00’. The
                                                                             internal delay timer of 5-10 µs will suspend operation
sequence for starting the primary oscillator following a
                                                                             after the Reset to allow the CPU to become ready for
Reset is the same for all forms of Reset, including
                                                                             code execution. The CPU and peripheral clock will be
POR. There is no transition sequence from the
                                                                             held in the first Q1.
alternate system clock to the primary system clock on
a Reset condition. Instead, the device will reset the                        The sequence of events is as follows:
state of the OSCCON register and default to the                              1.    A device Reset is asserted from one of many
primary system clock. The sequence of events that                                  sources (WDT, BOR, MCLR, etc.).
take place after this will depend upon the value of the                      2.    The device resets and the CPU start-up timer is
FOSC bits in the Configuration register. If the external                           enabled if in Sleep mode. The device is held in
oscillator is configured as a crystal (HS, XT or LP), the                          Reset until the CPU start-up time-out is
CPU will be held in the Q1 state until 1024 clock cycles                           complete.
have transpired on the primary clock. This is
                                                                             3.    If the primary system clock is configured as an
necessary because the crystal oscillator had been
                                                                                   external oscillator (HS, XT, LP), then the OST
powered down until the time of the transition.
                                                                                   will be active waiting for 1024 clocks of the pri-
During the oscillator start-up time, instruction                                   mary system clock. While waiting for the OST,
execution and/or peripheral operation is suspended.                                the device will be held in Reset. The OST and
  Note:       If Two-Speed Clock Start-up mode is                                  CPU start-up timers run in parallel.
              enabled, the INTRC will act as the system                      4.    After both the CPU start-up and OST timers
              clock until the OST timer has timed out.                             have timed out, the device will wait for one
                                                                                   additional clock cycle and instruction execution
If the primary system clock is either RC, EC or INTRC,
                                                                                   will begin.
the CPU will begin operating on the first Q1 cycle
following the wake-up event. This means that there is
FIGURE 4-10:              TIMING LP CLOCK TO PRIMARY SYSTEM CLOCK AFTER RESET (HS, XT, LP)
                                                             TT1P(1)
                    Q4      Q1                         Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4                Q1 Q2 Q3 Q4
          T1OSI
          OSC1
                                    TOST(4)
          OSC2
                                    TEPU(3)
                                                                TOSC(2)
  CPU Start-up
  System Clock
     Peripheral
         Clock
          Reset
          Sleep
        OSTS
      Program
      Counter        PC                                 0000h                 0001h           0003h          0004h           0005h
   Note 1:   TT1P = 30.52 µs.
        2:   TOSC = 50 ns minimum.
        3:   TEPU = 5-10 µs.
        4:   Refer to parameter “D032” in Section 18.0 “Electrical Characteristics”.
 2003 Microchip Technology Inc.                             Preliminary                                             DS30498B-page 45
PIC16F7X7
FIGURE 4-11:              TIMING LP CLOCK TO PRIMARY SYSTEM CLOCK AFTER RESET
                          (EC, RC, INTRC)
                                                      TT1P(1)
                   Q4          Q1             Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4   Q1 Q2 Q3 Q4   Q1 Q2 Q3 Q4
        T1OSI
        OSC1
        OSC2                        TCPU(2)
  CPU Start-up
 System Clock
        MCLR
        OSTS
      Program
      Counter      PC                         0000h             0001h     0002h         0003h          0004h
  Note 1:   TT1P = 30.52 µs.
       2:   TCPU = 5-10 µs.
DS30498B-page 46                                  Preliminary                      2003 Microchip Technology Inc.
                                                                                           PIC16F7X7
TABLE 4-4:         CLOCK SWITCHING MODES
   Current                                                                      New
                  SCS bits <1:0>                    OSTS    IOFS T1RUN
   System                               Delay                                  System              Comments
                   Modified to:                      bit     bit   bit
    Clock                                                                       Clock
 LP, XT, HS,           10             8 Clocks of     0      1(1)      0       INTRC    The internal RC oscillator
  T1OSC,            (INTRC)             INTRC                                    or     frequency is dependant upon
   EC, RC        FOSC<2:0> = LP,                                              INTOSC the IRCF bits.
                    XT or HS                                                     or
                                                                              INTOSC
                                                                             Postscaler
 LP, XT, HS,           01             8 Clocks of     0      N/A       1       T1OSC      T1OSCEN bit must be
   INTRC,           (T1OSC)             T1OSC                                             enabled.
   EC, RC        FOSC<2:0> = LP,
                    XT or HS
   INTRC              00              8 Clocks of     1      N/A       0         EC
   T1OSC         FOSC<2:0> = EC           EC                                     or
                       or                 or                                     RC
                 FOSC<2:0> = RC           RC
   INTRC               00            1024 Clocks      1      N/A       0     LP, XT, HS During the 1024 clocks,
   T1OSC         FOSC<2:0> = LP,        (OST)                                           program execution is
                     XT, HS                +                                            clocked from the secondary
                                      8 Clocks of                                       oscillator until the primary
                                      LP, XT, HS                                        oscillator becomes stable.
 LP, XT, HS              00          1024 Clocks      1      N/A       0     LP, XT, HS When a Reset occurs, there
                   (Due to Reset)       (OST)                                           is no clock transition
                     LP, XT, HS                                                         sequence. Instruction
                                                                                        execution and/or peripheral
                                                                                        operation is suspended
                                                                                        unless Two-Speed Start-up
                                                                                        mode is enabled, after which
                                                                                        the INTRC will act as the
                                                                                        system clock until the OST
                                                                                        timer has expired.
Note 1:      If the new clock source is INTOSC or INTOSC postscaler, then the IOFS bit will be set 4 ms after the clock
             change.
 2003 Microchip Technology Inc.                    Preliminary                                       DS30498B-page 47
PIC16F7X7
4.7.4       EXITING SLEEP WITH AN                             If SCS<1:0> = 01 or 10:
            INTERRUPT                                         1.    The device is held in Sleep until the CPU start-up
Any interrupt, such as WDT or INT0, will cause the part             time-out is complete.
to leave the Sleep mode.                                      2.    After the CPU start-up timer has timed out, the
The SCS bits are unaffected by a SLEEP command and                  device will exit Sleep and begin instruction
are the same before and after entering and leaving                  execution with the selected oscillator mode.
Sleep. The clock source used after an exit from Sleep              Note:   If a user changes SCS<1:0> just before
is determined by the SCS bits.                                             entering Sleep mode, the system clock
                                                                           used when exiting Sleep mode could be
4.7.4.1       Sequence of Events
                                                                           different than the system clock used when
If SCS<1:0> = 00:                                                          entering Sleep mode.
1.   The device is held in Sleep until the CPU start-up                    As an example, if SCS<1:0> = 01, T1OSC
     time-out is complete.                                                 is the system clock and the following
2.   If the primary system clock is configured as an                       instructions are executed:
     external oscillator (HS, XT, LP), then the OST will                   BCF           OSCCON,SCS0
     be active waiting for 1024 clocks of the primary                      SLEEP
     system clock. While waiting for the OST, the
     device will be held in Sleep unless Two-Speed                         then a clock change event is executed. If
     Start-up is enabled. The OST and CPU start-up                         the primary oscillator is XT, LP or HS, the
     timers run in parallel. Refer to Section 15.17.3                      core will continue to run off T1OSC and
     “Two-Speed Clock Start-up Mode” for details                           execute the SLEEP command.
     on Two-Speed Start-up.                                                When Sleep is exited, the part will resume
3.   After both the CPU start-up and OST timers                            operation with the primary oscillator after
     have timed out, the device will exit Sleep and                        the OST has expired.
     begin instruction execution with the primary
     clock defined by the FOSC bits.
DS30498B-page 48                                      Preliminary                        2003 Microchip Technology Inc.
                                                                                         PIC16F7X7
5.0      I/O PORTS                                            The other PORTA pins are multiplexed with analog
                                                              inputs, the analog VREF+ and VREF- inputs and the com-
Some pins for these I/O ports are multiplexed with an         parator voltage reference output. The operation of pins
alternate function for the peripheral features on the         RA3:RA0 and RA5 as A/D converter inputs is selected
device. In general, when a peripheral is enabled, that        by clearing/setting the control bits in the ADCON1 reg-
pin may not be used as a general purpose I/O pin.             ister (A/D Control Register 1). Pins RA0 through RA5
Additional information on I/O ports may be found in the       may also be used as comparator inputs or outputs by
PICmicro® Mid-Range MCU Family Reference Manual,              setting the appropriate bits in the CMCON register.
(DS33023).                                                      Note:     On a Power-on Reset, RA5 and RA3:RA0
                                                                          are configured as analog inputs and read
5.1      PORTA and the TRISA Register                                     as ‘0’. RA4 is configured as a digital input.
PORTA is a 8-bit wide, bidirectional port. The corre-         The RA4/T0CKI/C1OUT pin is a Schmitt Trigger input
sponding data direction register is TRISA. Setting a          and an open-drain output. All other PORTA pins have
TRISA bit (= 1) will make the corresponding PORTA pin         TTL input levels and full CMOS output drivers.
an input (i.e., put the corresponding output driver in a
                                                              The TRISA register controls the direction of the RA pins
high-impedance mode). Clearing a TRISA bit (= 0) will
                                                              even when they are being used as analog inputs. The
make the corresponding PORTA pin an output (i.e., put
                                                              user must ensure the bits in the TRISA register are
the contents of the output latch on the selected pin).
                                                              maintained set when using them as analog inputs.
Reading the PORTA register reads the status of the
pins, whereas writing to it, will write to the port latch.    EXAMPLE 5-1:           INITIALIZING PORTA
The RA4 pin is multiplexed with the Timer0 module              BCF      STATUS, RP0      ;
clock input and one of the comparator outputs to               BCF      STATUS, RP1      ;   Bank0
become the RA4/T0CKI/C1OUT pin. Pins RA6 and                   CLRF     PORTA            ;   Initialize PORTA by
RA7 are multiplexed with the main oscillator pins; they                                  ;   clearing output
are enabled as oscillator or I/O pins by the selection of                                ;   data latches
                                                               BSF      STATUS, RP0      ;   Select Bank 1
the main oscillator in Configuration Register 1H (see
                                                               MOVLW    0x0F             ;   Configure all pins
Section 15.1 “Configuration Bits” for details). When
                                                               MOVWF    ADCON1           ;   as digital inputs
they are not used as port pins, RA6 and RA7 and their          MOVLW    0xCF             ;   Value used to
associated TRIS and LAT bits are read as ‘0’.                                            ;   initialize data
                                                                                         ;   direction
                                                               MOVWF    TRISA            ;   Set RA<3:0> as inputs
                                                                                         ;   RA<5:4> as outputs
                                                                                         ;   TRISA<7:6>are always
                                                                                         ;   read as '0'.
 2003 Microchip Technology Inc.                      Preliminary                                   DS30498B-page 49
PIC16F7X7
FIGURE 5-1:                 BLOCK DIAGRAM OF                      FIGURE 5-2:                 BLOCK DIAGRAM OF
                            RA0/AN0:RA1/AN1 PINS                                              RA3/AN3/VREF+ PIN
                                                                   Data
 Data                                                              Bus
 Bus                                                                          D           Q
            D           Q                                                                                      VDD
                                             VDD                   WR
 WR                                                                PORTA
 PORTA                                                                            CK      Q
                CK      Q                                                                                       P
                                              P                               Data Latch
            Data Latch
                                                                              D           Q
            D           Q                                                                                               I/O pin
                                                      I/O pin      WR                                           N
 WR                                           N                    TRISA
 TRISA                                                                            CK      Q
                CK      Q
                                                                              TRIS Latch                       VSS
            TRIS Latch                       VSS                                                      Analog
                                    Analog                                                        Input Mode
                                Input Mode
                                                                                                             TTL
                                          TTL                                                            Input Buffer
                                       Input Buffer                                    RD TRISA
                     RD TRISA
                                                                                                     Q            D
                                   Q            D
                                                                                                             EN
                                           EN
                                                                          RD PORTA
        RD PORTA
                                                                             To Comparator
           To Comparator
                                                                             To A/D Module Channel Input
           To A/D Module Channel Input
                                                                              To A/D Module VREF+ Input
DS30498B-page 50                                          Preliminary                          2003 Microchip Technology Inc.
                                                                                                         PIC16F7X7
FIGURE 5-3:                   BLOCK DIAGRAM OF RA2/AN2/VREF-/CVREF PIN
       Data
       Bus           D            Q
       WR                                                                                 VDD
       PORTA
                         CK       Q
                                                                                          P
                     Data Latch
                     D            Q
                                                                                          N                          RA2/AN2/VREF-/
       WR                                                                                                              CVREF pin
       TRISA             CK       Q
                     TRIS Latch                                                           VSS
                                                                                                  Analog
                                                                                              Input Mode
                                                                                                     TTL
                              RD TRISA                                                            Input Buffer
                                                                   Q             D
                                                                            EN
              RD PORTA
                     To Comparator
                    To A/D Module VREF-
                    To A/D Module Channel Input
                                               CVROE
                                               CVREF
FIGURE 5-4:                   BLOCK DIAGRAM OF RA4/T0CKI/C1OUT PIN
    Data                                    Comparator Mode = 011, 101, 001
    Bus         D             Q
                                      Comparator 1 Output
    WR
    PORTA                                                               1
                 CK      Q
                Data Latch                                              0
                D             Q
                                                                                                                         RA4/T0CKI/
    WR                                                                                                      N
                                                                                                                         C1OUT pin
    TRISA
                    CK        Q
                TRIS Latch                                                      Analog                      VSS
                                                                            Input Mode
                                                                                                   Schmitt Trigger
                                                                                                      Input Buffer
                         RD TRISA
                                                                                     Q        D
                                                                                         EN
           RD PORTA
           TMR0 Clock Input
 2003 Microchip Technology Inc.                            Preliminary                                                DS30498B-page 51
PIC16F7X7
FIGURE 5-5:                  BLOCK DIAGRAM OF RA5/AN4/LVDIN/SS/C2OUT PIN
     Data                                         Comparator Mode = 011, 101
     Bus
                   D           Q
     WR                            Comparator 2 Output
                                                                                     VDD
     PORTA                                                      1
                       CK      Q
                                                                0                    P
                   Data Latch
                   D           Q
                                                                                                  RA5/AN4/LVDIN/
     WR                                                                              N
     TRISA                                                                                         SS/C2OUT pin
                       CK      Q
                   TRIS Latch                                              Analog    VSS
                                                                       Input Mode
                                                                                          TTL
                                                                                         Buffer
                            RD TRISA
                                                                       Q         D
                                                                            EN
       RD PORTA
        SS Input
        LVDIN
        To A/D Module Channel Input
DS30498B-page 52                                         Preliminary                  2003 Microchip Technology Inc.
                                                                                                   PIC16F7X7
FIGURE 5-6:                BLOCK DIAGRAM OF OSC2/CLKO/RA6 PIN
                                           (FOSC = 1x1)
            CLKO (FOSC/4)                                         From OSC1       Oscillator
                                               1                                   Circuit
                                               0
                                                                                                      VDD
          Data                                                                                                  OSC2/CLKO
          Bus          D           Q                                                      VDD                    RA6 pin
          WR
          PORTA            CK      Q                                                       P
                       Data Latch
                       D           Q
          WR                                                                               N
          TRISA
                           CK      Q
                       TRIS Latch                                      (FOSC = 1x1)
                                                                           EMUL           VSS
                                                   EMUL + FOSC = 00x,010
                                                                           (FOSC = 1x0,011)
                                RD TRISA
                                                                                                       TTL
                                              Q          D                              EMUL          Buffer
                                                    EN                                     1
                                                                                               0
                 RD PORTA
                                                                                                                   ERA6 pin
                                                                                        (FOSC = 1x0,011)
                                                                       VDD
                                                                           N
        (FOSC = 1x1)
                       EMUL + FOSC = 00x, 010
                                                                       VSS
     Note 1: CLKO signal is 1/4 of the FOSC frequency.
 2003 Microchip Technology Inc.                             Preliminary                                       DS30498B-page 53
PIC16F7X7
FIGURE 5-7:            BLOCK DIAGRAM OF OSC1/CLKI/RA7 PIN
                                                       Oscillator
                                                        Circuit
                                                                                                 VDD
                                                                              (FOSC = 011)
        Data
        Bus                                                                                             OSC1/CLKI
                   D           Q
                                                                     VDD                                 RA7 pin
        WR
        PORTA
                       CK      Q                                        P
                   Data Latch
                   D           Q
        WR                                                              N
        TRISA
                       CK      Q
                   TRIS Latch          (FOSC = 10x) + EMUL
                                                                        VSS
                                                                              (FOSC = 10x)
                            RD TRISA
                                       Q           D
                                                                               NEMUL
                                                                                              TTL
                                                                                  1          Buffer
                                              EN
                                                                                  0
               RD PORTA
                                                                                                            ERA7 pin
                                                                                             (FOSC = 10x)
                                                                    VDD
                        (FOSC = 10x) + EMUL
                                                                    VSS
DS30498B-page 54                                          Preliminary                     2003 Microchip Technology Inc.
                                                                                                    PIC16F7X7
TABLE 5-1:         PORTA FUNCTIONS
            Name                   Bit#      Buffer                                       Function
RA0/AN0                            bit 0       TTL         Input/output or analog input.
RA1/AN1                            bit 1       TTL         Input/output or analog input.
RA2/AN2/VREF-/CVREF                bit 2       TTL         Input/output or analog input or VREF-.
RA3/AN3/VREF+                      bit 3       TTL         Input/output or analog input or VREF+.
RA4/T0CKI/C1OUT                    bit 4       ST          Input/output or external clock input for Timer0. Output is
                                                           open-drain type.
RA5/AN4/LVDIN/SS/C2OUT             bit 5       TTL         Input/output or slave select input for synchronous serial port or
                                                           analog input.
OSC2/CLKO/RA6                      bit 6       ST          Input/output, connects to crystal or resonator, oscillator output or
                                                           1/4 the frequency of OSC1 and denotes the instruction cycle in
                                                           RC mode.
OSC1/CLKI/RA7                      bit 7   ST/CMOS(1) Input/output, connects to crystal or resonator or oscillator input.
Legend: TTL = TTL input, ST = Schmitt Trigger input
Note 1: This buffer is a Schmitt Trigger input when configured in RC Oscillator mode and a CMOS input otherwise.
TABLE 5-2:         SUMMARY OF REGISTERS ASSOCIATED WITH PORTA
                                                                                                                   Value on
                                                                                                     Value on:
Address     Name       Bit 7       Bit 6    Bit 5     Bit 4    Bit 3    Bit 2     Bit 1     Bit 0                  all other
                                                                                                     POR, BOR
                                                                                                                    Resets
05h        PORTA       RA7         RA6      RA5       RA4      RA3      RA2       RA1       RA0      xx0x 0000    uu0u 0000
85h        TRISA      PORTA Data Direction Register                                                  1111 1111    1111 1111
9Fh        ADCON1       —           —      VCFG1 VCFG0 PCFG3 PCFG2               PCFG1     PCFG0     --00 0000    --00 0000
9Ch        CMCON      C2OUT    C1OUT       C2INV     C1INV      CIS     CM2       CM1       CM0      0000 0111    0000 0111
9Dh        CVRCON     CVREN CVROE          CVRR        —       CVR3     CVR2     CVR1       CVR0     000- 0000    000- 0000
Legend:     x = unknown, u = unchanged, - = unimplemented locations read as ‘0’. Shaded cells are not used by PORTA.
  Note:     When using the SSP module in SPI Slave mode and SS enabled, the A/D converter must be set to one of
            the following modes, where PCFG2:PCFG0 = 100, 101, 11x.
 2003 Microchip Technology Inc.                        Preliminary                                         DS30498B-page 55
PIC16F7X7
5.2          PORTB and the TRISB Register                       The interrupt-on-change feature is recommended for
                                                                wake-up on key depression operation and operations
PORTB is an 8-bit wide, bidirectional port. The corre-          where PORTB is only used for the interrupt-on-change
sponding data direction register is TRISB. Setting a            feature. Polling of PORTB is not recommended while
TRISB bit (= 1) will make the corresponding PORTB               using the interrupt-on-change feature.
pin an input (i.e., put the corresponding output driver in
a high-impedance mode). Clearing a TRISB bit (= 0)              This interrupt on mismatch feature, together with soft-
will make the corresponding PORTB pin an output (i.e.,          ware configureable pull-ups on these four pins, allow
put the contents of the output latch on the selected pin).      easy interface to a keypad and make it possible for
                                                                wake-up on key depression. Refer to the Application
Each of the PORTB pins has a weak internal pull-up. A           Note AN552, “Implementing Wake-up on Key Stroke”
single control bit can turn on all the pull-ups. This is per-   (DS00552).
formed by clearing bit RBPU (OPTION_REG<7>). The
weak pull-up is automatically turned off when the port          RB0/INT is an external interrupt input pin and is
pin is configured as an output. The pull-ups are                configured using the INTEDG bit (OPTION_REG<6>).
disabled on a Power-on Reset.                                   RB0/INT is discussed in detail in Section 15.15.1 “INT
                                                                Interrupt”.
PORTB pins are multiplexed with analog inputs. The
operation of each pin is selected by clearing/setting the       PORTB is multiplexed with several peripheral functions
appropriate control bits in the ADCON1 register.                (see Table 5-3). PORTB pins have Schmitt Trigger
                                                                input buffers.
     Note:    On a Power-on Reset, these pins are
                                                                When enabling peripheral functions, care should be
              configured as analog inputs and read as
                                                                taken in defining TRIS bits for each PORTB pin. Some
              ‘0’.
                                                                peripherals override the TRIS bit to make a pin an out-
Four of the PORTB pins (RB7:RB4) have an interrupt-             put, while other peripherals override the TRIS bit to
on-change feature. Only pins configured as inputs can           make a pin an input. Since the TRIS bit override is in
cause this interrupt to occur (i.e., any RB7:RB4 pin            effect while the peripheral is enabled, read-modify-
configured as an output is excluded from the interrupt-         write instructions (BSF, BCF, XORWF) with TRISB as
on-change comparison). The input pins (of RB7:RB4)              destination should be avoided. The user should refer to
are compared with the old value latched on the last             the corresponding peripheral section for the correct
read of PORTB. The “mismatch” outputs of RB7:RB4                TRIS bit settings.
are ORed together to generate the RB port change
interrupt with flag bit, RBIF (INTCON<0>).
This interrupt can wake the device from Sleep. The
user, in the Interrupt Service Routine, can clear the
interrupt in the following manner:
a)    Any read or write of PORTB. This will end the
      mismatch condition.
b)    Clear flag bit RBIF.
A mismatch condition will continue to set flag bit RBIF.
Reading PORTB will end the mismatch condition and
allow flag bit RBIF to be cleared.
DS30498B-page 56                                        Preliminary                      2003 Microchip Technology Inc.
                                                                                                    PIC16F7X7
FIGURE 5-8:            BLOCK DIAGRAM OF RB0/INT/AN12 PIN
                                                                                                         VDD
              Analog               RBPU (1)                                                                 Weak
              Input Mode                                                                                  P Pull-up
                                                      Data Latch
                                   Data Bus
                                                      D     Q
                                   WR PORTB                                                                   I/O pin
                                                       CK
                                                      TRIS Latch
                                                       D    Q
                                   WR TRISB            CK                             Analog
                                                                                    Input Mode
                                                                                          TTL
                                                            RD TRISB                   Input Buffer
                                                                                           Q        D
                                                    RD PORTB                                     EN
                                                                         Analog
                                                                       Input Mode
                                                                                                   RD PORTB
                                          To INT
                           To A/D Channel Input
              Note 1: To enable weak pull-ups, set the appropriate TRIS bit(s) and clear the RBPU bit.
FIGURE 5-9:            BLOCK DIAGRAM OF RB1/AN10 PIN
                                                                                                        VDD
               Analog          RBPU (1)                                                                   Weak
               Input Mode                                                                               P Pull-up
                                                    Data Latch
                               Data Bus
                                                     D    Q
                               WR PORTB                                                                    I/O pin
                                                     CK
                                                    TRIS Latch
                                                     D    Q
                               WR TRISB              CK                           Analog
                                                                                Input Mode
                                                                                         TTL
                                                    RD TRISB                          Input Buffer
                                                                                       Q       D
                                                   RD PORTB                                    EN
                                                                                               RD PORTB
                      To A/D Channel Input
                Note 1: To enable weak pull-ups, set the appropriate TRIS bit(s) and clear the RBPU bit.
 2003 Microchip Technology Inc.                       Preliminary                                               DS30498B-page 57
PIC16F7X7
FIGURE 5-10:           BLOCK DIAGRAM OF RB2/AN8 PIN
                                                                                                VDD
                           RBPU(1)
                                                                                                   Weak
                                                                                                 P Pull-up
                                               Data Latch
                           Data Bus
                                                D    Q
                                                                                                    I/O pin
                           WR PORTB
                                                CK
                                               TRIS Latch
                                                D    Q
                                                                                Analog
                           WR TRISB                                           Input Mode
                                                CK
                                                                                    TTL
                                                                                 Input Buffer
                                               RD TRISB
                                                                                   Q     D
                                              RD PORTB                                  EN
                                                                                         RD PORTB
                   To A/D Channel Input
                   Note 1: To enable weak pull-ups, set the appropriate TRIS bit(s) and clear the RBPU bit.
DS30498B-page 58                                      Preliminary                                2003 Microchip Technology Inc.
                                                                                                   PIC16F7X7
FIGURE 5-11:           BLOCK DIAGRAM OF RB3/CCP2/AN9 PIN
                                                                  Analog
                                                                Input Mode
                CCP2 Output Select and CCPMX
                                    CCP2 Output
                                                                     1
                                                                                                         VDD
                          RBPU(1)
                                                                                                           Weak
                                                                                                         P Pull-up
                                             Data Latch                                            VDD
                          Data Bus
                                              D
                                                   Q                                               P
                          WR PORTB
                                               CK
                                                                                                            I/O pin
                                                                                                   N
                                                                                                   VSS
                                             TRIS Latch
                                              D     Q
                          WR TRISB             CK      Q                                Analog
                                                                                      Input Mode
                                                                                            TTL
                                                                                         Input Buffer
                                             RD TRISB
                                                                                          Q        D
                                            RD PORTB                                            EN
                                To A/D Channel Input                                               RD PORTB
                                                       Schmitt Trigger     Analog
                                                       Buffer            Input Mode
                                To CCP Module Input
                   Note 1: To enable weak pull-ups, set the appropriate TRIS bit(s) and clear the RBPU bit.
                        2: The SDA Schmitt conforms to the I2C specification.
 2003 Microchip Technology Inc.                       Preliminary                                             DS30498B-page 59
PIC16F7X7
FIGURE 5-12:          BLOCK DIAGRAM OF RB4/AN11 PIN
                                                             Analog
                                                             Input Mode
                                                             RBPU(1)                          VDD
                                                                                                 Weak
                                                                                               P Pull-up
                                                                                     VDD
                                                                                     P
                                  Data Latch
               Data Bus
                                   D     Q
                                                                                     N            I/O pin
               WR PORTB             CK
                                  TRIS Latch
                                                                                     VSS
                                   D    Q
               WR TRISB             CK
                                  RD TRISB
                                                                               Analog
                                                                           Input Mode
                                                                                  TTL
                                                                               Input Buffer
                                                                                  Latch
                                                                                 Q    D
                                  RD PORTB                                               EN         Q1
                   Set RBIF
                                                   Analog
                                                   Input Mode
                   From other                                                    Q       D       RD PORTB
                   RB7:RB4 pins
                                                                                         EN
                                                                                                     Q3
               To A/D channel input
               Note 1: To enable weak pull-ups, set the appropriate TRIS bit(s) and clear the RBPU bit.
                    2: The SCL Schmitt conforms to the I2C specification.
DS30498B-page 60                                    Preliminary                                2003 Microchip Technology Inc.
                                                                                                        PIC16F7X7
FIGURE 5-13:           BLOCK DIAGRAM OF RB5/AN13/CCP3 PIN
                                                         Analog
                                                       Input Mode
         CCP3 Output Select
               CCP3 Output
                                                                1
                                                                0                                 VDD
                               (1)                                                                  Weak
                        RBPU                                                                      P Pull-up
                                          Data Latch
                        Data Bus
                                           D    Q
                                                                                                     I/O pin
                        WR PORTB           CK
                                          TRIS Latch
                                           D    Q
                        WR TRISB           CK
                                                                                   Analog
                                                                                 Input Mode
                                                                                      TTL
                                          RD TRISB                                 Input Buffer
                                                                                      Latch
                                                                                     Q    D
                                        RD PORTB                                          EN            Q1
                         Set RBIF                               Analog
                                                                Input Mode
                         From other                                                  Q     D             RD PORTB
                         RB7:RB4 pins
                                                                      Analog
                                                                                          EN
                                              Schmitt Trigger       Input Mode                          Q3
                                              Buffer
                   To CCP Module Input
                   To A/D Channel Input
            Note 1: To enable weak pull-ups, set the appropriate TRIS bit(s) and clear the RBPU bit.
 2003 Microchip Technology Inc.                         Preliminary                                           DS30498B-page 61
PIC16F7X7
FIGURE 5-14:         BLOCK DIAGRAM OF RB6/PGC PIN
             Program Mode/ICD                                                            VDD
                        RBPU(1)                                                                Weak
                                                                                             P Pull-up
                                       Data Latch
                    Data Bus
                                        D    Q
                                                                                                I/O pin
                    WR PORTB            CK
                                      TRIS Latch
                                       D    Q
                    WR TRISB            CK
                                                                                 TTL
                                      RD TRISB                                Input Buffer
                                                                              Latch
                                                                             Q     D
                                    RD PORTB                                      EN              Q1
                      Set RBIF                        Program Mode/ICD
                       From other                                            Q     D
                       RB7:RB4 pins                                                      RD PORTB
                                                                                  EN
                                                                                                  Q3
                                               Schmitt Trigger
                                               Buffer
                       PGC
           Note 1: To enable weak pull-ups, set the appropriate TRIS bit(s) and clear the RBPU bit.
DS30498B-page 62                                    Preliminary                                2003 Microchip Technology Inc.
                                                                                                    PIC16F7X7
FIGURE 5-15:            BLOCK DIAGRAM OF RB7/PGD PIN
          PORT/Program Mode/ICD
                               PGD
                                                                       1
                                                                       0                              VDD
                              RBPU(1)
                                                                                                           Weak
                                                                                                         P Pull-up
                                                    Data Latch
                              Data Bus
                                                     D    Q
                              WR PORTB                                                                      I/O pin
                                                      CK
                                                    TRIS Latch
                                                     D    Q                           0
                              WR TRISB
                                                      CK                              1
                                                                                             TTL
                                                    RD TRISB                              Input Buffer
                              PGD DRVEN
                                                                                           Latch
                                                                                          Q     D
                                                    RD PORTB       Program Mode/ICD           EN      Q1
                                   Set RBIF
                                   From other                                             Q    D
                                                                                                            RD PORTB
                                   RB7:RB4 pins
                                                                                              EN
                                                                                                               Q3
                                              PGD
           Note 1: To enable weak pull-ups, set the appropriate TRIS bit(s) and clear the RBPU bit.
 2003 Microchip Technology Inc.                           Preliminary                                          DS30498B-page 63
PIC16F7X7
TABLE 5-3:         PORTB FUNCTIONS
          Name             Bit#       Buffer                                      Function
RB0/INT/AN12               bit 0     TTL/ST(1) Input/output pin or external interrupt input. Internal software
                                               programmable weak pull-up or analog input.
RB1/AN10                   bit 1        TTL       Input/output pin. Internal software programmable weak pull-up or
                                                  analog input.
RB2/AN8                    bit 2        TTL       Input/output pin. Internal software programmable weak pull-up or
                                                  analog input.
RB3/CCP2/AN9               bit 3        TTL       Input/output pin or Capture 2 input/Compare 2 output/PWM 2 output.
                                                  Internal software programmable weak pull-up or analog input.
RB4/AN11                   bit 4        TTL       Input/output pin (with interrupt-on-change). Internal software
                                                  programmable weak pull-up or analog input.
RB5/AN13/CCP3              bit 5        TTL       Input/output pin (with interrupt-on-change). Internal software
                                                  programmable weak pull-up or analog input or Capture 2 input/
                                                  Compare 2 output/PWM 2 output.
RB6/PGC                    bit 6     TTL/ST(2) Input/output pin (with interrupt-on-change). Internal software
                                               programmable weak pull-up. Serial programming clock.
RB7/PGD                    bit 7     TTL/ST(2) Input/output pin (with interrupt-on-change). Internal software
                                               programmable weak pull-up. Serial programming data.
Legend: TTL = TTL input, ST = Schmitt Trigger input
Note 1: This buffer is a Schmitt Trigger input when configured as the external interrupt.
     2: This buffer is a Schmitt Trigger input when used in Serial Programming mode.
TABLE 5-4:         SUMMARY OF REGISTERS ASSOCIATED WITH PORTB
                                                                                                                   Value on
                                                                                                     Value on:
Address      Name        Bit 7      Bit 6      Bit 5    Bit 4    Bit 3    Bit 2    Bit 1     Bit 0                 all other
                                                                                                     POR, BOR
                                                                                                                    Resets
06h, 106h PORTB          RB7        RB6        RB5      RB4      RB3      RB2      RB1       RB0     xx00 0000 uu00 0000
86h, 186h TRISB        PORTB Data Direction Register                                                 1111 1111 1111 1111
81h, 181h OPTION_REG RBPU          INTEDG      T0CS     T0SE     PSA      PS2      PS1       PS0     1111 1111 1111 1111
9Fh       ADCON1        ADFM       ADCS2      VCFG1    VCFG0    PCFG3 PCFG2 PCFG1 PCFG0 0000 0000 0000 0000
Legend:    x = unknown, u = unchanged. Shaded cells are not used by PORTB.
DS30498B-page 64                                       Preliminary                            2003 Microchip Technology Inc.
                                                                                                        PIC16F7X7
5.3       PORTC and the TRISC Register                                FIGURE 5-17:                 PORTC BLOCK DIAGRAM
                                                                                                   (PERIPHERAL OUTPUT
PORTC is an 8-bit wide, bidirectional port. The corre-
                                                                                                   OVERRIDE) RC<4:3> PINS
sponding data direction register is TRISC. Setting a
TRISC bit (= 1) will make the corresponding PORTC                      Port/Peripheral Select(2)
pin an input (i.e., put the corresponding output driver in
a high-impedance mode). Clearing a TRISC bit (= 0)                     Peripheral Data Out
                                                                                                    0
will make the corresponding PORTC pin an output (i.e.,                                                                  VDD
                                                                       Data Bus
put the contents of the output latch on the selected pin).             WR
                                                                                     D       Q                              P      I/O
                                                                       Port                         1                              pin(1)
PORTC is multiplexed with several peripheral functions                                CK      Q
(Table 5-5). PORTC pins have Schmitt Trigger input                                  Data Latch
buffers.
                                                                                     D        Q
When enabling peripheral functions, care should be                     WR
                                                                       TRIS
taken in defining TRIS bits for each PORTC pin. Some                                  CK      Q                         N
peripherals override the TRIS bit to make a pin an                                  TRIS Latch
output, while other peripherals override the TRIS bit to               RD
                                                                                                                        Vss
make a pin an input. Since the TRIS bit override is in                 TRIS
                                                                                                                  Schmitt
effect while the peripheral is enabled, read-modify-                                                              Trigger
write instructions (BSF, BCF, XORWF) with TRISC as                     Peripheral
destination should be avoided. The user should refer to                OE(3)                            Q     D                 Schmitt
the corresponding peripheral section for the correct                                                                            Trigger
                                                                                                            EN                  with
TRIS bit settings and to Section 16.1 “Read-Modify-                    RD                                                       SMBus
Write Operations” for additional information on                        Port                                             0       Levels
read-modify-write operations.                                          SSPl Input
                                                                                                                        1
FIGURE 5-16:                  PORTC BLOCK DIAGRAM                                                           CKE
                              (PERIPHERAL OUTPUT                                                            SSPSTAT<6>
                              OVERRIDE) RC<2:0>,
                                                                       Note 1: I/O pins have diode protection to VDD and VSS.
                              RC<7:5> PINS                                  2: Port/Peripheral Select signal selects between port data
                                                                               and peripheral output.
  Port/Peripheral Select(2)                                                 3: Peripheral OE (Output Enable) is only activated if
                                                                               Peripheral Select is active.
  Peripheral Data Out
                               0                   VDD
  Data Bus
                D        Q
  WR                                                   P   I/O
  Port           CK      Q     1                           pin(1)
                Data Latch
                 D       Q
  WR
  TRIS           CK      Q                             N
                TRIS Latch
                                                   VSS
  RD
  TRIS
                                             Schmitt
                                             Trigger
  Peripheral
  OE(3)                            Q     D
  RD                                    EN
  Port
  Peripheral Input
  Note 1: I/O pins have diode protection to VDD and VSS.
         2: Port/Peripheral Select signal selects between port
            data and peripheral output.
         3: Peripheral OE (Output Enable) is only activated if
            Peripheral Select is active.
 2003 Microchip Technology Inc.                              Preliminary                                         DS30498B-page 65
PIC16F7X7
TABLE 5-5:         PORTC FUNCTIONS
       Name            Bit#     Buffer Type                                        Function
RC0/T1OSO/T1CKI        bit 0           ST           Input/output port pin or Timer1 oscillator output/Timer1 clock input.
RC1/T1OSI/CCP2         bit 1           ST           Input/output port pin or Timer1 oscillator input or Capture2 input/
                                                    Compare2 output/PWM2 output.
RC2/CCP1               bit 2           ST           Input/output port pin or Capture1 input/Compare1 output/PWM1 output.
RC3/SCK/SCL            bit 3           ST           RC3 can also be the synchronous serial clock for both SPI and I2C
                                                    modes.
RC4/SDI/SDA            bit 4           ST           RC4 can also be the SPI data in (SPI mode) or data I/O (I2C mode).
RC5/SDO                bit 5           ST           Input/output port pin or Synchronous Serial Port data output.
RC6/TX/CK              bit 6           ST           Input/output port pin or USART asynchronous transmit or synchronous
                                                    clock.
RC7/RX/DT              bit 7           ST           Input/output port pin or USART asynchronous receive or synchronous
                                                    data.
Legend: ST = Schmitt Trigger input
TABLE 5-6:         SUMMARY OF REGISTERS ASSOCIATED WITH PORTC
                                                                                                                 Value on
                                                                                                  Value on:
Address     Name     Bit 7     Bit 6        Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0                   all other
                                                                                                  POR, BOR
                                                                                                                  Resets
07h       PORTC      RC7       RC6          RC5       RC4      RC3      RC2      RC1      RC0    xxxx xxxx uuuu uuuu
87h       TRISC     PORTC Data Direction Register                                                1111 1111 1111 1111
Legend: x = unknown, u = unchanged
DS30498B-page 66                                       Preliminary                             2003 Microchip Technology Inc.
                                                                                                               PIC16F7X7
5.4       PORTD and TRISD Registers                                      FIGURE 5-18:                   PORTD BLOCK DIAGRAM
                                                                                                        (IN I/O PORT MODE)
This section is not applicable to the PIC16F737 or
PIC16F767.                                                                    Data Bus           D        Q
PORTD is an 8-bit port with Schmitt Trigger input buff-
ers. Each pin is individually configureable as an input or                                                                        I/O pin(1)
                                                                              WR Port             CK
output.
                                                                                                 Data Latch
PORTD can be configured as an 8-bit wide micro-
processor port (Parallel Slave Port) by setting control                                          D       Q
bit, PSPMODE (TRISE<4>). In this mode, the input
                                                                              WR TRIS                                 Schmitt
buffers are TTL.                                                                                  CK                  Trigger
                                                                                                 TRIS Latch           Input
                                                                                                                      Buffer
                                                                              RD TRIS
                                                                                                                Q     D
                                                                                                                    ENEN
                                                                              RD Port
                                                                             Note 1: I/O pins have protection diodes to VDD and VSS.
TABLE 5-7:           PORTD FUNCTIONS
      Name           Bit#            Buffer Type                                            Function
RD0/PSP0             bit 0             ST/TTL(1)        Input/output port pin or Parallel Slave Port bit 0.
RD1/PSP1             bit 1             ST/TTL(1)        Input/output port pin or Parallel Slave Port bit 1.
RD2/PSP2             bit 2             ST/TTL   (1)     Input/output port pin or Parallel Slave Port bit 2.
RD3/PSP3             bit 3             ST/TTL   (1)     Input/output port pin or Parallel Slave Port bit 3.
RD4/PSP4             bit 4             ST/TTL(1)        Input/output port pin or Parallel Slave Port bit 4.
RD5/PSP5             bit 5             ST/TTL(1)        Input/output port pin or Parallel Slave Port bit 5.
RD6/PSP6             bit 6             ST/TTL(1)        Input/output port pin or Parallel Slave Port bit 6.
RD7/PSP7             bit 7             ST/TTL(1)        Input/output port pin or Parallel Slave Port bit 7.
Legend: ST = Schmitt Trigger input, TTL = TTL input
Note 1: Input buffers are Schmitt Triggers when in I/O mode and TTL buffers when in Parallel Slave Port mode.
TABLE 5-8:           SUMMARY OF REGISTERS ASSOCIATED WITH PORTD
                                                                                                                                 Value on
                                                                                                                Value on:
 Address      Name           Bit 7   Bit 6   Bit 5     Bit 4     Bit 3     Bit 2         Bit 1         Bit 0                     all other
                                                                                                                POR, BOR
                                                                                                                                  Resets
08h          PORTD           RD7     RD6     RD5        RD4      RD3       RD2           RD1           RD0      xxxx xxxx       uuuu uuuu
88h          TRISD       PORTD Data Direction Register                                                          1111 1111       1111 1111
                                                                   (1)
89h          TRISE           IBF     OBF     IBOV     PSPMODE    —       PORTE Data Direction bits              0000 1111       0000 1111
Legend:      x = unknown, u = unchanged, - = unimplemented, read as ‘0’. Shaded cells are not used by PORTD.
Note 1:      RE3 is an input only. The state of the TRISE3 bit has no effect and will always read ‘1’.
 2003 Microchip Technology Inc.                              Preliminary                                              DS30498B-page 67
PIC16F7X7
5.5       PORTE and TRISE Register                                           FIGURE 5-19:                  PORTE BLOCK DIAGRAM
                                                                                                           (IN I/O PORT MODE)
This section is not applicable to the PIC16F737 or
PIC16F767.
                                                                                 Data Bus           D       Q
PORTE has four pins, RE0/RD/AN5, RE1/WR/AN6,
RE2/CS/AN7 and MCLR/VPP/RE3, which are individu-                                                                                      I/O pin(1)
                                                                                 WR Port             CK
ally configureable as inputs or outputs. These pins have
Schmitt Trigger input buffers. RE3 is only available as an                                          Data Latch
input if MCLRE is ‘0’ in Configuration Word 1.                                                      D      Q
I/O PORTE becomes control inputs for the micro-
                                                                                 WR TRIS                                  Schmitt
processor port when bit, PSPMODE (TRISE<4>), is                                                      CK                   Trigger
set. In this mode, the user must make sure that the                                                 TRIS Latch            Input
TRISE<2:0> bits are set (pins are configured as digital                                                                   Buffer
inputs). Ensure ADCON1 is configured for digital I/O. In
this mode, the input buffers are TTL.                                            RD TRIS
Register 5-1 shows the TRISE register, which also
controls the Parallel Slave Port operation.                                                                        Q      D
PORTE pins are multiplexed with analog inputs. When
selected as an analog input, these pins will read as ‘0’s.                                                             ENEN
TRISE controls the direction of the RE pins, even when                           RD Port
they are being used as analog inputs. The user must
make sure to keep the pins configured as inputs when
                                                                                 Note 1: I/O pins have protection diodes to VDD and VSS.
using them as analog inputs.
  Note:      On a Power-on Reset, these pins are
             configured as analog inputs and read as ‘0’.
TABLE 5-9:          PORTE FUNCTIONS
      Name         Bit#      Buffer Type                                                   Function
                                        (1)
RE0/RD/AN5         bit 0      ST/TTL          Input/output port pin or read control input in Parallel Slave Port mode or analog input.
                                              For RD (PSP mode):
                                              1 = Idle
                                              0 = Read operation. Contents of PORTD register output to PORTD I/O pins (if chip selected).
RE1/WR/AN6         bit 1      ST/TTL(1)       Input/output port pin or write control input in Parallel Slave Port mode or analog input.
                                              For WR (PSP mode):
                                              1 = Idle
                                              0 = Write operation. Value of PORTD I/O pins latched into PORTD register (if chip selected).
RE2/CS/AN7         bit 2      ST/TTL(1)       Input/output port pin or chip select control input in Parallel Slave Port mode or analog input.
                                              For CS (PSP mode):
                                              1 = Device is not selected
                                              0 = Device is selected
MCLR/VPP/RE3       bit 3         ST           Input, Master Clear (Reset) or programming input voltage.
Legend:      ST = Schmitt Trigger input, TTL = TTL input
Note 1:      Input buffers are Schmitt Triggers when in I/O mode and TTL buffers when in Parallel Slave Port mode.
TABLE 5-10:         SUMMARY OF REGISTERS ASSOCIATED WITH PORTE
                                                                                                                                     Value on
                                                                                                                   Value on:
 Addr     Name       Bit 7      Bit 6         Bit 5     Bit 4        Bit 3     Bit 2        Bit 1       Bit 0                        all other
                                                                                                                   POR, BOR
                                                                                                                                      Resets
09h     PORTE         —          —             —          —          RE3        RE2         RE1         RE0        ---- x000        ---- -uuu
89h     TRISE        IBF        OBF           IBOV    PSPMODE        — (1)   PORTE Data Direction bits             0000 1111        0000 1111
9Fh     ADCON1      ADFM       ADCS2 VCFG1             VCFG0       PCFG3 PCFG2          PCFG1         PCFG0        0000 0000        0000 0000
Legend:      x = unknown, u = unchanged, - = unimplemented, read as ‘0’. Shaded cells are not used by PORTE.
Note 1:      RE3 is an input only. The state of the TRISE3 bit has no effect and will always read ‘1’.
DS30498B-page 68                                                Preliminary                                     2003 Microchip Technology Inc.
                                                                                              PIC16F7X7
REGISTER 5-1:          TRISE REGISTER (ADDRESS 89h)
                            R-0         R-0         R/W-0          R/W-0         U-0        R/W-1      R/W-1      R/W-1
                            IBF        OBF          IBOV        PSPMODE         —(1)       TRISE2     TRISE1      TRISE0
                        bit 7                                                                                         bit 0
            bit 7       Parallel Slave Port Status/Control bits:
                        IBF: Input Buffer Full Status bit
                        1 = A word has been received and is waiting to be read by the CPU
                        0 = No word has been received
            bit 6       OBF: Output Buffer Full Status bit
                        1 = The output buffer still holds a previously written word
                        0 = The output buffer has been read
            bit 5       IBOV: Input Buffer Overflow Detect bit (in Microprocessor mode)
                        1 = A write occurred when a previously input word has not been read (must be cleared in
                            software)
                        0 = No overflow occurred
            bit 4       PSPMODE: Parallel Slave Port Mode Select bit
                        1 = Parallel Slave Port mode
                        0 = General Purpose I/O mode
            bit 3       Unimplemented: Read as ‘1’(1)
                          Note 1: RE3 is an input only. The state of the TRISE3 bit has no effect and will always read ‘1’.
            bit 2       PORTE Data Direction bits:
                        TRISE2: Direction Control bit for pin RE2/CS/AN7
                        1 = Input
                        0 = Output
            bit 1       TRISE1: Direction Control bit for pin RE1/WR/AN6
                        1 = Input
                        0 = Output
            bit 0       TRISE0: Direction Control bit for pin RE0/RD/AN5
                        1 = Input
                        0 = Output
                        Legend:
                        R = Readable bit              W = Writable bit       U = Unimplemented bit, read as ‘0’
                        - n = Value at POR            ‘1’ = Bit is set       ‘0’ = Bit is cleared   x = Bit is unknown
 2003 Microchip Technology Inc.                    Preliminary                                         DS30498B-page 69
PIC16F7X7
5.6      Parallel Slave Port                                  When either the CS or RD pins are detected high, the
                                                              PORTD outputs are disabled and the interrupt flag bit
The Parallel Slave Port (PSP) is not implemented on           PSPIF is set on the Q4 clock cycle following the next
the PIC16F737 or PIC16F767.                                   Q2 cycle, indicating that the read is complete. OBF
PORTD operates as an 8-bit wide Parallel Slave Port or        remains low until firmware writes new data to PORTD.
microprocessor port when control bit, PSPMODE                 When not in PSP mode, the IBF and OBF bits are held
(TRISE<4>), is set. In Slave mode, it is asynchronously       clear. Flag bit IBOV remains unchanged. The PSPIF bit
readable and writable by an external system using the         must be cleared by the user in firmware; the interrupt
read control input pin RE0/RD/AN5, the write control          can be disabled by clearing the interrupt enable bit,
input pin RE1/WR/AN6 and the chip select control input        PSPIE (PIE1<7>).
pin RE2/CS/AN7.
The PSP can directly interface to an 8-bit micro-             FIGURE 5-20:                 PORTD AND PORTE
processor data bus. The external microprocessor can                                        BLOCK DIAGRAM
read or write the PORTD latch as an 8-bit latch. Setting                                   (PARALLEL SLAVE PORT)
bit PSPMODE enables port pin RE0/RD/AN5 to be the
RD input, RE1/WR/AN6 to be the WR input and
RE2/CS/AN7 to be the CS (Chip Select) input. For this               Data Bus
                                                                                    D     Q
functionality, the corresponding data direction bits of
                                                                          WR                                            RDx pin
the TRISE register (TRISE<2:0>) must be configured                        Port
as inputs (i.e., set). The A/D port configuration bits,                             CK
PCFG3:PCFG0 (ADCON1<3:0>), must be set to                                                                   TTL
configure pins RE2:RE0 as digital I/O.
                                                                                   Q       D
There are actually two 8-bit latches, one for data output
(external reads) and one for data input (external                         RD             ENEN
writes). The firmware writes 8-bit data to the PORTD                      Port
output data latch and reads data from the PORTD input
                                                                One bit of PORTD
data latch (note that they have the same address). In
this mode, the TRISD register is ignored since the                  Set Interrupt Flag
external device is controlling the direction of data flow.          PSPIF (PIR1<7>)
An external write to the PSP occurs when the CS and
WR lines are both detected low. Firmware can read the
actual data on the PORTD pins during this time. When
either the CS or WR lines become high (level trig-                                                        Read
                                                                                                                  TTL       RD
gered), the data on the PORTD pins is latched and the
Input Buffer Full (IBF) status flag bit (TRISE<7>) and                                                 Chip Select
                                                                                                                 TTL        CS
interrupt flag bit, PSPIF (PIR1<7>), are set on the Q4
clock cycle following the next Q2 cycle to signal the                                                     Write
write is complete (Figure 5-21). Firmware clears the                                                              TTL       WR
IBF flag by reading the latched PORTD data and clears
the PSPIF bit.                                                  Note: I/O pin has protection diodes to VDD and VSS.
The Input Buffer Overflow (IBOV) status flag bit
(TRISE<5>) is set if an external write to the PSP occurs
while the IBF flag is set from a previous external write.
The previous PORTD data is overwritten with the new
data. IBOV is cleared by reading PORTD and clearing
IBOV.
A read from the PSP occurs when both the CS and RD
lines are detected low. The data in the PORTD output
latch is output to the PORTD pins. The Output Buffer
Full (OBF) status flag bit (TRISE<6>) is cleared imme-
diately (Figure 5-22), indicating that the PORTD latch is
being read or has been read by the external bus. If
firmware writes new data to the output latch during this
time, it is immediately output to the PORTD pins but
OBF will remain cleared.
DS30498B-page 70                                      Preliminary                                2003 Microchip Technology Inc.
                                                                                                          PIC16F7X7
FIGURE 5-21:            PARALLEL SLAVE PORT WRITE WAVEFORMS
                          Q1          Q2     Q3      Q4      Q1           Q2       Q3       Q4     Q1       Q2    Q3      Q4
              CS
              WR
              RD
      PORTD<7:0>
              IBF
             OBF
           PSPIF
FIGURE 5-22:            PARALLEL SLAVE PORT READ WAVEFORMS
                         Q1          Q2      Q3      Q4      Q1           Q2       Q3      Q4      Q1      Q2     Q3     Q4
              CS
              WR
              RD
      PORTD<7:0>
              IBF
             OBF
           PSPIF
TABLE 5-11:         REGISTERS ASSOCIATED WITH PARALLEL SLAVE PORT
                                                                                                                        Value on
                                                                                                           Value on:
Address     Name       Bit 7        Bit 6   Bit 5    Bit 4        Bit 3        Bit 2     Bit 1    Bit 0                 all other
                                                                                                           POR, BOR
                                                                                                                         Resets
08h       PORTD      Port Data Latch when written: Port pins when read                                     xxxx xxxx   uuuu uuuu
09h       PORTE         —            —       —        —           RE3          RE2       RE1      RE0      ---- x000   ---- x000
89h       TRISE         IBF         OBF     IBOV    PSPMODE       —(2)     PORTE Data Direction bits       0000 1111   0000 1111
0Ch       PIR1       PSPIF    (1)   ADIF    RCIF     TXIF     SSPIF        CCP1IF TMR2IF TMR1IF            0000 0000   0000 0000
8Ch       PIE1       PSPIE    (1)   ADIE    RCIE     TXIE     SSPIE        CCP1IE TMR2IE TMR1IE            0000 0000   0000 0000
9Fh       ADCON1      ADFM          ADCS2 VCFG1      VCFG0    PCFG3 PCFG2               PCFG1    PCFG0     0000 0000   0000 0000
Legend:    x = unknown, u = unchanged, - = unimplemented, read as ‘0’. Shaded cells are not used by the Parallel Slave Port.
Note 1:    Bits PSPIE and PSPIF are reserved on the PIC16F737/767; always maintain these bits clear.
     2:    RE3 is an input only. The state of the TRISE3 bit has no effect and will always read ‘1’.
 2003 Microchip Technology Inc.                          Preliminary                                            DS30498B-page 71
PIC16F7X7
NOTES:
DS30498B-page 72   Preliminary    2003 Microchip Technology Inc.
                                                                                                            PIC16F7X7
6.0       TIMER0 MODULE                                                    Counter mode is selected by setting bit, T0CS
                                                                           (OPTION_REG<5>). In Counter mode, Timer0 will
The Timer0 module timer/counter has the following                          increment, either on every rising or falling edge of pin
features:                                                                  RA4/T0CKI/C1OUT. The incrementing edge is deter-
•   8-bit timer/counter                                                    mined by the Timer0 Source Edge Select bit, T0SE
•   Readable and writable                                                  (OPTION_REG<4>). Clearing bit T0SE selects the rising
                                                                           edge. Restrictions on the external clock input are
•   8-bit software programmable prescaler
                                                                           discussed in detail in Section 6.3 “Using Timer0 With
•   Internal or external clock select                                      an External Clock”.
•   Interrupt on overflow from FFh to 00h
                                                                           The prescaler is mutually, exclusively shared between
•   Edge select for external clock                                         the Timer0 module and the Watchdog Timer. The
Additional information on the Timer0 module is                             prescaler is not readable or writable. Section 6.4
available in the PICmicro® Mid-Range MCU Family                            “Prescaler” details the operation of the prescaler.
Reference Manual (DS33023).
Figure 6-1 is a block diagram of the Timer0 module and                     6.2       Timer0 Interrupt
the prescaler shared with the WDT.                                         The TMR0 interrupt is generated when the TMR0 reg-
                                                                           ister overflows from FFh to 00h. This overflow sets bit
6.1       Timer0 Operation                                                 TMR0IF (INTCON<2>). The interrupt can be masked
                                                                           by clearing bit TMR0IE (INTCON<5>). Bit TMR0IF
Timer0 operation is controlled through the
                                                                           must be cleared in software by the Timer0 module
OPTION_REG register (see Register 2-2). Timer mode
                                                                           Interrupt Service Routine before re-enabling this inter-
is selected by clearing bit T0CS (OPTION_REG<5>).
                                                                           rupt. The TMR0 interrupt cannot awaken the processor
In Timer mode, the Timer0 module will increment every
                                                                           from Sleep since the timer is shut-off during Sleep.
instruction cycle (without prescaler). If the TMR0 regis-
ter is written, the increment is inhibited for the following
two instruction cycles. The user can work around this
by writing an adjusted value to the TMR0 register.
FIGURE 6-1:             BLOCK DIAGRAM OF THE TIMER0/WDT PRESCALER
         CLKO (= FOSC/4)                                                                                     Data Bus
                                                                                                                  8
                                         0    M                    1
                                              U                            M
                                                                                            Sync
                                              X                            U                 2              TMR0 Reg
                                         1                         0
     RA4/T0CKI/C1OUT                                                       X               Cycles
           pin
                        T0SE
                                             T0CS                                                                 Set Flag bit TMR0IF
                                                                       PSA
                                                                                                                       on Overflow
                                                                               Prescaler
                                         0
                                              M                8-bit Prescaler
            WDT Timer
                                              U
                                         1    X
                      16-bit                                           8
       31.25 kHz
                    Prescaler
                                                               8 - to - 1 MUX                     PS2:PS0
      WDT Enable bit                         PSA
                                                               0                1
                                                                       MUX                  PSA
                                                               WDT Time-out
    Note: T0CS, T0SE, PSA and PS2:PS0 are (OPTION_REG<5:0>).
 2003 Microchip Technology Inc.                       Preliminary                                                    DS30498B-page 73
PIC16F7X7
6.3      Using Timer0 With an External                        Note:     Although the prescaler can be assigned to
         Clock                                                          either the WDT or Timer0, but not both, a
When no prescaler is used, the external clock input is                  new divide counter is implemented in the
the same as the prescaler output. The synchronization                   WDT circuit to give multiple WDT time-out
of T0CKI with the internal phase clocks is accom-                       selections. This allows TMR0 and WDT to
plished by sampling the prescaler output on the Q2 and                  each have their own scaler. Refer to
Q4 cycles of the internal phase clocks. Therefore, it is                Section 15.17 “Watchdog Timer (WDT)”
necessary for T0CKI to be high for at least 2 TOSC (and                 for further details.
a small RC delay of 20 ns) and low for at least 2 TOSC
                                                            The PSA and PS2:PS0 bits (OPTION_REG<3:0>)
(and a small RC delay of 20 ns). Refer to the electrical
                                                            determine the prescaler assignment and prescale ratio.
specification of the desired device.
                                                            When assigned to the Timer0 module, all instructions
6.4      Prescaler                                          writing to the TMR0 register (e.g., CLRF 1, MOVWF 1,
                                                            BSF 1,x....etc.) will clear the prescaler. When assigned
There is only one prescaler available, which is mutually    to WDT, a CLRWDT instruction will clear the prescaler
exclusively shared between the Timer0 module and the        along with the Watchdog Timer. The prescaler is not
Watchdog Timer. A prescaler assignment for the              readable or writable.
Timer0 module means that the prescaler cannot be
                                                              Note:     Writing to TMR0 when the prescaler is
used by the Watchdog Timer and vice versa. This
                                                                        assigned to Timer0 will clear the prescaler
prescaler is not readable or writable (see Figure 6-1).
                                                                        count but will not change the prescaler
                                                                        assignment.
DS30498B-page 74                                    Preliminary                      2003 Microchip Technology Inc.
                                                                                           PIC16F7X7
REGISTER 6-1:          OPTION_REG REGISTER
                          R/W-1       R/W-1        R/W-1        R/W-1     R/W-1         R/W-1     R/W-1       R/W-1
                          RBPU       INTEDG        T0CS         T0SE      PSA(1)         PS2       PS1        PS0
                        bit 7                                                                                    bit 0
           bit 7        RBPU: PORTB Pull-up Enable bit
                        1 = PORTB pull-ups are disabled
                        0 = PORTB pull-ups are enabled
           bit 6        INTEDG: Interrupt Edge Select bit
                        1 = Interrupt on rising edge of RB0/INT pin
                        0 = Interrupt on falling edge of RB0/INT pin
           bit 5        T0CS: TMR0 Clock Source Select bit
                        1 = Transition on T0CKI pin
                        0 = Internal instruction cycle clock (CLKO)
           bit 4        T0SE: TMR0 Source Edge Select bit
                        1 = Increment on high-to-low transition on T0CKI pin
                        0 = Increment on low-to-high transition on T0CKI pin
           bit 3        PSA: Prescaler Assignment bit(1)
                        1 = Prescaler is assigned to the WDT
                        0 = Prescaler is assigned to the Timer0 module
                          Note 1: To avoid an unintended device Reset, the instruction sequence shown in the
                                  PICmicro® Mid-Range MCU Family Reference Manual (DS33023) must be
                                  executed when changing the prescaler assignment from Timer0 to the WDT. This
                                  sequence must be followed even if the WDT is disabled.
           bit 2-0      PS<2:0>: Prescaler Rate Select bits
                        Bit Value TMR0 Rate WDT Rate
                          000       1:2      1:1
                          001       1:4      1:2
                          010       1:8      1:4
                          011       1 : 16   1:8
                          100       1 : 32   1 : 16
                          101       1 : 64   1 : 32
                          110       1 : 128  1 : 64
                          111       1 : 256  1 : 128
                        Legend:
                        R = Readable bit            W = Writable bit     U = Unimplemented bit, read as ‘0’
                        - n = Value at POR          ‘1’ = Bit is set     ‘0’ = Bit is cleared   x = Bit is unknown
 2003 Microchip Technology Inc.                   Preliminary                                      DS30498B-page 75
PIC16F7X7
EXAMPLE 6-1:           CHANGING THE PRESCALER ASSIGNMENT FROM WDT TO TIMER0
 CLRWDT                                 ;   Clear WDT and prescaler
 BANKSEL     OPTION                     ;   Select Bank of OPTION
 MOVLW       b'xxxx0xxx'                ;   Select TMR0, new prescale
 MOVWF       OPTION                     ;   value and clock source
TABLE 6-1:         REGISTERS ASSOCIATED WITH TIMER0
                                                                                                                  Value on
                                                                                                     Value on
 Address     Name       Bit 7      Bit 6       Bit 5     Bit 4    Bit 3    Bit 2    Bit 1   Bit 0                 all other
                                                                                                    POR, BOR
                                                                                                                   Resets
01h,101h    TMR0      Timer0 Module Register                                                        xxxx xxxx    uuuu uuuu
0Bh,8Bh,  INTCON         GIE       PEIE      TMR0IE     INT0IE    RBIE TMR0IF INT0IF RBIF 0000 000x              0000 000u
10Bh,18Bh
81h,181h    OPTION      RBPU      INTEDG       T0CS      T0SE      PSA     PS2      PS1     PS0     1111 1111    1111 1111
Legend:    x = unknown, u = unchanged, - = unimplemented locations read as ‘0’. Shaded cells are not used by Timer0.
DS30498B-page 76                                       Preliminary                            2003 Microchip Technology Inc.
                                                                                      PIC16F7X7
7.0      TIMER1 MODULE                                      7.1      Timer1 Operation
The Timer1 module is a 16-bit timer/counter consisting      Timer1 can operate in one of three modes:
of two 8-bit registers (TMR1H and TMR1L), which are         • as a Timer
readable and writable. The TMR1 register pair
                                                            • as a Synchronous Counter
(TMR1H:TMR1L) increments from 0000h to FFFFh
and rolls over to 0000h. The TMR1 interrupt, if enabled,    • as an Asynchronous Counter
is generated on overflow which is latched in interrupt      The operating mode is determined by the clock select
flag bit, TMR1IF (PIR1<0>). This interrupt can be           bit, TMR1CS (T1CON<1>).
enabled/disabled by setting/clearing TMR1 interrupt         In Timer mode, Timer1 increments every instruction
enable bit, TMR1IE (PIE1<0>).                               cycle. In Counter mode, it increments on every rising
The Timer1 oscillator can be used as a secondary clock      edge of the external clock input.
source in low-power modes. When the T1RUN bit is set        Timer1 can be enabled/disabled by setting/clearing
along with SCS<1:0> = 01, the Timer1 oscillator is pro-     control bit, TMR1ON (T1CON<0>).
viding the system clock. If the Fail-Safe Clock Monitor
is enabled and the Timer1 oscillator fails while            Timer1 also has an internal “Reset input”. This Reset
providing the system clock, polling the T1RUN bit will      can be generated by the CCP1 module as the special
indicate whether the clock is being provided by the         event trigger (see Section 9.4 “Capture Mode”).
Timer1 oscillator or another source.                        Register 7-1 shows the Timer1 Control register.
Timer1 can also be used to provide Real-Time Clock          When the Timer1 oscillator is enabled (T1OSCEN is
(RTC) functionality to applications with only a minimal     set), the RC0/T1OSO/T1CKI and RC1/T1OSI/CCP2
addition of external components and code overhead.          pins become inputs. That is, the TRISB<7:6> value is
                                                            ignored and these pins read as ‘0’.
                                                            Additional information on timer modules is available in
                                                            the PICmicro® Mid-Range MCU Family Reference
                                                            Manual (DS33023).
 2003 Microchip Technology Inc.                    Preliminary                                 DS30498B-page 77
PIC16F7X7
REGISTER 7-1:      T1CON: TIMER1 CONTROL REGISTER (ADDRESS 10h)
                      U-0         R-0         R/W-0        R/W-0          R/W-0        R/W-0       R/W-0          R/W-0
                       —        T1RUN       T1CKPS1      T1CKPS0       T1OSCEN       T1SYNC       TMR1CS         TMR1ON
                   bit 7                                                                                             bit 0
        bit 7      Unimplemented: Read as ‘0’
        bit 6      T1RUN: Timer1 System Clock Status bit
                   1 = System clock is derived from Timer1 oscillator
                   0 = System clock is derived from another source
        bit 5-4    T1CKPS<1:0>: Timer1 Input Clock Prescale Select bits
                   11 = 1:8 prescale value
                   10 = 1:4 prescale value
                   01 = 1:2 prescale value
                   00 = 1:1 prescale value
        bit 3      T1OSCEN: Timer1 Oscillator Enable Control bit
                   1 = Oscillator is enabled
                   0 = Oscillator is shut-off (the oscillator inverter is turned off to eliminate power drain)
        bit 2      T1SYNC: Timer1 External Clock Input Synchronization Control bit
                   TMR1CS = 1:
                   1 = Do not synchronize external clock input
                   0 = Synchronize external clock input
                   TMR1CS = 0:
                   This bit is ignored. Timer1 uses the internal clock when TMR1CS = 0.
        bit 1      TMR1CS: Timer1 Clock Source Select bit
                   1 = External clock from pin RC0/T1OSO/T1CKI (on the rising edge)
                   0 = Internal clock (FOSC/4)
        bit 0      TMR1ON: Timer1 On bit
                   1 = Enables Timer1
                   0 = Stops Timer1
                   Legend:
                   R = Readable bit               W = Writable bit        U = Unimplemented bit, read as ‘0’
                   - n = Value at POR             ‘1’ = Bit is set        ‘0’ = Bit is cleared    x = Bit is unknown
DS30498B-page 78                                 Preliminary                              2003 Microchip Technology Inc.
                                                                                                       PIC16F7X7
7.2       Timer1 Operation in Timer Mode                                  7.4       Timer1 Operation in Synchronized
Timer mode is selected by clearing the TMR1CS
                                                                                    Counter Mode
(T1CON<1>) bit. In this mode, the input clock to the                      Counter mode is selected by setting bit TMR1CS. In
timer is FOSC/4. The synchronize control bit, T1SYNC                      this mode, the timer increments on every rising edge of
(T1CON<2>), has no effect since the internal clock is                     clock input on pin RC1/T1OSI/CCP2, when bit
always in sync.                                                           T1OSCEN is set, or on pin RC0/T1OSO/T1CKI, when
                                                                          bit T1OSCEN is cleared.
7.3       Timer1 Counter Operation                                        If T1SYNC is cleared, then the external clock input is
Timer1 may operate in Asynchronous or Synchronous                         synchronized with internal phase clocks. The synchro-
mode depending on the setting of the TMR1CS bit.                          nization is done after the prescaler stage. The
                                                                          prescaler stage is an asynchronous ripple counter.
When Timer1 is being incremented via an external
source, increments occur on a rising edge. After Timer1                   In this configuration during Sleep mode, Timer1 will not
is enabled in Counter mode, the module must first have                    increment, even if the external clock is present since
a falling edge before the counter begins to increment.                    the synchronization circuit is shut-off. The prescaler,
                                                                          however, will continue to increment.
FIGURE 7-1:                 TIMER1 INCREMENTING EDGE
      T1CKI
      (Default High)
      T1CKI
      (Default Low)
      Note: Arrows indicate counter increments.
FIGURE 7-2:                 TIMER1 BLOCK DIAGRAM
                      Set Flag bit
                      TMR1IF on
                      Overflow                                                                            Synchronized
                                               TMR1                                          0
                                                                                                           Clock Input
                                       TMR1H        TMR1L
                                                                                             1
                                                                        TMR1ON
                                                                         On/Off         T1SYNC
                                        T1OSC
                                                                                1
                                                                                                             Synchronize
                                                                                         Prescaler
              T1OSO/T1CKI                                                                1, 2, 4, 8
                                                     T1OSCEN FOSC/4                                                det
                                                     Enable        Internal     0
                                                     Oscillator(1) Clock                    2                  Q Clock
                      T1OSI                                                        T1CKPS1:T1CKPS0
                                                                              TMR1CS
             Note 1:       When the T1OSCEN bit is cleared, the inverter is turned off. This eliminates power drain.
 2003 Microchip Technology Inc.                           Preliminary                                             DS30498B-page 79
PIC16F7X7
7.5      Timer1 Operation in                               7.5.1       READING AND WRITING TIMER1 IN
         Asynchronous Counter Mode                                     ASYNCHRONOUS COUNTER MODE
If control bit, T1SYNC (T1CON<2>), is set, the external    Reading TMR1H or TMR1L while the timer is running
clock input is not synchronized. The timer continues to    from an external asynchronous clock will ensure a valid
increment asynchronous to the internal phase clocks.       read (taken care of in hardware). However, the user
The timer will continue to run during Sleep and can        should keep in mind that reading the 16-bit timer in two
generate an interrupt on overflow that will wake-up the    8-bit values itself, poses certain problems, since the
processor. However, special precautions in software        timer may overflow between the reads.
are needed to read/write the timer (Section 7.5.1          For writes, it is recommended that the user simply stop
“Reading and Writing Timer1 in Asynchronous                the timer and write the desired values. A write conten-
Counter Mode”).                                            tion may occur by writing to the Timer registers while
In Asynchronous Counter mode, Timer1 cannot be             the register is incrementing. This may produce an
used as a time base for capture or compare operations.     unpredictable value in the Timer register.
                                                           Reading the 16-bit value requires some care. The
                                                           example codes provided in Example 7-1 and
                                                           Example 7-2 demonstrate how to write to and read
                                                           Timer1 while it is running in Asynchronous mode.
EXAMPLE 7-1:          WRITING A 16-BIT FREE RUNNING TIMER
  ; All interrupts are disabled
  CLRF      TMR1L          ; Clear Low byte, Ensures no rollover into TMR1H
  MOVLW     HI_BYTE        ; Value to load into TMR1H
  MOVWF     TMR1H, F       ; Write High byte
  MOVLW     LO_BYTE        ; Value to load into TMR1L
  MOVWF     TMR1H, F       ; Write Low byte
  ; Re-enable the Interrupt (if required)
  CONTINUE                 ; Continue with your code
EXAMPLE 7-2:          READING A 16-BIT FREE RUNNING TIMER
  ; All interrupts are disabled
  MOVF      TMR1H, W        ; Read high byte
  MOVWF     TMPH
  MOVF      TMR1L, W        ; Read low byte
  MOVWF     TMPL
  MOVF      TMR1H, W        ; Read high byte
  SUBWF     TMPH, W         ; Sub 1st read with 2nd read
  BTFSC     STATUS,Z        ; Is result = 0
  GOTO      CONTINUE        ; Good 16-bit read
  ; TMR1L may have rolled over between the read of the high and low bytes.
  ; Reading the high and low bytes now will read a good value.
  MOVF      TMR1H, W        ; Read high byte
  MOVWF     TMPH
  MOVF      TMR1L, W        ; Read low byte
  MOVWF     TMPL            ; Re-enable the Interrupt (if required)
  CONTINUE                  ; Continue with your code
DS30498B-page 80                                   Preliminary                      2003 Microchip Technology Inc.
                                                                                           PIC16F7X7
7.6        Timer1 Oscillator                                    7.7       Timer1 Oscillator Layout
A crystal oscillator circuit is built between pins T1OSI
                                                                          Considerations
(input) and T1OSO (amplifier output). It is enabled by          The Timer1 oscillator circuit draws very little power dur-
setting control bit, T1OSCEN (T1CON<3>). The oscil-             ing operation. Due to the low-power nature of the oscil-
lator is a low-power oscillator, rated up to 32.768 kHz.        lator, it may also be sensitive to rapidly changing
It will continue to run during all power managed modes.         signals in close proximity.
It is primarily intended for a 32 kHz crystal. The circuit
                                                                The oscillator circuit, shown in Figure 7-3, should be
for a typical LP oscillator is shown in Figure 7-3.
                                                                located as close as possible to the microcontroller.
Table 7-1 shows the capacitor selection for the Timer1
                                                                There should be no circuits passing within the oscillator
oscillator.
                                                                circuit boundaries other than VSS or VDD.
The user must provide a software time delay to ensure
                                                                If a high-speed circuit must be located near the oscilla-
proper oscillator start-up.
                                                                tor, a grounded guard ring around the oscillator circuit,
                                                                as shown in Figure 7-4, may be helpful when used on
FIGURE 7-3:              EXTERNAL                               a single sided PCB or in addition to a ground plane.
                         COMPONENTS FOR THE
                         TIMER1 LP OSCILLATOR                   FIGURE 7-4:             OSCILLATOR CIRCUIT
                                                                                        WITH GROUNDED
        C1                           PIC16F7X7
       33 pF
                                                                                        GUARD RING
                                T1OSI
                                                                                                   VSS
                  XTAL
                  32.768 kHz                                                                       OSC1
                                T1OSO                                                              OSC2
        C2
       33 pF
   Note:      See the Notes with Table 7-1 for additional
              information about capacitor selection.                                               RC0
                                                                                                   RC1
TABLE 7-1:          CAPACITOR SELECTION FOR                                                        RC2
                    THE TIMER1 OSCILLATOR
 Osc Type           Freq            C1           C2
      LP           32 kHz          33 pF        33 pF           7.8       Resetting Timer1 Using a CCP
                                                                          Trigger Output
   Note 1: Microchip suggests this value as a starting          If the CCP1 module is configured in Compare mode to
           point in validating the oscillator circuit.          generate     a   “special   event    trigger"   signal
           2: Higher capacitance increases the stability        (CCP1M3:CCP1M0 = 1011), the signal will reset
              of the oscillator but also increases the          Timer1 and start an A/D conversion (if the A/D module
              start-up time.                                    is enabled).
           3: Since each resonator/crystal has its own            Note:     The special event triggers from the CCP1
              characteristics, the user should consult                      module will not set interrupt flag bit,
              the resonator/crystal manufacturer for                        TMR1IF (PIR1<0>).
              appropriate      values    of   external          Timer1 must be configured for either Timer or Synchro-
              components.                                       nized Counter mode to take advantage of this feature.
           4: Capacitor values are for design guidance          If Timer1 is running in Asynchronous Counter mode,
              only.                                             this Reset operation may not work.
                                                                In the event that a write to Timer1 coincides with a
                                                                special event trigger from CCP1, the write will take
                                                                precedence.
                                                                In this mode of operation, the CCPR1H:CCPR1L
                                                                register pair effectively becomes the period register for
                                                                Timer1.
 2003 Microchip Technology Inc.                        Preliminary                                      DS30498B-page 81
PIC16F7X7
7.9       Resetting Timer1 Register Pair                        battery or supercapacitor as a power source, it can
          (TMR1H, TMR1L)                                        completely eliminate the need for a separate RTC
                                                                device and battery backup.
TMR1H and TMR1L registers are not reset to 00h on a
                                                                The application code routine, RTCisr, shown in
POR, or any other Reset, except by the CCP1 special
                                                                Example 7-3, demonstrates a simple method to incre-
event triggers.
                                                                ment a counter at one-second intervals using an Inter-
T1CON register is reset to 00h on a Power-on Reset or           rupt Service Routine. Incrementing the TMR1 register
a Brown-out Reset, which shuts off the timer and                pair to overflow, triggers the interrupt and calls the rou-
leaves a 1:1 prescale. In all other Resets, the register        tine which increments the seconds counter by one;
is unaffected.                                                  additional counters for minutes and hours are
                                                                incremented as the previous counter overflows.
7.10      Timer1 Prescaler                                      Since the register pair is 16 bits wide, counting up to
The prescaler counter is cleared on writes to the               overflow the register directly from a 32.768 kHz clock
TMR1H or TMR1L registers.                                       would take 2 seconds. To force the overflow at the
                                                                required one-second intervals, it is necessary to
                                                                preload it; the simplest method is to set the MSbit of
7.11      Using Timer1 as a Real-Time Clock                     TMR1H with a BSF instruction. Note that the TMR1L
Adding an external LP oscillator to Timer1 (such as the         register is never preloaded or altered; doing so may
one described in Section 7.6 “Timer1 Oscillator”)               introduce cumulative error over many cycles.
gives users the option to include RTC functionality in          For this method to be accurate, Timer1 must operate in
their applications. This is accomplished with an inex-          Asynchronous mode and the Timer1 overflow interrupt
pensive watch crystal to provide an accurate time base          must be enabled (PIE1<0> = 1) as shown in the
and several lines of application code to calculate the          routine, RTCinit. The Timer1 oscillator must also be
time. When operating in Sleep mode and using a                  enabled and running at all times.
EXAMPLE 7-3:           IMPLEMENTING A REAL-TIME CLOCK USING A TIMER1 INTERRUPT SERVICE
 RTCinit       BANKSEL       TMR1H
               MOVLW         0x80                    ; Preload TMR1 register pair
               MOVWF         TMR1H                   ; for 1 second overflow
               CLRF          TMR1L
               MOVLW         b’00001111’             ; Configure for external clock,
               MOVWF         T1CON                   ; Asynchronous operation, external oscillator
               CLRF          secs                    ; Initialize timekeeping registers
               CLRF          mins
               MOVLW         .12
               MOVWF         hours
               BANKSEL       PIE1
               BSF           PIE1, TMR1IE            ; Enable Timer1 interrupt
               RETURN
 RTCisr        BANKSEL       TMR1H
               BSF           TMR1H, 7                ; Preload for 1 sec overflow
               BCF           PIR1, TMR1IF            ; Clear interrupt flag
               INCF          secs, F                 ; Increment seconds
               MOVF          secs, w
               SUBLW         .60
               BTFSS         STATUS, Z               ;   60 seconds elapsed?
               RETURN                                ;   No, done
               CLRF          seconds                 ;   Clear seconds
               INCF          mins, f                 ;   Increment minutes
               MOVF          mins, w
               SUBLW         .60
               BTFSS         STATUS, Z               ;   60 seconds elapsed?
               RETURN                                ;   No, done
               CLRF          mins                    ;   Clear minutes
               INCF          hours, f                ;   Increment hours
               MOVF          hours, w
               SUBLW         .24
               BTFSS         STATUS, Z               ;   24 hours elapsed?
               RETURN                                ;   No, done
               CLRF          hours                   ;   Clear hours
               RETURN                                ;   Done
DS30498B-page 82                                    Preliminary                           2003 Microchip Technology Inc.
                                                                                                    PIC16F7X7
TABLE 7-2:         REGISTERS ASSOCIATED WITH TIMER1 AS A TIMER/COUNTER
                                                                                                                         Value on
                                                                                                              Value on
 Address      Name      Bit 7      Bit 6    Bit 5      Bit 4       Bit 3      Bit 2     Bit 1        Bit 0               all other
                                                                                                             POR, BOR
                                                                                                                          Resets
0Bh, 8Bh, INTCON        GIE        PEIE    TMR0IE      INTE       RBIE      TMR0IF      INTF         RBIF    0000 000x 0000 000u
10Bh, 18Bh
0Ch         PIR1      PSPIF(1)     ADIF     RCIF       TXIF       SSPIF     CCP1IF     TMR2IF       TMR1IF 0000 0000 0000 0000
8Ch         PIE1      PSPIE(1)     ADIE     RCIE       TXIE       SSPIE     CCP1IE     TMR2IE       TMR1IE 0000 0000 0000 0000
0Eh         TMR1L     Holding Register for the Least Significant Byte of the 16-bit TMR1 Register            xxxx xxxx uuuu uuuu
0Fh         TMR1H     Holding Register for the Most Significant Byte of the 16-bit TMR1 Register             xxxx xxxx uuuu uuuu
10h         T1CON        —       T1RUN T1CKPS1 T1CKPS0 T1OSCEN T1SYNC TMR1CS TMR1ON -000 0000 -uuu uuuu
Legend:    x = unknown, u = unchanged, - = unimplemented, read as ‘0’. Shaded cells are not used by the Timer1 module.
Note 1:    Bits PSPIE and PSPIF are reserved on the PIC16F737/767 devices; always maintain these bits clear.
 2003 Microchip Technology Inc.                       Preliminary                                             DS30498B-page 83
PIC16F7X7
NOTES:
DS30498B-page 84   Preliminary    2003 Microchip Technology Inc.
                                                                                             PIC16F7X7
8.0      TIMER2 MODULE                                      8.1       Timer2 Prescaler and Postscaler
Timer2 is an 8-bit timer with a prescaler and a             The prescaler and postscaler counters are cleared
postscaler. It can be used as the PWM time base for the     when any of the following occurs:
PWM mode of the CCP module(s). The TMR2 register            • a write to the TMR2 register
is readable and writable and is cleared on any device
                                                            • a write to the T2CON register
Reset.
                                                            • any device Reset (POR, MCLR Reset, WDT
The input clock (FOSC/4) has a prescale option of 1:1,        Reset or BOR)
1:4   or     1:16,  selected     by   control    bits,
T2CKPS1:T2CKPS0 (T2CON<1:0>).                               TMR2 is not cleared when T2CON is written.
The Timer2 module has an 8-bit period register, PR2.
                                                            8.2       Output of TMR2
Timer2 increments from 00h until it matches PR2 and
then resets to 00h on the next increment cycle. PR2 is      The output of TMR2 (before the postscaler) is fed to the
a readable and writable register. The PR2 register is       SSP module which optionally uses it to generate the
initialized to FFh upon Reset.                              shift clock.
The match output of TMR2 goes through a 4-bit
postscaler (which gives a 1:1 to 1:16 scaling inclusive)    FIGURE 8-1:                   TIMER2 BLOCK DIAGRAM
to generate a TMR2 interrupt, latched in flag bit,
                                                               Sets Flag
TMR2IF (PIR1<1>).                                              bit TMR2IF
                                                                             TMR2
                                                                             Output(1)
Timer2 can be shut-off by clearing control bit, TMR2ON
(T2CON<2>), to minimize power consumption.                                      Reset                   Prescaler
                                                                                         TMR2 Reg                      FOSC/4
Register 8-1 shows the Timer2 Control register.                                                       1:1, 1:4, 1:16
                                                                  Postscaler
Additional information on timer modules is available in                                  Comparator            2
                                                                  1:1 to 1:16     EQ
the PICmicro® Mid-Range MCU Family Reference                                                             T2CKPS1:
Manual (DS33023).                                                        4                PR2 Reg        T2CKPS0
                                                                  T2OUTPS3:
                                                                  T2OUTPS0
                                                              Note 1: TMR2 register output can be software selected by the
                                                                      SSP module as a baud clock.
 2003 Microchip Technology Inc.                    Preliminary                                         DS30498B-page 85
PIC16F7X7
REGISTER 8-1:           T2CON: TIMER2 CONTROL REGISTER (ADDRESS 12h)
                           U-0       R/W-0             R/W-0       R/W-0       R/W-0        R/W-0          R/W-0         R/W-0
                             —     TOUTPS3 TOUTPS2 TOUTPS1 TOUTPS0 TMR2ON T2CKPS1 T2CKPS0
                        bit 7                                                                                               bit 0
           bit 7        Unimplemented: Read as ‘0’
           bit 6-3      TOUTPS3:TOUTPS0: Timer2 Output Postscale Select bits
                        0000 = 1:1 postscale
                        0001 = 1:2 postscale
                        0010 = 1:3 postscale
                        •
                        •
                        •
                        1111 = 1:16 postscale
           bit 2        TMR2ON: Timer2 On bit
                        1 = Timer2 is on
                        0 = Timer2 is off
           bit 1-0      T2CKPS1:T2CKPS0: Timer2 Clock Prescale Select bits
                        00 = Prescaler is 1
                        01 = Prescaler is 4
                        1x = Prescaler is 16
                        Legend:
                        R = Readable bit                  W = Writable bit      U = Unimplemented bit, read as ‘0’
                        - n = Value at POR                ‘1’ = Bit is set      ‘0’ = Bit is cleared       x = Bit is unknown
TABLE 8-1:           REGISTERS ASSOCIATED WITH TIMER2 AS A TIMER/COUNTER
                                                                                                                          Value on
                                                                                                             Value on:
 Address     Name      Bit 7      Bit 6        Bit 5      Bit 4      Bit 3    Bit 2     Bit 1      Bit 0                  all other
                                                                                                             POR, BOR
                                                                                                                           Resets
0Bh,8Bh,   INTCON       GIE       PEIE     TMR0IE        INT0IE      RBIE    TMR0IF    INT0IF      RBIF      0000 000x 0000 000u
10Bh, 18Bh
0Ch        PIR1       PSPIF(1)    ADIF         RCIF       TXIF      SSPIF    CCP1IF    TMR2IF    TMR1IF 0000 0000 0000 0000
8Ch        PIE1       PSPIE(1)    ADIE         RCIE       TXIE      SSPIE    CCP1IE    TMR2IE    TMR1IE 0000 0000 0000 0000
11h        TMR2       Timer2 Module Register                                                                 0000 0000 0000 0000
12h        T2CON         —       TOUTPS3 TOUTPS2 TOUTPS1 TOUTPS0 TMR2ON T2CKPS1 T2CKPS0 -000 0000 -000 0000
92h        PR2        Timer2 Period Register                                                                 1111 1111 1111 1111
Legend:    x = unknown, u = unchanged, - = unimplemented, read as ‘0’. Shaded cells are not used by the Timer2 module.
Note 1:    Bits PSPIE and PSPIF are reserved on the PIC16F737/767 devices; always maintain these bits clear.
DS30498B-page 86                                         Preliminary                             2003 Microchip Technology Inc.
                                                                                        PIC16F7X7
9.0       CAPTURE/COMPARE/PWM                                 9.2       CCP2 Module
          MODULES                                             Capture/Compare/PWM Register 1 (CCPR1) is com-
Each Capture/Compare/PWM (CCP) module contains                prised of two 8-bit registers: CCPR1L (low byte) and
a 16-bit register which can operate as a:                     CCPR1H (high byte). The CCP2CON register controls
                                                              the operation of CCP2. The special event trigger is gen-
• 16-bit Capture register                                     erated by a compare match; it will clear both TMR1H and
• 16-bit Compare register                                     TMR1L registers and start an A/D conversion (if the A/D
• PWM Master/Slave Duty Cycle register                        module is enabled).
The CCP1, CCP2 and CCP3 modules are identical in              Additional information on CCP modules is available in
operation, with the exception being the operation of the      the PICmicro® Mid-Range MCU Family Reference
special event trigger. Table 9-1 and Table 9-2 show the       Manual (DS33023) and in Application Note AN594,
resources and interactions of the CCP module(s). In           “Using the CCP Module(s)” (DS00594).
the following sections, the operation of a CCP module
is described with respect to CCP1. CCP2 and CCP3              9.3       CCP3 Module
operate the same as CCP1, except where noted.
                                                              Capture/Compare/PWM Register 1 (CCPR1) is com-
                                                              prised of two 8-bit registers: CCPR1L (low byte) and
9.1       CCP1 Module
                                                              CCPR1H (high byte). The CCP3CON register controls
Capture/Compare/PWM Register 1 (CCPR1) is                     the operation of CCP3.
comprised of two 8-bit registers: CCPR1L (low byte)
and CCPR1H (high byte). The CCP1CON register con-             TABLE 9-1:          CCP MODE – TIMER
trols the operation of CCP1. The special event trigger                            RESOURCES REQUIRED
is generated by a compare match and will clear both
TMR1H and TMR1L registers.                                             CCP Mode                Timer Resource
                                                                        Capture                     Timer1
                                                                        Compare                     Timer1
                                                                         PWM                        Timer2
TABLE 9-2:        INTERACTION OF TWO CCP MODULES
CCPx Mode CCPy Mode                                                 Interaction
Capture        Capture        Same TMR1 time base.
Capture        Compare        Same TMR1 time base.
Compare        Compare        Same TMR1 time base.
PWM            PWM            The PWMs will have the same frequency and update rate (TMR2 interrupt).
                              The rising edges are aligned.
PWM            Capture        None.
PWM            Compare        None.
 2003 Microchip Technology Inc.                    Preliminary                                    DS30498B-page 87
PIC16F7X7
REGISTER 9-1:       CCPxCON REGISTER (ADDRESS 17h, 1Dh, 97h)
                       U-0        U-0       R/W-0        R/W-0     R/W-0        R/W-0       R/W-0       R/W-0
                        —          —        CCPxX       CCPxY     CCPxM3      CCPxM2       CCPxM1      CCPxM0
                    bit 7                                                                                   bit 0
          bit 7-6   Unimplemented: Read as ‘0’
          bit 5-4   CCPxX:CCPxY: PWM Least Significant bits
                    Capture mode:
                    Unused.
                    Compare mode:
                    Unused.
                    PWM mode:
                    These bits are the two LSbs of the PWM duty cycle. The eight MSbs are found in CCPRxL.
          bit 3-0   CCPxM3:CCPxM0: CCPx Mode Select bits
                    0000 = Capture/Compare/PWM disabled (resets CCPx module)
                    0100 = Capture mode, every falling edge
                    0101 = Capture mode, every rising edge
                    0110 = Capture mode, every 4th rising edge
                    0111 = Capture mode, every 16th rising edge
                    1000 = Compare mode, set output on match (CCPxIF bit is set)
                    1001 = Compare mode, clear output on match (CCPxIF bit is set)
                    1010 = Compare mode, generate software interrupt on match (CCPxIF bit is set, CCPx pin is
                           unaffected)
                    1011 = Compare mode, trigger special event (CCPxIF bit is set, CCPx pin is unaffected);
                           CCP1 clears Timer1; CCP2 clears Timer1 and starts an A/D conversion (if A/D module
                           is enabled)
                    11xx = PWM mode
                     Legend:
                     R = Readable bit          W = Writable bit     U = Unimplemented bit, read as ‘0’
                     - n = Value at POR        ‘1’ = Bit is set     ‘0’ = Bit is cleared   x = Bit is unknown
DS30498B-page 88                             Preliminary                           2003 Microchip Technology Inc.
                                                                                                         PIC16F7X7
9.4         Capture Mode                                               9.4.4         CCP PRESCALER
In Capture mode, CCPR1H:CCPR1L captures the                            There are four prescaler settings specified by bits,
16-bit value of the TMR1 register when an event occurs                 CCP1M3:CCP1M0. Whenever the CCP module is
on pin RC2/CCP1. An event is defined as one of the                     turned off, or the CCP module is not in Capture mode,
following and is configured by CCPxCON<3:0>:                           the prescaler counter is cleared. Any Reset will clear
                                                                       the prescaler counter.
•   Every falling edge
                                                                       Switching from one capture prescaler to another may
•   Every rising edge
                                                                       generate an interrupt. Also, the prescaler counter will
•   Every 4th rising edge                                              not be cleared, therefore, the first capture may be from
•   Every 16th rising edge                                             a non-zero prescaler. Example 9-1 shows the
An event is selected by control bits, CCP1M3:CCP1M0                    recommended method for switching between capture
(CCP1CON<3:0>). When a capture is made, the inter-                     prescalers. This example also clears the prescaler
rupt request flag bit, CCP1IF (PIR1<2>), is set. The                   counter and will not generate the “false” interrupt.
interrupt flag must be cleared in software. If another
capture occurs before the value in register CCPR1 is                   EXAMPLE 9-1:                 CHANGING BETWEEN
read, the old captured value is overwritten by the new                                              CAPTURE PRESCALERS
captured value.                                                         CLRF      CCP1CON               ;Turn CCP module off
                                                                        MOVLW     NEW_CAPT_PS           ;Load the W reg with
9.4.1           CCP PIN CONFIGURATION                                                                   ;the new prescaler
                                                                                                        ;move value and CCP ON
In Capture mode, the RC2/CCP1 pin should be
                                                                        MOVWF     CCP1CON               ;Load CCP1CON with this
configured as an input by setting the TRISC<2> bit.
                                                                                                        ;value
    Note:       If the RC2/CCP1 pin is configured as an
                output, a write to the port can cause a
                capture condition.                                     9.5        Compare Mode
                                                                       In Compare mode, the 16-bit CCPR1 register value is
FIGURE 9-1:                     CAPTURE MODE                           constantly compared against the TMR1 register pair
                                OPERATION BLOCK                        value. When a match occurs, the RC2/CCP1 pin is:
                                DIAGRAM                                • Driven high
                             Set Flag bit CCP1IF                       • Driven low
                                  (PIR1<2>)
                Prescaler                                              • Remains unchanged
                ÷ 1, 4, 16
    RC2/CCP1                                  CCPR1H   CCPR1L          The action on the pin is based on the value of control
      pin                                                              bits, CCP1M3:CCP1M0 (CCP1CON<3:0>). At the
                  and                    Capture                       same time, interrupt flag bit CCP1IF is set.
               Edge Detect               Enable
                                              TMR1H    TMR1L           FIGURE 9-2:                  COMPARE MODE
                     CCP1CON<3:0>                                                                   OPERATION BLOCK
               Q’s                                                                                  DIAGRAM
                                                                                               CCP1CON<3:0>
                                                                                                Mode Select
9.4.2           TIMER1 MODE SELECTION
Timer1 must be running in Timer mode or Synchro-                                                        Set Flag bit CCP1IF
                                                                                                            (PIR1<2>)
nized Counter mode for the CCP module to use the
capture feature. In Asynchronous Counter mode, the                                                                    CCPR1H CCPR1L
capture operation may not work.                                                          Q     S   Output
                                                                                                   Logic                Comparator
                                                                        RC2/CCP1               R              Match
9.4.3           SOFTWARE INTERRUPT                                        pin
                                                                                                                       TMR1H   TMR1L
When the Capture mode is changed, a false capture                               TRISC<2>
                                                                               Output Enable
interrupt may be generated. The user should keep bit,
CCP1IE (PIE1<2>), clear to avoid false interrupts and                                        Special Event Trigger
should clear the flag bit, CCP1IF, following any such
                                                                          Special Event Trigger will:
change in operating mode.
                                                                          • clear TMR1H and TMR1L registers
                                                                          • NOT set interrupt flag bit, TMR1F (PIR1<0>)
                                                                          • (for CCP2 only) set the GO/DONE bit (ADCON0<2>)
 2003 Microchip Technology Inc.                               Preliminary                                            DS30498B-page 89
PIC16F7X7
9.5.1      CCP PIN CONFIGURATION                                      9.5.4           SPECIAL EVENT TRIGGER
The user must configure the RC2/CCP1 pin as an                        In this mode, an internal hardware trigger is generated
output by clearing the TRISC<2> bit.                                  which may be used to initiate an action.
  Note:    Clearing the CCP1CON register will force                   The special event trigger output of CCP1 resets the
           the RC2/CCP1 compare output latch to                       TMR1 register pair. This allows the CCPR1 register to
           the default low level. This is not the                     effectively be a 16-bit programmable period register for
           PORTC I/O data latch.                                      Timer1.
                                                                      The special event trigger output of CCP2 resets the
9.5.2      TIMER1 MODE SELECTION                                      TMR1 register pair and starts an A/D conversion (if the
Timer1 must be running in Timer mode or Synchro-                      A/D module is enabled).
nized Counter mode if the CCP module is using the
                                                                           Note:      The special event trigger from the CCP1
compare feature. In Asynchronous Counter mode, the
                                                                                      and CCP2 modules will not set interrupt
compare operation may not work.
                                                                                      flag bit, TMR1IF (PIR1<0>).
9.5.3      SOFTWARE INTERRUPT MODE
When Generate Software Interrupt mode is chosen, the
CCP1 pin is not affected. The CCP1IF or CCP2IF bit is
set, causing a CCP interrupt (if enabled).
TABLE 9-3:         REGISTERS ASSOCIATED WITH CAPTURE, COMPARE AND TIMER1
                                                                                                                          Value on
                                                                                                             Value on:
 Address     Name       Bit 7    Bit 6     Bit 5       Bit 4       Bit 3      Bit 2      Bit 1       Bit 0                all other
                                                                                                             POR, BOR
                                                                                                                           Resets
0Bh,8Bh, INTCON         GIE      PEIE     TMR0IE      INT0IE       RBIE      TMR0IF      INT0IF      RBIF    0000 000x 0000 000u
10Bh,18Bh
0Ch        PIR1       PSPIF(1)   ADIF      RCIF        TXIF       SSPIF      CCP1IF     TMR2IF      TMR1IF 0000 0000 0000 0000
0Dh        PIR2        OSFIF     CMIF      LVDIF        —         BCLIF         —       CCP3IF      CCP2IF 000- 0--0 000- 0--0
8Ch        PIE1       PSPIE(1)   ADIE      RCIE        TXIE       SSPIE      CCP1IE TMR2IE          TMR1IE 0000 0000 0000 0000
8Dh        PIE2        OSFIE     CMIE      LVDIE        —         BCLIE         —       CCP3IE      CCP2IE 000- 0--0 000- 0--0
87h        TRISC      PORTC Data Direction Register                                                          1111 1111 1111 1111
0Eh        TMR1L      Holding Register for the Least Significant Byte of the 16-bit TMR1 Register            xxxx xxxx uuuu uuuu
0Fh        TMR1H      Holding Register for the Most Significant Byte of the 16-bit TMR1 Register             xxxx xxxx uuuu uuuu
10h        T1CON         —        —      T1CKPS1 T1CKPS0 T1OSCEN T1SYNC TMR1CS TMR1ON --00 0000 --uu uuuu
15h        CCPR1L     Capture/Compare/PWM Register 1 (LSB)                                                   xxxx xxxx uuuu uuuu
16h        CCPR1H     Capture/Compare/PWM Register 1 (MSB)                                                   xxxx xxxx uuuu uuuu
17h        CCP1CON       —        —       CCP1X       CCP1Y      CCP1M3 CCP1M2 CCP1M1 CCP1M0 --00 0000 --00 0000
1Bh        CCPR2L     Capture/Compare/PWM Register 2 (LSB)                                                   xxxx xxxx uuuu uuuu
1Ch        CCPR2H     Capture/Compare/PWM Register 2 (MSB)                                                   xxxx xxxx uuuu uuuu
1Dh        CCP2CON       —        —       CCP2X       CCP2Y      CCP2M3 CCP2M2 CCP2M1 CCP2M0 --00 0000 --00 0000
95h        CCPR3L     Capture/Compare/PWM Register 3 (LSB)                                                   xxxx xxxx uuuu uuuu
96h        CCPR3H     Capture/Compare/PWM Register 3 (MSB)                                                   xxxx xxxx uuuu uuuu
97h        CCP3CON       —        —       CCP3X       CCP3Y      CCP3M3 CCP3M2 CCP3M1 CCP3M0 --00 0000 --00 0000
Legend:    x = unknown, u = unchanged, - = unimplemented, read as ‘0’. Shaded cells are not used by Capture and Timer1.
Note 1:    The PSP is not implemented on the PIC16F737/767 devices; always maintain these bits clear.
DS30498B-page 90                                       Preliminary                                   2003 Microchip Technology Inc.
                                                                                                PIC16F7X7
9.6         PWM Mode (PWM)                                           9.6.1        PWM PERIOD
In Pulse Width Modulation mode, the CCPx pin                         The PWM period is specified by writing to the PR2
produces up to a 10-bit resolution PWM output. Since                 register. The PWM period can be calculated using the
the CCP1 pin is multiplexed with the PORTC data latch,               following formula:
the TRISC<2> bit must be cleared to make the CCP1                          PWM Period = [(PR2) + 1] • 4 • TOSC •
pin an output.                                                                          (TMR2 Prescale Value)
  Note:        Clearing the CCP1CON register will force              PWM frequency is defined as 1/[PWM period].
               the CCP1 PWM output latch to the default              When TMR2 is equal to PR2, the following three events
               low level. This is not the PORTC I/O data             occur on the next increment cycle:
               latch.
                                                                     • TMR2 is cleared
Figure 9-3 shows a simplified block diagram of the
                                                                     • The CCP1 pin is set (exception: if PWM duty
CCP module in PWM mode.
                                                                       cycle = 0%, the CCP1 pin will not be set)
For a step-by-step procedure on how to set up the CCP                • The PWM duty cycle is latched from CCPR1L into
module for PWM operation, see Section 9.6.3 “Setup                     CCPR1H
for PWM Operation”.
                                                                       Note:      The Timer2 postscaler (see Section 9.4
FIGURE 9-3:                  SIMPLIFIED PWM BLOCK                                 “Capture Mode”) is not used in the deter-
                             DIAGRAM                                              mination of the PWM frequency. The
                               CCP1CON<5:4>
                                                                                  postscaler could be used to have a servo
      Duty Cycle Registers
                                                                                  update rate at a different frequency than
      CCPR1L                                                                      the PWM output.
                                                                     9.6.2        PWM DUTY CYCLE
                                                                     The PWM duty cycle is specified by writing to the
  CCPR1H (Slave)                                                     CCPR1L register and to the CCP1CON<5:4> bits. Up
                                                                     to 10-bit resolution is available. The CCPR1L contains
         Comparator                    R      Q                      the eight MSbs and the CCP1CON<5:4> contains the
                                                                     two LSbs. This 10-bit value is represented by
                                                      RC2/CCP1
       TMR2            (1)
                                                                     CCPR1L:CCP1CON<5:4>. The following equation is
                                       S                             used to calculate the PWM duty cycle in time:
 (Note 1)
                                                                           PWM Duty Cycle = (CCPR1L:CCP1CON<5:4>) •
      Comparator                                  TRISC<2>
                                                                                            TOSC • (TMR2 Prescale Value)
                        Clear Timer,
                        CCP1 pin and                                 CCPR1L and CCP1CON<5:4> can be written to at any
                        latch D.C.
         PR2                                                         time, but the duty cycle value is not latched into
                                                                     CCPR1H until after a match between PR2 and TMR2
   Note 1: The 8-bit timer is concatenated with the 2-bit            occurs (i.e., the period is complete). In PWM mode,
           internal Q clock or the 2 bits of the prescaler to
           create the 10-bit time base.                              CCPR1H is a read-only register.
                                                                     The CCPR1H register and a 2-bit internal latch are
A PWM output (Figure 9-4) has a time base (period)                   used to double-buffer the PWM duty cycle. This
and a time that the output stays high (duty cycle). The              double-buffering is essential for glitchless PWM
frequency of the PWM is the inverse of the period                    operation.
(1/period).
                                                                     When the CCPR1H and 2-bit latch match TMR2,
                                                                     concatenated with an internal 2-bit Q clock or 2 bits of
FIGURE 9-4:                  PWM OUTPUT
                                                                     the TMR2 prescaler, the CCP1 pin is cleared.
        TMR2                   TMR2                                  The maximum PWM resolution (bits) for a given PWM
        Reset                  Reset
                   Period                                            frequency is given by the formula:
                                                                                                   (FOSC
                                                                                               log FPWM   )
                                                                             Resolution =                 bits
                                                                                                  log(2)
             Duty Cycle
                                TMR2 = PR2                             Note:      If the PWM duty cycle value is longer than
                                                                                  the PWM period, the CCP1 pin will not be
                          TMR2 = Duty Cycle
                                                                                  cleared.
        TMR2 = PR2
 2003 Microchip Technology Inc.                             Preliminary                                   DS30498B-page 91
PIC16F7X7
9.6.3        SETUP FOR PWM OPERATION                                   3.    Make the CCP1 pin an output by clearing the
                                                                             TRISC<2> bit.
The following steps should be taken when configuring
the CCP module for PWM operation:                                      4.    Set the TMR2 prescale value and enable Timer2
                                                                             by writing to T2CON.
1.    Set the PWM period by writing to the PR2 register.
                                                                       5.    Configure the CCP1 module for PWM operation.
2.    Set the PWM duty cycle by writing to the
      CCPR1L register and CCP1CON<5:4> bits.
TABLE 9-4:          EXAMPLE PWM FREQUENCIES AND RESOLUTIONS (FOSC = 20 MHz)
        PWM Frequency                1.22 kHz            4.88 kHz     19.53 kHz            78.12 kHz      156.3 kHz      208.3 kHz
Timer Prescale (1, 4, 16)                  16               4                1                1                  1             1
PR2 Value                               0xFF              0xFF              0xFF             0x3F               0x1F          0x17
Maximum Resolution (bits)                  10              10                10               8                  7            6.6
TABLE 9-5:          REGISTERS ASSOCIATED WITH PWM AND TIMER2
                                                                                                                              Value on
                                                                                                                  Value on:
 Address      Name       Bit 7     Bit 6         Bit 5     Bit 4     Bit 3         Bit 2     Bit 1      Bit 0                 all other
                                                                                                                  POR, BOR
                                                                                                                               Resets
0Bh,8Bh, INTCON          GIE       PEIE         TMR0IE    INT0IE     RBIE         TMR0IF    INT0IF      RBIF      0000 000x 0000 000u
10Bh,18Bh
0Ch         PIR1       PSPIF(1)    ADIF          RCIF      TXIF     SSPIF         CCP1IF    TMR2IF     TMR1IF 0000 0000 0000 0000
0Dh         PIR2        OSFIF      CMIF         LVDIF       —       BCLIF           —       CCP3IF     CCP2IF 000- 0-00 000- 0-00
8Ch         PIE1       PSPIE(1)    ADIE          RCIE      TXIE     SSPIE         CCP1IE    TMR2IE     TMR1IE 0000 0000 0000 0000
8Dh         PIE2        OSFIE      CMIE         LVDIE       —       BCLIE           —       CCP3IE     CCP2IE 000- 0-00 000- 0-00
87h         TRISC      PORTC Data Direction Register                                                              1111 1111 1111 1111
11h         TMR2       Timer2 Module Register                                                                     0000 0000 0000 0000
92h         PR2        Timer2 Module Period Register                                                              1111 1111 1111 1111
12h         T2CON         —       TOUTPS3 TOUTPS2 TOUTPS1 TOUTPS0 TMR2ON T2CKPS1 T2CKPS0 -000 0000 -000 0000
15h         CCPR1L     Capture/Compare/PWM Register 1 (LSB)                                                       xxxx xxxx uuuu uuuu
16h         CCPR1H     Capture/Compare/PWM Register 1 (MSB)                                                       xxxx xxxx uuuu uuuu
17h         CCP1CON       —         —           CCP1X     CCP1Y     CCP1M3 CCP1M2 CCP1M1 CCP1M0 --00 0000 --00 0000
1Bh         CCPR2L     Capture/Compare/PWM Register 2 (LSB)                                                       xxxx xxxx uuuu uuuu
1Ch         CCPR2H     Capture/Compare/PWM Register 2 (MSB)                                                       xxxx xxxx uuuu uuuu
1Dh         CCP2CON       —         —           CCP2X     CCP2Y     CCP2M3 CCP2M2 CCP2M1 CCP2M0 --00 0000 --00 0000
95h         CCPR3L     Capture/Compare/PWM Register 3 (LSB)                                                       xxxx xxxx uuuu uuuu
96h         CCPR3H     Capture/Compare/PWM Register 3 (MSB)                                                       xxxx xxxx uuuu uuuu
97h         CCP3CON       —         —           CCP3X     CCP3Y     CCP3M3 CCP3M2 CCP3M1 CCP3M0 --00 0000 --00 0000
Legend:      x = unknown, u = unchanged, - = unimplemented, read as ‘0’. Shaded cells are not used by PWM and Timer2.
Note 1:      Bits PSPIE and PSPIF are reserved on the PIC16F737/767 devices; always maintain these bits clear.
DS30498B-page 92                                          Preliminary                                 2003 Microchip Technology Inc.
                                                                                            PIC16F7X7
10.0     MASTER SYNCHRONOUS                                   FIGURE 10-1:              MSSP BLOCK DIAGRAM
         SERIAL PORT (MSSP)                                                             (SPI MODE)
         MODULE                                                                                                 Internal
                                                                                                               Data Bus
                                                                                 Read                       Write
10.1     Master SSP (MSSP) Module
         Overview
                                                                                            SSPBUF Reg
The Master Synchronous Serial Port (MSSP) module is
a serial interface, useful for communicating with other         RC4/SDI/
peripheral or microcontroller devices. These peripheral          SDA
devices may be serial EEPROMs, shift registers, dis-                                        SSPSR Reg
play drivers, A/D converters, etc. The MSSP module              RC5/SDO              bit0                     Shift
can operate in one of two modes:                                                                              Clock
• Serial Peripheral Interface (SPI™)
• Inter-Integrated Circuit (I2C™)
  - Full Master mode                                                             Peripheral OE
                                                                RA5/AN4/
  - Slave mode (with general address call)                     LVDIN/SS/
The I2C interface supports the following modes in                C2OUT              SS Control
hardware:                                                                              Enable
• Master mode                                                                      Edge
                                                                                   Select
• Multi-Master mode
• Slave mode                                                                                        2
                                                                                               Clock Select
10.2     Control Registers
                                                                                         SSPM3:SSPM0
The MSSP module has three associated registers.                     RC3/            SMP:CKE 4
These include a status register (SSPSTAT) and two                   SCK/
                                                                    SCL
                                                                                         2              (
                                                                                                   TMR2 Output
                                                                                                          2            )
control registers (SSPCON and SSPCON2). The use                                      Edge
of these registers and their individual configuration bits                           Select       Prescaler TOSC
differ significantly, depending on whether the MSSP                                                4, 16, 64
module is operated in SPI or I2C mode.
                                                                                            Data to TX/RX in SSPSR
Additional details are provided under the individual                                        TRIS bit
sections.
10.3     SPI Mode
The SPI mode allows 8 bits of data to be synchronously          Note:      When the SPI is in Slave mode with SS pin
transmitted and received simultaneously. All four modes                    control enabled (SSPCON<3:0> = 0100),
of SPI are supported. To accomplish communication,                         the state of the SS pin can affect the state
typically three pins are used:                                             read back from the TRISC<5> bit. The
                                                                           Peripheral OE signal, from the SSP mod-
• Serial Data Out (SDO) – RC5/SDO
                                                                           ule into PORTC, controls the state that is
• Serial Data In (SDI) – RC4/SDI/SDA                                       read back from the TRISC<5> bit (see
• Serial Clock (SCK) – RC3/SCK/SCL                                         Section 5.3 “PORTC and the TRISC
Additionally, a fourth pin may be used when in a Slave                     Register” for information on PORTC). If
mode of operation:                                                         Read-Modify-Write instructions, such as
                                                                           BSF are performed on the TRISC register
• Slave Select (SS) – RA5/AN4/LVDIN/SS/C2OUT                               while the SS pin is high, this will cause the
Figure 10-1 shows the block diagram of the MSSP                            TRISC<5> bit to be set, thus disabling the
module when operating in SPI mode.                                         SDO output.
 2003 Microchip Technology Inc.                      Preliminary                                      DS30498B-page 93
PIC16F7X7
10.3.1       REGISTERS                                            SSPSR is the shift register used for shifting data in or
                                                                  out. SSPBUF is the buffer register to which data bytes
The MSSP module has four registers for SPI mode
                                                                  are written to or read from.
operation. These are:
                                                                  In receive operations, SSPSR and SSPBUF together
•   MSSP Control Register (SSPCON)
                                                                  create a double-buffered receiver. When SSPSR
•   MSSP Status Register (SSPSTAT)                                receives a complete byte, it is transferred to SSPBUF
•   Serial Receive/Transmit Buffer (SSPBUF)                       and the SSPIF interrupt is set.
•   MSSP Shift Register (SSPSR) – Not directly                    During transmission, the SSPBUF is not double-
    accessible                                                    buffered. A write to SSPBUF will write to both SSPBUF
SSPCON and SSPSTAT are the control and status                     and SSPSR.
registers in SPI mode operation. The SSPCON
register is readable and writable. The lower 6 bits of
the SSPSTAT are read-only. The upper two bits of the
SSPSTAT are read/write.
REGISTER 10-1:         SSPSTAT: MSSP STATUS (SPI MODE) REGISTER (ADDRESS 94h)
                          R/W-0      R/W-0         R-0          R-0          R-0         R-0         R-0          R-0
                           SMP        CKE          D/A            P           S          R/W          UA          BF
                        bit 7                                                                                       bit 0
            bit 7       SMP: Sample bit
                        SPI Master mode:
                        1 = Input data sampled at end of data output time
                        0 = Input data sampled at middle of data output time
                        SPI Slave mode:
                        SMP must be cleared when SPI is used in Slave mode.
            bit 6       CKE: SPI Clock Edge Select bit
                        When CKP = 0:
                        1 = Data transmitted on rising edge of SCK
                        0 = Data transmitted on falling edge of SCK
                        When CKP = 1:
                        1 = Data transmitted on falling edge of SCK
                        0 = Data transmitted on rising edge of SCK
            bit 5       D/A: Data/Address bit
                        Used in I2C mode only.
            bit 4       P: Stop bit
                        Used in I2C mode only. This bit is cleared when the MSSP module is disabled, SSPEN is cleared.
            bit 3       S: Start bit
                        Used in I2C mode only.
            bit 2       R/W: Read/Write bit Information
                        Used in I2C mode only.
            bit 1       UA: Update Address bit
                        Used in I2C mode only.
            bit 0       BF: Buffer Full Status bit (Receive mode only)
                        1 = Receive complete, SSPBUF is full
                        0 = Receive not complete, SSPBUF is empty
                        Legend:
                        R = Readable bit            W = Writable bit       U = Unimplemented bit, read as ‘0’
                        - n = Value at POR          ‘1’ = Bit is set       ‘0’ = Bit is cleared   x = Bit is unknown
DS30498B-page 94                                   Preliminary                             2003 Microchip Technology Inc.
                                                                                             PIC16F7X7
REGISTER 10-2:         SSPCON: MSSP CONTROL (SPI MODE) REGISTER 1 (ADDRESS 14h)
                          R/W-0        R/W-0        R/W-0          R/W-0   R/W-0        R/W-0       R/W-0       R/W-0
                          WCOL        SSPOV        SSPEN           CKP     SSPM3       SSPM2       SSPM1        SSPM0
                        bit 7                                                                                      bit 0
           bit 7        WCOL: Write Collision Detect bit (Transmit mode only)
                        1 = The SSPBUF register is written while it is still transmitting the previous word.
                            (Must be cleared in software.)
                        0 = No collision
           bit 6        SSPOV: Receive Overflow Indicator bit
                        SPI Slave mode:
                        1 = A new byte is received while the SSPBUF register is still holding the previous data. In case
                            of overflow, the data in SSPSR is lost. Overflow can only occur in Slave mode. The user
                            must read the SSPBUF, even if only transmitting data, to avoid setting overflow.
                            (Must be cleared in software.)
                        0 = No overflow
                          Note:     In Master mode, the overflow bit is not set since each new reception (and
                                    transmission) is initiated by writing to the SSPBUF register.
           bit 5        SSPEN: Synchronous Serial Port Enable bit
                        1 = Enables serial port and configures SCK, SDO, SDI and SS as serial port pins
                        0 = Disables serial port and configures these pins as I/O port pins
                          Note:     When enabled, these pins must be properly configured as input or output.
           bit 4        CKP: Clock Polarity Select bit
                        1 = Idle state for clock is a high level
                        0 = Idle state for clock is a low level
           bit 3-0      SSPM3:SSPM0: Synchronous Serial Port Mode Select bits
                        0101 = SPI Slave mode, clock = SCK pin. SS pin control disabled. SS can be used as I/O pin.
                        0100 = SPI Slave mode, clock = SCK pin. SS pin control enabled.
                        0011 = SPI Master mode, clock = TMR2 output/2
                        0010 = SPI Master mode, clock = FOSC/64
                        0001 = SPI Master mode, clock = FOSC/16
                        0000 = SPI Master mode, clock = FOSC/4
                          Note:     Bit combinations not specifically listed here are either reserved or implemented in
                                    I2C mode only.
                        Legend:
                        R = Readable bit              W = Writable bit     U = Unimplemented bit, read as ‘0’
                        - n = Value at POR            ‘1’ = Bit is set     ‘0’ = Bit is cleared   x = Bit is unknown
 2003 Microchip Technology Inc.                     Preliminary                                       DS30498B-page 95
PIC16F7X7
10.3.2      OPERATION                                         reading the data that was just received. Any write to the
                                                              SSPBUF register during transmission/reception of data
When initializing the SPI, several options need to be
                                                              will be ignored and the write collision detect bit, WCOL
specified. This is done by programming the appropriate
                                                              (SSPCON<7>), will be set. User software must clear
control bits (SSPCON<5:0> and SSPSTAT<7:6>).
                                                              the WCOL bit so that it can be determined if the follow-
These control bits allow the following to be specified:
                                                              ing write(s) to the SSPBUF register completed
• Master mode (SCK is the clock output)                       successfully.
• Slave mode (SCK is the clock input)                         When the application software is expecting to receive
• Clock Polarity (Idle state of SCK)                          valid data, the SSPBUF should be read before the next
• Data Input Sample Phase (middle or end of data              byte of data to transfer is written to the SSPBUF. Buffer
  output time)                                                Full bit, BF (SSPSTAT<0>), indicates when SSPBUF
• Clock Edge (output data on rising/falling edge of           has been loaded with the received data (transmission
  SCK)                                                        is complete). When the SSPBUF is read, the BF bit is
• Clock Rate (Master mode only)                               cleared. This data may be irrelevant if the SPI is only a
                                                              transmitter. Generally, the MSSP interrupt is used to
• Slave Select mode (Slave mode only)
                                                              determine when the transmission/reception has com-
The MSSP consists of a transmit/receive shift register        pleted. The SSPBUF must be read and/or written. If the
(SSPSR) and a buffer register (SSPBUF). The SSPSR             interrupt method is not going to be used, then software
shifts the data in and out of the device, MSb first. The      polling can be done to ensure that a write collision does
SSPBUF holds the data that was written to the SSPSR           not occur. Example 10-1 shows the loading of the
until the received data is ready. Once the 8 bits of data     SSPBUF (SSPSR) for data transmission.
have been received, that byte is moved to the SSPBUF
                                                              The SSPSR is not directly readable or writable, and
register. Then, the Buffer Full detect bit, BF
                                                              can only be accessed by addressing the SSPBUF
(SSPSTAT<0>), and the interrupt flag bit, SSPIF, are
                                                              register. Additionally, the MSSP Status register
set. This double-buffering of the received data
                                                              (SSPSTAT) indicates the various status conditions.
(SSPBUF) allows the next byte to start reception before
EXAMPLE 10-1:          LOADING THE SSPBUF (SSPSR) REGISTER
LOOP     BTFSS    SSPSTAT, BF        ;Has data been received (transmit complete)?
         BRA      LOOP               ;No
         MOVF     SSPBUF, W          ;WREG reg = contents of SSPBUF
         MOVWF    RXDATA             ;Save in user RAM, if data is meaningful
         MOVF     TXDATA, W          ;W reg = contents of TXDATA
         MOVWF    SSPBUF             ;New data to xmit
DS30498B-page 96                                      Preliminary                      2003 Microchip Technology Inc.
                                                                                                  PIC16F7X7
10.3.3      ENABLING SPI I/O                                          10.3.4      TYPICAL CONNECTION
To enable the serial port, SSP Enable bit, SSPEN                      Figure 10-2 shows a typical connection between two
(SSPCON<5>), must be set. To reset or reconfigure                     microcontrollers. The master controller (Processor 1)
SPI mode, clear the SSPEN bit, reinitialize the                       initiates the data transfer by sending the SCK signal.
SSPCON registers and then set the SSPEN bit. This                     Data is shifted out of both shift registers on their pro-
configures the SDI, SDO, SCK and SS pins as serial                    grammed clock edge and latched on the opposite edge
port pins. For the pins to behave as the serial port func-            of the clock. Both processors should be programmed to
tion, some must have their data direction bits (in the                the same Clock Polarity (CKP), then both controllers
TRIS register) appropriately programmed. That is:                     would send and receive data at the same time.
• SDI is automatically controlled by the SPI module                   Whether the data is meaningful (or dummy data)
                                                                      depends on the application software. This leads to
• SDO must have TRISC<5> bit cleared
                                                                      three scenarios for data transmission:
• SCK (Master mode) must have TRISC<3> bit
  cleared                                                             • Master sends data – Slave sends dummy data
• SCK (Slave mode) must have TRISC<3> bit set                         • Master sends data – Slave sends data
• SS must have TRISA<5> bit set                                       • Master sends dummy data – Slave sends data
Any serial port function that is not desired may be
overridden by programming the corresponding data
direction (TRIS) register to the opposite value.
FIGURE 10-2:             SPI MASTER/SLAVE CONNECTION
           SPI Master SSPM3:SSPM0 = 00xxb                                         SPI Slave SSPM3:SSPM0 = 010xb
                                                SDO                         SDI
                      Serial Input Buffer                                               Serial Input Buffer
                          (SSPBUF)                                                          (SSPBUF)
                         Shift Register         SDI                        SDO            Shift Register
                           (SSPSR)                                                          (SSPSR)
                   MSb                    LSb                                       MSb                    LSb
                                                       Serial Clock
                                                SCK                        SCK
                     PROCESSOR 1                                                           PROCESSOR 2
 2003 Microchip Technology Inc.                      Preliminary                                                DS30498B-page 97
PIC16F7X7
10.3.5      MASTER MODE                                               Figure 10-3, Figure 10-5 and Figure 10-6, where the
                                                                      MSB is transmitted first. In Master mode, the SPI clock
The master can initiate the data transfer at any time
                                                                      rate (bit rate) is user programmable to be one of the
because it controls the SCK. The master determines
                                                                      following:
when the slave (Processor 2, Figure 10-2) is to
broadcast data by the software protocol.                              •    FOSC/4 (or TCY)
In Master mode, the data is transmitted/received as                   •    FOSC/16 (or 4 • TCY)
soon as the SSPBUF register is written to. If the SPI is              •    FOSC/64 (or 16 • TCY)
only going to receive, the SDO output could be dis-                   •    Timer2 output/2
abled (programmed as an input). The SSPSR register
                                                                      This allows a maximum data rate (at 40 MHz) of
will continue to shift in the signal present on the SDI pin
                                                                      10.00 Mbps.
at the programmed clock rate. As each byte is
received, it will be loaded into the SSPBUF register as               Figure 10-3 shows the waveforms for Master mode.
if a normal received byte (interrupts and status bits                 When the CKE bit is set, the SDO data is valid before
appropriately set). This could be useful in receiver                  there is a clock edge on SCK. The change of the input
applications as a “Line Activity Monitor” mode.                       sample is shown based on the state of the SMP bit. The
                                                                      time when the SSPBUF is loaded with the received
The clock polarity is selected by appropriately program-
                                                                      data is shown.
ming the CKP bit (SSPCON<4>). This then, would give
waveforms for SPI communication as shown in
FIGURE 10-3:            SPI MODE WAVEFORM (MASTER MODE)
      Write to
      SSPBUF
      SCK
      (CKP = 0
      CKE = 0)
      SCK
      (CKP = 1
      CKE = 0)
                                                                                                                          4 Clock
      SCK                                                                                                                 Modes
      (CKP = 0
      CKE = 1)
      SCK
      (CKP = 1
      CKE = 1)
      SDO                     bit 7        bit 6   bit 5      bit 4       bit 3   bit 2    bit 1       bit 0
      (CKE = 0)
      SDO                     bit 7        bit 6   bit 5      bit 4       bit 3   bit 2    bit 1       bit 0
      (CKE = 1)
      SDI
      (SMP = 0)            bit 7                                                                     bit 0
      Input
      Sample
      (SMP = 0)
      SDI
      (SMP = 1)
                                   bit 7                                                                     bit 0
      Input
      Sample
      (SMP = 1)
      SSPIF
                                                                                                                     Next Q4 Cycle
      SSPSR to                                                                                                       after Q2↓
      SSPBUF
DS30498B-page 98                                           Preliminary                              2003 Microchip Technology Inc.
                                                                                        PIC16F7X7
10.3.6       SLAVE MODE                                      even if in the middle of a transmitted byte and becomes
                                                             a floating output. External pull-up/pull-down resistors
In Slave mode, the data is transmitted and received as
                                                             may be desirable, depending on the application.
the external clock pulses appear on SCK. When the
last bit is latched, the SSPIF interrupt flag bit is set.       Note 1: When the SPI is in Slave mode with SS pin
While in Slave mode, the external clock is supplied by                  control enabled (SSPCON<3:0> = 0100),
the external clock source on the SCK pin. This external                 the SPI module will reset if the SS pin is set
clock must meet the minimum high and low times, as                      to VDD.
specified in the electrical specifications.                           2: If the SPI is used in Slave mode with CKE
While in Sleep mode, the slave can transmit/receive                      set, then the SS pin control must be
data. When a byte is received, the device will wake-up                   enabled.
from Sleep.                                                  When the SPI module resets, the bit counter is forced
                                                             to ‘0’. This can be done by either forcing the SS pin to
10.3.7       SLAVE SELECT                                    a high level or clearing the SSPEN bit.
             SYNCHRONIZATION
                                                             To emulate two-wire communication, the SDO pin can
The SS pin allows a Synchronous Slave mode. The              be connected to the SDI pin. When the SPI needs to
SPI must be in Slave mode with SS pin control enabled        operate as a receiver, the SDO pin can be configured
(SSPCON<3:0> = 4h). The pin must not be driven low           as an input. This disables transmissions from the SDO.
for the SS pin to function as an input. The data latch       The SDI can always be left as an input (SDI function)
must be high. When the SS pin is low, transmission and       since it cannot create a bus conflict.
reception are enabled and the SDO pin is driven. When
the SS pin goes high, the SDO pin is no longer driven,
FIGURE 10-4:           SLAVE SYNCHRONIZATION WAVEFORM
 SS
 SCK
 (CKP = 0
 CKE = 0)
 SCK
 (CKP = 1
 CKE = 0)
 Write to
 SSPBUF
 SDO                               bit 7   bit 6                            bit 7                       bit 0
 SDI                                                                                                    bit 0
 (SMP = 0)                     bit 7                                       bit 7
 Input
 Sample
 (SMP = 0)
 SSPIF
 Interrupt
 Flag
                                                                                               Next Q4 Cycle
 SSPSR to                                                                                      after Q2↓
 SSPBUF
 2003 Microchip Technology Inc.                     Preliminary                                   DS30498B-page 99
PIC16F7X7
FIGURE 10-5:        SPI MODE WAVEFORM (SLAVE MODE WITH CKE = 0)
 SS
 Optional
 SCK
 (CKP = 0
 CKE = 0)
 SCK
 (CKP = 1
 CKE = 0)
 Write to
 SSPBUF
 SDO                       bit 7   bit 6   bit 5   bit 4   bit 3   bit 2   bit 1     bit 0
 SDI
 (SMP = 0)               bit 7                                                     bit 0
 Input
 Sample
 (SMP = 0)
 SSPIF
 Interrupt
 Flag
                                                                                             Next Q4 Cycle
 SSPSR to                                                                                    after Q2↓
 SSPBUF
FIGURE 10-6:        SPI MODE WAVEFORM (SLAVE MODE WITH CKE = 1)
  SS
  Not Optional
  SCK
  (CKP = 0
  CKE = 1)
  SCK
  (CKP = 1
  CKE = 1)
  Write to
  SSPBUF
  SDO                     bit 7    bit 6   bit 5   bit 4   bit 3   bit 2   bit 1    bit 0
  SDI
  (SMP = 0)              bit 7                                                     bit 0
  Input
  Sample
  (SMP = 0)
  SSPIF
  Interrupt
  Flag
                                                                                              Next Q4 Cycle
                                                                                              after Q2↓
  SSPSR to
  SSPBUF
DS30498B-page 100                          Preliminary                      2003 Microchip Technology Inc.
                                                                                                PIC16F7X7
10.3.8      SLEEP OPERATION                                            10.3.10    BUS MODE COMPATIBILITY
In Master mode, all module clocks are halted and the                   Table 10-1 shows the compatibility between the
transmission/reception will remain in that state until the             standard SPI modes and the states of the CKP and
device wakes from Sleep. After the device returns to                   CKE control bits.
normal mode, the module will continue to transmit/
receive data.                                                          TABLE 10-1:         SPI BUS MODES
In Slave mode, the SPI Transmit/Receive Shift register                                               Control Bits State
                                                                        Standard SPI Mode
operates asynchronously to the device. This allows the
device to be placed in Sleep mode and data to be                           Terminology               CKP           CKE
shifted into the SPI Transmit/Receive Shift register.                            0, 0                 0              1
When all 8 bits have been received, the MSSP interrupt
flag bit will be set and if enabled, will wake the device                        0, 1                 0              0
from Sleep.                                                                      1, 0                 1              1
                                                                                 1, 1                 1              0
10.3.9      EFFECTS OF A RESET
                                                                       There is also an SMP bit which controls when the data
A Reset disables the MSSP module and terminates the                    is sampled.
current transfer.
TABLE 10-2:           REGISTERS ASSOCIATED WITH SPI OPERATION
                                                                                                                   Value on
                                                                                                       Value on
  Name        Bit 7       Bit 6      Bit 5      Bit 4        Bit 3       Bit 2     Bit 1     Bit 0                 all other
                                                                                                      POR, BOR
                                                                                                                    Resets
INTCON      GIE/GIEH PEIE/GIEL      TMR0IE     INT0IE        RBIE      TMR0IF     INT0IF     RBIF    0000 000x 0000 000u
PIR1        PSPIF(1)      ADIF       RCIF       TXIF      SSPIF        CCP1IF     TMR2IF    TMR1IF   0000 0000 0000 0000
PIE1        PSPIE(1)      ADIE       RCIE       TXIE      SSPIE        CCP1IE     TMR2IE    TMR1IE   0000 0000 0000 0000
TRISC       PORTC Data Direction Register                                                            1111 1111 1111 1111
SSPBUF      Synchronous Serial Port Receive Buffer/Transmit Register                                 xxxx xxxx uuuu uuuu
SSPCON       WCOL        SSPOV      SSPEN       CKP       SSPM3        SSPM2      SSPM1      SSPM0   0000 0000 0000 0000
TRISA       PORTA Data Direction Register                                                            1111 1111 1111 1111
SSPSTAT       SMP         CKE         D/A         P           S          R/W       UA         BF     0000 0000 0000 0000
Legend:     x = unknown, u = unchanged, - = unimplemented, read as ‘0’. Shaded cells are not used by the MSSP in SPI mode.
Note 1:     The PSPIF, PSPIE and PSPIP bits are reserved on 28-pin devices; always maintain these bits clear.
 2003 Microchip Technology Inc.                        Preliminary                                        DS30498B-page 101
PIC16F7X7
10.4     I2C Mode                                                   10.4.1      REGISTERS
The MSSP module in I 2C mode fully implements all                   The MSSP module has six registers for I2C operation.
master and slave functions (including general call sup-             These are:
port) and provides interrupts on Start and Stop bits in             • MSSP Control Register (SSPCON)
hardware to determine a free bus (multi-master func-                • MSSP Control Register 2 (SSPCON2)
tion). The MSSP module implements the standard
                                                                    • MSSP Status Register (SSPSTAT)
mode specifications, as well as 7-bit and 10-bit
addressing.                                                         • Serial Receive/Transmit Buffer (SSPBUF)
                                                                    • MSSP Shift Register (SSPSR) – Not directly
Two pins are used for data transfer:
                                                                      accessible
• Serial clock (SCL) – RC3/SCK/SCL                                  • MSSP Address Register (SSPADD)
• Serial data (SDA) – RC4/SDI/SDA
                                                                    SSPCON, SSPCON2 and SSPSTAT are the control
The user must configure these pins as inputs or outputs             and status registers in I2C mode operation. The
through the TRISC<4:3> bits.                                        SSPCON and SSPCON2 registers are readable and
                                                                    writable. The lower 6 bits of the SSPSTAT are
FIGURE 10-7:            MSSP BLOCK DIAGRAM                          read-only. The upper two bits of the SSPSTAT are
                        (I2C MODE)                                  read/write.
                                                                    SSPSR is the shift register used for shifting data in or
                                                Internal            out. SSPBUF is the buffer register to which data bytes
                                                Data Bus
                                                                    are written to or read from.
                Read                        Write
                                                                    SSPADD register holds the slave device address
 RC3/SCK/
                                                                    when the SSP is configured in I2C Slave mode. When
                          SSPBUF Reg
   SCL                                                              the SSP is configured in Master mode, the lower
                                                                    seven bits of SSPADD act as the baud rate generator
                Shift
                Clock
                                                                    reload value.
                          SSPSR Reg
                                                                    In receive operations, SSPSR and SSPBUF together
                                                                    create a double-buffered receiver. When SSPSR
  RC4/              MSb                   LSb
  SDI/                                                              receives a complete byte, it is transferred to SSPBUF
  SDA                                                               and the SSPIF interrupt is set.
                          Match Detect              Addr Match
                                                                    During transmission, the SSPBUF is not double-
                                                                    buffered. A write to SSPBUF will write to both SSPBUF
                          SSPADD Reg
                                                                    and SSPSR.
                          Start and               Set, Reset
                        Stop bit Detect           S, P bits
                                                (SSPSTAT Reg)
DS30498B-page 102                                           Preliminary                      2003 Microchip Technology Inc.
                                                                                             PIC16F7X7
REGISTER 10-3:         SSPSTAT: MSSP STATUS (I2C MODE) REGISTER (ADDRESS 94h)
                          R/W-0       R/W-0         R-0          R-0           R-0       R-0        R-0         R-0
                           SMP         CKE          D/A            P            S        R/W        UA          BF
                        bit 7                                                                                      bit 0
           bit 7        SMP: Slew Rate Control bit
                        In Master or Slave mode:
                        1 = Slew rate control disabled for standard speed mode (100 kHz and 1 MHz)
                        0 = Slew rate control enabled for high-speed mode (400 kHz)
           bit 6        CKE: SMBus Select bit
                        In Master or Slave mode:
                        1 = Enable SMBus specific inputs
                        0 = Disable SMBus specific inputs
           bit 5        D/A: Data/Address bit
                        In Master mode:
                        Reserved.
                        In Slave mode:
                        1 = Indicates that the last byte received or transmitted was data
                        0 = Indicates that the last byte received or transmitted was address
           bit 4        P: Stop bit
                        1 = Indicates that a Stop bit has been detected last
                        0 = Stop bit was not detected last
                          Note:     This bit is cleared on Reset and when SSPEN is cleared.
           bit 3        S: Start bit
                        1 = Indicates that a Start bit has been detected last
                        0 = Start bit was not detected last
                          Note:     This bit is cleared on Reset and when SSPEN is cleared.
           bit 2        R/W: Read/Write bit Information bit (I2C mode only)
                        In Slave mode:
                        1 = Read
                        0 = Write
                           Note:   This bit holds the R/W bit information following the last address match. This bit is
                                   only valid from the address match to the next Start bit, Stop bit or not ACK bit.
                        In Master mode:
                        1 = Transmit is in progress
                        0 = Transmit is not in progress
                           Note:   ORing this bit with SEN, RSEN, PEN, RCEN or ACKEN will indicate if the MSSP is
                                   in Idle mode.
           bit 1        UA: Update Address bit (10-bit Slave mode only)
                        1 = Indicates that the user needs to update the address in the SSPADD register
                        0 = Address does not need to be updated
           bit 0        BF: Buffer Full Status bit
                        In Transmit mode:
                        1 = Receive complete, SSPBUF is full
                        0 = Receive not complete, SSPBUF is empty
                        In Receive mode:
                        1 = Data transmit in progress (does not include the ACK and Stop bits), SSPBUF is full
                        0 = Data transmit complete (does not include the ACK and Stop bits), SSPBUF is empty
                        Legend:
                        R = Readable bit             W = Writable bit      U = Unimplemented bit, read as ‘0’
                        - n = Value at POR           ‘1’ = Bit is set      ‘0’ = Bit is cleared   x = Bit is unknown
 2003 Microchip Technology Inc.                    Preliminary                                      DS30498B-page 103
PIC16F7X7
REGISTER 10-4:      SSPCON: MSSP CONTROL (I2C MODE) REGISTER 1 (ADDRESS 14h)
                      R/W-0       R/W-0       R/W-0        R/W-0      R/W-0        R/W-0       R/W-0       R/W-0
                      WCOL       SSPOV       SSPEN          CKP      SSPM3        SSPM2       SSPM1        SSPM0
                    bit 7                                                                                      bit 0
          bit 7     WCOL: Write Collision Detect bit
                    In Master Transmit mode:
                    1 = A write to the SSPBUF register was attempted while the I2C conditions were not valid for
                         a transmission to be started. (Must be cleared in software.)
                    0 = No collision
                    In Slave Transmit mode:
                    1 = The SSPBUF register is written while it is still transmitting the previous word. (Must be
                         cleared in software.)
                    0 = No collision
                    In Receive mode (Master or Slave modes):
                    This is a “don’t care” bit.
          bit 6     SSPOV: Receive Overflow Indicator bit
                    In Receive mode:
                    1 = A byte is received while the SSPBUF register is still holding the previous byte. (Must be
                         cleared in software.)
                    0 = No overflow
                    In Transmit mode:
                    This is a “don’t care” bit in Transmit mode.
          bit 5     SSPEN: Synchronous Serial Port Enable bit
                    1 = Enables the serial port and configures the SDA and SCL pins as the serial port pins
                    0 = Disables serial port and configures these pins as I/O port pins
                      Note:    When enabled, the SDA and SCL pins must be properly configured as input or output.
          bit 4     CKP: SCK Release Control bit
                    In Slave mode:
                    1 = Release clock
                    0 = Holds clock low (clock stretch). (Used to ensure data setup time.)
                    In Master mode:
                    Unused in this mode.
          bit 3-0   SSPM3:SSPM0: Synchronous Serial Port Mode Select bits
                    1111 = I2C Slave mode, 10-bit address with Start and Stop bit interrupts enabled
                    1110 = I2C Slave mode, 7-bit address with Start and Stop bit interrupts enabled
                    1011 = I2C Firmware Controlled Master mode (slave Idle)
                    1000 = I2C Master mode, clock = FOSC/(4 * (SSPADD + 1))
                    0111 = I2C Slave mode, 10-bit address
                    0110 = I2C Slave mode, 7-bit address
                      Note:    Bit combinations not specifically listed here are either reserved or implemented in
                               SPI mode only.
                    Legend:
                    R = Readable bit            W = Writable bit      U = Unimplemented bit, read as ‘0’
                    - n = Value at POR          ‘1’ = Bit is set      ‘0’ = Bit is cleared   x = Bit is unknown
DS30498B-page 104                              Preliminary                            2003 Microchip Technology Inc.
                                                                                            PIC16F7X7
REGISTER 10-5:         SSPCON2: MSSP CONTROL (I2C MODE) REGISTER 2 (ADDRESS 91h)
                          R/W-0       R/W-0        R/W-0         R/W-0      R/W-0       R/W-0      R/W-0        R/W-0
                          GCEN      ACKSTAT       ACKDT         ACKEN       RCEN         PEN       RSEN         SEN
                        bit 7                                                                                      bit 0
              bit 7     GCEN: General Call Enable bit (Slave mode only)
                        1 = Enable interrupt when a general call address (0000h) is received in the SSPSR
                        0 = General call address disabled
              bit 6     ACKSTAT: Acknowledge Status bit (Master Transmit mode only)
                        1 = Acknowledge was not received from slave
                        0 = Acknowledge was received from slave
              bit 5     ACKDT: Acknowledge Data bit (Master Receive mode only)
                        1 = Not Acknowledge
                        0 = Acknowledge
                          Note:    Value that will be transmitted when the user initiates an Acknowledge sequence at
                                   the end of a receive.
              bit 4     ACKEN: Acknowledge Sequence Enable bit (Master Receive mode only)
                        1 = Initiate Acknowledge sequence on SDA and SCL pins and transmit ACKDT data bit.
                            Automatically cleared by hardware.
                        0 = Acknowledge sequence Idle
              bit 3     RCEN: Receive Enable bit (Master mode only)
                        1 = Enables Receive mode for I2C
                        0 = Receive Idle
              bit 2     PEN: Stop Condition Enable bit (Master mode only)
                        1 = Initiate Stop condition on SDA and SCL pins. Automatically cleared by hardware.
                        0 = Stop condition Idle
              bit 1     RSEN: Repeated Start Condition Enabled bit (Master mode only)
                        1 = Initiate Repeated Start condition on SDA and SCL pins. Automatically cleared by hardware.
                        0 = Repeated Start condition Idle
              bit 0     SEN: Start Condition Enabled/Stretch Enabled bit
                        In Master mode:
                        1 = Initiate Start condition on SDA and SCL pins. Automatically cleared by hardware.
                        0 = Start condition Idle
                        In Slave mode:
                        1 = Clock stretching is enabled for both slave transmit and slave receive (stretch enabled)
                        0 = Clock stretching is enabled for slave transmit only (PIC16F87X compatibility)
                          Note:    For bits ACKEN, RCEN, PEN, RSEN, SEN: If the I2C module is not in the Idle mode,
                                   this bit may not be set (no spooling) and the SSPBUF may not be written (or writes
                                   to the SSPBUF are disabled).
                        Legend:
                        R = Readable bit             W = Writable bit      U = Unimplemented bit, read as ‘0’
                        - n = Value at POR           ‘1’ = Bit is set      ‘0’ = Bit is cleared   x = Bit is unknown
 2003 Microchip Technology Inc.                   Preliminary                                      DS30498B-page 105
PIC16F7X7
10.4.2     OPERATION                                         10.4.3.1       Addressing
The MSSP module functions are enabled by setting             Once the MSSP module has been enabled, it waits for
MSSP enable bit, SSPEN (SSPCON<5>).                          a Start condition to occur. Following the Start condition,
The SSPCON register allows control of the I 2C opera-        the 8 bits are shifted into the SSPSR register. All incom-
tion. Four mode selection bits (SSPCON<3:0>) allow           ing bits are sampled with the rising edge of the clock
one of the following I 2C modes to be selected:              (SCL) line. The value of register SSPSR<7:1> is com-
                                                             pared to the value of the SSPADD register. The
• I2C Master mode, clock = Osc/4 (SSPADD + 1)                address is compared on the falling edge of the eighth
• I 2C Slave mode (7-bit address)                            clock (SCL) pulse. If the addresses match and the BF
• I 2C Slave mode (10-bit address)                           and SSPOV bits are clear, the following events occur:
• I 2C Slave mode (7-bit address), with Start and            1.    The SSPSR register value is loaded into the
  Stop bit interrupts enabled                                      SSPBUF register.
• I 2C Slave mode (10-bit address), with Start and           2.    The Buffer Full bit, BF, is set.
  Stop bit interrupts enabled                                3.    An ACK pulse is generated.
• I 2C Firmware Controlled Master mode, slave is             4.    MSSP Interrupt Flag bit, SSPIF (PIR1<3>), is
  Idle                                                             set (interrupt is generated if enabled) on the
Selection of any I 2C mode, with the SSPEN bit set,                falling edge of the ninth SCL pulse.
forces the SCL and SDA pins to be open-drain, pro-           In 10-bit Address mode, two address bytes need to be
vided these pins are programmed to inputs by setting         received by the slave. The five Most Significant bits
the appropriate TRISC bits. To ensure proper operation       (MSbs) of the first address byte specify if this is a 10-bit
of the module, pull-up resistors must be provided            address. Bit R/W (SSPSTAT<2>) must specify a write
externally to the SCL and SDA pins.                          so the slave device will receive the second address
                                                             byte. For a 10-bit address, the first byte would equal
10.4.3     SLAVE MODE                                        ‘11110 A9 A8 0’, where ‘A9’ and ‘A8’ are the two
In Slave mode, the SCL and SDA pins must be config-          MSbs of the address. The sequence of events for
ured as inputs (TRISC<4:3> set). The MSSP module             10-bit address is as follows, with steps 7 through 9 for
will override the input state with the output data when      the slave-transmitter:
required (slave-transmitter).                                1.    Receive first (high) byte of address (bits SSPIF,
The I 2C Slave mode hardware will always generate an               BF and bit UA (SSPSTAT<1>) are set).
interrupt on an address match. Through the mode              2.    Update the SSPADD register with second (low)
select bits, the user can also choose to interrupt on              byte of address (clears bit UA and releases the
Start and Stop bits.                                               SCL line).
When an address is matched, or the data transfer after       3.    Read the SSPBUF register (clears bit BF) and
an address match is received, the hardware automati-               clear flag bit SSPIF.
cally will generate the Acknowledge (ACK) pulse and          4.    Receive second (low) byte of address (bits
load the SSPBUF register with the received value                   SSPIF, BF and UA are set).
currently in the SSPSR register.                             5.    Update the SSPADD register with the first (high)
Any combination of the following conditions will cause             byte of address. If match releases SCL line, this
the MSSP module not to give this ACK pulse:                        will clear bit UA.
• The Buffer Full bit, BF (SSPSTAT<0>), was set              6.    Read the SSPBUF register (clears bit BF) and
  before the transfer was received.                                clear flag bit SSPIF.
• The overflow bit, SSPOV (SSPCON<6>), was set               7.    Receive Repeated Start condition.
  before the transfer was received.                          8.    Receive first (high) byte of address (bits SSPIF
In this case, the SSPSR register value is not loaded               and BF are set).
into the SSPBUF, but bit SSPIF (PIR1<3>) is set. The         9.    Read the SSPBUF register (clears bit BF) and
BF bit is cleared by reading the SSPBUF register, while            clear flag bit SSPIF.
bit SSPOV is cleared through software.
The SCL clock input must have a minimum high and
low for proper operation. The high and low times of the
I2C specification, as well as the requirement of the
MSSP module, are shown in timing parameter #100
and parameter #101.
DS30498B-page 106                                    Preliminary                        2003 Microchip Technology Inc.
                                                                                       PIC16F7X7
10.4.3.2      Reception                                     10.4.3.3      Transmission
When the R/W bit of the address byte is clear and an        When the R/W bit of the incoming address byte is set
address match occurs, the R/W bit of the SSPSTAT            and an address match occurs, the R/W bit of the
register is cleared. The received address is loaded into    SSPSTAT register is set. The received address is loaded
the SSPBUF register and the SDA line is held low            into the SSPBUF register. The ACK pulse will be sent on
(ACK).                                                      the ninth bit and pin RC3/SCK/SCL is held low regard-
When the address byte overflow condition exists, then       less of SEN (see Section 10.4.4 “Clock Stretching”
the no Acknowledge (ACK) pulse is given. An overflow        for more detail). By stretching the clock, the master will
condition is defined as either bit BF (SSPSTAT<0>) is       be unable to assert another clock pulse until the slave is
set or bit SSPOV (SSPCON<6>) is set.                        done preparing the transmit data. The transmit data
                                                            must be loaded into the SSPBUF register, which also
An MSSP interrupt is generated for each data transfer       loads the SSPSR register. Then pin RC3/SCK/SCL
byte. Flag bit, SSPIF (PIR1<3>), must be cleared in         should be enabled by setting bit CKP (SSPCON<4>).
software. The SSPSTAT register is used to determine         The eight data bits are shifted out on the falling edge of
the status of the byte.                                     the SCL input. This ensures that the SDA signal is valid
If SEN is enabled (SSPCON<0> = 1), RC3/SCK/SCL              during the SCL high time (Figure 10-9).
will be held low (clock stretch) following each data        The ACK pulse from the master-receiver is latched on
transfer. The clock must be released by setting bit,        the rising edge of the ninth SCL input pulse. If the SDA
CKP (SSPCON<4>). See Section 10.4.4 “Clock                  line is high (not ACK), then the data transfer is com-
Stretching” for more detail.                                plete. In this case, when the ACK is latched by the
                                                            slave, the slave logic is reset (resets SSPSTAT regis-
                                                            ter) and the slave monitors for another occurrence of
                                                            the Start bit. If the SDA line was low (ACK), the next
                                                            transmit data must be loaded into the SSPBUF register.
                                                            Again, pin RC3/SCK/SCL must be enabled by setting
                                                            bit CKP.
                                                            An MSSP interrupt is generated for each data transfer
                                                            byte. The SSPIF bit must be cleared in software and
                                                            the SSPSTAT register is used to determine the status
                                                            of the byte. The SSPIF bit is set on the falling edge of
                                                            the ninth clock pulse.
 2003 Microchip Technology Inc.                    Preliminary                                  DS30498B-page 107
                                                                                                                                                                                                                                                 FIGURE 10-8:
DS30498B-page 108
                                                                                                                                                                                                                                                                                                                 PIC16F7X7
                                                                 Receiving Address              R/W = 0                    Receiving Data                     ACK                 Receiving Data                     ACK
                                   SDA               A7   A6    A5     A4    A3      A2    A1         ACK     D7   D6    D5     D4        D3   D2   D1   D0         D7   D6   D5      D4     D3    D2   D1   D0
                                   SCL               1    2     3      4      5      6     7      8       9   1    2      3     4         5    6    7    8    9     1    2    3        4     5     6    7    8        9
                                           S                                                                                                                                                                                       P
                                   SSPIF
                                                                                                                                                                                                                               Bus master
                                   (PIR1<3>)                                                                                                                                                                                   terminates
                                                                                                                                                                                                                               transfer
                                   BF (SSPSTAT<0>)
Preliminary
                                                                                                                    Cleared in software
                                                                                                                    SSPBUF is read
                                   SSPOV (SSPCON<6>)
                                                                                                                                                                                                                  SSPOV is set
                                                                                                                                                                                                                  because SSPBUF is
                                                                                                                                                                                                                  still full. ACK is not sent.
                                   CKP          (CKP does not reset to ‘0’ when SEN = 0)
                                                                                                                                                                                                                                                 I2C SLAVE MODE TIMING WITH SEN = 0 (RECEPTION, 7-BIT ADDRESS)
 2003 Microchip Technology Inc.
                                                                                                                                                                                                                                                    FIGURE 10-9:
                                                               Receiving Address        R/W = 1                                            Transmitting Data                                                 Transmitting Data
                                                                                                                                                                           ACK                                                         ACK
 2003 Microchip Technology Inc.
                                   SDA               A7   A6   A5   A4   A3   A2   A1             ACK                 D7      D6    D5     D4    D3    D2      D1     D0            D7     D6     D5    D4    D3      D2   D1     D0
                                   SCL
                                                     1    2    3    4    5    6    7      8       9                   1        2     3     4     5     6       7      8    9        1       2     3     4      5      6    7      8    9
                                          S
                                                     Data in                                            SCL held low                                                                                                                            P
                                                     sampled                                            while CPU
                                                                                                        responds to SSPIF
                                   SSPIF (PIR1<3>)
                                   BF (SSPSTAT<0>)
                                                                                                                                Cleared in software                                             Cleared in software
Preliminary
                                                                                                                                                                   From SSPIF ISR                                              From SSPIF ISR
                                                                                                                            SSPBUF is written in software                                 SSPBUF is written in software
                                   CKP
                                                                                                                                                                                                                                                    I2C SLAVE MODE TIMING (TRANSMISSION, 7-BIT ADDRESS)
                                                                                                                            CKP is set in software                                       CKP is set in software
DS30498B-page 109
                                                                                                                                                                                                                                                                                                          PIC16F7X7
                                                                                                                                                                                                                                                                                          FIGURE 10-10:
DS30498B-page 110
                                                                                                  Clock is held low until                         Clock is held low until
                                                                                                  update of SSPADD has                            update of SSPADD has
                                                                                                  taken place                                     taken place
                                                Receive First Byte of Address                               Receive Second Byte of Address                                  Receive Data Byte                          Receive Data Byte
                                                                                    R/W = 0                                                                                                                                                            ACK
                                                                                                                                                                                                                                                                                                                                                           PIC16F7X7
                                    SDA         1     1   1    1    0     A9 A8            ACK         A7       A6   A5   A4    A3   A2 A1     A0 ACK          D7     D6 D5 D4        D3 D2        D1 D0 ACK D7 D6 D5 D4          D3 D2        D1 D0
                                    SCL         1     2   3    4    5     6     7      8      9             1    2    3     4    5    6    7      8   9         1     2     3    4    5    6       7   8   9   1   2     3    4   5    6       7   8   9
                                            S                                                                                                                                                                                                                      P
                                                                                                                                                                                                                                                                         Bus master
                                                                                                                                                                                                                                                                         terminates
                                    SSPIF                                                                                                                                                                                                                                transfer
                                    (PIR1<3>)
                                                                                                                     Cleared in software                                     Cleared in software                         Cleared in software
                                                    Cleared in software
                                    BF (SSPSTAT<0>)
                                                           SSPBUF is written with                           Dummy read of SSPBUF
                                                           contents of SSPSR                                to clear BF flag
                                   SSPOV (SSPCON<6>)
                                                                                                                                                                                                                                                           SSPOV is set
Preliminary
                                                                                                                                                                                                                                                           because SSPBUF is
                                                                                                                                                                                                                                                           still full. ACK is not sent.
                                    UA (SSPSTAT<1>)
                                                          UA is set indicating that                             Cleared by hardware                                 Cleared by hardware when
                                                          the SSPADD needs to be                                when SSPADD is updated                              SSPADD is updated with high
                                                          updated                                               with low byte of address                            byte of address
                                                                                                                      UA is set indicating that
                                                                                                                      SSPADD needs to be
                                                                                                                      updated
                                   CKP          (CKP does not reset to ‘0’ when SEN = 0)
                                                                                                                                                                                                                                                                                          I2C SLAVE MODE TIMING WITH SEN = 0 (RECEPTION, 10-BIT ADDRESS)
 2003 Microchip Technology Inc.
                                                                                                                                                                                                                                                                                  FIGURE 10-11:
                                                                                                                                                                                                                                                                     Bus master
                                                                                                                                                                                                                                                                     terminates
                                                                                             Clock is held low until                              Clock is held low until                                                                                            transfer
                                                                                             update of SSPADD has                                 update of SSPADD has                                         Clock is held low until
 2003 Microchip Technology Inc.
                                                                                             taken place                                          taken place                                                  CKP is set to ‘1’
                                                                               R/W = 0
                                               Receive First Byte of Address                           Receive Second Byte of Address                               Receive First Byte of Address    R/W = 1                 Transmitting Data Byte            ACK
                                   SDA         1   1    1   1    0    A9 A8            ACK        A7       A6 A5 A4 A3 A2 A1                 A0   ACK               1       1   1   1   0   A9 A8         ACK          D7 D6 D5          D4 D3 D2 D1 D0
                                   SCL         1   2    3   4    5    6    7       8    9              1     2    3    4    5     6   7       8   9                 1       2   3   4   5   6    7    8   9             1    2    3      4   5    6    7   8    9
                                           S                                                                                                                 Sr                                                                                                         P
                                   SSPIF
                                   (PIR1<3>)
                                                                                                           Cleared in software                                    Cleared in software                                            Cleared in software
                                   BF (SSPSTAT<0>)
                                                       SSPBUF is written with                    Dummy read of SSPBUF
Preliminary
                                                                                                                                                          Dummy read of SSPBUF                                        Write of SSPBUF                      Completion of
                                                       contents of SSPSR                         to clear BF flag                                                                               BF flag is clear
                                                                                                                                                          to clear BF flag                                            initiates transmit                   data transmission
                                                                                                                                                                                                at the end of the
                                   UA (SSPSTAT<1>)                                                                                                                                              third address sequence                                     clears BF flag
                                                       UA is set indicating that                           Cleared by hardware when                            Cleared by hardware when
                                                       the SSPADD needs to be                              SSPADD is updated with low                          SSPADD is updated with high
                                                       updated                                             byte of address.                                    byte of address.
                                                                                                                 UA is set indicating that
                                                                                                                 SSPADD needs to be
                                                                                                                 updated
                                   CKP (SSPCON<4>)
                                                                                                                                                                                                                         CKP is set in software
                                                                                                                                                                                                                                                                                  I2C SLAVE MODE TIMING (TRANSMISSION, 10-BIT ADDRESS)
                                                                                                                                                                                                                  CKP is automatically cleared in hardware holding SCL low
DS30498B-page 111
                                                                                                                                                                                                                                                                                                                                         PIC16F7X7
PIC16F7X7
10.4.4       CLOCK STRETCHING                                 10.4.4.3      Clock Stretching for 7-bit Slave
Both 7-bit and 10-bit Slave modes implement                                 Transmit Mode
automatic clock stretching during a transmit sequence.        7-bit Slave Transmit mode implements clock stretching
The SEN bit (SSPCON2<0>) allows clock stretching to           by clearing the CKP bit after the falling edge of the
be enabled during receives. Setting SEN will cause            ninth clock, if the BF bit is clear. This occurs
the SCL pin to be held low at the end of each data            regardless of the state of the SEN bit.
receive sequence.                                             The user’s ISR must set the CKP bit before transmis-
                                                              sion is allowed to continue. By holding the SCL line
10.4.4.1      Clock Stretching for 7-bit Slave                low, the user has time to service the ISR and load the
              Receive Mode (SEN = 1)                          contents of the SSPBUF before the master device can
In 7-bit Slave Receive mode, on the falling edge of the       initiate another transmit sequence (see Figure 10-9).
ninth clock, at the end of the ACK sequence if the BF bit        Note 1: If the user loads the contents of SSPBUF,
is set, the CKP bit in the SSPCON register is automati-                  setting the BF bit before the falling edge of
cally cleared, forcing the SCL output to be held low. The                the ninth clock, the CKP bit will not be
CKP being cleared to ‘0’ will assert the SCL line low.                   cleared and clock stretching will not occur.
The CKP bit must be set in the user’s ISR before recep-
tion is allowed to continue. By holding the SCL line low,              2: The CKP bit can be set in software
the user has time to service the ISR and read the                         regardless of the state of the BF bit.
contents of the SSPBUF before the master device can
                                                              10.4.4.4      Clock Stretching for 10-bit Slave
initiate another receive sequence. This will prevent
buffer overruns from occurring (see Figure 10-13).                          Transmit Mode
                                                              In 10-bit Slave Transmit mode, clock stretching is con-
   Note 1: If the user reads the contents of the
                                                              trolled during the first two address sequences by the
           SSPBUF before the falling edge of the
                                                              state of the UA bit, just as it is in 10-bit Slave Receive
           ninth clock, thus clearing the BF bit, the
                                                              mode. The first two addresses are followed by a third
           CKP bit will not be cleared and clock
                                                              address sequence, which contains the high order bits
           stretching will not occur.
                                                              of the 10-bit address and the R/W bit set to ‘1’. After
          2: The CKP bit can be set in software               the third address sequence is performed, the UA bit is
             regardless of the state of the BF bit. The       not set, the module is now configured in Transmit
             user should be careful to clear the BF bit       mode and clock stretching is controlled by the BF flag
             in the ISR before the next receive               as in 7-bit Slave Transmit mode (see Figure 10-11).
             sequence in order to prevent an overflow
             condition.
10.4.4.2      Clock Stretching for 10-bit Slave
              Receive Mode (SEN = 1)
In 10-bit Slave Receive mode during the address
sequence, clock stretching automatically takes place
but CKP is not cleared. During this time, if the UA bit is
set after the ninth clock, clock stretching is initiated.
The UA bit is set after receiving the upper byte of the
10-bit address and following the receive of the second
byte of the 10-bit address, with the R/W bit cleared to
‘0’. The release of the clock line occurs upon updating
SSPADD. Clock stretching will occur on each data
receive sequence as described in 7-bit mode.
  Note:      If the user polls the UA bit and clears it by
             updating the SSPADD register before the
             falling edge of the ninth clock occurs and if
             the user hasn’t cleared the BF bit by read-
             ing the SSPBUF register before that time,
             then the CKP bit will still NOT be asserted
             low. Clock stretching on the basis of the
             state of the BF bit only occurs during a
             data sequence, not an address sequence.
DS30498B-page 112                                     Preliminary                       2003 Microchip Technology Inc.
                                                                               PIC16F7X7
10.4.4.5      Clock Synchronization
              and the CKP Bit
When the CKP bit is cleared, the SCL output is forced
to ‘0’; however, setting the CKP bit will not assert the
SCL output low until the SCL output is already sam-
pled low. Therefore, the CKP bit will not assert the
SCL line until an external I2C master device has
already asserted the SCL line. The SCL output will
remain low until the CKP bit is set and all other
devices on the I2C bus have deasserted SCL. This
ensures that a write to the CKP bit will not violate the
minimum high time requirement for SCL (see
Figure 10-12).
FIGURE 10-12:          CLOCK SYNCHRONIZATION TIMING
            Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
  SDA                              DX                                                  DX-1
  SCL
                                             Master device
  CKP                                        asserts clock
                                                             Master device
                                                             deasserts clock
  WR
  SSPCON
 2003 Microchip Technology Inc.                    Preliminary                    DS30498B-page 113
                                                                                                                                                                                                                                                                    FIGURE 10-13:
DS30498B-page 114
                                                                                                           Clock is not held low
                                                                                                                                                                                                                                                                                                                                    PIC16F7X7
                                                                                                           because buffer full bit is
                                                                                                           clear prior to falling edge                               Clock is held low until                                                Clock is not held low
                                                                                                           of 9th clock                                              CKP is set to ‘1’                                                      because ACK = 1
                                                              Receiving Address             R/W = 0                             Receiving Data                       ACK                            Receiving Data                     ACK
                                   SDA           A7      A6   A5   A4   A3        A2   A1         ACK          D7     D6      D5         D4   D3   D2   D1    D0               D7        D6        D5   D4    D3     D2   D1   D0
                                   SCL               1   2    3    4     5        6    7      8       9         1      2       3         4    5    6    7     8      9         1         2         3     4     5     6    7    8        9
                                           S                                                                                                                                                                                                         P
                                   SSPIF
                                                                                                                                                                                                                                                 Bus master
                                   (PIR1<3>)                                                                                                                                                                                                     terminates
                                                                                                                                                                                                                                                 transfer
                                   BF (SSPSTAT<0>)
Preliminary
                                                                                                                        Cleared in software
                                                                                                          SSPBUF is read
                                   SSPOV (SSPCON<6>)
                                                                                                                                                                                                                                    SSPOV is set
                                                                                                                                                                                                                                    because SSPBUF is
                                                                                                                                                                                                                                    still full. ACK is not sent.
                                   CKP
                                                                                                                                                                                       CKP
                                                                                                             If BF is cleared                                                          written
                                                                                                             prior to the falling                                                      to ‘1’ in
                                                                                                             edge of the 9th clock,                                                    software
                                                                                                             CKP will not be reset                           BF is set after falling
                                                                                                             to ‘0’ and no clock                             edge of the 9th clock,
                                                                                                             stretching will occur                           CKP is reset to ‘0’ and
                                                                                                                                                             clock stretching occurs
                                                                                                                                                                                                                                                                    I2C SLAVE MODE TIMING WITH SEN = 1 (RECEPTION, 7-BIT ADDRESS)
 2003 Microchip Technology Inc.
                                                                                                                                                                                                                                                                                                           FIGURE 10-14:
                                                                                                  Clock is held low until                                        Clock is held low until
                                                                                                  update of SSPADD has                                           update of SSPADD has                                                                                        Clock is not held low
                                                                                                                                                                                                                Clock is held low until
                                                                                                  taken place                                                    taken place                                                                                                 because ACK = 1
                                                                                                                                                                                                                CKP is set to ‘1’
                                                    Receive First Byte of Address                                Receive Second Byte of Address                                    Receive Data Byte                                          Receive Data Byte
                                                                                    R/W = 0                                                                                                                                                                                   ACK
                                                                                                                                                           ACK                                                      ACK
                                    SDA         1     1    1     1     0   A9 A8            ACK        A7       A6    A5     A4    A3   A2    A1   A0                  D7 D6 D5 D4             D3 D2     D1   D0                 D7 D6 D5 D4           D3 D2        D1 D0
 2003 Microchip Technology Inc.
                                    SCL         1     2    3      4    5   6    7       8     9             1     2     3      4    5     6    7     8      9          1     2     3      4    5    6    7    8     9            1        2   3    4   5    6       7   8      9
                                            S                                                                                                                                                                                                                                           P
                                    SSPIF
                                                                                                                                                                                                                                                                                     Bus master
                                    (PIR1<3>)                                                                                                                                                                                                                                        terminates
                                                                                                                      Cleared in software                                          Cleared in software                                        Cleared in software                    transfer
                                                    Cleared in software
                                    BF (SSPSTAT<0>)
                                                               SSPBUF is written with                       Dummy read of SSPBUF                                       Dummy read of SSPBUF
                                                               contents of SSPSR                            to clear BF flag                                           to clear BF flag
                                   SSPOV (SSPCON<6>)
                                                                                                                                                                                                                                                                            SSPOV is set
Preliminary
                                                                                                                                                                                                                                                                            because SSPBUF is
                                                                                                                                                                                                                                                                            still full. ACK is not sent.
                                    UA (SSPSTAT<1>)
                                                            UA is set indicating that                           Cleared by hardware when                                   Cleared by hardware when
                                                            the SSPADD needs to be                              SSPADD is updated with low                                 SSPADD is updated with high
                                                            updated                                             byte of address after falling edge                         byte of address after falling edge
                                                                                                                of ninth clock                                             of ninth clock
                                                                                                                        UA is set indicating that
                                                                                                                        SSPADD needs to be
                                                                                                                        updated
                                   CKP
                                                                                                                Note:       An update of the SSPADD
                                                                                                                            register before the falling
                                                                                                                            edge of the ninth clock will                                                                             CKP written to ‘1’
                                                                                                                            have no effect on UA and                                                                                 in software
                                                                                                                            UA will remain set.
                                                                                                                                                                           Note:       An update of the SSPADD register before the falling edge of
                                                                                                                                                                                       the ninth clock will have no effect on UA and UA will remain
                                                                                                                                                                                                                                                                                                           I2C SLAVE MODE TIMING WITH SEN = 1 (RECEPTION, 10-BIT ADDRESS)
                                                                                                                                                                                       set.
DS30498B-page 115
                                                                                                                                                                                                                                                                                                                                                                            PIC16F7X7
PIC16F7X7
10.4.5        GENERAL CALL ADDRESS                                      If the general call address matches, the SSPSR is
              SUPPORT                                                   transferred to the SSPBUF, the BF flag bit is set (eighth
                                                                        bit) and on the falling edge of the ninth bit (ACK bit), the
The addressing procedure for the I2C bus is such that
                                                                        SSPIF interrupt flag bit is set.
the first byte after the Start condition usually deter-
mines which device will be the slave addressed by the                   When the interrupt is serviced, the source for the inter-
master. The exception is the general call address,                      rupt can be checked by reading the contents of the
which can address all devices. When this address is                     SSPBUF. The value can be used to determine if the
used, all devices should, in theory, respond with an                    address was device specific or a general call address.
Acknowledge.                                                            In 10-bit mode, the SSPADD is required to be updated
The general call address is one of eight addresses                      for the second half of the address to match and the UA
reserved for specific purposes by the I2C protocol. It                  bit is set (SSPSTAT<1>). If the general call address is
consists of all ‘0’s with R/W = 0.                                      sampled when the GCEN bit is set and while the slave
                                                                        is configured in 10-bit Address mode, then the second
The general call address is recognized when the Gen-
                                                                        half of the address is not necessary, the UA bit will not
eral Call Enable bit (GCEN) is enabled (SSPCON2<7>
                                                                        be set and the slave will begin receiving data after the
set). Following a Start bit detect, 8 bits are shifted into
                                                                        Acknowledge (Figure 10-15).
the SSPSR and the address is compared against the
SSPADD. It is also compared to the general call
address and fixed in hardware.
FIGURE 10-15:            SLAVE MODE GENERAL CALL ADDRESS SEQUENCE
                         (7 OR 10-BIT ADDRESS MODE)
                                                                        Address is compared to general call address
                                                                        after ACK, set interrupt
                                                                                         Receiving Data                    ACK
                                                                  R/W = 0
      SDA                          General Call Address                  ACK D7    D6    D5   D4     D3   D2    D1    D0
      SCL
                            1     2    3    4     5       6   7     8    9    1    2     3     4     5     6     7    8    9
                     S
      SSPIF
      BF (SSPSTAT<0>)
                                                                                    Cleared in software
                                                                                    SSPBUF is read
      SSPOV (SSPCON<6>)                                                                                                        ‘0’
      GCEN (SSPCON2<7>)                                                                                                        ‘1’
DS30498B-page 116                                         Preliminary                                2003 Microchip Technology Inc.
                                                                                                               PIC16F7X7
10.4.6      MASTER MODE                                                            Note:       The MSSP module, when configured in
Master mode is enabled by setting and clearing the                                             I2C Master mode, does not allow queueing
appropriate SSPM bits in SSPCON and by setting the                                             of events. For instance, the user is not
SSPEN bit. In Master mode, the SCL and SDA lines                                               allowed to initiate a Start condition and
are manipulated by the MSSP hardware.                                                          immediately write the SSPBUF register to
                                                                                               initiate transmission before the Start condi-
Master mode of operation is supported by interrupt
                                                                                               tion is complete. In this case, the SSPBUF
generation on the detection of the Start and Stop con-
                                                                                               will not be written to and the WCOL bit will
ditions. The Stop (P) and Start (S) bits are cleared from
                                                                                               be set, indicating that a write to the
a Reset or when the MSSP module is disabled. Control
                                                                                               SSPBUF did not occur.
of the I 2C bus may be taken when the P bit is set or the
bus is Idle, with both the S and P bits clear.                                 The following events will cause SSP Interrupt Flag bit,
In Firmware Controlled Master mode, user code                                  SSPIF, to be set (SSP interrupt if enabled):
conducts all I 2C bus operations based on Start and                            •   Start condition
Stop bit conditions.
                                                                               •   Stop condition
Once Master mode is enabled, the user has six                                  •   Data transfer byte transmitted/received
options:
                                                                               •   Acknowledge Transmit
1.   Assert a Start condition on SDA and SCL.                                  •   Repeated Start
2.   Assert a Repeated Start condition on SDA and
     SCL.
3.   Write to the SSPBUF register, initiating
     transmission of data/address.
4.   Configure the I2C port to receive data.
5.   Generate an Acknowledge condition at the end
     of a received byte of data.
6.   Generate a Stop condition on SDA and SCL.
FIGURE 10-16:          MSSP BLOCK DIAGRAM (I2C MASTER MODE)
                                                                                    Internal                    SSPM3:SSPM0
                                                                                   Data Bus                     SSPADD<6:0>
                                                Read                          Write
                                                            SSPBUF                                                Baud
                                                                                                                  Rate
                                                                                                                  Generator
     SDA                                                                           Shift
                                                                                                                    Clock Arbitrate/WCOL Detect
                             SDA In                                                Clock
                                                            SSPSR
                                                                                                                       (hold off clock source)
                                                   MSb                  LSb
                               Receive Enable
                                                       Start bit, Stop bit,
                                                                                                  Clock Cntl
                                                         Acknowledge
                                                           Generate
     SCL
                                                    Start bit Detect
                                                     Stop bit Detect
                                    SCL In         Write Collision Detect                  Set/Reset S, P, WCOL (SSPSTAT)
                                                     Clock Arbitration                     Set SSPIF, BCLIF
                                   Bus Collision    State Counter for                      Reset ACKSTAT, PEN (SSPCON2)
                                                    end of XMIT/RCV
 2003 Microchip Technology Inc.                            Preliminary                                                                 DS30498B-page 117
PIC16F7X7
10.4.6.1      I2C Master Mode Operation                        A typical transmit sequence would go as follows:
The master device generates all of the serial clock            1.  The user generates a Start condition by setting
pulses and the Start and Stop conditions. A transfer is            the Start enable bit, SEN (SSPCON2<0>).
ended with a Stop condition or with a Repeated Start           2. SSPIF is set. The MSSP module will wait the
condition. Since the Repeated Start condition is also              required Start time before any other operation
the beginning of the next serial transfer, the I2C bus will        takes place.
not be released.                                               3. The user loads the SSPBUF with the slave
In Master Transmitter mode, serial data is output                  address to transmit.
through SDA while SCL outputs the serial clock. The            4. Address is shifted out the SDA pin until all 8 bits
first byte transmitted contains the slave address of the           are transmitted.
receiving device (7 bits) and the Read/Write (R/W) bit.        5. The MSSP module shifts in the ACK bit from the
In this case, the R/W bit will be logic ‘0’. Serial data is        slave device and writes its value into the
transmitted 8 bits at a time. After each byte is transmit-         SSPCON2 register (SSPCON2<6>).
ted, an Acknowledge bit is received. Start and Stop
                                                               6. The MSSP module generates an interrupt at the
conditions are output to indicate the beginning and the
                                                                   end of the ninth clock cycle by setting the SSPIF
end of a serial transfer.
                                                                   bit.
In Master Receive mode, the first byte transmitted con-        7. The user loads the SSPBUF with eight bits of
tains the slave address of the transmitting device                 data.
(7 bits) and the R/W bit. In this case, the R/W bit will be
                                                               8. Data is shifted out the SDA pin until all 8 bits are
logic ‘1’. Thus, the first byte transmitted is a 7-bit slave
                                                                   transmitted.
address followed by a ‘1’ to indicate a receive bit. Serial
data is received via SDA while SCL outputs the serial          9. The MSSP module shifts in the ACK bit from the
clock. Serial data is received 8 bits at a time. After each        slave device and writes its value into the
byte is received, an Acknowledge bit is transmitted.               SSPCON2 register (SSPCON2<6>).
Start and Stop conditions indicate the beginning and           10. The MSSP module generates an interrupt at the
end of transmission.                                               end of the ninth clock cycle by setting the SSPIF
                                                                   bit.
The baud rate generator used for the SPI mode opera-
tion is used to set the SCL clock frequency for either         11. The user generates a Stop condition by setting
100 kHz, 400 kHz or 1 MHz I2C operation. See                       the Stop enable bit, PEN (SSPCON2<2>).
Section 10.4.7 “Baud Rate Generator” for more                  12. Interrupt is generated once the Stop condition is
detail.                                                            complete.
DS30498B-page 118                                      Preliminary                       2003 Microchip Technology Inc.
                                                                                           PIC16F7X7
10.4.7      BAUD RATE GENERATOR                                 Once the given operation is complete (i.e., transmis-
   2                                                            sion of the last data bit is followed by ACK), the internal
In I C Master mode, the Baud Rate Generator (BRG)
                                                                clock will automatically stop counting and the SCL pin
reload value is placed in the lower 7 bits of the
                                                                will remain in its last state.
SSPADD register (Figure 10-17). When a write occurs
to SSPBUF, the Baud Rate Generator will automatically           Table 10-3 demonstrates clock rates based on
begin counting. The BRG counts down to 0 and stops              instruction cycles and the BRG value loaded into
until another reload has taken place. The BRG count is          SSPADD.
decremented twice per instruction cycle (TCY) on the
Q2 and Q4 clocks. In I2C Master mode, the BRG is
reloaded automatically.
FIGURE 10-17:          BAUD RATE GENERATOR BLOCK DIAGRAM
                                         SSPM3:SSPM0                  SSPADD<6:0>
                        SSPM3:SSPM0            Reload        Reload
                                   SCL         Control
                                                     CLKO       BRG Down Counter            FOSC/4
TABLE 10-3:         I2C CLOCK RATE w/BRG
                                                                                                       FSCL
             FCY                          FCY*2                       BRG VALUE
                                                                                               (2 Rollovers of BRG)
           10 MHz                        20 MHz                          19h                         400 kHz(1)
           10 MHz                        20 MHz                          20h                         312.5 kHz
           10 MHz                        20 MHz                          3Fh                          100 kHz
            4 MHz                        8 MHz                           0Ah                         400 kHz(1)
            4 MHz                        8 MHz                           0Dh                          308 kHz
            4 MHz                        8 MHz                           28h                          100 kHz
            1 MHz                        2 MHz                           03h                         333 kHz(1)
            1 MHz                        2 MHz                           0Ah                          100 kHz
            1 MHz                        2 MHz                           00h                          1 MHz(1)
Note 1:     The I2C interface does not conform to the 400 kHz I2C specification (which applies to rates greater than
            100 kHz) in all details, but may be used with care where higher rates are required by the application.
 2003 Microchip Technology Inc.                   Preliminary                                        DS30498B-page 119
PIC16F7X7
10.4.7.1     Clock Arbitration
Clock arbitration occurs when the master, during any
receive, transmit or Repeated Start/Stop condition,
deasserts the SCL pin (SCL allowed to float high).
When the SCL pin is allowed to float high, the Baud
Rate Generator (BRG) is suspended from counting
until the SCL pin is actually sampled high. When the
SCL pin is sampled high, the Baud Rate Generator is
reloaded with the contents of SSPADD<6:0> and
begins counting. This ensures that the SCL high time
will always be at least one BRG rollover count in the
event that the clock is held low by an external device
(Figure 10-18).
FIGURE 10-18:         BAUD RATE GENERATOR TIMING WITH CLOCK ARBITRATION
             SDA                   DX                           DX-1
                                   SCL deasserted but slave holds               SCL allowed to transition high
                                   SCL low (clock arbitration)
             SCL
                                                            BRG decrements on
                                                            Q2 and Q4 cycles
             BRG
                             03h        02h       01h        00h (hold off)       03h        02h
             Value
                                         SCL is sampled high, reload takes
                                         place and BRG starts its count
             BRG
             Reload
DS30498B-page 120                                  Preliminary                              2003 Microchip Technology Inc.
                                                                                                   PIC16F7X7
10.4.8      I2C MASTER MODE START                                    10.4.8.1          WCOL Status Flag
            CONDITION TIMING                                         If the user writes the SSPBUF when a Start sequence
To initiate a Start condition, the user sets the Start Con-          is in progress, the WCOL is set and the contents of the
dition Enable bit, SEN (SSPCON2<0>). If the SDA and                  buffer are unchanged (the write doesn’t occur).
SCL pins are sampled high, the Baud Rate Generator
                                                                        Note:       Because queueing of events is not
is reloaded with the contents of SSPADD<6:0> and
                                                                                    allowed, writing to the lower 5 bits of
starts its count. If SCL and SDA are both sampled high
                                                                                    SSPCON2 is disabled until the Start
when the Baud Rate Generator times out (TBRG), the
                                                                                    condition is complete.
SDA pin is driven low. The action of the SDA being
driven low while SCL is high is the Start condition and
causes the S bit (SSPSTAT<3>) to be set. Following
this, the Baud Rate Generator is reloaded with the con-
tents of SSPADD<6:0> and resumes its count. When
the Baud Rate Generator times out (TBRG), the SEN bit
(SSPCON2<0>) will be automatically cleared by hard-
ware, the Baud Rate Generator is suspended, leaving
the SDA line held low and the Start condition is
complete.
  Note:     If at the beginning of the Start condition,
            the SDA and SCL pins are already sam-
            pled low, or if during the Start condition, the
            SCL line is sampled low before the SDA
            line is driven low, a bus collision occurs,
            the Bus Collision Interrupt Flag, BCLIF, is
            set, the Start condition is aborted and the
            I2C module is reset into its Idle state.
FIGURE 10-19:           FIRST START BIT TIMING
                                                              Set S bit (SSPSTAT<3>)
                   Write to SEN bit occurs here
                                                  SDA = 1,
                                                                     At completion of Start bit,
                                                  SCL = 1
                                                                     hardware clears SEN bit
                                                                        and sets SSPIF bit
                                                    TBRG      TBRG            Write to SSPBUF occurs here
                                                                                    1st bit        2nd bit
                                SDA
                                                                                         TBRG
                                SCL
                                                                             TBRG
                                                               S
 2003 Microchip Technology Inc.                       Preliminary                                           DS30498B-page 121
PIC16F7X7
10.4.9      I2C MASTER MODE REPEATED                                    Immediately following the SSPIF bit getting set, the
            START CONDITION TIMING                                      user may write the SSPBUF with the 7-bit address in
                                                                        7-bit mode or the default first address in 10-bit mode.
A Repeated Start condition occurs when the RSEN bit
                                                                        After the first eight bits are transmitted and an ACK is
(SSPCON2<1>) is programmed high and the I2C logic
                                                                        received, the user may then transmit an additional eight
module is in the Idle state. When the RSEN bit is set,
                                                                        bits of address (10-bit mode) or eight bits of data (7-bit
the SCL pin is asserted low. When the SCL pin is sam-
                                                                        mode).
pled low, the Baud Rate Generator is loaded with the
contents of SSPADD<5:0> and begins counting. The                        10.4.9.1        WCOL Status Flag
SDA pin is released (brought high) for one Baud Rate
Generator count (TBRG). When the Baud Rate Genera-                      If the user writes the SSPBUF when a Repeated Start
tor times out, if SDA is sampled high, the SCL pin will                 sequence is in progress, the WCOL is set and the con-
be deasserted (brought high). When SCL is sampled                       tents of the buffer are unchanged (the write doesn’t
high, the Baud Rate Generator is reloaded with the                      occur).
contents of SSPADD<6:0> and begins counting. SDA                           Note:      Because queueing of events is not
and SCL must be sampled high for one TBRG. This                                       allowed, writing of the lower 5 bits of
action is then followed by assertion of the SDA pin                                   SSPCON2 is disabled until the Repeated
(SDA = 0) for one TBRG while SCL is high. Following                                   Start condition is complete.
this, the RSEN bit (SSPCON2<1>) will be automatically
cleared and the Baud Rate Generator will not be
reloaded, leaving the SDA pin held low. As soon as a
Start condition is detected on the SDA and SCL pins,
the S bit (SSPSTAT<3>) will be set. The SSPIF bit will
not be set until the Baud Rate Generator has timed out.
   Note 1: If RSEN is programmed while any other
           event is in progress, it will not take effect.
         2: A bus collision during the Repeated Start
            condition occurs if:
            • SDA is sampled low when SCL goes
               from low-to-high.
            • SCL goes low before SDA is
               asserted low. This may indicate that
               another master is attempting to
               transmit a data ‘1’.
FIGURE 10-20:           REPEAT START CONDITION WAVEFORM
                                                                                    Set S (SSPSTAT<3>)
                                          Write to SSPCON2
                                                             SDA = 1,
                                          occurs here.                             At completion of Start bit,
                                          SDA = 1,           SCL = 1
                                                                                   hardware clears RSEN bit
                                          SCL (no change).                            and sets SSPIF
                                                             TBRG   TBRG    TBRG
                                                                                                 1st bit
                           SDA
                  Falling edge of ninth clock.                                        Write to SSPBUF occurs here
                                End of Xmit.
                                                                                                    TBRG
                           SCL                                                           TBRG
                                                                           Sr = Repeated Start
DS30498B-page 122                                        Preliminary                                   2003 Microchip Technology Inc.
                                                                                           PIC16F7X7
10.4.10     I2C MASTER MODE                                    10.4.10.3     ACKSTAT Status Flag
            TRANSMISSION                                       In Transmit mode, the ACKSTAT bit (SSPCON2<6>) is
Transmission of a data byte, a 7-bit address or the            cleared when the slave has sent an Acknowledge
other half of a 10-bit address, is accomplished by sim-        (ACK = 0) and is set when the slave does not Acknowl-
ply writing a value to the SSPBUF register. This action        edge (ACK = 1). A slave sends an Acknowledge when
will set the Buffer Full flag bit, BF, and allow the Baud      it has recognized its address (including a general call)
Rate Generator to begin counting and start the next            or when the slave has properly received its data.
transmission. Each bit of address/data will be shifted
out onto the SDA pin after the falling edge of SCL is          10.4.11     I2C MASTER MODE RECEPTION
asserted (see data hold time specification parameter           Master mode reception is enabled by programming the
#106). SCL is held low for one Baud Rate Generator             Receive Enable bit, RCEN (SSPCON2<3>).
rollover count (TBRG). Data should be valid before SCL
is released high (see data setup time specification              Note:     The MSSP module must be in an Idle state
parameter #107). When the SCL pin is released high, it                     before the RCEN bit is set or the RCEN bit
is held that way for TBRG. The data on the SDA pin                         will be disregarded.
must remain stable for that duration and some hold             The Baud Rate Generator begins counting and on each
time after the next falling edge of SCL. After the eighth      rollover, the state of the SCL pin changes (high-to-low/
bit is shifted out (the falling edge of the eighth clock),     low-to-high) and data is shifted into the SSPSR. After
the BF flag is cleared and the master releases SDA.            the falling edge of the eighth clock, the receive enable
This allows the slave device being addressed to                flag is automatically cleared, the contents of the
respond with an ACK bit during the ninth bit time, if an       SSPSR are loaded into the SSPBUF, the BF flag bit is
address match occurred or if data was received prop-           set, the SSPIF flag bit is set and the Baud Rate Gener-
erly. The status of ACK is written into the ACKDT bit on       ator is suspended from counting, holding SCL low. The
the falling edge of the ninth clock. If the master receives    MSSP is now in Idle state, awaiting the next command.
an Acknowledge, the Acknowledge Status bit,                    When the buffer is read by the CPU, the BF flag bit is
ACKSTAT, is cleared. If not, the bit is set. After the ninth   automatically cleared. The user can then send an
clock, the SSPIF bit is set and the master clock (Baud         Acknowledge bit at the end of reception by setting the
Rate Generator) is suspended until the next data byte          Acknowledge Sequence Enable bit, ACKEN
is loaded into the SSPBUF, leaving SCL low and SDA             (SSPCON2<4>).
unchanged (Figure 10-21).
After the write to the SSPBUF, each bit of address will        10.4.11.1     BF Status Flag
be shifted out on the falling edge of SCL until all seven      In receive operation, the BF bit is set when an address
address bits and the R/W bit are completed. On the fall-       or data byte is loaded into SSPBUF from SSPSR. It is
ing edge of the eighth clock, the master will deassert         cleared when the SSPBUF register is read.
the SDA pin, allowing the slave to respond with an
Acknowledge. On the falling edge of the ninth clock, the       10.4.11.2     SSPOV Status Flag
master will sample the SDA pin to see if the address
                                                               In receive operation, the SSPOV bit is set when 8 bits
was recognized by a slave. The status of the ACK bit is
                                                               are received into the SSPSR and the BF flag bit is
loaded into the ACKSTAT status bit (SSPCON2<6>).
                                                               already set from a previous reception.
Following the falling edge of the ninth clock transmis-
sion of the address, the SSPIF is set, The BF flag Is          10.4.11.3     WCOL Status Flag
cleared and the Baud Rate Generator is turned off until
another write to the SSPBUF takes place, holding SCL           If the user writes the SSPBUF when a receive is
low and allowing SDA to float.                                 already in progress (i.e., SSPSR is still shifting in a data
                                                               byte), the WCOL bit is set and the contents of the buffer
10.4.10.1     BF Status Flag                                   are unchanged (the write doesn’t occur).
In Transmit mode, the BF bit (SSPSTAT<0>) is set
when the CPU writes to SSPBUF and is cleared when
all 8 bits are shifted out.
10.4.10.2     WCOL Status Flag
If the user writes the SSPBUF when a transmit is
already in progress (i.e., SSPSR is still shifting out a
data byte), the WCOL is set and the contents of the
buffer are unchanged (the write doesn’t occur).
WCOL must be cleared in software.
 2003 Microchip Technology Inc.                       Preliminary                                    DS30498B-page 123
                                                                                                                                                                                            FIGURE 10-21:
DS30498B-page 124
                                              Write SSPCON2<0> SEN = 1                                                                                                       ACKSTAT in
                                              Start condition begins                                                                                                         SSPCON2 = 1
                                                                                                                       From Slave, clear ACKSTAT bit SSPCON2<6>
                                                                                                                                                                                                                                                            PIC16F7X7
                                                     SEN = 0
                                                           Transmit Address to Slave        R/W = 0                 Transmitting Data or Second Half of 10-bit Address ACK
                                   SDA                A7   A6    A5    A4   A3   A2    A1             ACK = 0             D7   D6    D5   D4   D3    D2    D1   D0
                                                      SSPBUF written with 7-bit address and R/W
                                                      starts transmit
                                   SCL                1     2    3     4     5    6     7     8       9                    1    2     3    4     5    6     7    8     9
                                              S                                                                                                                                 P
                                                                                                            SCL held low
                                                                                                            while CPU
                                                                                                          responds to SSPIF
                                   SSPIF
                                                                                                                               Cleared in software service routine
                                                           Cleared in software                                                 from SSP interrupt
                                                                                                                                                                      Cleared in software
Preliminary
                                   BF (SSPSTAT<0>)
                                                      SSPBUF written                                                           SSPBUF is written in software
                                   SEN
                                                     After Start condition, SEN cleared by hardware
                                   PEN
                                   R/W
                                                                                                                                                                                            I 2C MASTER MODE WAVEFORM (TRANSMISSION, 7 OR 10-BIT ADDRESS)
 2003 Microchip Technology Inc.
                                                                                                                                                                                                                                                                                   FIGURE 10-22:
                                                                                                                                                               Write to SSPCON2<4>
                                                                                                                                                               to start Acknowledge sequence,
                                                                                                                                                               SDA = ACKDT (SSPCON2<5>) = 0
                                           Write to SSPCON2<0> (SEN = 1).
                                           Begin Start condition.                                                                                                         ACK from Master                    Set ACKEN, start Acknowledge sequence
                                                                                                              Master configured as a receiver                             SDA = ACKDT = 0                             SDA = ACKDT = 1
                                                       SEN = 0                                                by programming SSPCON2<3> (RCEN = 1)
 2003 Microchip Technology Inc.
                                                                                                                                                                                                                                              PEN bit = 1
                                                           Write to SSPBUF occurs here.                                                        RCEN cleared                  RCEN = 1, start                      RCEN cleared
                                                                                              ACK from Slave                                                                 next receive                         automatically               written here
                                                              Start XMIT.                                                                      automatically
                                                               Transmit Address to Slave           R/W = 1              Receiving Data from Slave                                     Receiving Data from Slave
                                   SDA                    A7    A6 A5 A4 A3 A2                A1             ACK   D7 D6 D5 D4 D3 D2 D1                    D0          ACK       D7 D6 D5 D4 D3 D2 D1                       D0      ACK
                                                                                                                                                                                                                                                                  Bus master
                                                                                                                                                                                                                                  ACK is not sent                 terminates
                                                                                                                                                                                                                                                                  transfer
                                                          1     2     3     4    5        6   7     8   9           1    2     3    4    5    6     7      8          9          1     2    3    4     5     6     7    8            9
                                   SCL         S                                                                                                                                                                                                      P
                                                                                                                                                                               Data shifted in on falling edge of CLK        Set SSPIF at end
                                                                                                                                                                                                                             of receive                      Set SSPIF interrupt
                                                                                                                                     Set SSPIF interrupt                                                                                                     at end of Acknow-
                                                                                                                                                                                     Set SSPIF interrupt                                                     ledge sequence
                                                                                                                                     at end of receive
                                                                                                                                                                                     at end of Acknowledge
                                   SSPIF                                                                                                                                             sequence
                                                                                                                                                                                                                                                          Set P bit
                                                                    Cleared in software                            Cleared in software       Cleared in software                       Cleared in software                                                (SSPSTAT<4>)
                                   SDA = 0, SCL = 1                                                                                                                                                                                      Cleared in
Preliminary
                                   while CPU                                                                                                                                                                                             software         and SSPIF
                                   responds to SSPIF
                                   BF
                                   (SSPSTAT<0>)                                                                                                                   Last bit is shifted into SSPSR and
                                                                                                                                                                  contents are unloaded into SSPBUF
                                   SSPOV
                                                                                                                                                                                                                         SSPOV is set because
                                                                                                                                                                                                                         SSPBUF is still full
                                   ACKEN
                                                                                                                                                                                                                                                                                   I 2C MASTER MODE WAVEFORM (RECEPTION, 7-BIT ADDRESS)
DS30498B-page 125
                                                                                                                                                                                                                                                                                                                                          PIC16F7X7
PIC16F7X7
10.4.12     ACKNOWLEDGE SEQUENCE                                             10.4.13        STOP CONDITION TIMING
            TIMING                                                           A Stop bit is asserted on the SDA pin at the end of a
An Acknowledge sequence is enabled by setting the                            receive/transmit by setting the Stop Sequence Enable
Acknowledge Sequence Enable bit, ACKEN                                       bit, PEN (SSPCON2<2>). At the end of a receive/
(SSPCON2<4>). When this bit is set, the SCL pin is                           transmit, the SCL line is held low after the falling edge
pulled low and the contents of the Acknowledge data bit                      of the ninth clock. When the PEN bit is set, the master
are presented on the SDA pin. If the user wishes to gen-                     will assert the SDA line low. When the SDA line is sam-
erate an Acknowledge, then the ACKDT bit should be                           pled low, the Baud Rate Generator is reloaded and
cleared. If not, the user should set the ACKDT bit before                    counts down to ‘0’. When the Baud Rate Generator
starting an Acknowledge sequence. The Baud Rate                              times out, the SCL pin will be brought high and one
Generator then counts for one rollover period (TBRG)                         TBRG (Baud Rate Generator rollover count) later, the
and the SCL pin is deasserted (pulled high). When the                        SDA pin will be deasserted. When the SDA pin is sam-
SCL pin is sampled high (clock arbitration), the Baud                        pled high while SCL is high, the P bit (SSPSTAT<4>) is
Rate Generator counts for TBRG. The SCL pin is then                          set. A TBRG later, the PEN bit is cleared and the SSPIF
pulled low. Following this, the ACKEN bit is automatically                   bit is set (Figure 10-24).
cleared, the Baud Rate Generator is turned off and the
MSSP module then goes into Idle mode (Figure 10-23).                         10.4.13.1        WCOL Status Flag
                                                                             If the user writes the SSPBUF when a Stop sequence
10.4.12.1     WCOL Status Flag                                               is in progress, then the WCOL bit is set and the
If the user writes the SSPBUF when an Acknowledge                            contents of the buffer are unchanged (the write doesn’t
sequence is in progress, then WCOL is set and the                            occur).
contents of the buffer are unchanged (the write doesn’t
occur).
FIGURE 10-23:            ACKNOWLEDGE SEQUENCE WAVEFORM
                  Acknowledge sequence starts here,                                          ACKEN automatically cleared
                                write to SSPCON2
                           ACKEN = 1, ACKDT = 0
                                                                  TBRG          TBRG
                  SDA                        D0                           ACK
                  SCL                       8                                    9
                SSPIF
                                                                                                         Cleared in
                          Set SSPIF at the end                 Cleared in                                software
                          of receive                           software         Set SSPIF at the end
                                                                                of Acknowledge sequence
              Note: TBRG = one Baud Rate Generator period.
FIGURE 10-24:            STOP CONDITION RECEIVE OR TRANSMIT MODE
                     Write to SSPCON2,                                   SCL = 1 for TBRG, followed by SDA = 1 for TBRG
                                set PEN                                  after SDA sampled high. P bit (SSPSTAT<4>) is set.
                     Falling edge of                                                 PEN bit (SSPCON2<2>) is cleared by
                     9th clock                                                        hardware and the SSPIF bit is set
                                            TBRG
               SCL
               SDA          ACK
                                                                   P
                                            TBRG            TBRG       TBRG
                                                            SCL brought high after TBRG
                                                 SDA asserted low before rising edge of clock to setup Stop condition
             Note: TBRG = one Baud Rate Generator period.
DS30498B-page 126                                          Preliminary                                     2003 Microchip Technology Inc.
                                                                                               PIC16F7X7
10.4.14      SLEEP OPERATION                                       10.4.17     MULTI-MASTER COMMUNICATION,
                               2
While in Sleep mode, the I C module can receive                                BUS COLLISION AND BUS
addresses or data and when an address match or                                 ARBITRATION
complete byte transfer occurs, wake the processor                  Multi-Master mode support is achieved by bus arbitra-
from Sleep (if the MSSP interrupt is enabled).                     tion. When the master outputs address/data bits onto
                                                                   the SDA pin, arbitration takes place when the master
10.4.15      EFFECT OF A RESET                                     outputs a ‘1’ on SDA by letting SDA float high and
A Reset disables the MSSP module and terminates the                another master asserts a ‘0’. When the SCL pin floats
current transfer.                                                  high, data should be stable. If the expected data on
                                                                   SDA is a ‘1’ and the data sampled on the SDA pin = 0,
10.4.16      MULTI-MASTER MODE                                     then a bus collision has taken place. The master will set
In Multi-Master mode, the interrupt generation on the              the Bus Collision Interrupt Flag, BCLIF, and reset the
detection of the Start and Stop conditions allows the              I2C port to its Idle state (Figure 10-25).
determination of when the bus is free. The Stop (P) and            If a transmit was in progress when the bus collision
Start (S) bits are cleared from a Reset or when the                occurred, the transmission is halted, the BF flag is
MSSP module is disabled. Control of the I 2C bus may               cleared, the SDA and SCL lines are deasserted and the
be taken when the P bit (SSPSTAT<4>) is set or the                 SSPBUF can be written to. When the user services the
bus is Idle, with both the S and P bits clear. When the            bus collision Interrupt Service Routine and if the I2C
bus is busy, enabling the SSP interrupt will generate              bus is free, the user can resume communication by
the interrupt when the Stop condition occurs.                      asserting a Start condition.
In multi-master operation, the SDA line must be moni-              If a Start, Repeated Start, Stop or Acknowledge condi-
tored for arbitration to see if the signal level is at the         tion was in progress when the bus collision occurred,
expected output level. This check is performed in                  the condition is aborted, the SDA and SCL lines are
hardware with the result placed in the BCLIF bit.                  deasserted and the respective control bits in the
The states where arbitration can be lost are:                      SSPCON2 register are cleared. When the user
                                                                   services the bus collision Interrupt Service Routine and
•   Address Transfer                                               if the I2C bus is free, the user can resume
•   Data Transfer                                                  communication by asserting a Start condition.
•   A Start Condition                                              The master will continue to monitor the SDA and SCL
•   A Repeated Start Condition                                     pins. If a Stop condition occurs, the SSPIF bit will be set.
•   An Acknowledge Condition                                       A write to the SSPBUF will start the transmission of
                                                                   data at the first data bit, regardless of where the
                                                                   transmitter left off when the bus collision occurred.
                                                                   In Multi-Master mode, the interrupt generation on the
                                                                   detection of Start and Stop conditions allows the determi-
                                                                   nation of when the bus is free. Control of the I2C bus can
                                                                   be taken when the P bit is set in the SSPSTAT register or
                                                                   the bus is Idle and the S and P bits are cleared.
FIGURE 10-25:           BUS COLLISION TIMING FOR TRANSMIT AND ACKNOWLEDGE
                            Data changes              SDA line pulled low        Sample SDA. While SCL is high,
                            while SCL = 0             by another source          data doesn’t match what is driven
                                                                                 by the master. Bus collision has occurred.
                                                 SDA released
                                                   by master
     SDA
     SCL                                                                               Set bus collision
                                                                                       interrupt (BCLIF)
     BCLIF
 2003 Microchip Technology Inc.                      Preliminary                                          DS30498B-page 127
PIC16F7X7
10.4.17.1        Bus Collision During a Start                         If the SDA pin is sampled low during this count, the
                 Condition                                            BRG is reset and the SDA line is asserted early
                                                                      (Figure 10-28). If, however, a ‘1’ is sampled on the SDA
During a Start condition, a bus collision occurs if:
                                                                      pin, the SDA pin is asserted low at the end of the BRG
a)       SDA or SCL are sampled low at the beginning of               count. The Baud Rate Generator is then reloaded and
         the Start condition (Figure 10-26).                          counts down to 0 and during this time, if the SCL pin is
b)       SCL is sampled low before SDA is asserted low                sampled as ‘0’, a bus collision does not occur. At the
         (Figure 10-27).                                              end of the BRG count, the SCL pin is asserted low.
During a Start condition, both the SDA and the SCL                      Note:     The reason that bus collision is not a factor
pins are monitored.                                                               during a Start condition is that no two bus
If the SDA pin is already low, or the SCL pin is already                          masters can assert a Start condition at the
low, then all of the following occur:                                             exact same time. Therefore, one master
                                                                                  will always assert SDA before the other.
• the Start condition is aborted,
                                                                                  This condition does not cause a bus colli-
• the BCLIF flag is set and                                                       sion because the two masters must be
• the MSSP module is reset to its Idle state                                      allowed to arbitrate the first address fol-
    (Figure 10-26).                                                               lowing the Start condition. If the address is
The Start condition begins with the SDA and SCL pins                              the same, arbitration must be allowed to
deasserted. When the SDA pin is sampled high, the                                 continue into the data portion, Repeated
Baud Rate Generator is loaded from SSPADD<6:0>                                    Start or Stop conditions.
and counts down to 0. If the SCL pin is sampled low
while SDA is high, a bus collision occurs because it is
assumed that another master is attempting to drive a
data ‘1’ during the Start condition.
FIGURE 10-26:             BUS COLLISION DURING START CONDITION (SDA ONLY)
                                        SDA goes low before the SEN bit is set.
                                        Set BCLIF,
                                        S bit and SSPIF set because
                                        SDA = 0, SCL = 1.
     SDA
     SCL
                            Set SEN, enable Start                            SEN cleared automatically because of bus collision.
                            condition if SDA = 1, SCL = 1                    SSP module resets into Idle state.
     SEN
                                SDA sampled low before
                                Start condition. Set BCLIF.
                                S bit and SSPIF set because
     BCLIF                      SDA = 0, SCL = 1.
                                                                                      SSPIF and BCLIF are
                                                                                      cleared in software
     SSPIF
                                                                    SSPIF and BCLIF are
                                                                    cleared in software
DS30498B-page 128                                       Preliminary                              2003 Microchip Technology Inc.
                                                                                                         PIC16F7X7
FIGURE 10-27:             BUS COLLISION DURING START CONDITION (SCL = 0)
                                                   SDA = 0, SCL = 1
                                                             TBRG           TBRG
              SDA
              SCL               Set SEN, enable Start
                                sequence if SDA = 1, SCL = 1
                                                                                     SCL = 0 before SDA = 0,
                                                                                     bus collision occurs. Set BCLIF.
              SEN
                          SCL = 0 before BRG time-out,
                          bus collision occurs. Set BCLIF.
              BCLIF
                                                                                                Interrupt cleared
                                                                                                in software
              S           ‘0’                                                                      ‘0’
              SSPIF       ‘0’                                                                      ‘0’
FIGURE 10-28:             BRG RESET DUE TO SDA ARBITRATION DURING START CONDITION
                                              SDA = 0, SCL = 1
                                                                    Set S          Set SSPIF
                                  Less than TBRG
                                                                        TBRG
                  SDA     SDA pulled low by other master.
                          Reset BRG and assert SDA.
                  SCL                                           S
                                                                                      SCL pulled low after BRG
                                                                                      time-out
                  SEN
                                                             Set SEN, enable Start
                                                             sequence if SDA = 1, SCL = 1
                  BCLIF                                                                                  ‘0’
                  SSPIF
                                                             SDA = 0, SCL = 1,                     Interrupts cleared
                                                             set SSPIF                             in software
 2003 Microchip Technology Inc.                        Preliminary                                              DS30498B-page 129
PIC16F7X7
10.4.17.2      Bus Collision During a Repeated                  If SDA is low, a bus collision has occurred (i.e., another
               Start Condition                                  master is attempting to transmit a data ‘0’, see
                                                                Figure 10-29). If SDA is sampled high, the BRG is
During a Repeated Start condition, a bus collision
                                                                reloaded and begins counting. If SDA goes from high-
occurs if:
                                                                to-low before the BRG times out, no bus collision
a)   A low level is sampled on SDA when SCL goes                occurs because no two masters can assert SDA at
     from low level to high level.                              exactly the same time.
b)   SCL goes low before SDA is asserted low,                   If SCL goes from high-to-low before the BRG times out
     indicating that another master is attempting to            and SDA has not already been asserted, a bus collision
     transmit a data ‘1’.                                       occurs. In this case, another master is attempting to
When the user deasserts SDA and the pin is allowed to           transmit a data ‘1’ during the Repeated Start condition
float high, the BRG is loaded with SSPADD<6:0> and              (Figure 10-30).
counts down to 0. The SCL pin is then deasserted and            If at the end of the BRG time-out, both SCL and SDA are
when sampled high, the SDA pin is sampled.                      still high, the SDA pin is driven low and the BRG is
                                                                reloaded and begins counting. At the end of the count,
                                                                regardless of the status of the SCL pin, the SCL pin is
                                                                driven low and the Repeated Start condition is complete.
FIGURE 10-29:         BUS COLLISION DURING A REPEATED START CONDITION (CASE 1)
          SDA
          SCL
                                                               Sample SDA when SCL goes high.
                                                               If SDA = 0, set BCLIF and release SDA and SCL.
          RSEN
          BCLIF
                                                                                        Cleared in software
          S                                                                                        ‘0’
          SSPIF                                                                                   ‘0’
FIGURE 10-30:         BUS COLLISION DURING A REPEATED START CONDITION (CASE 2)
                                                        TBRG                            TBRG
         SDA
         SCL
                                 SCL goes low before SDA,
         BCLIF                   set BCLIF. Release SDA and SCL.
                                                                                                Interrupt cleared
                                                                                                in software
         RSEN
         S                                                                                               ‘0’
         SSPIF
DS30498B-page 130                                 Preliminary                             2003 Microchip Technology Inc.
                                                                                         PIC16F7X7
10.4.17.3     Bus Collision During a Stop                      The Stop condition begins with SDA asserted low.
              Condition                                        When SDA is sampled low, the SCL pin is allowed to
                                                               float. When the pin is sampled high (clock arbitration),
Bus collision occurs during a Stop condition if:
                                                               the Baud Rate Generator is loaded with SSPADD<6:0>
a)   After the SDA pin has been deasserted and                 and counts down to 0. After the BRG times out, SDA is
     allowed to float high, SDA is sampled low after           sampled. If SDA is sampled low, a bus collision has
     the BRG has timed out.                                    occurred. This is due to another master attempting to
b)   After the SCL pin is deasserted, SCL is sampled           drive a data ‘0’ (Figure 10-31). If the SCL pin is
     low before SDA goes high.                                 sampled low before SDA is allowed to float high, a bus
                                                               collision occurs. This is another case of another master
                                                               attempting to drive a data ‘0’ (Figure 10-32).
FIGURE 10-31:          BUS COLLISION DURING A STOP CONDITION (CASE 1)
                                           TBRG            TBRG                 TBRG                    SDA sampled
                                                                                                        low after TBRG,
                                                                                                        set BCLIF
             SDA
                                     SDA asserted low
             SCL
             PEN
           BCLIF
               P                                                                                        ‘0’
           SSPIF                                                                                        ‘0’
FIGURE 10-32:           BUS COLLISION DURING A STOP CONDITION (CASE 2)
                                       TBRG             TBRG                TBRG
     SDA
                                   Assert SDA                            SCL goes low before SDA goes high,
                                                                         set BCLIF
     SCL
     PEN
     BCLIF
     P                                                                                            ‘0’
     SSPIF                                                                                        ‘0’
 2003 Microchip Technology Inc.                    Preliminary                                    DS30498B-page 131
PIC16F7X7
NOTES:
DS30498B-page 132   Preliminary    2003 Microchip Technology Inc.
                                                                                              PIC16F7X7
11.0     ADDRESSABLE UNIVERSAL                                    The USART can be configured in the following modes:
         SYNCHRONOUS                                              • Asynchronous (full-duplex)
         ASYNCHRONOUS RECEIVER                                    • Synchronous – Master (half-duplex)
         TRANSMITTER (USART)                                      • Synchronous – Slave (half-duplex)
                                                                  Bit SPEN (RCSTA<7>) and bits TRISC<7:6> have
The Universal Synchronous Asynchronous Receiver
                                                                  to be set in order to configure pins RC6/TX/CK and
Transmitter (USART) module is one of the two serial
                                                                  RC7/RX/DT      as    the    Universal  Synchronous
I/O modules. (USART is also known as a Serial
                                                                  Asynchronous Receiver Transmitter.
Communications Interface or SCI.) The USART can be
configured as a full-duplex asynchronous system that              The USART module also has a multi-processor
can communicate with peripheral devices, such as                  communication capability using 9-bit address detection.
CRT terminals and personal computers, or it can be
configured as a half-duplex synchronous system that
can communicate with peripheral devices, such as A/D
or D/A integrated circuits, serial EEPROMs, etc.
REGISTER 11-1:         TXSTA: TRANSMIT STATUS AND CONTROL REGISTER (ADDRESS 98h)
                           R/W-0       R/W-0       R/W-0        R/W-0          U-0         R/W-0      R-1        R/W-0
                           CSRC         TX9         TXEN        SYNC            —          BRGH      TRMT        TX9D
                        bit 7                                                                                       bit 0
           bit 7        CSRC: Clock Source Select bit
                        Asynchronous mode:
                        Don’t care.
                        Synchronous mode:
                        1 = Master mode (clock generated internally from BRG)
                        0 = Slave mode (clock from external source)
           bit 6        TX9: 9-bit Transmit Enable bit
                        1 = Selects 9-bit transmission
                        0 = Selects 8-bit transmission
           bit 5        TXEN: Transmit Enable bit
                        1 = Transmit enabled
                        0 = Transmit disabled
                          Note:     SREN/CREN overrides TXEN in Sync mode.
           bit 4        SYNC: USART Mode Select bit
                        1 = Synchronous mode
                        0 = Asynchronous mode
           bit 3        Unimplemented: Read as ‘0’
           bit 2        BRGH: High Baud Rate Select bit
                        Asynchronous mode:
                        1 = High speed
                        0 = Low speed
                        Synchronous mode:
                        Unused in this mode.
           bit 1        TRMT: Transmit Shift Register Status bit
                        1 = TSR empty
                        0 = TSR full
           bit 0        TX9D: 9th bit of Transmit Data, can be Parity bit
                        Legend:
                        R = Readable bit            W = Writable bit        U = Unimplemented bit, read as ‘0’
                        - n = Value at POR          ‘1’ = Bit is set        ‘0’ = Bit is cleared   x = Bit is unknown
 2003 Microchip Technology Inc.                   Preliminary                                        DS30498B-page 133
PIC16F7X7
REGISTER 11-2:      RCSTA: RECEIVE STATUS AND CONTROL REGISTER (ADDRESS 18h)
                      R/W-0       R/W-0        R/W-0        R/W-0      R/W-0         R-0         R-0         R-x
                      SPEN         RX9         SREN         CREN       ADDEN        FERR       OERR         RX9D
                    bit 7                                                                                       bit 0
          bit 7     SPEN: Serial Port Enable bit
                    1 = Serial port enabled (configures RC7/RX/DT and RC6/TX/CK pins as serial port pins)
                    0 = Serial port disabled
          bit 6     RX9: 9-bit Receive Enable bit
                    1 = Selects 9-bit reception
                    0 = Selects 8-bit reception
          bit 5     SREN: Single Receive Enable bit
                    Asynchronous mode:
                    Don’t care.
                    Synchronous mode – Master:
                    1 = Enables single receive
                    0 = Disables single receive
                    This bit is cleared after reception is complete.
                    Synchronous mode – Slave:
                    Don’t care.
          bit 4     CREN: Continuous Receive Enable bit
                    Asynchronous mode:
                    1 = Enables continuous receive
                    0 = Disables continuous receive
                    Synchronous mode:
                    1 = Enables continuous receive until enable bit CREN is cleared (CREN overrides SREN)
                    0 = Disables continuous receive
          bit 3     ADDEN: Address Detect Enable bit
                    Asynchronous mode 9-bit (RX9 = 1):
                    1 = Enables address detection, enables interrupt and load of the receive buffer when
                        RSR<8> is set
                    0 = Disables address detection, all bytes are received and ninth bit can be used as parity bit
          bit 2     FERR: Framing Error bit
                    1 = Framing error (can be updated by reading RCREG register and receiving next valid byte)
                    0 = No framing error
          bit 1     OERR: Overrun Error bit
                    1 = Overrun error (can be cleared by clearing bit CREN)
                    0 = No overrun error
          bit 0     RX9D: 9th bit of Received Data (can be parity bit, but must be calculated by user firmware)
                    Legend:
                    R = Readable bit             W = Writable bit      U = Unimplemented bit, read as ‘0’
                    - n = Value at POR           ‘1’ = Bit is set      ‘0’ = Bit is cleared   x = Bit is unknown
DS30498B-page 134                               Preliminary                            2003 Microchip Technology Inc.
                                                                                                 PIC16F7X7
11.1       USART Baud Rate Generator                                  It may be advantageous to use the high baud rate
           (BRG)                                                      (BRGH = 1), even for slower baud clocks. This is
                                                                      because the FOSC/(16(X + 1)) equation can reduce the
The BRG supports both the Asynchronous and Syn-                       baud rate error in some cases.
chronous modes of the USART. It is a dedicated 8-bit
                                                                      Writing a new value to the SPBRG register causes the
Baud Rate Generator. The SPBRG register controls
                                                                      BRG timer to be reset (or cleared). This ensures the
the period of a free-running 8-bit timer. In Asynchro-
                                                                      BRG does not wait for a timer overflow before
nous mode, bit BRGH (TXSTA<2>) also controls the
                                                                      outputting the new baud rate.
baud rate. In Synchronous mode, bit BRGH is ignored.
Table 11-1 shows the formula for computation of the                   11.1.1       SAMPLING
baud rate for different USART modes, which only apply
in Master mode (internal clock).                                      The data on the RC7/RX/DT pin is sampled three times
                                                                      by a majority detect circuit to determine if a high or a
Given the desired baud rate and FOSC, the nearest                     low level is present at the RX pin.
integer value for the SPBRG register can be calculated
using the formula in Table 11-1. From this, the error in
baud rate can be determined.
TABLE 11-1:       BAUD RATE FORMULA
   SYNC                      BRGH = 0 (Low Speed)                                     BRGH = 1 (High Speed)
       0         (Asynchronous) Baud Rate = FOSC/(64(X + 1))                        Baud Rate = FOSC/(16(X + 1))
       1          (Synchronous) Baud Rate = FOSC/(4(X + 1))                                     N/A
X = value in SPBRG (0 to 255)
TABLE 11-2:       REGISTERS ASSOCIATED WITH BAUD RATE GENERATOR
                                                                                                                   Value on
                                                                                                    Value on:
 Address      Name       Bit 7     Bit 6   Bit 5    Bit 4     Bit 3        Bit 2    Bit 1   Bit 0                  all other
                                                                                                    POR, BOR
                                                                                                                    Resets
98h          TXSTA      CSRC       TX9     TXEN    SYNC        —          BRGH     TRMT     TX9D    0000 -010     0000 -010
18h          RCSTA      SPEN       RX9     SREN    CREN     ADDEN         FERR     OERR     RX9D    0000 000x     0000 000x
99h          SPBRG     Baud Rate Generator Register                                                 0000 0000     0000 0000
Legend:     x = unknown, - = unimplemented, read as ‘0’. Shaded cells are not used by the BRG.
 2003 Microchip Technology Inc.                      Preliminary                                         DS30498B-page 135
PIC16F7X7
TABLE 11-3:         BAUD RATES FOR ASYNCHRONOUS MODE (BRGH = 0)
                  FOSC = 20 MHz                      FOSC = 16 MHz                       FOSC = 10 MHz
 BAUD
 RATE                           SPBRG                              SPBRG                               SPBRG
                      %                                  %                                  %
  (K)                            value                              value                               value
        KBAUD       ERROR                  KBAUD       ERROR                  KBAUD       ERROR
                               (decimal)                          (decimal)                           (decimal)
  0.3      -           -           -          -           -            -         -            -           -
  1.2    1.221        1.75        255       1.202        0.17        207       1.202        0.17         129
  2.4    2.404        0.17        129       2.404        0.17        103       2.404        0.17         64
  9.6    9.766        1.73        31        9.615        0.16          25      9.766        1.73         15
 19.2   19.531        1.72        15       19.231        0.16          12     19.531        1.72          7
 28.8   31.250        8.51        9        27.778        3.55          8      31.250        8.51          4
 33.6   34.722        3.34        8        35.714        6.29          6      31.250        6.99          4
 57.6   62.500        8.51        4        62.500        8.51          3      52.083        9.58          2
 HIGH    1.221         -          255       0.977         -          255       0.610          -          255
 LOW    312.500        -          0        250.000        -            0      156.250         -           0
                   FOSC = 4 MHz                    FOSC = 3.6864 MHz
 BAUD
 RATE                           SPBRG                              SPBRG
                      %                                  %
  (K)                            value                              value
        KBAUD       ERROR                  KBAUD       ERROR
                               (decimal)                          (decimal)
  0.3    0.300         0          207        0.3          0          191
  1.2    1.202        0.17        51         1.2          0            47
  2.4    2.404        0.17        25         2.4          0            23
  9.6    8.929        6.99         6         9.6          0            5
 19.2   20.833        8.51         2        19.2          0            2
 28.8   31.250        8.51         1        28.8          0            1
 33.6      -           -           -          -           -            -
 57.6   62.500        8.51         0        57.6          0            0
 HIGH    0.244         -          255       0.225         -          255
 LOW    62.500         -           0        57.6          -            0
TABLE 11-4:         BAUD RATES FOR ASYNCHRONOUS MODE (BRGH = 1)
                  FOSC = 20 MHz                      FOSC = 16 MHz                       FOSC = 10 MHz
 BAUD
 RATE                           SPBRG                              SPBRG                               SPBRG
                       %                                 %                                    %
  (K)                            value                              value                               value
        KBAUD        ERROR                 KBAUD       ERROR                  KBAUD         ERROR
                               (decimal)                          (decimal)                           (decimal)
  0.3      -            -          -          -            -            -            -            -           -
  1.2      -            -          -          -            -            -            -            -           -
  2.4      -            -          -          -            -            -      2.441         1.71        255
  9.6    9.615        0.16        129       9.615        0.16          103     9.615         0.16         64
 19.2    19.231       0.16        64        19.231       0.16          51      19.531        1.72         31
 28.8    29.070       0.94        42        29.412       2.13          33      28.409        1.36         21
 33.6    33.784       0.55        36        33.333       0.79          29      32.895        2.10         18
 57.6    59.524       3.34        20        58.824       2.13          16      56.818        1.36         10
 HIGH    4.883          -         255       3.906          -           255     2.441              -      255
 LOW    1250.000        -          0       1000.000                     0     625.000             -       0
                   FOSC = 4 MHz                    FOSC = 3.6864 MHz
 BAUD
 RATE                           SPBRG                              SPBRG
                       %                                 %
  (K)                            value                              value
        KBAUD        ERROR                 KBAUD       ERROR
                               (decimal)                          (decimal)
  0.3      -               -       -          -            -           -
  1.2    1.202        0.17        207        1.2          0          191
  2.4    2.404        0.17        103        2.4          0            95
  9.6    9.615        0.16        25         9.6          0            23
 19.2    19.231       0.16        12        19.2          0            11
 28.8    27.798       3.55         8        28.8          0            7
 33.6    35.714       6.29         6        32.9         2.04          6
 57.6    62.500       8.51         3        57.6          0            3
 HIGH    0.977             -      255        0.9           -         255
 LOW    250.000            -       0        230.4          -           0
DS30498B-page 136                                              Preliminary                                 2003 Microchip Technology Inc.
                                                                                                         PIC16F7X7
TABLE 11-5:         INTRC BAUD RATES FOR ASYNCHRONOUS MODE (BRGH = 0)
                  FOSC = 8 MHz                    FOSC = 4 MHz                      FOSC = 2 MHz                   FOSC = 1 MHz
 BAUD
 RATE                         SPBRG                             SPBRG                          SPBRG                          SPBRG
                     %                               %                                 %                              %
  (K)                          value                             value                          value                          value
         KBAUD     ERROR                 KBAUD     ERROR                   KBAUD     ERROR                KBAUD     ERROR
                             (decimal)                         (decimal)                      (decimal)                      (decimal)
  0.3      NA         —          —       0.300        0          207       0.300        0          103    0.300        0          51
  1.2     1.202     +0.16        103     1.202      +0.16         51       1.202      +0.16        25     1.202      +0.16        12
  2.4     2.404     +0.16        51      2.404      +0.16         25       2.404      +0.16        12     2.232      -6.99        6
  9.6     9.615     +0.16        12      8.929       -6.99        6        10.417     +8.51        2       NA         —           —
  19.2   17.857      -6.99        6      20.833     +8.51         2         NA         —           —       NA         —           —
  28.8   31.250     +8.51         3      31.250     +8.51         1        31.250     +8.51         0      NA         —           —
  38.4   41.667     +8.51         2       NA          —           —         NA         —           —       NA         —           —
  57.6   62.500     +8.51         1      62.500      8.51         0         NA         —           —       NA         —           —
TABLE 11-6:         INTRC BAUD RATES FOR ASYNCHRONOUS MODE (BRGH = 1)
                  FOSC = 8 MHz                    FOSC = 4 MHz                      FOSC = 2 MHz                   FOSC = 1 MHz
 BAUD
 RATE                         SPBRG                             SPBRG                          SPBRG                          SPBRG
                     %                               %                                 %                              %
  (K)                          value                             value                          value                          value
         KBAUD     ERROR                 KBAUD     ERROR                   KBAUD     ERROR                KBAUD     ERROR
                             (decimal)                         (decimal)                      (decimal)                      (decimal)
  0.3      NA         —          —        NA          —           —         NA         —           —      0.300        0          207
  1.2      NA         —          —       1.202      +0.16        207       1.202      +0.16        103    1.202      +0.16        51
  2.4     2.404     +0.16        207     2.404      +0.16        103       2.404      +0.16        51     2.404      +0.16        25
  9.6     9.615     +0.16        51      9.615      +0.16         25       9.615      +0.16        12     8.929      -6.99        6
  19.2   19.231     +0.16        25      19.231     +0.16         12       17.857     -6.99         6     20.833     +8.51        2
  28.8   29.412     +2.12        16      27.778      -3.55        8        31.250     +8.51         3     31.250     +8.51        1
  38.4   38.462     +0.16        12      35.714      -6.99        6        41.667     +8.51         2      NA         —           —
  57.6   55.556      -3.55        8      62.500     +8.51         3        62.500     +8.51         1     62.500     +8.51        0
 2003 Microchip Technology Inc.                             Preliminary                                           DS30498B-page 137
PIC16F7X7
11.2      USART Asynchronous Mode                                   rupt can be enabled/disabled by setting/clearing
                                                                    enable bit, TXIE (PIE1<4>). Flag bit TXIF will be set
In this mode, the USART uses standard Non-Return-                   regardless of the state of enable bit TXIE and cannot be
to-Zero (NRZ) format (one Start bit, eight or nine data             cleared in software. It will reset only when new data is
bits and one Stop bit). The most common data format                 loaded into the TXREG register. While flag bit TXIF
is 8-bits. An on-chip, dedicated, 8-bit Baud Rate Gen-              indicates the status of the TXREG register, another bit,
erator can be used to derive standard baud rate fre-                TRMT (TXSTA<1>), shows the status of the TSR reg-
quencies from the oscillator. The USART transmits and               ister. Status bit TRMT is a read-only bit which is set
receives the LSb first. The transmitter and receiver are            when the TSR register is empty. No interrupt logic is
functionally independent but use the same data format               tied to this bit, so the user has to poll this bit in order to
and baud rate. The Baud Rate Generator produces a                   determine if the TSR register is empty.
clock, either x16 or x64 of the bit shift rate, depending
on bit BRGH (TXSTA<2>). Parity is not supported by                       Note 1: The TSR register is not mapped in data
the hardware but can be implemented in software (and                             memory so it is not available to the user.
stored as the ninth data bit). Asynchronous mode is                           2: Flag bit TXIF is set when enable bit TXEN
stopped during Sleep.                                                            is set. TXIF is cleared by loading TXREG.
Asynchronous mode is selected by clearing bit, SYNC                 Transmission is enabled by setting enable bit, TXEN
(TXSTA<4>).                                                         (TXSTA<5>). The actual transmission will not occur
The USART asynchronous module consists of the                       until the TXREG register has been loaded with data
following important elements:                                       and the Baud Rate Generator (BRG) has produced a
                                                                    shift clock (Figure 11-2). The transmission can also be
•   Baud Rate Generator
                                                                    started by first loading the TXREG register and then
•   Sampling Circuit                                                setting enable bit TXEN. Normally, when transmission
•   Asynchronous Transmitter                                        is first started, the TSR register is empty. At that point,
•   Asynchronous Receiver                                           transfer to the TXREG register will result in an immedi-
                                                                    ate transfer to TSR, resulting in an empty TXREG. A
11.2.1      USART ASYNCHRONOUS                                      back-to-back transfer is thus possible (Figure 11-3).
            TRANSMITTER                                             Clearing enable bit TXEN during a transmission will
                                                                    cause the transmission to be aborted and will reset the
The USART transmitter block diagram is shown in
                                                                    transmitter. As a result, the RC6/TX/CK pin will revert
Figure 11-1. The heart of the transmitter is the Transmit
                                                                    to high-impedance.
(Serial) Shift Register (TSR). The Shift register obtains
its data from the Read/Write Transmit Buffer register,              In order to select 9-bit transmission, transmit bit TX9
TXREG. The TXREG register is loaded with data in                    (TXSTA<6>) should be set and the ninth bit should be
software. The TSR register is not loaded until the Stop             written to TX9D (TXSTA<0>). The ninth bit must be
bit has been transmitted from the previous load. As                 written before writing the 8-bit data to the TXREG
soon as the Stop bit is transmitted, the TSR is loaded              register. This is because a data write to the TXREG
with new data from the TXREG register (if available).               register can result in an immediate transfer of the data
Once the TXREG register transfers the data to the TSR               to the TSR register (if the TSR is empty). In such a
register (occurs in one TCY), the TXREG register is                 case, an incorrect ninth data bit may be loaded in the
empty and flag bit, TXIF (PIR1<4>), is set. This inter-             TSR register.
FIGURE 11-1:               USART TRANSMIT BLOCK DIAGRAM
                                                              Data Bus
                       TXIF                        TXREG Register
              TXIE
                                                             8
                                          MSb                              LSb
                                          (8)             • • •             0            Pin Buffer
                                                                                        and Control
                                                    TSR Register                                      RC6/TX/CK pin
               Interrupt
                           TXEN    Baud Rate CLK
                                                                                 TRMT        SPEN
                                  SPBRG
                           Baud Rate Generator       TX9
                                                   TX9D
DS30498B-page 138                                    Preliminary                                2003 Microchip Technology Inc.
                                                                                                                 PIC16F7X7
When setting up an Asynchronous Transmission,                                  5.    Enable the transmission by setting bit TXEN,
follow these steps:                                                                  which will also set bit TXIF.
1.     Initialize the SPBRG register for the appropriate                       6.    If 9-bit transmission is selected, the ninth bit
       baud rate. If a high-speed baud rate is desired,                              should be loaded in bit TX9D.
       set bit BRGH (Section 11.1 “USART Baud                                  7.    Load data to the TXREG register (starts
       Rate Generator (BRG)”).                                                       transmission).
2.     Enable the asynchronous serial port by clearing                         8.    If using interrupts, ensure that GIE and PEIE
       bit SYNC and setting bit SPEN.                                                (bits 7 and 6) of the INTCON register are set.
3.     If interrupts are desired, then set enable bit TXIE.
4.     If 9-bit transmission is desired, then set transmit
       bit TX9.
FIGURE 11-2:                  ASYNCHRONOUS MASTER TRANSMISSION
      Write to TXREG
                                   Word 1
      BRG Output
      (Shift Clock)
      RC6/TX/CK (pin)
                                               Start bit       bit 0        bit 1                      bit 7/8     Stop bit
                                                                             Word 1
      TXIF bit
      (Transmit Buffer
      Reg. Empty Flag)
      TRMT bit                    Word 1
                                  Transmit Shift Reg
      (Transmit Shift
      Reg. Empty Flag)
FIGURE 11-3:                  ASYNCHRONOUS MASTER TRANSMISSION (BACK TO BACK)
     Write to TXREG
                                      Word 1       Word 2
     BRG Output
     (Shift Clock)
     RC6/TX/CK (pin)
                                               Start bit      bit 0     bit 1                    bit 7/8     Stop bit    Start bit     bit 0
     TXIF bit                                                            Word 1                                               Word 2
     (Interrupt Reg. Flag)
     TRMT bit                    Word 1                                                              Word 2
     (Transmit Shift             Transmit Shift Reg.                                                 Transmit Shift Reg.
     Reg. Empty Flag)
     Note:      This timing diagram shows two consecutive transmissions.
TABLE 11-7:             REGISTERS ASSOCIATED WITH ASYNCHRONOUS TRANSMISSION
                                                                                                                                   Value on
                                                                                                                    Value on:
 Address         Name          Bit 7       Bit 6      Bit 5    Bit 4   Bit 3        Bit 2    Bit 1         Bit 0                   all other
                                                                                                                    POR, BOR
                                                                                                                                    Resets
0Bh, 8Bh, INTCON                GIE       PEIE      TMR0IE     INTE    RBIE     TMR0IF       INTF          R0IF     0000 000x     0000 000u
10Bh,18Bh
0Ch             PIR1          PSPIF(1)    ADIF        RCIF     TXIF    SSPIF    CCP1IF      TMR2IF      TMR1IF      0000 0000     0000 0000
18h             RCSTA          SPEN        RX9       SREN     CREN      —           FERR    OERR         RX9D       0000 -00x     0000 -00x
19h             TXREG        USART Transmit Register                                                                0000 0000     0000 0000
8Ch             PIE1         PSPIE(1)     ADIE        RCIE     TXIE    SSPIE CCP1IE         TMR2IE      TMR1IE      0000 0000     0000 0000
98h             TXSTA          CSRC        TX9        TXEN    SYNC      —           BRGH    TRMT         TX9D       0000 -010     0000 -010
99h             SPBRG Baud Rate Generator Register                                                                  0000 0000     0000 0000
Legend:        x = unknown, - = unimplemented locations read as ‘0’. Shaded cells are not used for asynchronous transmission.
Note 1:        Bits PSPIE and PSPIF are reserved on 28-pin devices; always maintain these bits clear.
 2003 Microchip Technology Inc.                                Preliminary                                                DS30498B-page 139
PIC16F7X7
11.2.2          USART ASYNCHRONOUS                                                is possible for two bytes of data to be received and
                RECEIVER                                                          transferred to the RCREG FIFO and a third byte to
                                                                                  begin shifting to the RSR register. On the detection of
The receiver block diagram is shown in Figure 11-4.
                                                                                  the Stop bit of the third byte, if the RCREG register is
The data is received on the RC7/RX/DT pin and drives
                                                                                  still full, the Overrun Error bit, OERR (RCSTA<1>), will
the data recovery block. The data recovery block is
                                                                                  be set. The word in the RSR will be lost. The RCREG
actually a high-speed shifter, operating at x16 times the
                                                                                  register can be read twice to retrieve the two bytes in
baud rate; whereas, the main receive serial shifter
                                                                                  the FIFO. Overrun bit OERR has to be cleared in soft-
operates at the bit rate or at FOSC.
                                                                                  ware. This is done by resetting the receive logic (CREN
Once Asynchronous mode is selected, reception is                                  is cleared and then set). If bit OERR is set, transfers
enabled by setting bit, CREN (RCSTA<4>).                                          from the RSR register to the RCREG register are inhib-
The heart of the receiver is the Receive (Serial) Shift                           ited and no further data will be received. It is, therefore,
Register (RSR). After sampling the Stop bit, the                                  essential to clear error bit OERR if it is set. Framing
received data in the RSR is transferred to the RCREG                              Error bit, FERR (RCSTA<2>), is set if a Stop bit is
register (if it is empty). If the transfer is complete, flag                      detected as clear. Bit FERR and the 9th receive bit are
bit, RCIF (PIR1<5>), is set. The actual interrupt can be                          buffered the same way as the receive data. Reading
enabled/disabled by setting/clearing enable bit, RCIE                             the RCREG will load bits RX9D and FERR with new
(PIE1<5>). Flag bit RCIF is a read-only bit which is                              values, therefore, it is essential for the user to read the
cleared by the hardware. It is cleared when the RCREG                             RCSTA register before reading the RCREG register, in
register has been read and is empty. The RCREG is a                               order not to lose the old FERR and RX9D information.
double-buffered register (i.e., it is a two-deep FIFO). It
FIGURE 11-4:                 USART RECEIVE BLOCK DIAGRAM
                             x64 Baud Rate CLK
                                                                        CREN                            OERR                      FERR
                FOSC
                                   SPBRG
                                                                ÷64                       MSb                   RSR Register             LSb
                                                                 or
                            Baud Rate Generator                 ÷16                       Stop    (8)      7      • • •       1    0 Start
                                   Pin Buffer                  Data
                                  and Control                Recovery                    RX9
                RC7/RX/DT
                                     SPEN                                                        RX9D          RCREG Register
                                                                                                                                         FIFO
                                                                                  RCIF                                8
                                                               Interrupt
                                                                                   RCIE                                   Data Bus
FIGURE 11-5:                 ASYNCHRONOUS RECEPTION
                             Start                                       Start                                        Start
     RX (pin)                bit                                                                                       bit
                                   bit 0   bit 1         bit 7/8 Stop     bit    bit 0           bit 7/8       Stop                   bit 7/8 Stop
                                                                  bit                                           bit                             bit
     Rcv Shift
     Reg
     Rcv Buffer Reg
                                                                        Word 1                    Word 2
                                                                        RCREG                     RCREG
     Read Rcv
     Buffer Reg
     RCREG
     RCIF
     (Interrupt Flag)
     OERR bit
     CREN
     Note:      This timing diagram shows three words appearing on the RX input. The RCREG (receive buffer) is read after the third word,
                causing the OERR (overrun) bit to be set.
DS30498B-page 140                                               Preliminary                                            2003 Microchip Technology Inc.
                                                                                                     PIC16F7X7
When setting up an Asynchronous Reception, follow                      6.  Flag bit RCIF will be set when reception is
these steps:                                                               complete and an interrupt will be generated if
1.    Initialize the SPBRG register for the appropriate                    enable bit RCIE is set.
      baud rate. If a high-speed baud rate is desired,                 7. Read the RCSTA register to get the ninth bit (if
      set bit BRGH (Section 11.1 “USART Baud                               enabled) and determine if any error occurred
      Rate Generator (BRG)”).                                              during reception.
2.    Enable the asynchronous serial port by clearing                  8. Read the 8-bit received data by reading the
      bit SYNC and setting bit SPEN.                                       RCREG register.
3.    If interrupts are desired, then set enable bit                   9. If any error occurred, clear the error by clearing
      RCIE.                                                                enable bit CREN.
4.    If 9-bit reception is desired, then set bit RX9.                 10. If using interrupts, ensure that GIE and PEIE
5.    Enable the reception by setting bit CREN.                            (bits 7 and 6) of the INTCON register are set.
TABLE 11-8:          REGISTERS ASSOCIATED WITH ASYNCHRONOUS RECEPTION
                                                                                                                      Value on
                                                                                                      Value on:
 Address      Name       Bit 7     Bit 6     Bit 5     Bit 4   Bit 3        Bit 2   Bit 1    Bit 0                    all other
                                                                                                      POR, BOR
                                                                                                                       Resets
0Bh, 8Bh, INTCON         GIE       PEIE     TMR0IE    INTE     RBIE     TMR0IF      INTF     R0IF     0000 000x     0000 000u
10Bh,18Bh
0Ch          PIR1      PSPIF(1)    ADIF      RCIF      TXIF    SSPIF    CCP1IF TMR2IF TMR1IF          0000 0000     0000 0000
18h          RCSTA      SPEN       RX9       SREN     CREN       —          FERR    OERR    RX9D      0000 -00x     0000 -00x
1Ah          RCREG USART Receive Register                                                             0000 0000     0000 0000
8Ch          PIE1      PSPIE(1)    ADIE      RCIE      TXIE    SSPIE CCP1IE TMR2IE TMR1IE             0000 0000     0000 0000
98h          TXSTA      CSRC       TX9       TXEN     SYNC       —          BRGH    TRMT    TX9D      0000 -010     0000 -010
99h          SPBRG     Baud Rate Generator Register                                                   0000 0000     0000 0000
Legend:      x = unknown, - = unimplemented locations read as ‘0’. Shaded cells are not used for asynchronous reception.
Note 1:      Bits PSPIE and PSPIF are reserved on 28-pin devices; always maintain these bits clear.
 2003 Microchip Technology Inc.                        Preliminary                                         DS30498B-page 141
PIC16F7X7
11.2.3      SETTING UP 9-BIT MODE WITH                              • Flag bit RCIF will be set when reception is
            ADDRESS DETECT                                            complete and an interrupt will be generated if
                                                                      enable bit RCIE was set.
When setting up an Asynchronous Reception with
address detect enabled:                                             • Read the RCSTA register to get the ninth bit and
                                                                      determine if any error occurred during reception.
• Initialize the SPBRG register for the appropriate
                                                                    • Read the 8-bit received data by reading the
  baud rate. If a high-speed baud rate is desired,
                                                                      RCREG register to determine if the device is
  set bit BRGH.
                                                                      being addressed.
• Enable the asynchronous serial port by clearing
                                                                    • If any error occurred, clear the error by clearing
  bit SYNC and setting bit SPEN.
                                                                      enable bit CREN.
• If interrupts are desired, then set enable bit RCIE.
                                                                    • If the device has been addressed, clear the
• Set bit RX9 to enable 9-bit reception.                              ADDEN bit to allow data bytes and address bytes
• Set ADDEN to enable address detect.                                 to be read into the receive buffer and interrupt the
• Enable the reception by setting enable bit CREN.                    CPU.
FIGURE 11-6:            USART RECEIVE BLOCK DIAGRAM
                       x64 Baud Rate CLK
                                                                                         OERR                     FERR
                                                         CREN
          FOSC
                            SPBRG
                                                  ÷ 64                      MSb               RSR Register               LSb
                                                   or
                       Baud Rate Generator        ÷ 16                    Stop     (8)    7      • • •        1    0 Start
                             Pin Buffer           Data
                            and Control         Recovery              RX9
           RC7/RX/DT
                                                                                                          8
                              SPEN
                                 RX9                            Enable
                               ADDEN                            Load of
                                 RX9                            Receive
                                                                Buffer
                              ADDEN
                              RSR<8>                                                                      8
                                                                                 RX9D           RCREG Register
                                                                                                                          FIFO
                                                 Interrupt         RCIF
                                                                                                       Data Bus
                                                                    RCIE
DS30498B-page 142                                    Preliminary                                          2003 Microchip Technology Inc.
                                                                                                                      PIC16F7X7
FIGURE 11-7:              ASYNCHRONOUS RECEPTION WITH ADDRESS DETECT
   RC7/RX/DT (pin)          Start                                              Start
                             bit    bit 0     bit 1            bit 8    Stop    bit    bit 0           bit 8   Stop
                                                                         bit                                    bit
         Load RSR
                                             bit 8 = 0, Data Byte                   bit 8 = 1, Address Byte       Word 1
                                                                                                                  RCREG
              Read
              RCIF
    Note:      This timing diagram shows a data byte followed by an address byte. The data byte is not read into the RCREG (receive buffer)
               because ADDEN = 1.
FIGURE 11-8:              ASYNCHRONOUS RECEPTION WITH ADDRESS BYTE FIRST
   RC7/RX/DT (pin)          Start                                              Start
                             bit bit 0       bit 1             bit 8    Stop    bit    bit 0           bit 8   Stop
                                                                         bit                                    bit
         Load RSR
                                        bit 8 = 1, Address Byte                     bit 8 = 0, Data Byte          Word 1
                                                                                                                  RCREG
              Read
              RCIF
      Note:     This timing diagram shows a data byte followed by an address byte. The data byte is not read into the RCREG (receive buffer)
                because ADDEN was not updated and still = 0.
TABLE 11-9:          REGISTERS ASSOCIATED WITH ASYNCHRONOUS RECEPTION
                                                                                                                                        Value on
                                                                                                                           Value on:
 Address        Name        Bit 7           Bit 6      Bit 5        Bit 4      Bit 3       Bit 2       Bit 1      Bit 0                 all other
                                                                                                                           POR, BOR
                                                                                                                                         Resets
0Bh, 8Bh, INTCON             GIE            PEIE      TMR0IE       INTE        RBIE      TMR0IF        INTF       R0IF     0000 000x   0000 000u
10Bh,18Bh
0Ch           PIR1        PSPIF(1)          ADIF       RCIF         TXIF       SSPIF     CCP1IF TMR2IF TMR1IF              0000 0000   0000 0000
18h           RCSTA         SPEN            RX9       SREN        CREN ADDEN               FERR       OERR        RX9D     0000 000x   0000 000x
1Ah           RCREG      USART Receive Register                                                                            0000 0000   0000 0000
8Ch           PIE1        PSPIE(1)          ADIE       RCIE         TXIE       SSPIE     CCP1IE TMR2IE TMR1IE              0000 0000   0000 0000
98h           TXSTA         CSRC            TX9       TXEN        SYNC          —         BRGH        TRMT        TX9D     0000 -010   0000 -010
99h           SPBRG      Baud Rate Generator Register                                                                      0000 0000   0000 0000
Legend:       x = unknown, - = unimplemented locations read as ‘0’. Shaded cells are not used for asynchronous reception.
Note 1:       Bits PSPIE and PSPIF are reserved on 28-pin devices; always maintain these bits clear.
 2003 Microchip Technology Inc.                                       Preliminary                                             DS30498B-page 143
PIC16F7X7
11.3     USART Synchronous                                     Clearing enable bit TXEN during a transmission will
         Master Mode                                           cause the transmission to be aborted and will reset the
                                                               transmitter. The DT and CK pins will revert to high-
In Synchronous Master mode, the data is transmitted in         impedance. If either bit CREN or bit SREN is set during
a half-duplex manner (i.e., transmission and reception         a transmission, the transmission is aborted and the DT
do not occur at the same time). When transmitting data,        pin reverts to a high-impedance state (for a reception).
the reception is inhibited and vice versa. Synchronous         The CK pin will remain an output if bit CSRC is set
mode is entered by setting bit, SYNC (TXSTA<4>). In            (internal clock). The transmitter logic, however, is not
addition, enable bit, SPEN (RCSTA<7>), is set in order         reset, although it is disconnected from the pins. In order
to configure the RC6/TX/CK and RC7/RX/DT I/O pins              to reset the transmitter, the user has to clear bit TXEN.
to CK (clock) and DT (data) lines, respectively. The           If bit SREN is set (to interrupt an on-going transmission
Master mode indicates that the processor transmits the         and receive a single word), then after the single word is
master clock on the CK line. The Master mode is                received, bit SREN will be cleared and the serial port
entered by setting bit, CSRC (TXSTA<7>).                       will revert back to transmitting since bit TXEN is still set.
                                                               The DT line will immediately switch from High-
11.3.1      USART SYNCHRONOUS MASTER                           Impedance Receive mode to transmit and start driving.
            TRANSMISSION                                       To avoid this, bit TXEN should be cleared.
The USART transmitter block diagram is shown in                In order to select 9-bit transmission, the TX9
Figure 11-6. The heart of the transmitter is the Transmit      (TXSTA<6>) bit should be set and the ninth bit should
(Serial) Shift Register (TSR). The Shift register obtains      be written to bit TX9D (TXSTA<0>). The ninth bit must
its data from the Read/Write Transmit Buffer register,         be written before writing the 8-bit data to the TXREG
TXREG. The TXREG register is loaded with data in               register. This is because a data write to the TXREG can
software. The TSR register is not loaded until the last        result in an immediate transfer of the data to the TSR
bit has been transmitted from the previous load. As            register (if the TSR is empty). If the TSR was empty and
soon as the last bit is transmitted, the TSR is loaded         the TXREG was written before writing the “new” TX9D,
with new data from the TXREG (if available). Once the          the “present” value of bit TX9D is loaded.
TXREG register transfers the data to the TSR register
                                                               Steps to follow when setting up a Synchronous Master
(occurs in one TCYCLE), the TXREG is empty and inter-
                                                               Transmission:
rupt bit, TXIF (PIR1<4>), is set. The interrupt can be
enabled/disabled by setting/clearing enable bit, TXIE          1.    Initialize the SPBRG register for the appropriate
(PIE1<4>). Flag bit TXIF will be set regardless of the               baud rate (Section 11.1 “USART Baud Rate
state of enable bit TXIE and cannot be cleared in soft-              Generator (BRG)”).
ware. It will reset only when new data is loaded into the      2.    Enable the synchronous master serial port by
TXREG register. While flag bit TXIF indicates the status             setting bits SYNC, SPEN and CSRC.
of the TXREG register, another bit, TRMT (TXSTA<1>),           3.    If interrupts are desired, set enable bit TXIE.
shows the status of the TSR register. TRMT is a read-          4.    If 9-bit transmission is desired, set bit TX9.
only bit which is set when the TSR is empty. No
                                                               5.    Enable the transmission by setting bit TXEN.
interrupt logic is tied to this bit so the user has to poll
this bit in order to determine if the TSR register is          6.    If 9-bit transmission is selected, the ninth bit
empty. The TSR is not mapped in data memory so it is                 should be loaded in bit TX9D.
not available to the user.                                     7.    Start transmission by loading data to the TXREG
                                                                     register.
Transmission is enabled by setting enable bit, TXEN
(TXSTA<5>). The actual transmission will not occur             8.    If using interrupts, ensure that GIE and PEIE
until the TXREG register has been loaded with data.                  (bits 7 and 6) of the INTCON register are set.
The first data bit will be shifted out on the next available
rising edge of the clock on the CK line. Data out is sta-
ble around the falling edge of the synchronous clock
(Figure 11-9). The transmission can also be started by
first loading the TXREG register and then setting bit
TXEN (Figure 11-10). This is advantageous when slow
baud rates are selected, since the BRG is kept in Reset
when bits TXEN, CREN and SREN are clear. Setting
enable bit TXEN will start the BRG, creating a shift
clock immediately. Normally, when transmission is first
started, the TSR register is empty so a transfer to the
TXREG register will result in an immediate transfer to
TSR, resulting in an empty TXREG. Back-to-back
transfers are possible.
DS30498B-page 144                                      Preliminary                        2003 Microchip Technology Inc.
                                                                                                                                                PIC16F7X7
TABLE 11-10: REGISTERS ASSOCIATED WITH SYNCHRONOUS MASTER TRANSMISSION
                                                                                                                                                              Value on
                                                                                                                                                 Value on:
 Address         Name            Bit 7           Bit 6           Bit 5           Bit 4      Bit 3       Bit 2           Bit 1            Bit 0                all other
                                                                                                                                                 POR, BOR
                                                                                                                                                               Resets
0Bh, 8Bh, INTCON                 GIE             PEIE       TMR0IE               INTE       RBIE      TMR0IF            INTF             R0IF    0000 000x   0000 000u
10Bh,18Bh
0Ch            PIR1          PSPIF(1)            ADIF            RCIF            TXIF      SSPIF      CCP1IF      TMR2IF            TMR1IF       0000 0000   0000 0000
18h            RCSTA             SPEN            RX9             SREN        CREN                —     FERR        OERR                 RX9D     0000 -00x   0000 -00x
19h            TXREG        USART Transmit Register                                                                                              0000 0000   0000 0000
8Ch            PIE1          PSPIE(1)            ADIE            RCIE            TXIE      SSPIE      CCP1IE TMR2IE TMR1IE 0000 0000                         0000 0000
98h            TXSTA             CSRC            TX9             TXEN        SYNC                —     BRGH         TRMT                TX9D     0000 -010   0000 -010
99h            SPBRG        Baud Rate Generator Register                                                                                         0000 0000   0000 0000
Legend:       x = unknown, - = unimplemented, read as ‘0’. Shaded cells are not used for synchronous master transmission.
Note 1:       Bits PSPIE and PSPIF are reserved on 28-pin devices; always maintain these bits clear.
FIGURE 11-9:                 SYNCHRONOUS TRANSMISSION
              Q1Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1Q2Q3 Q4Q1Q2 Q3 Q4Q1 Q2 Q3 Q4                          Q3 Q4 Q1 Q2 Q3Q4 Q1Q2 Q3 Q4 Q1 Q2Q3 Q4Q1 Q2 Q3 Q4 Q1Q2 Q3 Q4 Q1 Q2 Q3 Q4
  RC7/RX/DT
                                         bit 0           bit 1           bit 2                       bit 7      bit 0           bit 1                         bit 7
  pin
                                                         Word 1                                                           Word 2
  RC6/TX/CK
  pin
  Write to
  TXREG Reg
                       Write Word 1              Write Word 2
  TXIF bit
  (Interrupt Flag)
  TRMT bit
  TXEN bit     ‘1’                                                                                                                                                    ‘1’
  Note: Sync Master mode, SPBRG = 0. Continuous transmission of two 8-bit words.
FIGURE 11-10:                SYNCHRONOUS TRANSMISSION (THROUGH TXEN)
           RC7/RX/DT pin                                          bit 0                  bit 1        bit 2                             bit 6       bit 7
           RC6/TX/CK pin
                  Write to
               TXREG Reg
                      TXIF bit
                     TRMT bit
                     TXEN bit
 2003 Microchip Technology Inc.                                                 Preliminary                                                         DS30498B-page 145
PIC16F7X7
11.3.2      USART SYNCHRONOUS MASTER                                   data. Reading the RCREG register will load bit RX9D
            RECEPTION                                                  with a new value, therefore, it is essential for the user
                                                                       to read the RCSTA register before reading RCREG, in
Once Synchronous mode is selected, reception is
                                                                       order not to lose the old RX9D information.
enabled by setting either enable bit, SREN
(RCSTA<5>) or enable bit, CREN (RCSTA<4>). Data is                     When setting up a Synchronous Master Reception:
sampled on the RC7/RX/DT pin on the falling edge of                    1.  Initialize the SPBRG register for the appropriate
the clock. If enable bit SREN is set, then only a single                   baud rate (Section 11.1 “USART Baud Rate
word is received. If enable bit CREN is set, the recep-                    Generator (BRG)”).
tion is continuous until CREN is cleared. If both bits are             2. Enable the synchronous master serial port by
set, CREN takes precedence. After clocking the last bit,                   setting bits SYNC, SPEN and CSRC.
the received data in the Receive Shift Register (RSR)
                                                                       3. Ensure bits CREN and SREN are clear.
is transferred to the RCREG register (if it is empty).
When the transfer is complete, interrupt flag bit, RCIF                4. If interrupts are desired, then set enable bit
(PIR1<5>), is set. The actual interrupt can be enabled/                    RCIE.
disabled by setting/clearing enable bit, RCIE                          5. If 9-bit reception is desired, then set bit RX9.
(PIE1<5>). Flag bit RCIF is a read-only bit which is                   6. If a single reception is required, set bit SREN.
reset by the hardware. In this case, it is reset when the                  For continuous reception, set bit CREN.
RCREG register has been read and is empty. The                         7. Interrupt flag bit RCIF will be set when reception
RCREG is a double-buffered register (i.e., it is a two-                    is complete and an interrupt will be generated if
deep FIFO). It is possible for two bytes of data to be                     enable bit RCIE was set.
received and transferred to the RCREG FIFO and a
                                                                       8. Read the RCSTA register to get the ninth bit (if
third byte to begin shifting into the RSR register. On the
                                                                           enabled) and determine if any error occurred
clocking of the last bit of the third byte, if the RCREG
                                                                           during reception.
register is still full, then Overrun Error bit, OERR
(RCSTA<1>), is set. The word in the RSR will be lost.                  9. Read the 8-bit received data by reading the
The RCREG register can be read twice to retrieve the                       RCREG register.
two bytes in the FIFO. Bit OERR has to be cleared in                   10. If any error occurred, clear the error by clearing
software (by clearing bit CREN). If bit OERR is set,                       bit CREN.
transfers from the RSR to the RCREG are inhibited so                   11. If using interrupts, ensure that GIE and PEIE
it is essential to clear bit OERR if it is set. The ninth                  (bits 7 and 6) of the INTCON register are set.
receive bit is buffered the same way as the receive
TABLE 11-11: REGISTERS ASSOCIATED WITH SYNCHRONOUS MASTER RECEPTION
                                                                                                                       Value on
                                                                                                      Value on:
 Address      Name       Bit 7        Bit 6    Bit 5   Bit 4   Bit 3        Bit 2    Bit 1    Bit 0                    all other
                                                                                                      POR, BOR
                                                                                                                        Resets
0Bh, 8Bh, INTCON          GIE         PEIE    TMR0IE   INTE    RBIE     TMR0IF       INTF     R0IF    0000 000x     0000 000u
10Bh,18Bh
0Ch          PIR1      PSPIF(1)       ADIF     RCIF    TXIF    SSPIF    CCP1IF      TMR2IF   TMR1IF   0000 0000     0000 0000
18h          RCSTA      SPEN          RX9     SREN     CREN     —           FERR    OERR     RX9D     0000 -00x     0000 -00x
1Ah          RCREG     USART Receive Register                                                         0000 0000     0000 0000
                                (1)
8Ch          PIE1      PSPIE          ADIE     RCIE    TXIE    SSPIE    CCP1IE TMR2IE TMR1IE 0000 0000              0000 0000
98h          TXSTA      CSRC          TX9     TXEN     SYNC     —           BRGH    TRMT     TX9D     0000 -010     0000 -010
99h          SPBRG     Baud Rate Generator Register                                                   0000 0000     0000 0000
Legend:     x = unknown, - = unimplemented, read as ‘0’. Shaded cells are not used for synchronous master reception.
Note 1:     Bits PSPIE and PSPIF are reserved on 28-pin devices; always maintain these bits clear.
DS30498B-page 146                                      Preliminary                               2003 Microchip Technology Inc.
                                                                                                                    PIC16F7X7
FIGURE 11-11:                 SYNCHRONOUS RECEPTION (MASTER MODE, SREN)
                      Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
   RC7/RX/DT pin                          bit 0       bit 1       bit 2      bit 3       bit 4       bit 5      bit 6      bit 7
   RC6/TX/CK pin
           Write to
         bit SREN
         SREN bit
         CREN bit       ‘0’                                                                                                                     ‘0’
          RCIF bit
        (Interrupt)
            Read
          RXREG
    Note: Timing diagram demonstrates Sync Master mode with bit SREN = 1 and bit BRG = 0.
 2003 Microchip Technology Inc.                                  Preliminary                                                   DS30498B-page 147
PIC16F7X7
11.4      USART Synchronous Slave Mode                                  When setting up a Synchronous Slave Transmission,
                                                                        follow these steps:
Synchronous Slave mode differs from the Master mode
in the fact that the shift clock is supplied externally at              1.    Enable the synchronous slave serial port by
the RC6/TX/CK pin (instead of being supplied internally                       setting bits SYNC and SPEN and clearing bit
in Master mode). This allows the device to transfer or                        CSRC.
receive data while in Sleep mode. Slave mode is                         2.    Clear bits CREN and SREN.
entered by clearing bit, CSRC (TXSTA<7>).                               3.    If interrupts are desired, then set enable bit
                                                                              TXIE.
11.4.1       USART SYNCHRONOUS SLAVE                                    4.    If 9-bit transmission is desired, then set bit TX9.
             TRANSMIT                                                   5.    Enable the transmission by setting enable bit
The operation of the Synchronous Master and Slave                             TXEN.
modes is identical, except in the case of the Sleep mode.               6.    If 9-bit transmission is selected, the ninth bit
If two words are written to the TXREG and then the                            should be loaded in bit TX9D.
SLEEP instruction is executed, the following will occur:                7.    Start transmission by loading data to the TXREG
a)    The first word will immediately transfer to the                         register.
      TSR register and transmit.                                        8.    If using interrupts, ensure that GIE and PEIE
b)    The second word will remain in TXREG register.                          (bits 7 and 6) of the INTCON register are set.
c)    Flag bit TXIF will not be set.
d)    When the first word has been shifted out of TSR,
      the TXREG register will transfer the second word
      to the TSR and flag bit TXIF will now be set.
e)    If enable bit TXIE is set, the interrupt will wake
      the chip from Sleep and if the global interrupt is
      enabled, the program will branch to the interrupt
      vector (0004h).
TABLE 11-12: REGISTERS ASSOCIATED WITH SYNCHRONOUS SLAVE TRANSMISSION
                                                                                                                        Value on
                                                                                                         Value on:
 Address       Name       Bit 7     Bit 6     Bit 5    Bit 4    Bit 3         Bit 2    Bit 1     Bit 0                  all other
                                                                                                         POR, BOR
                                                                                                                         Resets
0Bh, 8Bh, INTCON           GIE      PEIE    TMR0IE     INTE     RBIE         TMR0IF    INTF      R0IF    0000 000x     0000 000u
10Bh,18Bh
0Ch           PIR1       PSPIF(1)   ADIF      RCIF     TXIF    SSPIF         CCP1IF TMR2IF TMR1IF 0000 0000            0000 0000
18h           RCSTA       SPEN       RX9     SREN      CREN    ADDEN         FERR     OERR      RX9D     0000 000x     0000 000x
19h           TXREG     USART Transmit Register                                                          0000 0000     0000 0000
8Ch           PIE1      PSPIE(1)    ADIE      RCIE     TXIE    SSPIE         CCP1IE TMR2IE TMR1IE 0000 0000            0000 0000
98h           TXSTA       CSRC       TX9     TXEN      SYNC       —          BRGH     TRMT      TX9D     0000 -010     0000 -010
99h           SPBRG     Baud Rate Generator Register                                                     0000 0000     0000 0000
Legend:      x = unknown, - = unimplemented, read as ‘0’. Shaded cells are not used for synchronous slave transmission.
Note 1:      Bits PSPIE and PSPIF are reserved on 28-pin devices; always maintain these bits clear.
DS30498B-page 148                                      Preliminary                                 2003 Microchip Technology Inc.
                                                                                                   PIC16F7X7
11.4.2      USART SYNCHRONOUS SLAVE                                   When setting up a Synchronous Slave Reception,
            RECEPTION                                                 follow these steps:
The operation of the Synchronous Master and Slave                     1.     Enable the synchronous master serial port by
modes is identical, except in the case of the Sleep                          setting bits SYNC and SPEN and clearing bit
mode. Bit SREN is a “don't care” in Slave mode.                              CSRC.
If receive is enabled by setting bit CREN prior to the                2.     If interrupts are desired, set enable bit RCIE.
SLEEP instruction, then a word may be received during                 3.     If 9-bit reception is desired, set bit RX9.
Sleep. On completely receiving the word, the RSR reg-                 4.     To enable reception, set enable bit CREN.
ister will transfer the data to the RCREG register and if             5.     Flag bit RCIF will be set when reception is com-
enable bit RCIE bit is set, the interrupt generated will                     plete and an interrupt will be generated if enable
wake the chip from Sleep. If the global interrupt is                         bit RCIE was set.
enabled, the program will branch to the interrupt vector              6.     Read the RCSTA register to get the ninth bit (if
(0004h).                                                                     enabled) and determine if any error occurred
                                                                             during reception.
                                                                      7.     Read the 8-bit received data by reading the
                                                                             RCREG register.
                                                                      8.     If any error occurred, clear the error by clearing
                                                                             bit CREN.
                                                                      9.     If using interrupts, ensure that GIE and PEIE
                                                                             (bits 7 and 6) of the INTCON register are set.
TABLE 11-13: REGISTERS ASSOCIATED WITH SYNCHRONOUS SLAVE RECEPTION
                                                                                                                       Value on
                                                                                                        Value on:
 Address      Name       Bit 7     Bit 6    Bit 5     Bit 4   Bit 3         Bit 2    Bit 1     Bit 0                   all other
                                                                                                        POR, BOR
                                                                                                                        Resets
0Bh, 8Bh, INTCON         GIE       PEIE    TMR0IE     INTE    RBIE         TMR0IF    INTF      R0IF    0000 000x      0000 000u
10Bh,18Bh
0Ch         PIR1       PSPIF(1)    ADIF     RCIF      TXIF    SSPIF        CCP1IF   TMR2IF    TMR1IF 0000 0000        0000 0000
18h         RCSTA       SPEN       RX9     SREN     CREN      ADDEN        FERR     OERR       RX9D    0000 000x      0000 000x
1Ah         RCREG      USART Receive Register                                                          0000 0000      0000 0000
8Ch         PIE1       PSPIE(1)    ADIE     RCIE      TXIE    SSPIE        CCP1IE TMR2IE TMR1IE 0000 0000             0000 0000
98h         TXSTA       CSRC       TX9     TXEN     SYNC       —           BRGH      TRMT      TX9D    0000 -010      0000 -010
99h         SPBRG      Baud Rate Generator Register                                                    0000 0000      0000 0000
Legend:     x = unknown, - = unimplemented, read as ‘0’. Shaded cells are not used for synchronous slave reception.
Note 1:     Bits PSPIE and PSPIF are reserved on 28-pin devices, always maintain these bits clear.
 2003 Microchip Technology Inc.                       Preliminary                                           DS30498B-page 149
PIC16F7X7
NOTES:
DS30498B-page 150   Preliminary    2003 Microchip Technology Inc.
                                                                                    PIC16F7X7
12.0     ANALOG-TO-DIGITAL                                The module has five registers:
         CONVERTER (A/D) MODULE                           •   A/D Result High Register (ADRESH)
                                                          •   A/D Result Low Register (ADRESL)
The Analog-to-Digital (A/D) Converter module has 11
inputs for the PIC16F737 and PIC16F767 devices and        •   A/D Control Register 0 (ADCON0)
14 for the PIC16F747 AND PIC16F777 devices.               •   A/D Control Register 1 (ADCON1)
The A/D allows conversion of an analog input signal to    •   A/D Control Register 2 (ADCON2)
a corresponding 10-bit digital number.                    The ADCON0 register, shown in Register 12-1, controls
A new feature for the A/D converter is the addition of    the operation of the A/D module and clock source. The
programmable acquisition time. This feature allows the    ADCON1 register, shown in Register 12-2, configures
user to select a new channel for conversion and to set    the functions of the port pins, justification and voltage
the GO/DONE bit immediately. When the GO/DONE bit         reference sources. The ADCON2, shown in
is set, the selected channel is sampled for the pro-      Register 12-3, configures the programmed acquisition
grammed acquisition time before a conversion is actu-     time.
ally started. This removes the firmware overhead          Additional information on using the A/D module can be
required to allow for an acquisition (sampling) period    found in the PICmicro® Mid-Range MCU Family
(see Register 12-3 and Section 12.2 “Selecting and        Reference Manual (DS33023) and in Application Note
Configuring Automatic Acquisition Time”).                 AN546, “Using the Analog-to-Digital (A/D) Converter”
                                                          (DS00546).
 2003 Microchip Technology Inc.                  Preliminary                                  DS30498B-page 151
PIC16F7X7
REGISTER 12-1:      ADCON0: A/D CONTROL REGISTER 0 (ADDRESS 1Fh)
                      R/W-0       R/W-0        R/W-0         R/W-0      R/W-0        R/W-0        R/W-0       R/W-0
                     ADCS1       ADCS0         CHS2          CHS1       CHS0       GO/DONE        CHS3        ADON
                    bit 7                                                                                        bit 0
         bit 7-6    ADCS1:ADCS0: A/D Conversion Clock Select bits
                    If ADCS2 = 0:
                    000 = FOSC/2
                    001 = FOSC/8
                    010 = FOSC/32
                    011 = FRC (clock derived from an RC oscillation)
                    If ADCS2 = 1:
                    00 = FOSC/4
                    01 = FOSC/16
                    10 = FOSC/64
                    11 = FRC (clock derived from an RC oscillation)
         bit 5-3    CHS<2:0>: Analog Channel Select bits
                    0000 = Channel 00 (AN0)
                    0001 = Channel 01 (AN1)
                    0010 = Channel 02 (AN2)
                    0011 = Channel 03 (AN3)
                    0100 = Channel 04 (AN4)
                    0101 = Channel 05 (AN5)(1)
                    0110 = Channel 06 (AN6)(1)
                    0111 = Channel 07 (AN7)(1)
                    1000 = Channel 08 (AN8)
                    1001 = Channel 09 (AN9)
                    1010 = Channel 10 (AN10)
                    1011 = Channel 11 (AN11)
                    1100 = Channel 12 (AN12)
                    1101 = Channel 13 (AN13)
                    111x = Unused
                      Note 1:Selecting AN5 through AN7 on the 28-pin product variant (PIC16F737 and
                              PIC16F767) will result in a full-scale conversion as unimplemented channels are
                              connected to VDD.
         bit 2      GO/DONE: A/D Conversion Status bit
                    1 = A/D conversion cycle in progress. Setting this bit starts an A/D conversion cycle. This bit is
                        automatically cleared by hardware when the A/D conversion has completed.
                    0 = A/D conversion completed/not in progress
         bit 1      CHS<3>: Analog Channel Select bit (see bit 5-3 for bit settings)
         bit 0      ADON: A/D Conversion Status bit
                    1 = A/D converter module is operating
                    0 = A/D converter is shut-off and consumes no operating current
                    Legend:
                    R = Readable bit              W = Writable bit      U = Unimplemented bit, read as ‘0’
                    - n = Value at POR            ‘1’ = Bit is set      ‘0’ = Bit is cleared    x = Bit is unknown
DS30498B-page 152                               Preliminary                             2003 Microchip Technology Inc.
                                                                                                        PIC16F7X7
REGISTER 12-2:         ADCON1: A/D CONTROL REGISTER 1 (ADDRESS 9Fh)
                          R/W-0            R/W-0          R/W-0        R/W-0       R/W-0              R/W-0       R/W-0       R/W-0
                          ADFM            ADCS2           VCFG1       VCFG0        PCFG3              PCFG2       PCFG1     PCFG0
                        bit 7                                                                                                   bit 0
           bit 7        ADFM: A/D Result Format Select bit
                        1 = Right justified. Six Most Significant bits of ADRESH are read as ‘0’.
                        0 = Left justified. Six Least Significant bits of ADRESL are read as ‘0’.
           bit 6        ADCS2: A/D Clock Divide by 2 Select bit
                        1 = A/D clock source is divided by two when system clock is used
                        0 = Disabled
           bit 5        VCFG1: Voltage Reference Configuration bit 1
                        0 = VREF- is connected to VSS
                        1 = VREF- is connected to external VREF- (RA2)
           bit 4        VCFG0: Voltage Reference Configuration bit 0
                        0 = VREF+ is connected to VDD
                        1 = VREF+ is connected to external VREF+ (RA3)
           bit 3-0      PCFG<3:0>: A/D Port Configuration bits
                                   AN13 AN12 AN11 AN10 AN9 AN8 AN7 AN6 AN5 AN4 AN3 AN2 AN1 AN0
                         0000       A         A       A       A       A        A   A       A      A      A    A     A     A      A
                         0001       A         A       A       A       A        A   A       A      A      A    A     A     A      A
                         0010       D         A       A       A       A        A   A       A      A      A    A     A     A      A
                         0011       D         D       A       A       A        A   A       A      A      A    A     A     A      A
                         0100       D         D       D       A       A        A   A       A      A      A    A     A     A      A
                         0101       D         D       D       D       A        A   A       A      A      A    A     A     A      A
                         0110       D         D       D       D       D        A   A       A      A      A    A     A     A      A
                         0111       D         D       D       D       D        D   A       A      A      A    A     A     A      A
                         1000       D         D       D       D       D        D   D       A      A      A    A     A     A      A
                         1001       D         D       D       D       D        D   D       D      A      A    A     A     A      A
                         1010       D         D       D       D       D        D   D       D      D      A    A     A     A      A
                         1011       D         D       D       D       D        D   D       D      D      D    A     A     A      A
                         1100       D         D       D       D       D        D   D       D      D      D    D     A     A      A
                         1101       D         D       D       D       D        D   D       D      D      D    D     D     A      A
                         1110       D         D       D       D       D        D   D       D      D      D    D     D     D      A
                         1111       D         D       D       D       D        D   D       D      D      D    D     D     D      D
                        Legend:         A = Analog input, D = Digital I/O
                         Note:       AN5 through AN7 are only available on the 40-pin product variant (PIC16F747 and
                                     PIC16F777).
                        Legend:
                        R = Readable bit                    W = Writable bit           U = Unimplemented bit, read as ‘0’
                        - n = Value at POR                  ‘1’ = Bit is set           ‘0’ = Bit is cleared   x = Bit is unknown
 2003 Microchip Technology Inc.                           Preliminary                                            DS30498B-page 153
PIC16F7X7
REGISTER 12-3:         ADCON2: A/D CONTROL REGISTER 2
                          U-0          U-0        R/W-0          R/W-0       R/W-0         U-0        U-0          U-0
                           —           —          ACQT2         ACQT1       ACQT0          —           —            —
                       bit 7                                                                                          bit 0
             bit 7-6   Unimplemented: Read as ‘0’
             bit 5-3   ACQT<2:0>: A/D Acquisition Time Select bits
                       000 = 0(1)
                       001 = 2 TAD
                       010 = 4 TAD
                       011 = 6 TAD
                       100 = 8 TAD
                       101 = 12TAD
                       110 = 16 TAD
                       111 = 20 TAD
                         Note 1: If the A/D clock source is selected as RC, a time of TCY is added before the A/D
                                 clock starts. This allows the SLEEP instruction to be executed.
             bit 2-0   Unimplemented: Read as ‘0’
                       Legend:
                       R = Readable bit             W = Writable bit       U = Unimplemented bit, read as ‘0’
                       -n = Value at POR            ‘1’ = Bit is set       ‘0’ = Bit is cleared    x = Bit is unknown
The analog reference voltage is software selectable              A device Reset forces all registers to their Reset state.
to either the device’s positive and negative supply              This forces the A/D module to be turned off and any
voltage (VDD and VSS) or the voltage level on the                conversion in progress is aborted.
RA3/AN3/VREF+ and RA2/AN2/VREF-/CVREF pins.                      Each port pin associated with the A/D converter can be
The A/D converter has a unique feature of being able             configured as an analog input or as a digital I/O. The
to operate while the device is in Sleep mode. To oper-           ADRESH and ADRESL registers contain the result of
ate in Sleep, the A/D conversion clock must be derived           the A/D conversion. When the A/D conversion is com-
from the A/D’s internal RC oscillator.                           plete, the result is loaded into the ADRESH/ADRESL
The output of the sample and hold is the input into the          registers, the GO/DONE bit (ADCON0 register) is
converter, which generates the result via successive             cleared and A/D Interrupt Flag bit, ADIF, is set. The block
approximation.                                                   diagram of the A/D module is shown in Figure 12-1.
DS30498B-page 154                                  Preliminary                             2003 Microchip Technology Inc.
                                                                                             PIC16F7X7
The value in the ADRESH/ADRESL registers is not                    2.   Configure A/D interrupt (if desired):
modified for a Power-on Reset. The ADRESH/                              • Clear ADIF bit
ADRESL registers will contain unknown data after a                      • Set ADIE bit
Power-on Reset.
                                                                        • Set PEIE bit
After the A/D module has been configured as desired,                    • Set GIE bit
the selected channel must be acquired before the con-
                                                                   3.   Wait the required acquisition time (if required).
version is started. The analog input channels must
have their corresponding TRIS bits selected as an                  4.   Start conversion:
input. To determine acquisition time, see Section 12.1                  • Set GO/DONE bit (ADCON0 register)
“A/D Acquisition Requirements”. After this acquisi-                5.   Wait for A/D conversion to complete, by either:
tion time has elapsed, the A/D conversion can be                        • Polling for the GO/DONE bit to be cleared
started. An acquisition time can be programmed to                       OR
occur between setting the GO/DONE bit and the actual
                                                                        • Waiting for the A/D interrupt
start of the conversion.
                                                                   6.   Read A/D Result registers (ADRESH:ADRESL);
The following steps should be followed to do an A/D                     clear bit ADIF, if required.
conversion:
                                                                   7.   For next conversion, go to step 1 or step 2, as
1.   Configure the A/D module:                                          required. The A/D conversion time per bit is
     • Configure analog pins, voltage reference and                     defined as TAD. A minimum wait of 2 TAD is
       digital I/O (ADCON1)                                             required before the next acquisition starts.
     • Select A/D input channel (ADCON0)
     • Select A/D acquisition time (ADCON2)
     • Select A/D conversion clock (ADCON0)
     • Turn on A/D module (ADCON0)
FIGURE 12-1:           A/D BLOCK DIAGRAM
                                                                          CHS<3:0>
                                                                                     1101
                                                                                                        AN13
                                                                                     1100
                                                                                                        AN12
                                                                                     1011
                                                                                                        AN11
                                                                         S
                                                                         S
                                                                                     0011
                                                                                                        AN3/VREF+
                                                                                     0010
                                                    VIN                                                 AN2/VREF-
                                               (Input Voltage)                       0001
                                                                                                        AN1
                                                                 VDD                 0000
                                                                                                        AN0
                  A/D
                Converter
                                       VREF+
                                    (Reference
                                     Voltage)
                                                 VCFG<1:0>
                                       VREF-
                                    (Reference
                                     Voltage)
                                                                  VSS
                                                 VCFG<1:0>
 2003 Microchip Technology Inc.                   Preliminary                                         DS30498B-page 155
PIC16F7X7
12.1     A/D Acquisition Requirements                                       To calculate the minimum acquisition time,
                                                                            Equation 12-1 may be used. This equation assumes
For the A/D converter to meet its specified accuracy,                       that 1/2 LSb error is used (1024 steps for the A/D). The
the charge holding capacitor (CHOLD) must be allowed                        1/2 LSb error is the maximum error allowed for the A/D
to fully charge to the input channel voltage level. The                     to meet its specified resolution.
analog input model is shown in Figure 12-2. The
source impedance (RS) and the internal sampling                             To calculate the minimum acquisition time, TACQ, see
switch (RSS) impedance directly affect the time                             the PICmicro® Mid-Range MCU Family Reference
required to charge the capacitor CHOLD. The sampling                        Manual (DS33023).
switch (RSS) impedance varies over the device voltage
(VDD), see Figure 12-2. The maximum recom-
mended impedance for analog sources is 2.5 kΩ.
As the impedance is decreased, the acquisition time
may be decreased. After the analog input channel is
selected (changed), this acquisition must be done
before the conversion can be started.
EQUATION 12-1:         ACQUISITION TIME
 TACQ     = Amplifier Settling Time + Hold Capacitor Charging Time + Temperature Coefficient
          =   TAMP + TC + TCOFF
          =   2 µs + TC + [(Temperature -25°C)(0.05 µs/°C)]
 TC       =   CHOLD (RIC + RSS + RS) In(1/2047)
          =   -120 pF (1 kΩ + 7 kΩ + 10 kΩ) In(0.0004885)
          =   16.47 µs
 TACQ     =   2 µs + 16.47 µs + [(50°C – 25°C)(0.05 µs/°C)
          =   19.72 µs
   Note 1: The reference voltage (VREF) has no effect on the equation since it cancels itself out.
        2: The charge holding capacitor (CHOLD) is not discharged after each conversion.
        3: The maximum recommended impedance for analog sources is 10 kΩ. This is required to meet the pin
           leakage specification.
        4: After a conversion has completed, a 2.0 TAD delay must complete before acquisition can begin again.
           During this time, the holding capacitor is not connected to the selected A/D input channel.
FIGURE 12-2:           ANALOG INPUT MODEL
                                                      VDD
                                                                                           Sampling
                                                                                           Switch
                                                              VT = 0.6V
                           RS     ANx                                          RIC ≤ 1k   SS   RSS
                                                                                                          CHOLD
                      VA           CPIN                                   ILEAKAGE                        = DAC Capacitance
                                   5 pF                     VT = 0.6V     ± 500 nA                        = 51.2 pF
                                                                                                        VSS
                    Legend CPIN         = input capacitance
                                                                                              6V
                           VT           = threshold voltage                                   5V
                                                                                          VDD 4V
                           ILEAKAGE = leakage current at the pin due to
                                      various junctions                                       3V
                                                                                              2V
                           RIC          = interconnect resistance
                           SS           = sampling switch
                                                                                                      5 6 7 8 9 10 11
                           CHOLD        = sample/hold capacitance (from DAC)
                                                                                                      Sampling Switch
                                                                                                          (kΩ)
DS30498B-page 156                                              Preliminary                                2003 Microchip Technology Inc.
                                                                                            PIC16F7X7
12.2     Selecting and Configuring                               12.3      Selecting the A/D Conversion
         Automatic Acquisition Time                                        Clock
The ADCON2 register allows the user to select an                 The A/D conversion time per bit is defined as TAD. The
acquisition time that occurs each time the GO/DONE               A/D conversion requires a minimum 12 TAD per 10-bit
bit is set.                                                      conversion. The source of the A/D conversion clock is
When the GO/DONE bit is set, sampling is stopped and             software selected. The seven possible options for TAD
a conversion begins. The user is responsible for ensur-          are:
ing the required acquisition time has passed between             •   2 TOSC
selecting the desired input channel and setting the              •   4 TOSC
GO/DONE bit. This occurs when the ACQT2:ACQT0                    •   8 TOSC
bits (ADCON2<5:3>) remain in their Reset state (‘000’)
                                                                 •   16 TOSC
and is compatible with devices that do not offer
programmable acquisition times.                                  •   32 TOSC
                                                                 •   64 TOSC
If desired, the ACQT bits can be set to select a pro-
grammable acquisition time for the A/D module. When              •   Internal A/D module, RC oscillator (2-6 µs)
the GO/DONE bit is set, the A/D module continues to              For correct A/D conversions, the A/D conversion clock
sample the input for the selected acquisition time, then         (TAD) must be selected to ensure a minimum TAD time
automatically begins a conversion. Since the acquisi-            of 1.6 µs.
tion time is programmed, there may be no need to wait
                                                                 Table 12-1 shows the resultant TAD times derived from
for an acquisition time between selecting a channel and
                                                                 the device operating frequencies and the A/D clock
setting the GO/DONE bit.
                                                                 source selected.
In either case, when the conversion is completed, the
GO/DONE bit is cleared, the ADIF flag is set and the
A/D begins sampling the currently selected channel
again. If an acquisition time is programmed, there is
nothing to indicate if the acquisition time has ended or
if the conversion has begun.
TABLE 12-1:         TAD vs. MAXIMUM DEVICE OPERATING FREQUENCIES (STANDARD DEVICES (F))
                                AD Clock Source (TAD)                                  Maximum Device Frequency
              Operation                          ADCS2:ADCS1:ADCS0                                  Max.
                2 TOSC                                     000                                    1.25 MHz
                4 TOSC                                     100                                     2.5 MHz
                8 TOSC                                     001                                      5 MHz
               16 TOSC                                     101                                     10 MHz
               32 TOSC                                     010                                     20 MHz
               64 TOSC                                     110                                     20 MHz
                    (1, 2, 3)
               RC                                          x11                                     (Note 1)
Note 1:     The RC source has a typical TAD time of 4 µs but can vary between 2-6 µs.
     2:     When the device frequencies are greater than 1 MHz, the RC A/D conversion clock source is only
            recommended for Sleep operation.
       3:   For extended voltage devices (LF), please refer to Section 18.0 “Electrical Characteristics”.
 2003 Microchip Technology Inc.                    Preliminary                                       DS30498B-page 157
PIC16F7X7
12.4     Operation in Power Managed                         12.5     Configuring Analog Port Pins
         Modes                                              The ADCON1, TRISA, TRISB and TRISE registers
The selection of the automatic acquisition time and         control the operation of the A/D port pins. The port pins
A/D conversion clock is determined in part by the clock     that are desired as analog inputs must have their cor-
source and frequency while in a power managed mode.         responding TRIS bits set (input). If the TRIS bit is
                                                            cleared (output), the digital output level (VOH or VOL)
If the A/D is expected to operate while the device is in
                                                            will be converted.
a power managed mode, the ACQT2:ACQT0 and
ADCS2:ADCS0 bits in ADCON2 should be updated in             The A/D operation is independent of the state of the
accordance with the power managed mode clock that           CHS2:CHS0 bits and the TRIS bits.
will be used. After the power managed mode is entered          Note 1: When reading the Port register, all pins
(either of the Power Managed Run modes), an A/D                        configured as analog input channels will
acquisition or conversion may be started. Once an                      read as cleared (a low level). Pins config-
acquisition or conversion is started, the device should                ured as digital inputs will convert an analog
continue to be clocked by the same power managed                       input. Analog levels on a digitally config-
mode clock source until the conversion has been                        ured input will not affect the conversion
completed.                                                             accuracy.
If the power managed mode clock frequency is less                    2: Analog levels on any pin that is defined as
than 1 MHz, the A/D RC clock source should be                           a digital input, but not as an analog input,
selected.                                                               may cause the digital input buffer to con-
Operation in Sleep mode requires the A/D RC clock to                    sume current that is out of the device’s
be selected. If bits ACQT2:ACQT0 are set to ‘000’ and                   specification.
a conversion is started, the conversion will be delayed
one instruction cycle to allow execution of the SLEEP
instruction and entry to Sleep mode.
DS30498B-page 158                                   Preliminary                      2003 Microchip Technology Inc.
                                                                                                    PIC16F7X7
12.6       A/D Conversions                                            Clearing the GO/DONE bit during a conversion will
                                                                      abort the current conversion. The A/D Result register
Figure 12-3 shows the operation of the A/D converter                  pair will NOT be updated with the partially completed
after the GO bit has been set and the ACQT2:ACQT0                     A/D     conversion     sample.   This    means      the
bits are cleared. A conversion is started after the follow-           ADRESH:ADRESL registers will continue to contain
ing instruction to allow entry into Sleep mode before the             the value of the last completed conversion (or the last
conversion begins.                                                    value written to the ADRESH:ADRESL registers).
Figure 12-4 shows the operation of the A/D converter                  After the A/D conversion is completed or aborted, a
after the GO bit has been set, the ACQT2:ACQT0 bits                   2 TAD wait is required before the next acquisition can
are set to ‘010’ and a 4 TAD acquisition time is selected             be started. After this wait, acquisition on the selected
before the conversion starts.                                         channel is automatically started.
                                                                        Note:       The GO/DONE bit should NOT be set in
                                                                                    the same instruction that turns on the A/D.
FIGURE 12-3:             A/D CONVERSION TAD CYCLES (ACQT<2:0> = 000, TACQ = 0)
           TCY - TAD TAD1 TAD2 TAD3 TAD4 TAD5 TAD6 TAD7 TAD8 TAD9 TAD10 TAD11
                           b9   b8    b7   b6  b5   b4   b3   b2    b1    b0
                   Conversion starts
            Holding capacitor is disconnected from analog input (typically 100 ns)
           Set GO bit
                                               Next Q4: ADRESH/ADRESL is loaded, GO bit is cleared,
                                                        ADIF bit is set, holding capacitor is connected to analog input.
FIGURE 12-4:             A/D CONVERSION TAD CYCLES (ACQT<2:0> = 010, TACQ = 4 TAD)
           TACQT Cycles                                         TAD Cycles
       1     2       3      4      1      2        3      4     5        6      7       8      9      10     11
                                          b9      b8     b7      b6     b5      b4      b3     b2     b1    b0
             Automatic
             Acquisition        Conversion starts
               Time             (Holding capacitor is disconnected)
   Set GO bit
   (Holding capacitor continues
   acquiring input)                           Next Q4: ADRESH:ADRESL is loaded, GO bit is cleared,
                                                       ADIF bit is set, holding capacitor is reconnected to analog input.
 2003 Microchip Technology Inc.                       Preliminary                                          DS30498B-page 159
PIC16F7X7
12.7      A/D Operation During Sleep                                     12.8        Effects of a Reset
The A/D module can operate during Sleep mode. This                       A device Reset forces all registers to their Reset state.
requires that the A/D clock source be set to RC                          The A/D module is disabled and any conversion in
(ADCS1:ADCS0 = 11). When the RC clock source is                          progress is aborted. All A/D input pins are configured
selected, the A/D module waits one instruction cycle                     as analog inputs.
before starting the conversion. This allows the SLEEP                    The ADRES register will contain unknown data after a
instruction to be executed which eliminates all digital                  Power-on Reset.
switching noise from the conversion. When the conver-
sion is completed, the GO/DONE bit will be cleared and
the result loaded into the ADRES register. If the A/D
                                                                         12.9        Use of the CCP Trigger
interrupt is enabled, the device will wake-up from                       An A/D conversion can be started by the “special event
Sleep. If the A/D interrupt is not enabled, the A/D                      trigger” of the CCP2 module. This requires that the
module will then be turned off, although the ADON bit                    CCP2M3:CCP2M0 bits (CCP2CON<3:0>) be pro-
will remain set.                                                         grammed as ‘1011’ and that the A/D module is enabled
When the A/D clock source is another clock option (not                   (ADON bit is set). When the trigger occurs, the
RC), a SLEEP instruction will cause the present conver-                  GO/DONE bit will be set, starting the A/D conversion,
sion to be aborted and the A/D module to be turned off,                  and the Timer1 counter will be reset to zero. Timer1 is
though the ADON bit will remain set.                                     reset to automatically repeat the A/D acquisition period
                                                                         with minimal software overhead (moving the ADRES to
Turning off the A/D places the A/D module in its lowest
                                                                         the desired location). The appropriate analog input
current consumption state.
                                                                         channel must be selected and an appropriate acquisi-
  Note:    For the A/D module to operate in Sleep,                       tion time should pass before the “special event trigger”
           the A/D clock source must be set to RC                        sets the GO/DONE bit (starts a conversion).
           (ADCS1:ADCS0 = 11). To perform an A/D                         If the A/D module is not enabled (ADON is cleared),
           conversion in Sleep, ensure the SLEEP                         then the “special event trigger” will be ignored by the
           instruction immediately follows the                           A/D module but will still reset the Timer1 counter.
           instruction that sets the GO/DONE bit.
TABLE 12-2:        SUMMARY OF A/D REGISTERS
                                                                                                                        Value on
                                                                                                          Value on:
 Address     Name         Bit 7        Bit 6    Bit 5     Bit 4     Bit 3       Bit 2    Bit 1    Bit 0                 all other
                                                                                                          POR, BOR
                                                                                                                         Resets
0Bh,8Bh,   INTCON          GIE         PEIE    TMR0IE    INT0IE     RBIE       TMR0IF   INT0IF   RBIF     0000 000x 0000 000u
10Bh, 18Bh
0Ch        PIR1          PSPIF(1)      ADIF     RCIF      TXIF     SSPIF       CCP1IF   TMR2IF TMR1IF 0000 0000 0000 0000
0Dh        PIR2           OSFIF        CMIF     LVDIF      —       BCLIF         —      CCP3IF CCP2IF 000- 0-00 000- 0-00
                                 (1)
8Ch        PIE1          PSPIE         ADIE     RCIE      TXIE     SSPIE       CCP1IE   TMR2IE TMR1IE 0000 0000 0000 0000
8Dh        PIE2          OSFIE         CMIE    LVDIE       —       BCLIE         —      CCP3IE CCP2IE 000- 0--0 000- 0--0
1Eh        ADRES         A/D Result Register                                                              xxxx xxxx uuuu uuuu
1Fh        ADCON0        ADCS1         ADCS0    CHS2      CHS1     CHS0 GO/DONE          CHS3    ADON     0000 0000 0000 0000
9Fh        ADCON1         ADFM         ADCS2 VCFG1       VCFG0     PCFG3       PCFG2    PCFG1    PCFG0    0000 000    0000 0000
05h        PORTA          RA7           RA6     RA5       RA4       RA3         RA2      RA1      RA0     xx0x 0000 uu0u 0000
85h        TRISA           —            —      PORTA Data Direction Register                              --11 1111 --11 1111
                   (2)
09h        PORTE            —           —         —         —        —          RE2      RE1      RE0     ---- x000 ---- x000
89h        TRISE(2)        IBF         OBF      IBOV    PSPMODE      —(3)   PORTE Data Direction bits     0000 1111 0000 1111
Legend:    x = unknown, u = unchanged, - = unimplemented, read as ‘0’. Shaded cells are not used for A/D conversion.
Note 1:    Bits PSPIE and PSPIF are reserved on the PIC16F737/767 devices; always maintain these bits clear.
     2:    These registers are reserved on the PIC16F737/767 devices.
     3:    RE3 is an input only. The state of the TRISE3 bit has no effect and will always read ‘1’.
DS30498B-page 160                                          Preliminary                            2003 Microchip Technology Inc.
                                                                                           PIC16F7X7
13.0     COMPARATOR MODULE                                      The CMCON register (Register 13-1) controls the com-
                                                                parator input and output multiplexers. A block diagram
The comparator module contains two analog com-                  of the various comparator configurations is shown in
parators. The inputs to the comparators are                     Figure 13-1.
multiplexed with I/O port pins RA0 through RA3, while
the outputs are multiplexed to pins RA4 and RA5. The
on-chip voltage reference (Section 14.0 “Comparator
Voltage Reference Module”) can also be an input to
the comparators.
REGISTER 13-1:         CMCON REGISTER
                            R-0       R-0       R/W-0        R/W-0       R/W-0        R/W-1      R/W-1        R/W-1
                          C2OUT     C1OUT       C2INV        C1INV        CIS          CM2        CM1         CM0
                        bit 7                                                                                    bit 0
           bit 7        C2OUT: Comparator 2 Output bit
                        When C2INV = 0:
                        1 = C2 VIN+ > C2 VIN-
                        0 = C2 VIN+ < C2 VIN-
                        When C2INV = 1:
                        1 = C2 VIN+ < C2 VIN-
                        0 = C2 VIN+ > C2 VIN-
           bit 6        C1OUT: Comparator 1 Output bit
                        When C1INV = 0:
                        1 = C1 VIN+ > C1 VIN-
                        0 = C1 VIN+ < C1 VIN-
                        When C1INV = 1:
                        1 = C1 VIN+ < C1 VIN-
                        0 = C1 VIN+ > C1 VIN-
           bit 5        C2INV: Comparator 2 Output Inversion bit
                        1 = C2 output inverted
                        0 = C2 output not inverted
           bit 4        C1INV: Comparator 1 Output Inversion bit
                        1 = C1 output inverted
                        0 = C1 output not inverted
           bit 3        CIS: Comparator Input Switch bit
                        When CM2:CM0 = 110:
                        1 = C1 VIN- connects to RA3/AN3
                            C2 VIN- connects to RA2/AN2
                        0 = C1 VIN- connects to RA0/AN0
                            C2 VIN- connects to RA1/AN1
           bit 2-0      CM2:CM0: Comparator Mode bits
                        Figure 13-1 shows the Comparator modes and CM2:CM0 bit settings.
                        Legend:
                        R = Readable bit          W = Writable bit       U = Unimplemented bit, read as ‘0’
                        - n = Value at POR        ‘1’ = Bit is set       ‘0’ = Bit is cleared   x = Bit is unknown
 2003 Microchip Technology Inc.                  Preliminary                                      DS30498B-page 161
PIC16F7X7
13.1     Comparator Configuration                                    be valid for the specified mode change delay shown in
                                                                     the Electrical Specifications (Section 18.0 “Electrical
There are eight modes of operation for the compara-                  Characteristics”).
tors. The CMCON register is used to select these
modes. Figure 13-1 shows the eight possible modes.                      Note:       Comparator interrupts should be disabled
The TRISA register controls the data direction of the                               during a Comparator mode change.
comparator pins for each mode. If the Comparator                                    Otherwise, a false interrupt may occur.
mode is changed, the comparator output level may not
FIGURE 13-1:            COMPARATOR I/O OPERATING MODES
 Comparators Reset                                                 Comparators Off (POR Default Mode)
 CM2:CM0 = 000                                                     CM2:CM0 = 111
              A      VIN-                                                       D       VIN-
   RA0/AN0                                                           RA0/AN0
              A      VIN+    C1          Off (Read as ‘0’)                      D       VIN+      C1          Off (Read as ‘0’)
   RA3/AN3                                                           RA3/AN3
              A      VIN-                                                       D       VIN-
   RA1/AN1                                                           RA1/AN1
              A      VIN+    C2          Off (Read as ‘0’)                      D       VIN+      C2          Off (Read as ‘0’)
   RA2/AN2                                                           RA2/AN2
                                                                   Two Independent Comparators with Outputs
 Two Independent Comparators
                                                                   CM2:CM0 = 011
 CM2:CM0 = 010
                                                                                A       VIN-
              A      VIN-                                            RA0/AN0
   RA0/AN0
                                                                                A       VIN+      C1          C1OUT
              A      VIN+    C1          C1OUT                       RA3/AN3
   RA3/AN3
                                                                     RA4/T0CKI/C1OUT
              A      VIN-
   RA1/AN1                                                                      A       VIN-
                                                                     RA1/AN1
              A      VIN+    C2          C2OUT                                                                C2OUT
   RA2/AN2                                                                      A       VIN+      C2
                                                                     RA2/AN2
                                                                     RA5/AN4/LVDIN/SS/C2OUT
 Two Common Reference Comparators                                  Two Common Reference Comparators with Outputs
 CM2:CM0 = 100                                                     CM2:CM0 = 101
              A      VIN-                                                       A       VIN-
   RA0/AN0                                                         RA0/AN0
              A      VIN+    C1          C1OUT                                  A       VIN+      C1          C1OUT
   RA3/AN3                                                         RA3/AN3
                                                                   RA4/T0CKI/C1OUT
              A      VIN-
   RA1/AN1
                             C2          C2OUT                                  A       VIN-
              D      VIN+                                          RA1/AN1
   RA2/AN2
                                                                                D       VIN+      C2          C2OUT
                                                                   RA2/AN2
                                                                   RA5/AN4/LVDIN/SS/C2OUT
 One Independent Comparator with Output                            Four Inputs Multiplexed to Two Comparators
 CM2:CM0 = 001                                                     CM2:CM0 = 110
              A      VIN-                                                       A
   RA0/AN0                                                           RA0/AN0            CIS = 0        VIN-
              A      VIN+    C1          C1OUT                       RA3/AN3    A       CIS = 1
   RA3/AN3                                                                                             VIN+   C1           C1OUT
   RA4/T0CKI/C1OUT                                                              A
                                                                     RA1/AN1            CIS = 0        VIN-
                                                                                A       CIS = 1
                                                                     RA2/AN2                           VIN+   C2           C2OUT
              D      VIN-
   RA1/AN1
              D      VIN+    C2          Off (Read as ‘0’)
   RA2/AN2                                                                                               CVREF From Comparator
                                                                                                               VREF Module
  A = Analog Input, port reads zeros always   D = Digital Input   CIS (CMCON<3>) is the Comparator Input Switch
DS30498B-page 162                                        Preliminary                               2003 Microchip Technology Inc.
                                                                                        PIC16F7X7
13.2       Comparator Operation                              13.3.2       INTERNAL REFERENCE SIGNAL
A single comparator is shown in Figure 13-2, along with      The comparator module also allows the selection of an
the relationship between the analog input levels and         internally generated voltage reference for the compara-
the digital output. When the analog input at VIN+ is less    tors. Section 14.0 “Comparator Voltage Reference
than the analog input VIN-, the output of the comparator     Module” contains a detailed description of the compar-
is a digital low level. When the analog input at VIN+ is     ator voltage reference module that provides this signal.
greater than the analog input VIN-, the output of the        The internal reference signal is used when comparators
comparator is a digital high level. The shaded areas of      are in mode CM<2:0> = 110 (Figure 13-1). In this
the output of the comparator in Figure 13-2 represent        mode, the internal voltage reference is applied to the
the uncertainty due to input offsets and response time.      VIN+ pin of both comparators.
13.3       Comparator Reference                              13.4     Comparator Response Time
An external or internal reference signal may be used         Response time is the minimum time after selecting a
depending on the comparator operating mode. The              new reference voltage or input source, before the
analog signal present at VIN- is compared to the signal      comparator output has a valid level. If the internal
at VIN+ and the digital output of the comparator is          reference is changed, the maximum delay of the inter-
adjusted accordingly (Figure 13-2).                          nal voltage reference must be considered when using
                                                             the comparator outputs. Otherwise, the maximum
                                                             delay of the comparators should be used (Section 18.0
FIGURE 13-2:           SINGLE COMPARATOR
                                                             “Electrical Characteristics”).
                                                             13.5     Comparator Outputs
       VIN+           +
                                          Output             The comparator outputs are read through the CMCON
       VIN-           –                                      register. These bits are read-only. The comparator
                                                             outputs may also be directly output to the RA4 and RA5
                                                             I/O pins. When enabled, multiplexors in the output path
                                                             of the RA4 and RA5 pins will switch and the output of
                                                             each pin will be the unsynchronized output of the com-
                                                             parator. The uncertainty of each of the comparators is
  VIN-
   VIN–
                                                             related to the input offset voltage and the response time
  VIN+
   VIN+                                                      given in the specifications. Figure 13-3 shows the
                                                             comparator output block diagram.
                                                             The TRISA bits will still function as an output enable/
  Output                                                     disable for the RA4 and RA5 pins while in this mode.
  Output
                                                             The polarity of the comparator outputs can be changed
                                                             using the C2INV and C1INV bits (CMCON<4:5>).
                                                                Note 1: When reading the Port register, all pins
13.3.1        EXTERNAL REFERENCE SIGNAL                                 configured as analog inputs will read as a
                                                                        ‘0’. Pins configured as digital inputs will
When external voltage references are used, the
                                                                        convert an analog input according to the
comparator module can be configured to have the com-
                                                                        Schmitt Trigger input specification.
parators operate from the same or different reference
sources. However, threshold detector applications may                 2: Analog levels on any pin defined as a dig-
require the same reference. The reference signal must                    ital input may cause the input buffer to
be between VSS and VDD and can be applied to either                      consume more current than is specified.
pin of the comparator(s).                                             3: RA4 is an open collector I/O pin. When
                                                                         used as an output, a pull-up resistor is
                                                                         required.
 2003 Microchip Technology Inc.                     Preliminary                                  DS30498B-page 163
PIC16F7X7
FIGURE 13-3:            COMPARATOR OUTPUT BLOCK DIAGRAM
                                                                                           Port pins
                                                                                          MULTIPLEX
                                                                                            +    -
                                                                                                            CxINV
                               To RA4 or
                               RA5 pin
                               Bus                            Q        D
                               Data
                                           Read CMCON             EN
                              Set
                              CMIF                                Q          D
                              bit               From
                                                Other                      EN
                                                Comparator
                                                                      CL            Read CMCON
                                                                                  Reset
13.6     Comparator Interrupts                                              Note:    If a change in the CMCON register
                                                                                     (C1OUT or C2OUT) should occur when a
The comparator interrupt flag is set whenever there is
                                                                                     read operation is being executed (start of
a change in the output value of either comparator.
                                                                                     the Q2 cycle), then the CMIF (PIR
Software will need to maintain information about the
                                                                                     registers) interrupt flag may not get set.
status of the output bits, as read from CMCON<7:6>, to
determine the actual change that occurred. The CMIF                    The user, in the Interrupt Service Routine, can clear the
bit (PIR registers) is the Comparator Interrupt Flag. The              interrupt in the following manner:
CMIF bit must be reset by clearing it (‘0’). Since it is
                                                                       a)       Any read or write of CMCON will end the
also possible to write a ‘1’ to this register, a simulated
                                                                                mismatch condition.
interrupt may be initiated.
                                                                       b)       Clear flag bit CMIF.
The CMIE bit (PIE registers) and the PEIE bit (INTCON
register) must be set to enable the interrupt. In addition,            A mismatch condition will continue to set flag bit CMIF.
the GIE bit must also be set. If any of these bits are                 Reading CMCON will end the mismatch condition and
clear, the interrupt is not enabled, though the CMIF bit               allow flag bit CMIF to be cleared.
will still be set if an interrupt condition occurs.
DS30498B-page 164                                     Preliminary                                       2003 Microchip Technology Inc.
                                                                                                  PIC16F7X7
13.7      Comparator Operation                                     13.9       Analog Input Connection
          During Sleep                                                        Considerations
When a comparator is active and the device is placed               A simplified circuit for an analog input is shown in
in Sleep mode, the comparator remains active and the               Figure 13-4. Since the analog pins are connected to a
interrupt is functional if enabled. This interrupt will            digital output, they have reverse biased diodes to VDD
wake-up the device from Sleep mode when enabled.                   and VSS. The analog input, therefore, must be between
While the comparator is powered up, higher Sleep                   VSS and VDD. If the input voltage deviates from this
currents than shown in the power-down current                      range by more than 0.6V in either direction, one of the
specification will occur. Each operational comparator              diodes is forward biased and a latch-up condition may
will consume additional current as shown in the com-               occur. A maximum source impedance of 10 kΩ is
parator specifications. To minimize power consumption              recommended for the analog sources. Any external
while in Sleep mode, turn off the comparators                      component connected to an analog input pin, such as
(CM<2:0> = 111) before entering Sleep. If the device               a capacitor or a Zener diode, should have very little
wakes up from Sleep, the contents of the CMCON                     leakage current.
register are not affected.
13.8      Effects of a Reset
A device Reset forces the CMCON register to its Reset
state, causing the comparator module to be in the
Comparator Off mode, CM<2:0> = 111. This ensures
compatibility to the PIC16F87X devices.
FIGURE 13-4:            ANALOG INPUT MODEL
                                                       VDD
                                                            VT = 0.6V                     RIC
                     RS < 10K
                             AIN
                                   CPIN                                       ILEAKAGE
              VA                                            VT = 0.6V         ±500 nA
                                   5 pF
                                                                            VSS
                Legend:     CPIN       =    Input Capacitance
                            VT         =    Threshold Voltage
                            ILEAKAGE   =    Leakage Current at the pin due to various junctions
                            RIC        =    Interconnect Resistance
                            RS         =    Source Impedance
                            VA         =    Analog Voltage
TABLE 13-1:         REGISTERS ASSOCIATED WITH COMPARATOR MODULE
                                                                                                                    Value on
                                                                                                         Value on
 Address      Name        Bit 7     Bit 6     Bit 5    Bit 4    Bit 3    Bit 2    Bit 1         Bit 0               all other
                                                                                                           POR
                                                                                                                     Resets
9Ch          CMCON      C2OUT      C1OUT     C2INV    C1INV     CIS       CM2     CM1           CM0     0000 0111 0000 0111
9Dh          CVRCON CVREN          CVROE     CVRR       —      CVR3     CVR2      CVR1          CVR0    000- 0000 000- 0000
0Bh, 8Bh, INTCON          GIE       PEIE    TMR0IE INT0IE       RBIE    TMR0IF   INT0IF         RBIF    0000 000x 0000 000u
10Bh,18Bh
0Dh          PIR2        OSFIF      CMIF      LVDIF     —      BCLIF      —      CCP3IF     CCP2IF      000- 0-00 000- 0-00
8Dh          PIE2        OSFIE      CMIE      LVDIE     —      BCLIE      —      CCP3IE     CCP2IE      000- 0-00 000- 0-00
05h          PORTA        RA7       RA6       RA5      RA4      RA3       RA2     RA1           RA0     xx0x 0000 uu0u 0000
85h          TRISA      TRISA7     TRISA6 PORTA Data Direction Register                                 1111 1111 1111 1111
Legend:     x = unknown, u = unchanged, - = unimplemented, read as ‘0’. Shaded cells are unused by the comparator module.
 2003 Microchip Technology Inc.                      Preliminary                                          DS30498B-page 165
PIC16F7X7
NOTES:
DS30498B-page 166   Preliminary    2003 Microchip Technology Inc.
                                                                                                PIC16F7X7
14.0     COMPARATOR VOLTAGE                                          supply voltage (also referred to as CVRSRC) comes
                                                                     directly from VDD. It should be noted, however, that the
         REFERENCE MODULE                                            voltage at the top of the ladder is CVRSRC – VSAT,
The comparator voltage reference generator is a 16-tap               where VSAT is the saturation voltage of the power
resistor ladder network that provides a fixed voltage                switch transistor. This reference will only be as
reference when the comparators are in mode ‘110’. A                  accurate as the values of CVRSRC and VSAT.
programmable register controls the function of the                   The output of the reference generator may be
reference generator. Register 14-1 lists the bit functions           connected to the RA2/AN2/VREF-/CVREF pin. This can
of the CVRCON register.                                              be used as a simple D/A function by the user if a very
As shown in Figure 14-1, the resistor ladder is seg-                 high-impedance load is used. The primary purpose of
mented to provide two ranges of CVREF values and has                 this function is to provide a test path for testing the
a power-down function to conserve power when the                     reference generator function.
reference is not being used. The comparator reference
REGISTER 14-1:          CVRCON CONTROL REGISTER (ADDRESS 9Dh)
                           R/W-0       R/W-0        R/W-0          U-0        R/W-0        R/W-0       R/W-0       R/W-0
                          CVREN       CVROE         CVRR            —          CVR3        CVR2        CVR1        CVR0
                         bit 7                                                                                         bit 0
            bit 7        CVREN: Comparator Voltage Reference Enable bit
                         1 = CVREF circuit powered on
                         0 = CVREF circuit powered down
            bit 6        CVROE: Comparator VREF Output Enable bit
                         1 = CVREF voltage level is output on RA2/AN2/VREF-/CVREF pin
                         0 = CVREF voltage level is disconnected from RA2/AN2/VREF-/CVREF pin
            bit 5        CVRR: Comparator VREF Range Selection bit
                         1 = 0 to 0.75 CVRSRC, with CVRSRC/24 step size
                         0 = 0.25 CVRSRC to 0.75 CVRSRC, with CVRSRC/32 step size
            bit 4        Unimplemented: Read as ‘0’
            bit 3-0      CVR3:CVR0: Comparator VREF Value Selection bits 0 ≤ VR3:VR0 ≤ 15
                         When CVRR = 1:
                         CVREF = (CVR<3:0>/24) • (CVRSRC)
                         When CVRR = 0:
                         CVREF = 1/4 • (CVRSRC) + (CVR3:CVR0/32) • (CVRSRC)
                         Legend:
                         R = Readable bit              W = Writable bit       U = Unimplemented bit, read as ‘0’
                         -n = Value at POR             ‘1’ = Bit is set       ‘0’ = Bit is cleared   x = Bit is unknown
 2003 Microchip Technology Inc.                      Preliminary                                        DS30498B-page 167
PIC16F7X7
FIGURE 14-1:             COMPARATOR VOLTAGE REFERENCE BLOCK DIAGRAM
                             VDD
                                                                16 Stages
        CVREN
                                      8R        R           R                   R      R
                                                                                                    8R           CVRR
       RA2/AN2/VREF-/CVREF
                            CVROE
                                                                                                    CVR3
          CVREF                                                                                     CVR2
                                                                 16:1 Analog MUX
         Input to                                                                                   CVR1
      Comparator                                                                                    CVR0
TABLE 14-1:          REGISTERS ASSOCIATED WITH COMPARATOR VOLTAGE REFERENCE
                                                                                                                  Value on
                                                                                                     Value on
Address       Name       Bit 7     Bit 6     Bit 5     Bit 4     Bit 3      Bit 2   Bit 1   Bit 0                 all other
                                                                                                       POR
                                                                                                                   Resets
9Dh         CVRCON      CVREN      CVROE    CVRR        —       CVR3        CVR2    CVR1    CVR0    000- 0000 000- 0000
9Ch         CMCON       C2OUT      C1OUT    C2INV     C1INV      CIS        CM2     CM1     CM0     0000 0111 0000 0111
Legend:      x = unknown, u = unchanged, - = unimplemented, read as ‘0’.
             Shaded cells are not used with the comparator voltage reference.
DS30498B-page 168                                       Preliminary                          2003 Microchip Technology Inc.
                                                                                        PIC16F7X7
15.0     SPECIAL FEATURES OF THE                              Sleep mode is designed to offer a very low current
                                                              power-down mode. The user can wake-up from Sleep
         CPU
                                                              through external Reset, Watchdog Timer Wake-up or
These devices have a host of features intended to max-        through an interrupt.
imize system reliability, minimize cost through elimina-      Several oscillator options are also made available to
tion of external components, provide power saving             allow the part to fit the application. The RC oscillator
operating modes and offer code protection:                    option saves system cost while the LP crystal option
• Reset                                                       saves power. Configuration bits are used to select the
  - Power-on Reset (POR)                                      desired oscillator mode.
  - Power-up Timer (PWRT)                                     Additional information on special features is available
  - Oscillator Start-up Timer (OST)                           in the PICmicro® Mid-Range MCU Family Reference
                                                              Manual (DS33023).
  - Brown-out Reset (BOR)
  - Low-Voltage Detect (LVD)
                                                              15.1     Configuration Bits
• Interrupts
• Watchdog Timer (WDT)                                        The configuration bits can be programmed (read as ‘0’)
• Two-Speed Start-up                                          or left unprogrammed (read as ‘1’) to select various
                                                              device configurations. These bits are mapped in
• Fail-Safe Clock Monitor
                                                              program memory locations 2007h and 2008h.
• Sleep
                                                              The user will note that address 2007h is beyond the
• Code Protection
                                                              user program memory space which can be accessed
• ID Locations                                                only during programming.
• In-Circuit Serial Programming
There are two timers that offer necessary delays on
power-up. One is the Oscillator Start-up Timer (OST),
intended to keep the chip in Reset until the crystal oscil-
lator is stable. The other is the Power-up Timer
(PWRT), which provides a fixed delay of 72 ms (nomi-
nal) on power-up only. It is designed to keep the part in
Reset while the power supply stabilizes and is enabled
or disabled using a configuration bit. With these two
timers on-chip, most applications need no external
Reset circuitry.
 2003 Microchip Technology Inc.                      Preliminary                                 DS30498B-page 169
PIC16F7X7
REGISTER 15-1:         CONFIGURATION WORD REGISTER 1 (ADDRESS 2007h)
R/P-1 R/P-1       R/P-1    U-1   U-1    R/P-1    R/P-1        R/P-1   R/P-1   R/P-1      R/P-1      R/P-1    R/P-1    R/P-1
 CP       CCPMX DEBUG      —      —    BORV1 BORV0 BOREN MCLRE FOSC2 PWRTEN WDTEN FOSC1 FOSC0
bit 13                                                                                                                  bit 0
bit 13     CP: Flash Program Memory Code Protection bits
           1 = Code protection off
           0 = 0000h to 1FFFh code-protected for PIC16F767/777 and 0000h to 0FFFh for PIC16F737/747 (all protected)
bit 12     CCPMX: CCP2 Multiplex bit
           1 = CCP2 is on RC1
           0 = CCP2 is on RB3
bit 11     DEBUG: In-Circuit Debugger Mode bit
           1 = In-circuit debugger disabled, RB6 and RB7 are general purpose I/O pins
           0 = In-circuit debugger enabled, RB6 and RB7 are dedicated to the debugger
bit 10-9 Unimplemented: Read as ‘1’
bit 8-7    BORV<1:0>: Brown-out Reset Voltage bits
           11 = VBOR set to 2.0V
           10 = VBOR set to 2.7V
           01 = VBOR set to 4.2V
           00 = VBOR set to 4.5V
bit 6      BOREN: Brown-out Reset Enable bit
           BOREN combines with BORSEN to control when BOR is enabled and how it is controlled.
           BOREN:BORSEN:
           11 = BOR enabled and always on
           10 = BOR enabled during operation and disabled during Sleep by hardware
           01 = BOR controlled by software bit SBOREN (refer to PCON register (Register 2-8), bit 2)
           00 = BOR disabled
bit 5      MCLRE: MCLR/VPP/RE3 Pin Function Select bit
           1 = MCLR/VPP/RE3 pin function is MCLR
           0 = MCLR/VPP/RE3 pin function is digital input only, MCLR gated to ‘1’
bit 3      PWRTEN: Power-up Timer Enable bit
           1 = PWRT disabled
           0 = PWRT enabled
bit 2      WDTEN: Watchdog Timer Enable bit
           1 = WDT enabled
           0 = WDT disabled
bit 4, 1-0 FOSC2:FOSC0: Oscillator Selection bits
           111 = EXTRC oscillator; CLKO function on OSC2/CLKO/RA6
           110 = EXTRC oscillator; port I/O function on OSC2/CLKO/RA6
           101 = INTRC oscillator; CLKO function on OSC2/CLKO/RA6 and port I/O function on OSC1/CLKI/RA7
           100 = INTRC oscillator; port I/O function on OSC1/CLKI/RA7 and OSC2/CLKO/RA6
           011 = EXTCLK; port I/O function on OSC2/CLKO/RA6
           010 = HS oscillator
           001 = XT oscillator
           000 = LP oscillator
            Legend:
            R = Readable bit               W = Writable bit            U = Unimplemented bit, read as ‘0’
            -n = Value at POR              ‘1’ = Bit is set            ‘0’ = Bit is cleared        x = Bit is unknown
DS30498B-page 170                                   Preliminary                                2003 Microchip Technology Inc.
                                                                                                   PIC16F7X7
REGISTER 15-2:          CONFIGURATION WORD REGISTER 2 (ADDRESS 2008h)
  U-1     U-1     U-1      U-1     U-1      U-1     U-1         R/P-1     U-1      U-1         U-1     U-1     R/P-1   R/P-1
   —       —       —       —        —       —        —         BORSEN     —         —          —       —       IESO FCMEN
bit 13                                                                                                                    bit 0
bit 13-7 Unimplemented: Read as ‘1’
bit 6     BORSEN: Brown-out Reset Software Enable bit
          Refer to Configuration Word Register 1, bit 6 for the function of this bit.
bit 5-2   Unimplemented: Read as ‘1’
bit 1     IESO: Internal External Switch Over bit
          1 = Internal External Switch Over mode enabled
          0 = Internal External Switch Over mode disabled
bit 0     FCMEN: Fail-Safe Clock Monitor Enable bit
          1 = Fail-Safe Clock Monitor enabled
          0 = Fail-Safe Clock Monitor disabled
           Legend:
           R = Readable bit                 W = Writable bit            U = Unimplemented bit, read as ‘0’
           -n = Value at POR                ‘1’ = Bit is set            ‘0’ = Bit is cleared         x = Bit is unknown
 2003 Microchip Technology Inc.                     Preliminary                                             DS30498B-page 171
PIC16F7X7
15.2       Reset                                                                 Some registers are not affected in any Reset condition.
                                                                                 Their status is unknown on POR and unchanged in any
The PIC16F7X7 differentiates between various kinds of                            other Reset. Most other registers are reset to a “Reset
Reset:                                                                           state” on Power-on Reset (POR), on the MCLR and
•   Power-on Reset (POR)                                                         WDT Reset, on MCLR Reset during Sleep and Brown-
•   MCLR Reset during normal operation                                           out Reset (BOR). They are not affected by a WDT
                                                                                 wake-up which is viewed as the resumption of normal
•   MCLR Reset during Sleep
                                                                                 operation. The TO and PD bits are set or cleared differ-
•   WDT Reset during normal operation                                            ently in different Reset situations, as indicated in
•   WDT Wake-up during Sleep                                                     Table 15-3. These bits are used in software to deter-
•   Brown-out Reset (BOR)                                                        mine the nature of the Reset. Upon a POR, BOR or
                                                                                 wake-up from Sleep, the CPU requires approximately
                                                                                 5-10 µs to become ready for code execution. This
                                                                                 delay runs in parallel with any other timers. See
                                                                                 Table 15-4 for a full description of Reset states of all
                                                                                 registers.
                                                                                 A simplified block diagram of the on-chip Reset circuit
                                                                                 is shown in Figure 15-1.
FIGURE 15-1:                    SIMPLIFIED BLOCK DIAGRAM OF ON-CHIP RESET CIRCUIT
                                           External
                                           Reset
    MCLR/VPP/RE3 pin
                                             Sleep
                            WDT        WDT
                           Module      Time-out
                                       Reset
                          VDD Rise
                           Detect
                                          Power-on Reset
          VDD
                          Brown-out
                            Detect       BOREN
                                        BORSEN                                                                           S
                     OST/PWRT
                                 OST
                                                                                                                                  Chip_Reset
                                      10-bit Ripple Counter                                                              R    Q
         OSC1/
        CLKI pin
                                  PWRT
                     INTRC(1)          11-bit Ripple Counter
                                                                                                        Enable PWRT
                                                                                                        Enable OST
     Note 1:    This is the 32 kHz INTRC oscillator. See Section 4.0 “Oscillator Configurations” for more information.
DS30498B-page 172                                                Preliminary                                    2003 Microchip Technology Inc.
                                                                                       PIC16F7X7
15.3      MCLR                                               15.5     Power-up Timer (PWRT)
PIC16F7X7 devices have a noise filter in the MCLR            The Power-up Timer (PWRT) of the PIC16F7X7 is a
Reset path. The filter will detect and ignore small          counter that uses the INTRC oscillator as the clock
pulses.                                                      input. This yields a count of 72 ms. While the PWRT is
It should be noted that a WDT Reset does not drive           counting, the device is held in Reset.
MCLR pin low.                                                The power-up time delay depends on the INTRC and
The behavior of the ESD protection on the MCLR pin           will vary from chip-to-chip due to temperature and
has been altered from previous devices of this family.       process variation. See DC parameter #33 for details.
Voltages applied to the pin that exceed its specification    The PWRT is enabled by clearing configuration bit
can result in both MCLR and excessive current beyond         PWRTEN.
the device specification during the ESD event. For this
reason, Microchip recommends that the MCLR pin no            15.6     Oscillator Start-up Timer (OST)
longer be tied directly to VDD. The use of an
RC network, as shown in Figure 15-2, is suggested.           The Oscillator Start-up Timer (OST) provides 1024
                                                             oscillator cycles (from OSC1 input) delay after the
The MCLR/VPP/RE3 pin can be configured for MCLR
                                                             PWRT delay is over (if enabled). This helps to ensure
(default) or as an input pin (RE3). This is configured
                                                             that the crystal oscillator or resonator has started and
through the MCLRE bit in Configuration Word
                                                             stabilized.
Register 1.
                                                             The OST time-out is invoked only for XT, LP and HS
FIGURE 15-2:               RECOMMENDED MCLR                  modes and only on Power-on Reset or wake-up from
                                                             Sleep.
                           CIRCUIT
    VDD                                                      15.7     Brown-out Reset (BOR)
                                       PIC16F7X7
                                                             Three configuration bits (BOREN – Configuration Word
          R1                                                 Register 1, bit 6; BORSEN – Configuration Word Reg-
          1 kΩ (or greater)                                  ister 2, bit 6; SBOREN – PCON, bit 2) together disable
                                     MCLR                    or enable the Brown-out Reset circuit in one of its three
                                                             operating modes.
          C1
          0.1 µF                                             If VDD falls below VBOR (defined by BORV<1:0> bits in
          (optional, not critical)                           Configuration Word Register 1) for longer than TBOR
                                                             (parameter #35, about 100 µs), the brown-out situation
                                                             will reset the device. If VDD falls below VBOR for less
                                                             than TBOR, a Reset may not occur.
15.4      Power-on Reset (POR)                               Once the brown-out occurs, the device will remain in
A Power-on Reset pulse is generated on-chip when             Brown-out Reset until VDD rises above VBOR. The
VDD rise is detected (in the range of 1.2V-1.7V). To take    Power-up Timer (if enabled) will keep the device in
advantage of the POR, tie the MCLR pin to VDD, as            Reset for TPWRT (parameter #33, about 72 ms). If VDD
described in Section 15.3 “MCLR”. A maximum rise             should fall below VBOR during TPWRT, the Brown-out
time for VDD is specified. See Section 18.0 “Electrical      Reset process will restart when VDD rises above VBOR
Characteristics” for details.                                with the Power-up Timer Reset. Unlike previous PIC16
                                                             devices, the PWRT is no longer automatically enabled
When the device starts normal operation (exits the           when the Brown-out Reset circuit is enabled. The
Reset condition), device operating parameters (volt-         PWRTEN and BOREN configuration bits are
age, frequency, temperature,...) must be met to ensure       independent of each other.
operation. If these conditions are not met, the device
must be held in Reset until the operating conditions are
met. For more information, see Application Note
AN607, “Power-up Trouble Shooting” (DS00607).
 2003 Microchip Technology Inc.                     Preliminary                                  DS30498B-page 173
PIC16F7X7
15.8      Low-Voltage Detect                                      time TA. The application software then has the time,
                                                                  until the device voltage is no longer in valid operating
In many applications, the ability to determine if the             range, to shut down the system. Voltage point VB is the
device voltage (VDD) is below a specified voltage level           minimum valid operating voltage specification. This
is a desirable feature. A window of operation for the             occurs at time TB. The difference, TB – TA, is the total
application can be created, where the application soft-           time for shutdown.
ware can do “housekeeping tasks” before the device
voltage exits the valid operating range. This can be              The block diagram for the LVD module is shown in
done using the Low-Voltage Detect module.                         Figure 15-4. A comparator uses an internally gener-
                                                                  ated reference voltage as the set point. When the
This module is a software programmable circuitry,                 selected tap output of the device voltage crosses the
where a device voltage trip point can be specified.               set point (is lower than), the LVDIF bit is set.
When the voltage of the device becomes lower then the
specified point, an interrupt flag is set. If the interrupt is    Each node in the resistor divider represents a “trip
enabled, the program execution will branch to the inter-          point” voltage. The “trip point” voltage is the minimum
rupt vector address and the software can then respond             supply voltage level at which the device can operate
to that interrupt source.                                         before the LVD module asserts an interrupt. When the
                                                                  supply voltage is equal to the trip point, the voltage
The Low-Voltage Detect circuitry is completely under              tapped off of the resistor array is equal to the 1.2V
software control. This allows the circuitry to be turned          internal reference voltage generated by the voltage ref-
off by the software which minimizes the current                   erence module. The comparator then generates an
consumption for the device.                                       interrupt signal setting the LVDIF bit. This voltage is
Figure 15-3 shows a possible application voltage curve            software programmable to any one of 16 values (see
(typically for batteries). Over time, the device voltage          Figure 15-4). The trip point is selected by programming
decreases. When the device voltage equals voltage VA,             the LVDL3:LVDL0 bits (LVDCON<3:0>).
the LVD logic generates an interrupt. This occurs at
FIGURE 15-3:                      TYPICAL LOW-VOLTAGE DETECT APPLICATION
                             VA
                             VB
                   Voltage
                                                                          Legend:
                                                                             VA = LVD trip point
                                                                             VB = Minimum valid device
                                                                                  operating voltage
                                                     TA     TB
                                            Time
DS30498B-page 174                                         Preliminary                      2003 Microchip Technology Inc.
                                                                                                       PIC16F7X7
FIGURE 15-4:           LOW-VOLTAGE DETECT (LVD) BLOCK DIAGRAM
                                 VDD     LVDIN
                                                                                        LVD Control
                                                                                          Register
                                                          16 to 1 MUX
                                                                                                      LVDIF
                   LVDEN                     Internally Generated
                                             Reference Voltage
                                             1.2V
The LVD module has an additional feature that allows                       pin, LVDIN (Figure 15-5). This gives users flexibility
the user to supply the sense voltage to the module                         because it allows them to configure the Low-Voltage
from an external source. This mode is enabled when                         Detect interrupt to occur at any voltage in the valid
bits LVDL3:LVDL0 are set to ‘1111’. In this state, the                     operating range.
comparator input is multiplexed from the external input
FIGURE 15-5:           LOW-VOLTAGE DETECT (LVD) WITH EXTERNAL INPUT BLOCK DIAGRAM
                           VDD
                                                   VDD
                                                                                                  LVD Control
                                                                                                   Register
                                                                        16 to 1 MUX
                                 LVDIN                                                                        LVDEN
    Externally Generated
         Trip Point
                                                                                                                      LVD
                                                                                      VxEN
                                                                                      BODEN
                                             EN
                                                                                               BGAP
 2003 Microchip Technology Inc.                   Preliminary                                                   DS30498B-page 175
PIC16F7X7
15.9    Control Register
The Low-Voltage Detect Control register controls the
operation of the Low-Voltage Detect circuitry.
REGISTER 15-3:         LVDCON REGISTER
                           U-0         U-0         R-0         R/W-0       R/W-0        R/W-1       R/W-0       R/W-1
                           —           —          IRVST       LVDEN        LVDL3        LVDL2       LVDL1       LVDL0
                       bit 7                                                                                        bit 0
             bit 7-6   Unimplemented: Read as ‘0’
             bit 5     IRVST: Internal Reference Voltage Stable Flag bit
                       1 = Indicates that the Low-Voltage Detect logic will generate the interrupt flag at the specified
                           voltage range
                       0 = Indicates that the Low-Voltage Detect logic will not generate the interrupt flag at the
                           specified voltage range and the LVD interrupt should not be enabled
             bit 4     LVDEN: Low-Voltage Detect Power Enable bit
                       1 = Enables LVD, powers up LVD circuit
                       0 = Disables LVD, powers down LVD circuit
             bit 3-0   LVDL3:LVDL0: Low-Voltage Detection Limit bits
                       1111 = External analog input is used (input comes from the LVDIN pin)
                       1110 = 4.50V-4.78V
                       1101 = 4.20V-4.46V
                       1100 = 4.00V-4.26V
                       1011 = 3.80V-4.04V
                       1010 = 3.60V-3.84V
                       1001 = 3.50V-3.72V
                       1000 = 3.30V-3.52V
                       0111 = 3.00V-3.20V
                       0110 = 2.80V-2.98V
                       0101 = 2.70V-2.86V
                       0100 = 2.50V-2.66V
                       0011 = 2.40V-2.55V
                       0010 = 2.20V-2.34V
                       0001 = Reserved
                       0000 = Reserved
                         Note:     LVDL3:LVDL0 modes which result in a trip point below the valid operating voltage
                                   of the device are not tested.
                        Legend:
                        R = Readable bit            W = Writable bit       U = Unimplemented bit, read as ‘0’
                        - n = Value at POR          ‘1’ = Bit is set       ‘0’ = Bit is cleared    x = Bit is unknown
DS30498B-page 176                                  Preliminary                             2003 Microchip Technology Inc.
                                                                                               PIC16F7X7
15.10 Operation                                                    The following steps are needed to set up the LVD
                                                                   module:
Depending on the power source for the device voltage,
the voltage normally decreases relatively slowly. This             1.   Write the value to the LVDL3:LVDL0 bits
means that the LVD module does not need to be con-                      (LVDCON register) which selects the desired
stantly operating. To decrease the current require-                     LVD trip point.
ments, the LVD circuitry only needs to be enabled for              2.   Ensure that LVD interrupts are disabled (the
short periods where the voltage is checked. After doing                 LVDIE bit is cleared or the GIE bit is cleared).
the check, the LVD module may be disabled.                         3.   Enable the LVD module (set the LVDEN bit in
Each time that the LVD module is enabled, the circuitry                 the LVDCON register).
requires some time to stabilize. After the circuitry has           4.   Wait for the LVD module to stabilize (the IRVST
stabilized, all status flags may be cleared. The module                 bit to become set).
will then indicate the proper state of the system.                 5.   Clear the LVD interrupt flag, which may have
                                                                        falsely become set, until the LVD module has
                                                                        stabilized (clear the LVDIF bit).
                                                                   6.   Enable the LVD interrupt (set the LVDIE and the
                                                                        GIE bits).
                                                                   Figure 15-6 shows typical waveforms that the LVD
                                                                   module may be used to detect.
FIGURE 15-6:               LOW-VOLTAGE DETECT WAVEFORMS
        CASE 1:
                                                           LVDIF may not be set
                   VDD
                                                                                                           VLVD
                  LVDIF
            Enable LVD
    Internally Generated                              TIVRST
        Reference Stable
                                                                                                LVDIF cleared in software
        CASE 2:
                   VDD
                                                                                                           VLVD
                  LVDIF
            Enable LVD
    Internally Generated                              TIVRST
        Reference Stable
                                                                                      LVDIF cleared in software
                                                                   LVDIF cleared in software,
                                                                   LVDIF remains set since LVD condition still exists
 2003 Microchip Technology Inc.                    Preliminary                                           DS30498B-page 177
PIC16F7X7
15.10.1     REFERENCE VOLTAGE SET POINT                       15.13 Time-out Sequence
The internal reference voltage of the LVD module may          On power-up, the time-out sequence is as follows: the
be used by other internal circuitry (the Programmable         PWRT delay starts (if enabled) when a POR occurs.
Brown-out Reset). If these circuits are disabled (lower       Then, OST starts counting 1024 oscillator cycles when
current consumption), the reference voltage circuit           PWRT ends (LP, XT, HS). When the OST ends, the
requires a time to become stable before a low-voltage         device comes out of Reset.
condition can be reliably detected. This time is invariant
of system clock speed. This start-up time is specified in     If MCLR is kept low long enough, all delays will expire.
electrical specification parameter #36. The low-voltage       Bringing MCLR high will begin execution immediately.
interrupt flag will not be enabled until a stable reference   This is useful for testing purposes or to synchronize
voltage is reached. Refer to the waveform in Figure 15-6.     more than one PIC16F7X7 device operating in parallel.
                                                              Table 15-3 shows the Reset conditions for the Status,
15.10.2     CURRENT CONSUMPTION                               PCON and PC registers, while Table 15-4 shows the
When the module is enabled, the LVD comparator and            Reset conditions for all the registers.
voltage divider are enabled and will consume static cur-
rent. The voltage divider can be tapped from multiple         15.14 Power Control/Status Register
places in the resistor array. Total current consumption,            (PCON)
when enabled, is specified in electrical specification
parameter #D022B.                                             The Power Control/Status register, PCON, has two bits
                                                              to indicate the type of Reset that last occurred.
15.11 Operation During Sleep                                  Bit 0 is Brown-out Reset Status bit, BOR. Bit BOR is
                                                              unknown on a Power-on Reset. It must then be set by
When enabled, the LVD circuitry continues to operate          the user and checked on subsequent Resets to see if
during Sleep. If the device voltage crosses the trip          bit BOR cleared, indicating a Brown-out Reset
point, the LVDIF bit will be set and the device will wake-    occurred. When the Brown-out Reset is disabled, the
up from Sleep. Device execution will continue from the        state of the BOR bit is unpredictable.
interrupt vector address if interrupts have been globally
enabled.                                                      Bit 1 is Power-on Reset Status bit, POR. It is cleared on
                                                              a Power-on Reset and unaffected otherwise. The user
                                                              must set this bit following a Power-on Reset.
15.12 Effects of a Reset
A device Reset forces all registers to their Reset state.
This forces the LVD module to be turned off.
  Note:     If the LVD is enabled and the BOR module
            is not enabled, the band gap will require a
            start-up time of no more than 50 µs before
            the band gap reference is stable. Before
            enabling the LVD interrupt, the user
            should ensure that the band gap reference
            voltage is stable by monitoring the IRVST
            bit in the LVDCON register. The LVD could
            cause erroneous interrupts before the
            band gap is stable.
DS30498B-page 178                                     Preliminary                      2003 Microchip Technology Inc.
                                                                                             PIC16F7X7
TABLE 15-1:       TIME-OUT IN VARIOUS SITUATIONS
                                           Power-up                     Brown-out Reset              Wake-up from
 Oscillator Configuration
                                   PWRTE = 0     PWRTE = 1          PWRTE = 0      PWRTE = 1            Sleep
XT, HS, LP                          TPWRT +      1024 • TOSC         TPWRT +       1024 • TOSC         1024 • TOSC
                                   1024 • TOSC                      1024 • TOSC
EXTRC, INTRC                         TPWRT        5-10 µs(1)          TPWRT         5-10 µs(1)          5-10 µs(1)
T1OSC                                  —              —                 —                —              5-10 µs(1)
Note 1:     CPU start-up is always invoked on POR, BOR and wake-up from Sleep. The 5 µs-10 µs delay is based on
            a 1 MHz system clock.
TABLE 15-2:       STATUS BITS AND THEIR SIGNIFICANCE
   POR          BOR          TO            PD
     0            x           1              1   Power-on Reset
     0            x           0              x   Illegal, TO is set on POR
     0            x           x              0   Illegal, PD is set on POR
     1            0           1              1   Brown-out Reset
     1            1           0              1   WDT Reset
     1            1           0              0   WDT Wake-up
     1            1           u              u   MCLR Reset during normal operation
     1            1           1              0   MCLR Reset during Sleep or Interrupt Wake-up from Sleep
Legend: u = unchanged, x = unknown
TABLE 15-3:       RESET CONDITION FOR SPECIAL REGISTERS
                                                          Program              Status                  PCON
                      Condition
                                                          Counter             Register                Register
Power-on Reset                                              000h            0001 1xxx                ---- --0x
MCLR Reset during normal operation                          000h            000u uuuu                ---- --uu
MCLR Reset during Sleep                                     000h            0001 0uuu                ---- --uu
WDT Reset                                                   000h            0000 1uuu                ---- --uu
WDT Wake-up                                                PC + 1           uuu0 0uuu                ---- --uu
Brown-out Reset                                             000h            0001 1uuu                ---- --u0
Interrupt Wake-up from Sleep                              PC + 1(1)         uuu1 0uuu                ---- --uu
Legend: u = unchanged, x = unknown, - = unimplemented bit, read as ‘0’
Note 1: When the wake-up is due to an interrupt and the GIE bit is set, the PC is loaded with the interrupt vector
        (0004h).
 2003 Microchip Technology Inc.                   Preliminary                                       DS30498B-page 179
PIC16F7X7
TABLE 15-4:      INITIALIZATION CONDITIONS FOR ALL REGISTERS
                               Power-on Reset,                MCLR Reset,                 Wake-up via WDT or
        Register
                               Brown-out Reset                 WDT Reset                       Interrupt
W                                 xxxx xxxx                    uuuu uuuu                       uuuu uuuu
INDF                                  N/A                          N/A                             N/A
TMR0                              xxxx xxxx                    uuuu uuuu                       uuuu uuuu
PCL                                  0000h                        0000h                         PC + 1(2)
                                                                           (3)
STATUS                            0001 1xxx                    000q quuu                       uuuq quuu(3)
FSR                               xxxx xxxx                    uuuu uuuu                       uuuu uuuu
PORTA                             xx0x 0000                    uu0u 0000                       uuuu uuuu
PORTB                             xx00 0000                    uu00 0000                       uuuu uuuu
PORTC                             xxxx xxxx                    uuuu uuuu                       uuuu uuuu
PORTD                             xxxx xxxx                    uuuu uuuu                       uuuu uuuu
PORTE (PIC16F737/767)             ---- x---                    ---- u---                       ---- u---
PORTE (PIC16F747/777)             ---- x000                    ---- u000                       ---- uuuu
PCLATH                            ---0 0000                    ---0 0000                       ---u uuuu
INTCON                            0000 000x                    0000 000u                       uuuu uuuu(1)
PIR1                              0000 0000                    0000 0000                       uuuu uuuu(1)
PIR2                              000- 0-00                    000- 0-00                       uuu- u-uu
TMR1L                             xxxx xxxx                    uuuu uuuu                       uuuu uuuu
TMR1H                             xxxx xxxx                    uuuu uuuu                       uuuu uuuu
T1CON                             -000 0000                    -uuu uuuu                       -uuu uuuu
TMR2                              0000 0000                    0000 0000                       uuuu uuuu
T2CON                             -000 0000                    -000 0000                       -uuu uuuu
SSPBUF                            xxxx xxxx                    uuuu uuuu                       uuuu uuuu
SSPCON                            0000 0000                    0000 0000                       uuuu uuuu
SSPCON2                           0000 0000                    0000 0000                       uuuu uuuu
CCPR1L                            xxxx xxxx                    uuuu uuuu                       uuuu uuuu
CCPR1H                            xxxx xxxx                    uuuu uuuu                       uuuu uuuu
CCP1CON                           --00 0000                    --00 0000                       --uu uuuu
CCP2CON                           --00 0000                    --00 0000                       --uu uuuu
CCP3CON                           --00 0000                    --00 0000                       uuuu uuuu
CCPR2L                            xxxx xxxx                    uuuu uuuu                       uuuu uuuu
CCPR2H                            xxxx xxxx                    uuuu uuuu                       uuuu uuuu
CCPR3L                            xxxx xxxx                    uuuu uuuu                       uuuu uuuu
CCPR3H                            xxxx xxxx                    uuuu uuuu                       uuuu uuuu
RCSTA                             0000 000x                    0000 000x                       uuuu uuuu
TXREG                             0000 0000                    0000 0000                       uuuu uuuu
RCREG                             0000 0000                    0000 0000                       uuuu uuuu
ADRESH                            xxxx xxxx                    uuuu uuuu                       uuuu uuuu
ADCON0                            0000 0000                    0000 0000                       uuuu uuuu
OPTION                            1111 1111                    1111 1111                       uuuu uuuu
Legend: u = unchanged, x = unknown, - = unimplemented bit, read as ‘0’, q = value depends on condition,
        r = reserved, maintain clear
Note 1: One or more bits in INTCON, PIR1 and PR2 will be affected (to cause wake-up).
     2: When the wake-up is due to an interrupt and the GIE bit is set, the PC is loaded with the interrupt vector
        (0004h).
     3: See Table 15-3 for Reset value for specific condition.
DS30498B-page 180                                Preliminary                           2003 Microchip Technology Inc.
                                                                                       PIC16F7X7
TABLE 15-4:       INITIALIZATION CONDITIONS FOR ALL REGISTERS (CONTINUED)
                                   Power-on Reset,            MCLR Reset,                 Wake-up via WDT or
         Register
                                   Brown-out Reset             WDT Reset                       Interrupt
TRISA                                1111 1111                 1111 1111                      uuuu uuuu
TRISB                                1111 1111                 1111 1111                      uuuu uuuu
TRISC                                1111 1111                 1111 1111                      uuuu uuuu
TRISD                                1111 1111                 1111 1111                      uuuu uuuu
TRISE (PIC16F737/767)                ---- 1---                 ---- u---                      ---- 1---
TRISE (PIC16F747/777)                0000 1111                 0000 1111                      uuuu uuuu
PIE1                                 0000 0000                 0000 0000                      -uuu uuuu
PIE2                                 000- 0-00                 000- 0-00                      uuu- u-uu
PCON                                 ---- -1qq                 ---- -uuu                      ---- -uuu
OSCCON                               -000 1000                 -000 1000                      -uuu uuuu
OSCTUNE                              --00 0000                 --00 0000                      --uu uuuu
PR2                                  1111 1111                 1111 1111                      1111 1111
SSPADD                               0000 0000                 0000 0000                      uuuu uuuu
SSPSTAT                              0000 0000                 0000 0000                      uuuu uuuu
TXSTA                                0000 -010                 0000 -010                      uuuu -u1u
SPBRG                                0000 0000                 0000 0000                      uuuu uuuu
CMCON                                0000 0111                 0000 0111                      uuuu uuuu
CVRCON                               000- 0000                 000- 0000                      uuu- uuuu
WDTCON                               ---0 1000                 ---0 1000                      ---u uuuu
ADRESL                               xxxx xxxx                 uuuu uuuu                      uuuu uuuu
ADCON1                               0000 0000                 0000 0000                      uuuu uuuu
ADCON2                               --00 0---                 --00 0---                      uuuu uuuu
PMDATA                               xxxx xxxx                 uuuu uuuu                      uuuu uuuu
PMADR                                xxxx xxxx                 uuuu uuuu                      uuuu uuuu
PMDATH                               --xx xxxx                 --uu uuuu                      --uu uuuu
PMADRH                               ---- xxxx                 ---- uuuu                      ---- uuuu
PMCON1                               ---- ---0                 ---- ---u                      ---- ---u
LVDCON                               --00 0101                 --00 0101                      --uu uuuu
Legend: u = unchanged, x = unknown, - = unimplemented bit, read as ‘0’, q = value depends on condition,
        r = reserved, maintain clear
Note 1: One or more bits in INTCON, PIR1 and PR2 will be affected (to cause wake-up).
     2: When the wake-up is due to an interrupt and the GIE bit is set, the PC is loaded with the interrupt vector
        (0004h).
     3: See Table 15-3 for Reset value for specific condition.
 2003 Microchip Technology Inc.                     Preliminary                                 DS30498B-page 181
PIC16F7X7
FIGURE 15-7:              TIME-OUT SEQUENCE ON POWER-UP (MCLR TIED TO VDD THROUGH
                          PULL-UP RESISTOR)
                  VDD
                MCLR
         Internal POR
                                             TPWRT
       PWRT Time-out                                         TOST
        OST Time-out
        Internal Reset
FIGURE 15-8:              TIME-OUT SEQUENCE ON POWER-UP (MCLR TIED TO VDD THROUGH
                          RC NETWORK): CASE 1
                  VDD
                MCLR
          Internal POR
                                                     TPWRT
       PWRT Time-out                                                TOST
         OST Time-out
         Internal Reset
FIGURE 15-9:              TIME-OUT SEQUENCE ON POWER-UP (MCLR TIED TO VDD THROUGH
                          RC NETWORK): CASE 2
                  VDD
                MCLR
         Internal POR
                                                     TPWRT
       PWRT Time-out                                                TOST
        OST Time-out
        Internal Reset
DS30498B-page 182                           Preliminary                     2003 Microchip Technology Inc.
                                                                      PIC16F7X7
FIGURE 15-10:            SLOW RISE TIME (MCLR TIED TO VDD THROUGH RC NETWORK)
                                                         5V
                      VDD           0V              1V
                    MCLR
              Internal POR
                                         TPWRT
           PWRT Time-out
                                                               TOST
             OST Time-out
             Internal Reset
 2003 Microchip Technology Inc.                 Preliminary               DS30498B-page 183
PIC16F7X7
15.15 Interrupts                                                     The peripheral interrupt flags are contained in the
                                                                     Special Function Register, PIR1. The corresponding
The PIC16F7X7 has up to 17 sources of interrupt. The                 interrupt enable bits are contained in Special Function
Interrupt Control register (INTCON) records individual               Register, PIE1 and the peripheral interrupt enable bit is
interrupt requests in flag bits. It also has individual and          contained in Special Function Register, INTCON.
global interrupt enable bits.
                                                                     When an interrupt is serviced, the GIE bit is cleared to
  Note:        Individual interrupt flag bits are set regard-        disable any further interrupt, the return address is
               less of the status of their corresponding             pushed onto the stack and the PC is loaded with 0004h.
               mask bit or the GIE bit.                              Once in the Interrupt Service Routine, the source(s) of
A global interrupt enable bit, GIE (INTCON<7>),                      the interrupt can be determined by polling the interrupt
enables (if set) all unmasked interrupts or disables (if             flag bits. The interrupt flag bit(s) must be cleared in soft-
cleared) all interrupts. When bit GIE is enabled and an              ware before re-enabling interrupts to avoid recursive
interrupt’s flag bit and mask bit are set, the interrupt will        interrupts.
vector immediately. Individual interrupts can be                     For external interrupt events, such as the INT pin or
disabled through their corresponding enable bits in                  PORTB change interrupt, the interrupt latency will be
various registers. Individual interrupt bits are set                 three or four instruction cycles. The exact latency
regardless of the status of the GIE bit. The GIE bit is              depends on when the interrupt event occurs relative to
cleared on Reset.                                                    the current Q cycle. The latency is the same for one or
The “return from interrupt” instruction, RETFIE, exits               two-cycle instructions. Individual interrupt flag bits are
the interrupt routine, as well as sets the GIE bit which             set regardless of the status of their corresponding
re-enables interrupts.                                               mask bit, PEIE bit or the GIE bit.
The RB0/INT pin interrupt, the RB port change interrupt
and the TMR0 overflow interrupt flags are contained in
the INTCON register.
FIGURE 15-11:              INTERRUPT LOGIC
    PSPIF(1)
    PSPIE(1)
     OSFIF
     OSFIE
                  BCLIF
                  BCLIE
                       ADIF
                       ADIE                                                                         Wake-up (If in Sleep mode)
                       RCIF                                        TMR0IF
                       RCIE                                        TMR0IE
                                                                      INTF
                                 TXIF
                                                                      INTE
                                 TXIE                                                                         Interrupt to CPU
                                                                      RBIF
                                SSPIF                                 RBIE
                                SSPIE
                                                                      PEIE
                              CCP1IF
                              CCP1IE
                                                                      GIE
                               CCP2IF
                               CCP2IE
                               CCP3IF
                               CCP3IE
                           TMR2IF
                           TMR2IE
                  TMR1IF
                  TMR1IE
        CMIF
        CMIE
      Note 1:      PSP interrupt is implemented only on PIC16F747/777 devices.
DS30498B-page 184                                        Preliminary                            2003 Microchip Technology Inc.
                                                                                         PIC16F7X7
15.15.1      INT INTERRUPT                                    15.15.3     PORTB INTCON CHANGE
External interrupt on the RB0/INT pin is edge-triggered,      An input change on PORTB<7:4> sets flag bit, RBIF
either rising if bit INTEDG (OPTION<6>) is set or falling     (INTCON<0>). The interrupt can be enabled/disabled
if the INTEDG bit is clear. When a valid edge appears         by setting/clearing enable bit, RBIE (INTCON<4>), see
on the RB0/INT pin, flag bit INTF (INTCON<1>) is set.         Section 2.2 “Data Memory Organization”.
This interrupt can be disabled by clearing enable bit,
INTE (INTCON<4>). Flag bit INTF must be cleared in            15.16 Context Saving During Interrupts
software in the Interrupt Service Routine before re-
enabling this interrupt. The INT interrupt can wake-up        During an interrupt, only the return PC value is saved
the processor from Sleep if bit INTE was set prior to         on the stack. Typically, users may wish to save key
going into Sleep. The status of global interrupt enable       registers during an interrupt (i.e., W, Status registers).
bit, GIE, decides whether or not the processor                Since the upper 16 bytes of each bank are common in
branches to the interrupt vector following wake-up. See       the PIC16F7X7 devices, temporary holding registers
Section 15.18 “Power-down Mode (Sleep)” for                   W_TEMP, STATUS_TEMP and PCLATH_TEMP
details on Sleep mode.                                        should be placed in here. These 16 locations don’t
                                                              require banking and therefore, make it easier for con-
15.15.2      TMR0 INTERRUPT                                   text save and restore. The same code shown in
An overflow (FFh → 00h) in the TMR0 register will set         Example 15-1 can be used.
flag bit, TMR0IF (INTCON<2>). The interrupt can be
enabled/disabled by setting/clearing enable bit,
TMR0IE (INTCON<5>), see Section 6.0 “Timer0
Module”.
EXAMPLE 15-1:           SAVING STATUS AND W REGISTERS IN RAM
     MOVWF     W_TEMP                  ;Copy   W to TEMP register
     SWAPF     STATUS, W               ;Swap   status to be saved into W
     CLRF      STATUS                  ;bank   0, regardless of current bank, Clears IRP,RP1,RP0
     MOVWF     STATUS_TEMP             ;Save   status to bank zero STATUS_TEMP register
     :
     :(ISR)                            ;Insert user code here
     :
     SWAPF     STATUS_TEMP, W          ;Swap STATUS_TEMP register into W
                                       ;(sets bank to original state)
     MOVWF     STATUS                  ;Move W into STATUS register
     SWAPF     W_TEMP, F               ;Swap W_TEMP
     SWAPF     W_TEMP, W               ;Swap W_TEMP into W
 2003 Microchip Technology Inc.                     Preliminary                                   DS30498B-page 185
PIC16F7X7
15.17 Watchdog Timer (WDT)                                           A new prescaler has been added to the path between
                                                                     the internal RC and the multiplexors used to select the
For PIC16F7X7 devices, the WDT has been modified                     path for the WDT. This prescaler is 16 bits and can be
from previous PIC16 devices. The new WDT is code                     programmed to divide the internal RC by 128 to 65536,
and functionally backward compatible with previous                   giving the time base used for the WDT a nominal range
PIC16 WDT modules, and allows the user to have a                     of 1 ms to 2.097s.
scaler value for the WDT and TMR0 at the same time.
In addition, the WDT time-out value can be extended to               15.17.2          WDT CONTROL
268 seconds, using the prescaler with the postscaler
                                                                     The WDTEN bit is located in Configuration Word
when PSA is set to ‘1’.
                                                                     Register 1 and when this bit is set, the WDT runs
15.17.1    WDT OSCILLATOR                                            continuously.
The WDT derives its time base from the 31.25 kHz                     The SWDTEN bit is in the WDTCON register. When the
INTRC; therefore, the accuracy of the 31.25 kHz will be              WDTEN bit in the Configuration Word Register 1 is set,
the same accuracy for the WDT time-out period.                       the SWDTEN bit has no effect. If WDTEN is clear, then
                                                                     the SWDTEN bit can be used to enable and disable the
The value of WDTCON is ‘---0 1000’ on all Resets.                    WDT. Setting the bit will enable it and clearing the bit
This gives a nominal time base of 16.38 ms, which is                 will disable it.
compatible with the time base generated with previous
PIC16 microcontroller versions.                                      The PSA and PS<2:0> bits (OPTION_REG) have the
                                                                     same function as in previous versions of the PIC16
  Note:    When the OST is invoked, the WDT is held                  family of microcontrollers.
           in Reset because the WDT ripple counter
           is used by the OST to perform the oscilla-
           tor delay count. When the OST count has
           expired, the WDT will begin counting (if
           enabled).
FIGURE 15-12:         WATCHDOG TIMER BLOCK DIAGRAM
                                                                From TMR0 Clock Source
                                                                                                       Postscaler
                                                                                  1
                               16-bit Programmable Prescaler WDT
                                                                                       PSA
                                                                                                                        PS<2:0>
     31.25 kHz                           WDTPS<3:0>                                                                     TO TMR0
   INTRC Clock
                                                                                                   0        1
                                                                                                                       PSA
                                WDTEN from Configuration Word
                                SWDTEN from WDTCON
                                                                                                  WDT Time-out
TABLE 15-5:       PRESCALER/POSTSCALER BIT STATUS
                           Conditions                                                 Prescaler          Postscaler (PSA = 1)
WDTEN = 0
CLRWDT command
                                                                                       Cleared                      Cleared
Osc Fail detected
Exit Sleep + System Clock = T1OSC, EXTRC, INTRC, EXTCLK
Exit Sleep + System Clock = XT, HS, LP                                    Cleared at end of OST         Cleared at end of OST
DS30498B-page 186                                     Preliminary                                  2003 Microchip Technology Inc.
                                                                                                   PIC16F7X7
REGISTER 15-4:             WDTCON REGISTER
                           U-0              U-0            U-0         R/W-0       R/W-1  R/W-0  R/W-0  R/W-0
                            —               —              —          WDTPS3      WDTPS2 WDTPS1 WDTPS0 SWDTEN
                       bit 7                                                                               bit 0
            bit 7-5    Unimplemented: Read as ‘0’
            bit 4-1    WDTPS<3:0>: Watchdog Timer Period Select bits
                       0000 = 1:32 prescale rate
                       0001 = 1:64 prescale rate
                       0010 = 1:128 prescale rate
                       0011 = 1:256 prescale rate
                       0100 = 1:512 prescale rate
                       0101 = 1:1024 prescale rate
                       0110 = 1:2048 prescale rate
                       0111 = 1:4096 prescale rate
                       1000 = 1:8192 prescale rate
                       1001 = 1:16394 prescale rate
                       1010 = 1:32768 prescale rate
                       1011 = 1:65536 prescale rate
                       1100 = 1:1 prescale rate
            bit 0      SWDTEN: Software Enable/Disable for Watchdog Timer bit(1)
                       1 = WDT is turned on
                       0 = WDT is turned off
                           Note 1: If WDTEN configuration bit = 1, then WDT is always enabled irrespective of this
                                   control bit. If WDTEN configuration bit = 0, then it is possible to turn WDT on/off with
                                   this control bit.
                       Legend:
                       R = Readable bit                    W = Writable bit      U = Unimplemented bit, read as ‘0’
                       -n = Value at POR                   ‘1’ = Bit is set      ‘0’ = Bit is cleared     x = Bit is unknown
TABLE 15-6:         SUMMARY OF WATCHDOG TIMER REGISTERS
                                                                                                                       Value on
                                                                                                           Value on
 Address       Name         Bit 7   Bit 6         Bit 5    Bit 4     Bit 3    Bit 2    Bit 1      Bit 0                all other
                                                                                                          POR, BOR
                                                                                                                        Resets
81h, 181h OPTION_REG RBPU INTEDG T0CS                      T0SE      PSA      PS2      PS1        PS0     1111 1111 1111 1111
2007h      Configuration    BORV0 BOREN MCLRE             FOSC2    PWRTEN WDTEN       FOSC1      FOSC0    uuuu uuuu uuuu uuuu
           bits
105h       WDTCON            —       —             —      WDTPS3 WDTPS2 WSTPS1 WDTPS0 SWDTEN ---0 1000 ---0 1000
Legend:    Shaded cells are not used by the Watchdog Timer.
Note 1:    See Register 15-1 for operation of these bits.
 2003 Microchip Technology Inc.                           Preliminary                                       DS30498B-page 187
PIC16F7X7
15.17.3     TWO-SPEED CLOCK START-UP                        Checking the state of the OSTS bit will confirm
            MODE                                            whether the primary clock configuration is engaged. If
                                                            not, the OSTS bit will remain clear.
Two-Speed Start-up minimizes the latency between
oscillator start-up and code execution that may be          When the device is auto-configured in INTRC mode
selected with the IESO (Internal/External Switch Over)      following a POR or wake-up from Sleep, the rules for
bit in Configuration Word Register 2. This mode is          entering other oscillator modes still apply, meaning the
achieved by initially using the INTRC for code              SCS<1:0> bits in OSCCON can be modified before the
execution until the primary oscillator is stable.           OST time-out has occurred. This would allow the
                                                            application to wake-up from Sleep, perform a few
If this mode is enabled and any of the following condi-
                                                            instructions using the INTRC as the clock source and
tions exist, the system will begin execution with the
                                                            go back to Sleep without waiting for the primary
INTRC oscillator. This results in almost immediate
                                                            oscillator to become stable.
code execution with a minimum of delay.
• POR and after the Power-up Timer has expired (if               Note:   Executing a SLEEP instruction will abort
  PWRTEN = 0)                                                            the oscillator start-up time and will cause
                                                                         the OSTS bit to remain clear.
• or following a wake-up from Sleep
• or a Reset, when running from T1OSC or INTRC              15.17.3.1      Two-Speed Start-up Sequence
  (after a Reset, SCS<1:0> are always set to ‘00’).
                                                            1.    Wake-up from Sleep, Reset or POR.
  Note:     Following any Reset, the IRCF bits are          2.    OSCON bits configured to run from INTRC
            zeroed and the frequency selection is                 (31.25 kHz).
            forced to 31.25 kHz. The user can modify
                                                            3.    Instructions begin execution by INTRC
            the IRCF bits to select a higher internal
                                                                  (31.25 kHz).
            oscillator frequency.
                                                            4.    OST enabled to count 1024 clock cycles.
If the primary oscillator is configured to be anything
                                                            5.    OST timed out, wait for falling edge of INTRC.
other than XT, LP or HS, then Two-Speed Start-up is
disabled because the primary oscillator will not require    6.    OSTS is set.
any time to become stable after POR or an exit from         7.    System clock held low for eight falling edges of
Sleep.                                                            new clock (LP, XT or HS).
If the IRCF bits of the OSCCON register are configured      8.    System clock is switched to primary source (LP,
to a non-zero value prior to entering Sleep mode, the             XT or HS).
secondary system clock frequency will come from the         The software may read the OSTS bit to determine
output of the INTOSC. The IOFS bit in the OSCCON            when the switch over takes place so that any software
register will be clear until the INTOSC is stable. This     timing edges can be adjusted.
will allow the user to determine when the internal
oscillator can be used for time critical applications.
FIGURE 15-13:          TWO-SPEED START-UP
                      CPU Start-up
                         Q1               Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4     Q1 Q2 Q3 Q4    Q1 Q2 Q3 Q4
       INTRC
        OSC1
                               TOST
        OSC2
  System Clock
         Sleep
        OSTS
      Program    PC                            0000h        0001h            0003h         0004h          0005h
      Counter
DS30498B-page 188                                   Preliminary                       2003 Microchip Technology Inc.
                                                                                                  PIC16F7X7
15.17.4        FAIL-SAFE OPTION                                       The FSCM sample clock is generated by dividing the
                                                                      INTRC clock by 64. This will allow enough time
The Fail-Safe Clock Monitor (FSCM) is designed to
                                                                      between FSCM sample clocks for a system clock edge
allow the device to continue to operate even in the
                                                                      to occur.
event of an oscillator failure.
                                                                      On the rising edge of the postscaled clock, the
FIGURE 15-14:              FSCM BLOCK DIAGRAM                         monitoring latch (CM = 0) will be cleared. On a falling
                                                                      edge of the primary or secondary system clock, the
                               Clock Monitor
                                Latch (CM)                            monitoring latch will be set (CM = 1). In the event that
                              (edge-triggered)                        a falling edge of the postscaled clock occurs and the
  Peripheral                                                          monitoring latch is not set, a clock failure has been
                                   S     Q
    Clock                                                             detected.
                                                                      While in Fail-Safe mode, a Reset will exit the Fail-Safe
                                                                      condition. If the primary clock source is configured for
   INTRC
  Oscillator
                    ÷ 64           C     Q                            a crystal, the OST timer will wait for the 1024 clock
                                                                      cycles for the OST time-out and the device will con-
  31.25 kHz        488 Hz                                             tinue running from the internal oscillator until the OST
   (32 µs)       (2.048 ms)                                           is complete. A SLEEP instruction, or a write to the SCS
                                                                      bits (where SCS bits do not = 00), can be performed to
                                                     Clock            put the device into a low-power mode.
                                                   Failure
                                                  Detected            If Reset occurs while in Fail-Safe mode and the
                                                                      primary clock source is EC or RC, then the device will
The FSCM function is enabled by setting the FCMEN                     immediately switch back to EC or RC mode.
bit in Configuration Word Register 2.                                   Note:      Two-Speed Start-up is automatically
In the event of an oscillator failure, the FSCM will                               enabled when the Fail-Safe option is
generate an oscillator fail interrupt and will switch the                          enabled.
system clock over to the internal oscillator. The system
will continue to come from the internal oscillator until              15.17.4.1      Fail-Safe in Low-Power Mode
the Fail-Safe condition is exited. The Fail-Safe                      A change of SCS<1:0> or the SLEEP instruction will
condition is exited with either a Reset, the execution of             end the Fail-Safe condition. The system clock will
a SLEEP instruction or a write to the SCS bits of a                   default to the source selected by the SCS bits, which
different value.                                                      is either T1OSC, INTRC or none (Sleep mode). How-
The frequency of the internal oscillator will depend                  ever, the FSCM will continue to monitor the system
upon the value contained in the IRCF bits. Another                    clock. If the secondary clock fails, the device will
clock source can be selected via the IRCF and the                     immediately switch to the internal oscillator clock. If
SCS bits of the OSCCON register.                                      OSFIE is set, an interrupt will be generated.
FIGURE 15-15:              FSCM TIMING DIAGRAM
     Sample Clock
              System                                                         Oscillator
               Clock                                                         Failure
              Output
        CM Output
              (Q)
                                                                                                  Failure
                                                                                                 Detected
           OSCFIF
                                        CM Test                         CM Test                         CM Test
      Note:       The system clock is normally at a much higher frequency than the sample clock. The relative frequencies in
                  this example have been chosen for clarity.
 2003 Microchip Technology Inc.                        Preliminary                                         DS30498B-page 189
PIC16F7X7
15.17.4.2     FSCM and the Watchdog Timer                       15.18.1      WAKE-UP FROM SLEEP
When a clock failure is detected, SCS<1:0> will be              The device can wake-up from Sleep through one of the
forced to ‘10’ which will reset the WDT (if enabled).           following events:
                                                                1.    External Reset input on MCLR pin.
15.17.4.3     POR or Wake from Sleep
                                                                2.    Watchdog Timer wake-up (if WDT was
The FSCM is designed to detect oscillator failure at any              enabled).
point after the device has exited Power-on Reset
                                                                3.    Interrupt from INT pin, RB port change or a
(POR) or low-power Sleep mode. When the primary
                                                                      peripheral interrupt.
system clock is EC, RC or INTRC modes, monitoring
can begin immediately following these events.                   External MCLR Reset will cause a device Reset. All
                                                                other events are considered a continuation of program
For oscillator modes involving a crystal or resonator
                                                                execution and cause a “wake-up”. The TO and PD bits
(HS, LP or XT), the situation is somewhat different.
                                                                in the Status register can be used to determine the
Since the oscillator may require a start-up time consid-
                                                                cause of the device Reset. The PD bit, which is set on
erably longer than the FSCM sample clock time, a false
                                                                power-up, is cleared when Sleep is invoked. The TO bit
clock failure may be detected. To prevent this, the inter-
                                                                is cleared if a WDT time-out occurred and caused
nal oscillator block is automatically configured as the
                                                                wake-up.
system clock and functions until the primary clock is
stable (the OST and PLL timers have timed out). This            The following peripheral interrupts can wake the device
is identical to Two-Speed Start-up mode. Once the               from Sleep:
primary clock is stable, the INTR returns to its role as        1.    TMR1 interrupt. Timer1 must be operating as an
the FSCM source.                                                      asynchronous counter.
  Note:     The same logic that prevents false oscilla-         2.    CCP Capture mode interrupt.
            tor failure interrupts on POR or wake from          3.    Special event trigger (Timer1 in Asynchronous
            Sleep, will also prevent the detection of                 mode using an external clock).
            the oscillator’s failure to start at all follow-    4.    SSP (Start/Stop) bit detect interrupt.
            ing these events. This can be avoided by            5.    SSP transmit or receive in Slave mode (SPI/I2C).
            monitoring the OSTS bit and using a
                                                                6.    A/D conversion (when A/D clock source is RC).
            timing routine to determine if the oscillator
            is taking too long to start. Even so, no            7.    EEPROM write operation completion.
            oscillator failure interrupt will be flagged.       8.    Comparator output changes state.
                                                                9.    USART RX or TX (Synchronous Slave mode).
15.18 Power-down Mode (Sleep)                                   Other peripherals cannot generate interrupts since
Power-down mode is entered by executing a SLEEP                 during Sleep, no on-chip clocks are present.
instruction.                                                    When the SLEEP instruction is being executed, the next
If enabled, the Watchdog Timer will be cleared but              instruction (PC + 1) is prefetched. For the device to
keeps running, the PD bit (Status<3>) is cleared, the           wake-up through an interrupt event, the corresponding
TO (Status<4>) bit is set and the oscillator driver is          interrupt enable bit must be set (enabled). Wake-up
turned off. The I/O ports maintain the status they had          occurs regardless of the state of the GIE bit. If the GIE
before the SLEEP instruction was executed (driving              bit is clear (disabled), the device continues execution at
high, low or high-impedance).                                   the instruction after the SLEEP instruction. If the GIE bit
                                                                is set (enabled), the device executes the instruction
For lowest current consumption in this mode, place all          after the SLEEP instruction and then branches to the
I/O pins at either VDD or VSS, ensure no external cir-          interrupt address (0004h). In cases where the execu-
cuitry is drawing current from the I/O pin, power-down          tion of the instruction following SLEEP is not desirable,
the A/D and disable external clocks. Pull all I/O pins          the user should have a NOP after the SLEEP instruction.
that are high-impedance inputs, high or low externally,
to avoid switching currents caused by floating inputs.
The T0CKI input should also be at VDD or VSS for low-
est current consumption. The contribution from on-chip
pull-ups on PORTB should also be considered.
The MCLR pin must be at a logic high level (VIHMC).
DS30498B-page 190                                       Preliminary                       2003 Microchip Technology Inc.
                                                                                                                   PIC16F7X7
15.18.2         WAKE-UP USING INTERRUPTS                                         Even if the flag bits were checked before executing a
                                                                                 SLEEP instruction, it may be possible for flag bits to
When global interrupts are disabled (GIE cleared) and
                                                                                 become set before the SLEEP instruction completes. To
any interrupt source has both its interrupt enable bit
                                                                                 determine whether a SLEEP instruction executed, test
and interrupt flag bit set, one of the following will occur:
                                                                                 the PD bit. If the PD bit is set, the SLEEP instruction
• If the interrupt occurs before the execution of a                              was executed as a NOP.
  SLEEP instruction, the SLEEP instruction will com-
                                                                                 To ensure that the WDT is cleared, a CLRWDT instruction
  plete as a NOP. Therefore, the WDT and WDT
                                                                                 should be executed before a SLEEP instruction.
  prescaler and postscaler (if enabled) will not be
  cleared, the TO bit will not be set and the PD bit
  will not be cleared.
• If the interrupt occurs during or after the
  execution of a SLEEP instruction, the device will
  immediately wake-up from Sleep. The SLEEP
  instruction will be completely executed before the
  wake-up. Therefore, the WDT and WDT prescaler
  and postscaler (if enabled) will be cleared, the TO
  bit will be set and the PD bit will be cleared.
FIGURE 15-16:                WAKE-UP FROM SLEEP THROUGH INTERRUPT
                 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1                                   Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
  OSC1
  CLKO(4)                                                           TOST(2)
  INT pin
  INTF Flag
  (INTCON<1>)                                                                                 Interrupt Latency
                                                                                                  (Note 2)
  GIE bit
  (INTCON<7>)                                        Processor in
                                                       Sleep
  INSTRUCTION FLOW
            PC          PC              PC+1                  PC+2                PC+2              PC + 2           0004h            0005h
  Instruction
  Fetched        Inst(PC) = Sleep    Inst(PC + 1)                              Inst(PC + 2)                        Inst(0004h)      Inst(0005h)
  Instruction                                                                                  Dummy Cycle        Dummy Cycle
  Executed          Inst(PC - 1)       Sleep                                   Inst(PC + 1)                                         Inst(0004h)
 Note 1:    XT, HS or LP Oscillator mode assumed.
      2:    TOST = 1024 TOSC (drawing not to scale). This delay will not be there for RC Osc mode.
      3:    GIE = 1 assumed. In this case, after wake-up, the processor jumps to the interrupt routine.
            If GIE = 0, execution will continue in-line.
       4:   CLKO is not available in these osc modes but shown here for timing reference.
 2003 Microchip Technology Inc.                                Preliminary                                                      DS30498B-page 191
PIC16F7X7
15.19 In-Circuit Debugger                                     15.22 In-Circuit Serial Programming
When the DEBUG bit in the Configuration Word is pro-          PIC16F7X7 microcontrollers can be serially
grammed to a ‘0’, the in-circuit debugger functionality is    programmed while in the end application circuit. This is
enabled. This function allows simple debugging                simply done with two lines for clock and data and three
functions when used with MPLAB® ICD. When the                 other lines for power, ground and the programming
microcontroller has this feature enabled, some of the         voltage (see Figure 15-17 for an example). This allows
resources are not available for general use. Table 15-7       customers to manufacture boards with unprogrammed
shows which features are consumed by the background           devices and then program the microcontroller just
debugger.                                                     before shipping the product. This also allows the most
                                                              recent firmware or a custom firmware to be
TABLE 15-7:        DEBUGGER RESOURCES                         programmed.
I/O pins                           RB6, RB7                   For general information of serial programming, please
Stack                                1 level                  refer to the In-Circuit Serial Programming™ (ICSP™)
                                                              Guide (DS30277).
Program Memory           Address 0000h must be NOP
                                Last 100h words               FIGURE 15-17:             TYPICAL IN-CIRCUIT
Data Memory              0x070 (0x0F0, 0x170, 0x1F0)                                    SERIAL PROGRAMMING
                                0x1EB-0x1EF                                             CONNECTION
To use the in-circuit debugger function of the micro-                                To Normal
controller, the design must implement In-Circuit Serial                              Connections
Programming connections to MCLR/VPP, VDD, GND,                  External
RB7 and RB6. This will interface to the in-circuit              Connector                   *
                                                                Signals                                PIC16F7X7
debugger module available from Microchip, or one of
the third party development tool companies.                         +5V                               VDD
                                                                      0V                              VSS
15.20 Program Verification/Code                                      VPP                              MCLR/VPP/RE3
      Protection                                                    CLK                               RB6
If the code protection bit(s) have not been                     Data I/O                              RB7
programmed, the on-chip program memory can be
read out for verification purposes.
15.21 ID Locations
                                                                                 *      *       *
Four memory locations (2000h-2003h) are designated
as ID locations, where the user can store checksum or                                                       VDD
other code identification numbers. These locations are                               To Normal
                                                                                     Connections
not accessible during normal execution, but are
readable and writable during program/verify. It is               * Isolation devices (as required).
recommended that only the four Least Significant bits
of the ID location are used.
DS30498B-page 192                                     Preliminary                         2003 Microchip Technology Inc.
                                                                                                   PIC16F7X7
16.0      INSTRUCTION SET SUMMARY                               For example, a “CLRF PORTB” instruction will read
                                                                PORTB, clear all the data bits, then write the result
The PIC16 instruction set is highly orthogonal and is           back to PORTB. This example would have the unin-
comprised of three basic categories:                            tended result that the condition that sets the RBIF flag
• Byte-oriented operations                                      would be cleared for pins configured as inputs and
• Bit-oriented operations                                       using the PORTB interrupt-on-change feature.
• Literal and control operations
                                                                TABLE 16-1:              OPCODE FIELD
Each PIC16 instruction is a 14-bit word divided into an                                  DESCRIPTIONS
opcode, which specifies the instruction type and one or
more operands, which further specify the operation of            Field                          Description
the instruction. The formats for each of the categories          f        Register file address (0x00 to 0x7F)
are presented in Figure 16-1, while the various opcode
                                                                 W        Working register (accumulator)
fields are summarized in Table 16-1.
                                                                 b        Bit address within an 8-bit file register
Table 13-2 lists the instructions recognized by the
MPASMTM Assembler. A complete description of each                k        Literal field, constant data or label
instruction is also available in the PICmicro® Mid-Range         x        Don’t care location (= 0 or 1).
MCU Family Reference Manual (DS33023).                                    The assembler will generate code with x = 0.
For byte-oriented instructions, ‘f’ represents a file                     It is the recommended form of use for
register designator and ‘d’ represents a destination                      compatibility with all Microchip software tools.
designator. The file register designator specifies which         d        Destination select; d = 0: store result in W,
file register is to be used by the instruction.                           d = 1: store result in file register f.
                                                                          Default is d = 1.
The destination designator specifies where the result of
the operation is to be placed. If ‘d’ is zero, the result is     PC       Program Counter
placed in the W register. If ‘d’ is one, the result is placed    TO       Time-out bit
in the file register specified in the instruction.               PD       Power-down bit
For bit-oriented instructions, ‘b’ represents a bit field
designator which selects the bit affected by the opera-
tion, while ‘f’ represents the address of the file in which     FIGURE 16-1:                  GENERAL FORMAT FOR
the bit is located.                                                                           INSTRUCTIONS
For literal and control operations, ‘k’ represents an                 Byte-oriented file register operations
eight or eleven-bit constant or literal value                           13                 8 7 6                               0
One instruction cycle consists of four oscillator periods;                 OPCODE               d        f (FILE #)
for an oscillator frequency of 4 MHz, this gives a normal                     d = 0 for destination W
instruction execution time of 1 µs. All instructions are                      d = 1 for destination f
executed within a single instruction cycle, unless a                          f = 7-bit file register address
conditional test is true, or the program counter is
changed as a result of an instruction. When this occurs,              Bit-oriented file register operations
the execution takes two instruction cycles, with the                    13                 10 9      7 6                       0
second cycle executed as a NOP.                                               OPCODE          b (BIT #)    f (FILE #)
  Note:      To maintain upward compatibility with                            b = 3-bit bit address
             future PIC16F7X7 products, do not use                            f = 7-bit file register address
             the OPTION and TRIS instructions.
All instruction examples use the format ‘0xhh’ to                     Literal and control operations
represent a hexadecimal number, where ‘h’ signifies a                 General
hexadecimal digit.                                                       13                         8   7                      0
                                                                                OPCODE                           k (literal)
16.1      Read-Modify-Write Operations
                                                                              k = 8-bit immediate value
Any instruction that specifies a file register as part of
the instruction performs a Read-Modify-Write (R-M-W)                  CALL and GOTO instructions only
operation. The register is read, the data is modified,                   13             11    10                               0
and the result is stored according to either the instruc-
                                                                              OPCODE                      k (literal)
tion, or the destination designator ‘d’. A read operation
is performed on a register even if the instruction writes                     k = 11-bit immediate value
to that register.
 2003 Microchip Technology Inc.                        Preliminary                                             DS30498B-page 193
PIC16F7X7
TABLE 16-2:          PIC16F7X7 INSTRUCTION SET
    Mnemonic,                                                                             14-Bit Opcode            Status
                                          Description                    Cycles                                                Notes
    Operands                                                                       MSb                     LSb    Affected
                                         BYTE-ORIENTED FILE REGISTER OPERATIONS
ADDWF         f, d     Add W and f                                          1       00     0111   dfff    ffff     C, DC, Z     1, 2
ANDWF         f, d     AND W with f                                         1       00     0101   dfff    ffff        Z         1, 2
CLRF            f      Clear f                                              1       00     0001   lfff    ffff        Z          2
CLRW            -      Clear W                                              1       00     0001   0xxx    xxxx        Z
COMF          f, d     Complement f                                         1       00     1001   dfff    ffff        Z         1, 2
DECF          f, d     Decrement f                                          1       00     0011   dfff    ffff        Z         1, 2
DECFSZ        f, d     Decrement f, Skip if 0                              1(2)     00     1011   dfff    ffff                 1, 2, 3
INCF          f, d     Increment f                                          1       00     1010   dfff    ffff        Z         1, 2
INCFSZ        f, d     Increment f, Skip if 0                              1(2)     00     1111   dfff    ffff                 1, 2, 3
IORWF         f, d     Inclusive OR W with f                                1       00     0100   dfff    ffff        Z         1, 2
MOVF          f, d     Move f                                               1       00     1000   dfff    ffff        Z         1, 2
MOVWF           f      Move W to f                                          1       00     0000   lfff    ffff
NOP             -      No Operation                                         1       00     0000   0xx0    0000
RLF           f, d     Rotate Left f through Carry                          1       00     1101   dfff    ffff        C         1,2
RRF           f, d     Rotate Right f through Carry                         1       00     1100   dfff    ffff        C         1, 2
SUBWF         f, d     Subtract W from f                                    1       00     0010   dfff    ffff     C, DC, Z     1, 2
SWAPF         f, d     Swap nibbles in f                                    1       00     1110   dfff    ffff                  1, 2
XORWF         f, d     Exclusive OR W with f                                1       00     0110   dfff    ffff        Z         1, 2
                                           BIT-ORIENTED FILE REGISTER OPERATIONS
BCF           f, b     Bit Clear f                                           1      01     00bb   bfff    ffff                  1, 2
BSF           f, b     Bit Set f                                             1      01     01bb   bfff    ffff                  1, 2
BTFSC         f, b     Bit Test f, Skip if Clear                           1 (2)    01     10bb   bfff    ffff                   3
BTFSS         f, b     Bit Test f, Skip if Set                             1 (2)    01     11bb   bfff    ffff                   3
                                              LITERAL AND CONTROL OPERATIONS
ADDLW          k       Add literal and W                                     1      11     111x   kkkk    kkkk     C, DC, Z
ANDLW          k       AND literal with W                                    1      11     1001   kkkk    kkkk        Z
CALL           k       Call subroutine                                       2      10     0kkk   kkkk    kkkk
CLRWDT         -       Clear Watchdog Timer                                  1      00     0000   0110    0100     TO, PD
GOTO           k       Go to address                                         2      10     1kkk   kkkk    kkkk
IORLW          k       Inclusive OR literal with W                           1      11     1000   kkkk    kkkk        Z
MOVLW          k       Move literal to W                                     1      11     00xx   kkkk    kkkk
RETFIE         -       Return from interrupt                                 2      00     0000   0000    1001
RETLW          k       Return with literal in W                              2      11     01xx   kkkk    kkkk
RETURN         -       Return from Subroutine                                2      00     0000   0000    1000
SLEEP          -       Go into Standby mode                                  1      00     0000   0110    0011     TO, PD
SUBLW          k       Subtract W from literal                               1      11     110x   kkkk    kkkk     C, DC, Z
XORLW          k       Exclusive OR literal with W                           1      11     1010   kkkk    kkkk        Z
Note 1:    When an I/O register is modified as a function of itself ( e.g., MOVF PORTB, 1), the value used will be that value
           present on the pins themselves. For example, if the data latch is ‘1’ for a pin configured as input and is driven low by an
           external device, the data will be written back with a ‘0’.
      2:   If this instruction is executed on the TMR0 register (and where applicable, d = 1), the prescaler will be cleared if
           assigned to the Timer0 module.
      3:   If Program Counter (PC) is modified or a conditional test is true, the instruction requires two cycles. The second cycle is
           executed as a NOP.
  Note:    Additional information on the mid-range instruction set is available in the PICmicro® Mid-Range MCU
           Family Reference Manual (DS33023).
DS30498B-page 194                                       Preliminary                                 2003 Microchip Technology Inc.
                                                                                               PIC16F7X7
16.2      Instruction Descriptions
ADDLW               Add Literal and W                              BCF                 Bit Clear f
Syntax:             [ label ] ADDLW         k                      Syntax:             [ label ] BCF       f,b
Operands:           0 ≤ k ≤ 255                                    Operands:           0 ≤ f ≤ 127
Operation:          (W) + k → (W)                                                      0≤b≤7
Status Affected:    C, DC, Z                                       Operation:          0 → (f<b>)
Description:        The contents of the W register                 Status Affected:    None
                    are added to the eight-bit literal ‘k’         Description:        Bit ‘b’ in register ‘f’ is cleared.
                    and the result is placed in the W
                    register.
ADDWF              Add W and f                                     BSF                 Bit Set f
Syntax:            [ label ] ADDWF          f,d                    Syntax:             [ label ] BSF     f,b
Operands:          0 ≤ f ≤ 127                                     Operands:           0 ≤ f ≤ 127
                   d ∈ [0,1]                                                           0≤b≤7
Operation:         (W) + (f) → (destination)                       Operation:          1 → (f<b>)
Status Affected:   C, DC, Z                                        Status Affected:    None
Description:       Add the contents of the W register              Description:        Bit ‘b’ in register ‘f’ is set.
                   with register ‘f’. If ‘d’ is ‘0’, the
                   result is stored in the W register. If
                   ‘d’ is ‘1’, the result is stored back
                   in register ‘f’.
ANDLW               AND Literal with W                             BTFSS              Bit Test f, Skip if Set
Syntax:             [ label ] ANDLW         k                      Syntax:            [ label ] BTFSS f,b
Operands:           0 ≤ k ≤ 255                                    Operands:          0 ≤ f ≤ 127
                                                                                      0≤b<7
Operation:          (W) .AND. (k) → (W)
                                                                   Operation:         skip if (f<b>) = 1
Status Affected:    Z
                                                                   Status Affected:   None
Description:        The contents of W register are
                    AND’ed with the eight-bit literal              Description:       If bit ‘b’ in register ‘f’ is ‘0’, the next
                    ‘k’. The result is placed in the W                                instruction is executed.
                    register.                                                         If bit ‘b’ is ‘1’, then the next
                                                                                      instruction is discarded and a NOP
                                                                                      is executed instead, making this a
                                                                                      2 TCY instruction.
ANDWF              AND W with f                                    BTFSC              Bit Test, Skip if Clear
Syntax:            [ label ] ANDWF          f,d                    Syntax:            [ label ] BTFSC f,b
Operands:          0 ≤ f ≤ 127                                     Operands:          0 ≤ f ≤ 127
                   d ∈ [0,1]                                                          0≤b≤7
Operation:         (W) .AND. (f) → (destination)                   Operation:         skip if (f<b>) = 0
Status Affected:   Z                                               Status Affected:   None
Description:       AND the W register with register                Description:       If bit ‘b’ in register ‘f’ is ‘1’, the next
                   ‘f’. If ‘d’ is ‘0’, the result is stored in                        instruction is executed.
                   the W register. If ‘d’ is ‘1’, the                                 If bit ‘b’ in register ‘f’ is ‘0’, the next
                   result is stored back in register ‘f’.                             instruction is discarded and a NOP
                                                                                      is executed instead, making this a
                                                                                      2 TCY instruction.
 2003 Microchip Technology Inc.                           Preliminary                                     DS30498B-page 195
PIC16F7X7
CALL                Call Subroutine                            CLRWDT             Clear Watchdog Timer
Syntax:             [ label ] CALL k                           Syntax:            [ label ] CLRWDT
Operands:          0 ≤ k ≤ 2047                                Operands:          None
Operation:         (PC)+ 1→ TOS,                               Operation:         00h → WDT
                   k → PC<10:0>,                                                  0 → WDT prescaler,
                   (PCLATH<4:3>) → PC<12:11>                                      1 → TO
Status Affected:    None                                                          1 → PD
Description:       Call Subroutine. First, return              Status Affected:   TO, PD
                   address (PC+1) is pushed onto               Description:       CLRWDT instruction resets the
                   the stack. The eleven-bit                                      Watchdog Timer. It also resets the
                   immediate address is loaded into                               prescaler of the WDT. Status bits,
                   PC bits<10:0>. The upper bits of                               TO and PD, are set.
                   the PC are loaded from PCLATH.
                   CALL is a two-cycle instruction.
CLRF                Clear f                                    COMF               Complement f
Syntax:             [ label ] CLRF    f                        Syntax:            [ label ] COMF        f,d
Operands:           0 ≤ f ≤ 127                                Operands:          0 ≤ f ≤ 127
Operation:          00h → (f)                                                     d ∈ [0,1]
                    1→Z                                        Operation:         (f) → (destination)
Status Affected:    Z                                          Status Affected:   Z
Description:        The contents of register ‘f’ are           Description:       The contents of register ‘f’ are
                    cleared and the Z bit is set.                                 complemented. If ‘d’ is ‘0’, the
                                                                                  result is stored in W. If ‘d’ is ‘1’, the
                                                                                  result is stored back in register ‘f’.
CLRW                Clear W                                    DECF               Decrement f
Syntax:             [ label ] CLRW                             Syntax:            [ label ] DECF f,d
Operands:           None                                       Operands:          0 ≤ f ≤ 127
Operation:          00h → (W)                                                     d ∈ [0,1]
                    1→Z                                        Operation:         (f) - 1 → (destination)
Status Affected:    Z                                          Status Affected:   Z
Description:        W register is cleared. Zero bit (Z)        Description:       Decrement register ‘f’. If ‘d’ is ‘0’,
                    is set.                                                       the result is stored in the W
                                                                                  register. If ‘d’ is ‘1’, the result is
                                                                                  stored back in register ‘f’.
DS30498B-page 196                                      Preliminary                       2003 Microchip Technology Inc.
                                                                                          PIC16F7X7
DECFSZ             Decrement f, Skip if 0                      INCFSZ             Increment f, Skip if 0
Syntax:            [ label ] DECFSZ f,d                        Syntax:            [ label ]    INCFSZ f,d
Operands:          0 ≤ f ≤ 127                                 Operands:          0 ≤ f ≤ 127
                   d ∈ [0,1]                                                      d ∈ [0,1]
Operation:         (f) - 1 → (destination);                    Operation:         (f) + 1 → (destination),
                   skip if result = 0                                              skip if result = 0
Status Affected:   None                                        Status Affected:   None
Description:       The contents of register ‘f’ are            Description:       The contents of register ‘f’ are
                   decremented. If ‘d’ is ‘0’, the result                         incremented. If ‘d’ is ‘0’, the result
                   is placed in the W register. If ‘d’ is                         is placed in the W register. If ‘d’ is
                   ‘1’, the result is placed back in                              ‘1’, the result is placed back in
                   register ‘f’.                                                  register ‘f’.
                   If the result is ‘1’, the next                                 If the result is ‘1’, the next
                   instruction is executed. If the                                instruction is executed. If the
                   result is ‘0’, then a NOP is                                   result is ‘0’, a NOP is executed
                   executed instead, making it a                                  instead, making it a 2 TCY
                   2 TCY instruction.                                             instruction.
GOTO               Unconditional Branch                        IORLW               Inclusive OR Literal with W
Syntax:            [ label ]   GOTO k                          Syntax:             [ label ]   IORLW k
Operands:          0 ≤ k ≤ 2047                                Operands:           0 ≤ k ≤ 255
Operation:         k → PC<10:0>                                Operation:          (W) .OR. k → (W)
                   PCLATH<4:3> → PC<12:11>                     Status Affected:    Z
Status Affected:   None                                        Description:        The contents of the W register are
Description:       GOTO is an unconditional branch.                                OR’ed with the eight-bit literal ‘k’.
                   The eleven-bit immediate value is                               The result is placed in the W
                   loaded into PC bits<10:0>. The                                  register.
                   upper bits of PC are loaded from
                   PCLATH<4:3>. GOTO is a
                   two-cycle instruction.
INCF               Increment f                                 IORWF              Inclusive OR W with f
Syntax:            [ label ]   INCF f,d                        Syntax:            [ label ]    IORWF       f,d
Operands:          0 ≤ f ≤ 127                                 Operands:          0 ≤ f ≤ 127
                   d ∈ [0,1]                                                      d ∈ [0,1]
Operation:         (f) + 1 → (destination)                     Operation:         (W) .OR. (f) → (destination)
Status Affected:   Z                                           Status Affected:   Z
Description:       The contents of register ‘f’ are            Description:       Inclusive OR the W register with
                   incremented. If ‘d’ is ‘0’, the result                         register ‘f’. If ‘d’ is ‘0’, the result is
                   is placed in the W register. If ‘d’ is                         placed in the W register. If ‘d’ is
                   ‘1’, the result is placed back in                              ‘1’, the result is placed back in
                   register ‘f’.                                                  register ‘f’.
 2003 Microchip Technology Inc.                       Preliminary                                     DS30498B-page 197
PIC16F7X7
MOVF               Move f                                         NOP                No Operation
Syntax:            [ label ]    MOVF f,d                          Syntax:            [ label ]   NOP
Operands:          0 ≤ f ≤ 127                                    Operands:          None
                   d ∈ [0,1]                                      Operation:         No operation
Operation:         (f) → (destination)                            Status Affected:   None
Status Affected:   Z                                              Description:       No operation.
Description:       The contents of register ‘f’ are
                   moved to a destination dependant
                   upon the status of ‘d’. If d = 0,
                   the destination is W register. If
                   d = 1, the destination is file register
                   ‘f’ itself. d = 1 is useful to test a file
                   register since status flag Z is
                   affected.
MOVLW               Move Literal to W                             RETFIE             Return from Interrupt
Syntax:             [ label ]   MOVLW k                           Syntax:            [ label ]   RETFIE
Operands:           0 ≤ k ≤ 255                                   Operands:          None
Operation:          k → (W)                                       Operation:         TOS → PC,
Status Affected:    None                                                             1 → GIE
Description:        The eight-bit literal ‘k’ is loaded           Status Affected:   None
                    into W register. The don’t cares
                    will assemble as ‘0’s.
MOVWF               Move W to f                                   RETLW              Return with Literal in W
Syntax:             [ label ]   MOVWF         f                   Syntax:            [ label ]   RETLW k
Operands:           0 ≤ f ≤ 127                                   Operands:          0 ≤ k ≤ 255
Operation:          (W) → (f)                                     Operation:         k → (W);
Status Affected:    None                                                             TOS → PC
Description:        Move data from W register to                  Status Affected:   None
                    register ‘f’.                                 Description:       The W register is loaded with the
                                                                                     eight-bit literal ‘k’. The program
                                                                                     counter is loaded from the top of
                                                                                     the stack (the return address).
                                                                                     This is a two-cycle instruction.
DS30498B-page 198                                         Preliminary                       2003 Microchip Technology Inc.
                                                                                              PIC16F7X7
RLF                Rotate Left f through Carry                   SLEEP
Syntax:            [ label ] RLF       f,d                       Syntax:               [ label ] SLEEP
Operands:          0 ≤ f ≤ 127                                   Operands:             None
                   d ∈ [0,1]                                     Operation:            00h → WDT,
Operation:         See description below                                               0 → WDT prescaler,
Status Affected:   C                                                                   1 → TO,
                                                                                       0 → PD
Description:       The contents of register ‘f’ are
                   rotated one bit to the left through the       Status Affected:      TO, PD
                   Carry flag. If ‘d’ is ‘0’, the result is      Description:          The power-down status bit, PD,
                   placed in the W register. If ‘d’ is ‘1’,                            is cleared. Time-out status bit,
                   the result is stored back in register ‘f’.                          TO, is set. Watchdog Timer and
                               C        Register f                                     its prescaler are cleared.
                                                                                       The processor is put into Sleep
                                                                                       mode with the oscillator stopped.
RETURN             Return from Subroutine                        SUBLW              Subtract W from Literal
Syntax:            [ label ]       RETURN                        Syntax:            [ label ] SUBLW k
Operands:          None                                          Operands:          0 ≤ k ≤ 255
Operation:         TOS → PC                                      Operation:         k - (W) → (W)
Status Affected:   None                                          Status Affected: C, DC, Z
Description:       Return from subroutine. The stack             Description:       The W register is subtracted (2’s
                   is POPed and the top of the stack                                complement method) from the
                   (TOS) is loaded into the program                                 eight-bit literal ‘k’. The result is
                   counter. This is a two-cycle                                     placed in the W register.
                   instruction.
RRF                Rotate Right f through Carry                  SUBWF              Subtract W from f
Syntax:            [ label ]       RRF f,d                       Syntax:            [ label ] SUBWF f,d
Operands:          0 ≤ f ≤ 127                                   Operands:          0 ≤ f ≤ 127
                   d ∈ [0,1]                                                        d ∈ [0,1]
Operation:         See description below                         Operation:         (f) - (W) → (destination)
Status Affected:   C                                             Status Affected: C, DC, Z
Description:       The contents of register ‘f’ are              Description:       Subtract (2’s complement method)
                   rotated one bit to the right through                             W register from register ‘f’. If ‘d’ is
                   the Carry flag. If ‘d’ is ‘0’, the                               ‘0’, the result is stored in the W
                   result is placed in the W register.                              register. If ‘d’ is ‘1’, the result is
                   If ‘d’ is ‘1’, the result is placed                              stored back in register ‘f’.
                   back in register ‘f’.
                               C        Register f
 2003 Microchip Technology Inc.                         Preliminary                                    DS30498B-page 199
PIC16F7X7
SWAPF              Swap Nibbles in f                           XORWF              Exclusive OR W with f
Syntax:            [ label ] SWAPF f,d                         Syntax:            [ label ] XORWF        f,d
Operands:          0 ≤ f ≤ 127                                 Operands:          0 ≤ f ≤ 127
                   d ∈ [0,1]                                                      d ∈ [0,1]
Operation:         (f<3:0>) → (destination<7:4>),              Operation:         (W) .XOR. (f) → (destination)
                   (f<7:4>) → (destination<3:0>)               Status Affected:   Z
Status Affected:   None                                        Description:       Exclusive OR the contents of the
Description:       The upper and lower nibbles of                                 W register with register ‘f’. If ‘d’ is
                   register ‘f’ are exchanged. If ‘d’ is                          ‘0’, the result is stored in the W
                   ‘0’, the result is placed in the W                             register. If ‘d’ is ‘1’, the result is
                   register. If ‘d’ is ‘1’, the result is                         stored back in register ‘f’.
                   placed in register ‘f’.
XORLW               Exclusive OR Literal with W
Syntax:             [ label ] XORLW k
Operands:           0 ≤ k ≤ 255
Operation:          (W) .XOR. k → (W)
Status Affected:    Z
Description:        The contents of the W register
                    are XOR’ed with the eight-bit
                    literal ‘k’. The result is placed in
                    the W register.
DS30498B-page 200                                      Preliminary                      2003 Microchip Technology Inc.
                                                                                     PIC16F7X7
17.0     DEVELOPMENT SUPPORT                              17.1     MPLAB Integrated Development
                                                                   Environment Software
The PICmicro® microcontrollers are supported with a
full range of hardware and software development tools:    The MPLAB IDE software brings an ease of software
• Integrated Development Environment                      development previously unseen in the 8/16-bit micro-
                                                          controller market. The MPLAB IDE is a Windows®
  - MPLAB® IDE Software
                                                          based application that contains:
• Assemblers/Compilers/Linkers
                                                          • An interface to debugging tools
  - MPASMTM Assembler
                                                            - simulator
  - MPLAB C17 and MPLAB C18 C Compilers
                                                            - programmer (sold separately)
  - MPLINKTM Object Linker/
     MPLIBTM Object Librarian                               - emulator (sold separately)
  - MPLAB C30 C Compiler                                    - in-circuit debugger (sold separately)
  - MPLAB ASM30 Assembler/Linker/Library                  • A full-featured editor with color coded context
• Simulators                                              • A multiple project manager
  - MPLAB SIM Software Simulator                          • Customizable data windows with direct edit of
                                                            contents
  - MPLAB dsPIC30 Software Simulator
                                                          • High-level source code debugging
• Emulators
                                                          • Mouse over variable inspection
  - MPLAB ICE 2000 In-Circuit Emulator
                                                          • Extensive on-line help
  - MPLAB ICE 4000 In-Circuit Emulator
• In-Circuit Debugger                                     The MPLAB IDE allows you to:
  - MPLAB ICD 2                                           • Edit your source files (either assembly or C)
• Device Programmers                                      • One touch assemble (or compile) and download
  - PRO MATE® II Universal Device Programmer                to PICmicro emulator and simulator tools
                                                            (automatically updates all project information)
  - PICSTART® Plus Development Programmer
                                                          • Debug using:
• Low-Cost Demonstration Boards
                                                            - source files (assembly or C)
  - PICDEMTM 1 Demonstration Board
                                                            - absolute listing file (mixed assembly and C)
  - PICDEM.netTM Demonstration Board
                                                            - machine code
  - PICDEM 2 Plus Demonstration Board
  - PICDEM 3 Demonstration Board                          MPLAB IDE supports multiple debugging tools in a
                                                          single development paradigm, from the cost effective
  - PICDEM 4 Demonstration Board
                                                          simulators, through low-cost in-circuit debuggers, to
  - PICDEM 17 Demonstration Board                         full-featured emulators. This eliminates the learning
  - PICDEM 18R Demonstration Board                        curve when upgrading to tools with increasing flexibility
  - PICDEM LIN Demonstration Board                        and power.
  - PICDEM USB Demonstration Board
• Evaluation Kits
                                                          17.2     MPASM Assembler
  - KEELOQ®                                               The MPASM assembler is a full-featured, universal
  - PICDEM MSC                                            macro assembler for all PICmicro MCUs.
  - microID®                                              The MPASM assembler generates relocatable object
  - CAN                                                   files for the MPLINK object linker, Intel® standard HEX
  - PowerSmart®                                           files, MAP files to detail memory usage and symbol ref-
                                                          erence, absolute LST files that contain source lines and
  - Analog
                                                          generated machine code and COFF files for
                                                          debugging.
                                                          The MPASM assembler features include:
                                                          • Integration into MPLAB IDE projects
                                                          • User defined macros to streamline assembly code
                                                          • Conditional assembly for multi-purpose source
                                                            files
                                                          • Directives that allow complete control over the
                                                            assembly process
 2003 Microchip Technology Inc.                  Preliminary                                  DS30498B-page201
PIC16F7X7
17.3     MPLAB C17 and MPLAB C18                              17.6      MPLAB ASM30 Assembler, Linker
         C Compilers                                                    and Librarian
The MPLAB C17 and MPLAB C18 Code Development                  MPLAB ASM30 assembler produces relocatable
Systems are complete ANSI C compilers for                     machine code from symbolic assembly language for
Microchip’s PIC17CXXX and PIC18CXXX family of                 dsPIC30F devices. MPLAB C30 compiler uses the
microcontrollers. These compilers provide powerful            assembler to produce it’s object file. The assembler
integration capabilities, superior code optimization and      generates relocatable object files that can then be
ease of use not found with other compilers.                   archived or linked with other relocatable object files and
For easy source level debugging, the compilers provide        archives to create an executable file. Notable features
symbol information that is optimized to the MPLAB IDE         of the assembler include:
debugger.                                                     •   Support for the entire dsPIC30F instruction set
                                                              •   Support for fixed-point and floating-point data
17.4     MPLINK Object Linker/                                •   Command line interface
         MPLIB Object Librarian                               •   Rich directive set
The MPLINK object linker combines relocatable                 •   Flexible macro language
objects created by the MPASM assembler and the                •   MPLAB IDE compatibility
MPLAB C17 and MPLAB C18 C compilers. It can link
relocatable objects from precompiled libraries, using         17.7      MPLAB SIM Software Simulator
directives from a linker script.
                                                              The MPLAB SIM software simulator allows code devel-
The MPLIB object librarian manages the creation and           opment in a PC hosted environment by simulating the
modification of library files of precompiled code. When       PICmicro series microcontrollers on an instruction
a routine from a library is called from a source file, only   level. On any given instruction, the data areas can be
the modules that contain that routine will be linked in       examined or modified and stimuli can be applied from
with the application. This allows large libraries to be       a file, or user defined key press, to any pin. The execu-
used efficiently in many different applications.              tion can be performed in Single-Step, Execute Until
The object linker/library features include:                   Break or Trace mode.
• Efficient linking of single libraries instead of many       The MPLAB SIM simulator fully supports symbolic
  smaller files                                               debugging using the MPLAB C17 and MPLAB C18
• Enhanced code maintainability by grouping                   C Compilers, as well as the MPASM assembler. The
  related modules together                                    software simulator offers the flexibility to develop and
• Flexible creation of libraries with easy module             debug code outside of the laboratory environment,
  listing, replacement, deletion and extraction               making it an excellent, economical software
                                                              development tool.
17.5     MPLAB C30 C Compiler
                                                              17.8      MPLAB SIM30 Software Simulator
The MPLAB C30 C compiler is a full-featured, ANSI
compliant, optimizing compiler that translates standard       The MPLAB SIM30 software simulator allows code
ANSI C programs into dsPIC30F assembly language               development in a PC hosted environment by simulating
source. The compiler also supports many command-              the dsPIC30F series microcontrollers on an instruction
line options and language extensions to take full             level. On any given instruction, the data areas can be
advantage of the dsPIC30F device hardware capabili-           examined or modified and stimuli can be applied from
ties and afford fine control of the compiler code             a file, or user defined key press, to any of the pins.
generator.                                                    The MPLAB SIM30 simulator fully supports symbolic
MPLAB C30 is distributed with a complete ANSI C               debugging using the MPLAB C30 C Compiler and
standard library. All library functions have been vali-       MPLAB ASM30 assembler. The simulator runs in either
dated and conform to the ANSI C library standard. The         a Command Line mode for automated tasks, or from
library includes functions for string manipulation,           MPLAB IDE. This high-speed simulator is designed to
dynamic memory allocation, data conversion, time-             debug, analyze and optimize time intensive DSP
keeping and math functions (trigonometric, exponential        routines.
and hyperbolic). The compiler provides symbolic
information for high-level source debugging with the
MPLAB IDE.
DS30498B-page 202                                     Preliminary                       2003 Microchip Technology Inc.
                                                                                        PIC16F7X7
17.9     MPLAB ICE 2000                                      17.11 MPLAB ICD 2 In-Circuit Debugger
         High-Performance Universal                          Microchip’s In-Circuit Debugger, MPLAB ICD 2, is a
         In-Circuit Emulator                                 powerful, low-cost, run-time development tool,
The MPLAB ICE 2000 universal in-circuit emulator is          connecting to the host PC via an RS-232 or high-speed
intended to provide the product development engineer         USB interface. This tool is based on the Flash
with a complete microcontroller design tool set for          PICmicro MCUs and can be used to develop for these
PICmicro microcontrollers. Software control of the           and other PICmicro microcontrollers. The MPLAB
MPLAB ICE 2000 in-circuit emulator is advanced by            ICD 2 utilizes the in-circuit debugging capability built
the MPLAB Integrated Development Environment,                into the Flash devices. This feature, along with
which allows editing, building, downloading and source       Microchip’s In-Circuit Serial ProgrammingTM (ICSPTM)
debugging from a single environment.                         protocol, offers cost effective in-circuit Flash debugging
                                                             from the graphical user interface of the MPLAB Inte-
The MPLAB ICE 2000 is a full-featured emulator sys-          grated Development Environment. This enables a
tem with enhanced trace, trigger and data monitoring         designer to develop and debug source code by setting
features. Interchangeable processor modules allow the        breakpoints, single-stepping and watching variables,
system to be easily reconfigured for emulation of differ-    CPU status and peripheral registers. Running at full
ent processors. The universal architecture of the            speed enables testing hardware and applications in
MPLAB ICE in-circuit emulator allows expansion to            real-time. MPLAB ICD 2 also serves as a development
support new PICmicro microcontrollers.                       programmer for selected PICmicro devices.
The MPLAB ICE 2000 in-circuit emulator system has
been designed as a real-time emulation system with           17.12 PRO MATE II Universal Device
advanced features that are typically found on more                 Programmer
expensive development tools. The PC platform and
Microsoft® Windows 32-bit operating system were              The PRO MATE II is a universal, CE compliant device
chosen to best make these features available in a            programmer with programmable voltage verification at
simple, unified application.                                 VDDMIN and VDDMAX for maximum reliability. It features
                                                             an LCD display for instructions and error messages
17.10 MPLAB ICE 4000                                         and a modular detachable socket assembly to support
                                                             various package types. In Stand-Alone mode, the
      High-Performance Universal
                                                             PRO MATE II device programmer can read, verify and
      In-Circuit Emulator                                    program PICmicro devices without a PC connection. It
The MPLAB ICE 4000 universal in-circuit emulator is          can also set code protection in this mode.
intended to provide the product development engineer
with a complete microcontroller design tool set for high-    17.13 PICSTART Plus Development
end PICmicro microcontrollers. Software control of the             Programmer
MPLAB ICE in-circuit emulator is provided by the
                                                             The PICSTART Plus development programmer is an
MPLAB Integrated Development Environment, which
                                                             easy-to-use, low-cost, prototype programmer. It con-
allows editing, building, downloading and source
                                                             nects to the PC via a COM (RS-232) port. MPLAB
debugging from a single environment.
                                                             Integrated Development Environment software makes
The MPLAB ICD 4000 is a premium emulator system,             using the programmer simple and efficient. The
providing the features of MPLAB ICE 2000, but with           PICSTART Plus development programmer supports
increased emulation memory and high-speed perfor-            most PICmicro devices up to 40 pins. Larger pin count
mance for dsPIC30F and PIC18XXXX devices. Its                devices, such as the PIC16C92X and PIC17C76X,
advanced emulator features include complex triggering        may be supported with an adapter socket. The
and timing, up to 2 Mb of emulation memory and the           PICSTART Plus development programmer is CE
ability to view variables in real-time.                      compliant.
The MPLAB ICE 4000 in-circuit emulator system has
been designed as a real-time emulation system with
advanced features that are typically found on more
expensive development tools. The PC platform and
Microsoft Windows 32-bit operating system were
chosen to best make these features available in a
simple, unified application.
 2003 Microchip Technology Inc.                     Preliminary                                   DS30498B-page203
PIC16F7X7
17.14 PICDEM 1 PICmicro                                       17.17 PICDEM 3 PIC16C92X
      Demonstration Board                                           Demonstration Board
The PICDEM 1 demonstration board demonstrates the             The PICDEM 3 demonstration board supports the
capabilities of the PIC16C5X (PIC16C54 to                     PIC16C923 and PIC16C924 in the PLCC package. All
PIC16C58A), PIC16C61, PIC16C62X, PIC16C71,                    the necessary hardware and software is included to run
PIC16C8X, PIC17C42, PIC17C43 and PIC17C44. All                the demonstration programs.
necessary hardware and software is included to run
basic demo programs. The sample microcontrollers              17.18 PICDEM 4 8/14/18-Pin
provided with the PICDEM 1 demonstration board can                  Demonstration Board
be programmed with a PRO MATE II device program-
mer or a PICSTART Plus development programmer.                The PICDEM 4 can be used to demonstrate the capa-
The PICDEM 1 demonstration board can be connected             bilities of the 8, 14 and 18-pin PIC16XXXX and
to the MPLAB ICE in-circuit emulator for testing. A           PIC18XXXX MCUs, including the PIC16F818/819,
prototype area extends the circuitry for additional appli-    PIC16F87/88, PIC16F62XA and the PIC18F1320 fam-
cation components. Features include an RS-232                 ily of microcontrollers. PICDEM 4 is intended to show-
interface, a potentiometer for simulated analog input,        case the many features of these low pin count parts,
push button switches and eight LEDs.                          including LIN and Motor Control using ECCP. Special
                                                              provisions are made for low-power operation with the
17.15 PICDEM.net Internet/Ethernet                            supercapacitor circuit and jumpers allow on-board
      Demonstration Board                                     hardware to be disabled to eliminate current draw in
                                                              this mode. Included on the demo board are provisions
The PICDEM.net demonstration board is an Internet/            for Crystal, RC or Canned Oscillator modes, a five volt
Ethernet demonstration board using the PIC18F452              regulator for use with a nine volt wall adapter or battery,
microcontroller and TCP/IP firmware. The board                DB-9 RS-232 interface, ICD connector for program-
supports any 40-pin DIP device that conforms to the           ming via ICSP and development with MPLAB ICD 2,
standard pinout used by the PIC16F877 or                      2x16 liquid crystal display, PCB footprints for H-Bridge
PIC18C452. This kit features a user friendly TCP/IP           motor driver, LIN transceiver and EEPROM. Also
stack, web server with HTML, a 24L256 Serial                  included are: header for expansion, eight LEDs, four
EEPROM for Xmodem download to web pages into                  potentiometers, three push buttons and a prototyping
Serial EEPROM, ICSP/MPLAB ICD 2 interface con-                area. Included with the kit is a PIC16F627A and a
nector, an Ethernet interface, RS-232 interface and a         PIC18F1320. Tutorial firmware is included along with
16 x 2 LCD display. Also included is the book and             the User’s Guide.
CD-ROM “TCP/IP Lean, Web Servers for Embedded
Systems,” by Jeremy Bentham                                   17.19 PICDEM 17 Demonstration Board
17.16 PICDEM 2 Plus                                           The PICDEM 17 demonstration board is an evaluation
                                                              board that demonstrates the capabilities of several
      Demonstration Board                                     Microchip microcontrollers, including PIC17C752,
The PICDEM 2 Plus demonstration board supports                PIC17C756A, PIC17C762 and PIC17C766. A pro-
many 18, 28 and 40-pin microcontrollers, including            grammed sample is included. The PRO MATE II device
PIC16F87X and PIC18FXX2 devices. All the neces-               programmer, or the PICSTART Plus development pro-
sary hardware and software is included to run the dem-        grammer, can be used to reprogram the device for user
onstration programs. The sample microcontrollers              tailored application development. The PICDEM 17
provided with the PICDEM 2 demonstration board can            demonstration board supports program download and
be programmed with a PRO MATE II device program-              execution from external on-board Flash memory. A
mer, PICSTART Plus development programmer, or                 generous prototype area is available for user hardware
MPLAB ICD 2 with a Universal Programmer Adapter.              expansion.
The MPLAB ICD 2 and MPLAB ICE in-circuit emulators
may also be used with the PICDEM 2 demonstration
board to test firmware. A prototype area extends the
circuitry for additional application components. Some
of the features include an RS-232 interface, a 2 x 16
LCD display, a piezo speaker, an on-board temperature
sensor, four LEDs and sample PIC18F452 and
PIC16F877 Flash microcontrollers.
DS30498B-page 204                                     Preliminary                       2003 Microchip Technology Inc.
                                                                                    PIC16F7X7
17.20 PICDEM 18R PIC18C601/801                            17.23 PICDEM USB PIC16C7X5
      Demonstration Board                                       Demonstration Board
The PICDEM 18R demonstration board serves to assist       The PICDEM USB Demonstration Board shows off the
development of the PIC18C601/801 family of Microchip      capabilities of the PIC16C745 and PIC16C765 USB
microcontrollers. It provides hardware implementation     microcontrollers. This board provides the basis for
of both 8-bit Multiplexed/Demultiplexed and 16-bit        future USB products.
Memory modes. The board includes 2 Mb external
Flash memory and 128 Kb SRAM memory, as well as           17.24 Evaluation and
serial EEPROM, allowing access to the wide range of             Programming Tools
memory types supported by the PIC18C601/801.
                                                          In addition to the PICDEM series of circuits, Microchip
17.21 PICDEM LIN PIC16C43X                                has a line of evaluation kits and demonstration software
      Demonstration Board                                 for these products.
                                                          • KEELOQ evaluation and programming tools for
The powerful LIN hardware and software kit includes a       Microchip’s HCS Secure Data Products
series of boards and three PICmicro microcontrollers.
                                                          • CAN developers kit for automotive network
The small footprint PIC16C432 and PIC16C433 are
                                                            applications
used as slaves in the LIN communication and feature
on-board LIN transceivers. A PIC16F874 Flash              • Analog design boards and filter design software
microcontroller serves as the master. All three micro-    • PowerSmart battery charging evaluation/
controllers are programmed with firmware to provide         calibration kits
LIN bus communication.                                    • IrDA® development kit
                                                          • microID development and rfLabTM development
17.22 PICkitTM 1 Flash Starter Kit                          software
A complete “development system in a box”, the PICkit      • SEEVAL® designer kit for memory evaluation and
Flash Starter Kit includes a convenient multi-section       endurance calculations
board for programming, evaluation and development of      • PICDEM MSC demo boards for Switching mode
8/14-pin Flash PIC® microcontrollers. Powered via           power supply, high-power IR driver, delta sigma
USB, the board operates under a simple Windows GUI.         ADC and flow rate sensor
The PICkit 1 Starter Kit includes the user's guide (on
                                                          Check the Microchip web page and the latest Product
CD ROM), PICkit 1 tutorial software and code for vari-
                                                          Line Card for the complete list of demonstration and
ous applications. Also included are MPLAB® IDE (Inte-
                                                          evaluation kits.
grated Development Environment) software, software
and hardware “Tips 'n Tricks for 8-pin Flash PIC®
Microcontrollers” Handbook and a USB Interface
Cable. Supports all current 8/14-pin Flash PIC
microcontrollers, as well as many future planned
devices.
 2003 Microchip Technology Inc.                  Preliminary                                  DS30498B-page205
PIC16F7X7
NOTES:
DS30498B-page 206   Preliminary    2003 Microchip Technology Inc.
                                                                                                                                PIC16F7X7
18.0         ELECTRICAL CHARACTERISTICS
Absolute Maximum Ratings †
Ambient temperature under bias................................................................................................................ .-55 to +125°C
Storage temperature .............................................................................................................................. -65°C to +150°C
Voltage on any pin with respect to VSS (except VDD, MCLR. and RA4) ......................................... -0.3V to (VDD + 0.3V)
Voltage on VDD with respect to VSS ............................................................................................................ -0.3 to +6.5V
Voltage on MCLR with respect to VSS (Note 2) ..............................................................................................0 to +13.5V
Voltage on RA4 with respect to Vss ...................................................................................................................0 to +12V
Total power dissipation (Note 1) ...............................................................................................................................1.0W
Maximum current out of VSS pin ...........................................................................................................................300 mA
Maximum current into VDD pin ..............................................................................................................................250 mA
Input clamp current, IIK (VI < 0 or VI > VDD)..................................................................................................................... ± 20 mA
Output clamp current, IOK (VO < 0 or VO > VDD) ............................................................................................................. ± 20 mA
Maximum output current sunk by any I/O pin..........................................................................................................25 mA
Maximum output current sourced by any I/O pin ....................................................................................................25 mA
Maximum current sunk by PORTA, PORTB and PORTE (combined) (Note 3) ....................................................200 mA
Maximum current sourced by PORTA, PORTB and PORTE (combined) (Note 3)...............................................200 mA
Maximum current sunk by PORTC and PORTD (combined) (Note 3) .................................................................200 mA
Maximum current sourced by PORTC and PORTD (combined) (Note 3) ............................................................200 mA
   Note 1: Power dissipation is calculated as follows: Pdis = VDD x {IDD - ∑ IOH} + ∑ {(VDD - VOH) x IOH} + ∑(VOl x IOL)
           2: Voltage spikes at the MCLR pin may cause latchup. A series resistor of greater than 1 kΩ should be used
              to pull MCLR to VDD, rather than tying the pin directly to VDD.
           3: PORTD and PORTE are not implemented on the PIC16F737/767 devices.
 † NOTICE: Stresses above those listed under “Absolute Maximum Ratings” may cause permanent damage to the
 device. This is a stress rating only and functional operation of the device at those or any other conditions above those
 indicated in the operation listings of this specification is not implied. Exposure to maximum rating conditions for
 extended periods may affect device reliability.
 2003 Microchip Technology Inc.                                         Preliminary                                                          DS30498B-page 207
PIC16F7X7
FIGURE 18-1:               PIC16F7X7 VOLTAGE-FREQUENCY GRAPH
                       6.0V
                       5.5V
                       5.0V
                       4.5V
           Voltage
                       4.0V
                       3.5V
                       3.0V
                       2.5V
                       2.0V
                                                          16 MHz                      20 MHz
                                                    Frequency
FIGURE 18-2:               PIC16LF7X7 VOLTAGE-FREQUENCY GRAPH
                                        6.0V
                                        5.5V
                                        5.0V
                                        4.5V
                              Voltage
                                        4.0V
                                        3.5V
                                        3.0V
                                        2.5V
                                        2.0V
                                                  4 MHz       10 MHz
                                                    Frequency
                     FMAX = (12 MHz/V) (VDDAPPMIN - 2.5V) + 4 MHz
                     Note 1: VDDAPPMIN is the minimum voltage of the PICmicro® device in the application.
                     Note 2: FMAX has a maximum frequency of 10 MHz.
DS30498B-page 208                                     Preliminary                          2003 Microchip Technology Inc.
                                                                                         PIC16F7X7
18.1     DC Characteristics: PIC16F737/747/767/777 (Industrial, Extended)
                             PIC16LF737/747/767/777 (Industrial)
PIC16LF737/747/767/777                          Standard Operating Conditions (unless otherwise stated)
  (Industrial)                                  Operating temperature -40°C ≤ TA ≤ +85°C for industrial
PIC16F737/747/767/777                           Standard Operating Conditions (unless otherwise stated)
  (Industrial, Extended)                        Operating temperature -40°C ≤ TA ≤ +85°C for industrial
Param
      Sym                Characteristic          Min    Typ† Max Units                     Conditions
 No.
         VDD     Supply Voltage
D001                               PIC16LF7X7    2.5       —     5.5    V    A/D in use, -40°C to +85°C
                                                 2.2       —     5.5    V    A/D in use, 0°C to +85°C
                                                 2.0       —     5.5    V    A/D not used, -40°C to +85°C
D001                                PIC16F7X7    4.0       —     5.5    V    All configurations
D001A                                           VBOR*      —     5.5    V    BOR enabled (Note 7)
D002*    VDR     RAM Data Retention               —        1.5   —      V
                 Voltage (Note 1)
D003     VPOR VDD Start Voltage to                —     VSS      —      V    See section on Power-on Reset for details
              ensure internal Power-on
              Reset signal
D004*    SVDD VDD Rise Rate to ensure            0.05      —     —     V/ms See section on Power-on Reset for details
              internal Power-on Reset signal
         VBOR Brown-out Reset Voltage
                                   PIC16LF7X7 Industrial Low Voltage
D005             BORV1:BORV0 = 11                NA        —     NA     V    Reserved
                 BORV1:BORV0 = 10                2.50   2.72 2.94       V
                 BORV1:BORV0 = 01                3.88   4.22 4.56       V
                 BORV1:BORV0 = 00                4.18   4.54 4.90       V
D005                                PIC16F7X7 Industrial
                 BORV1:BORV0 = 1x                NA        —     NA     V    Not in operating voltage range of device
                 BORV1:BORV0 = 01                3.88   4.22 4.56       V
                 BORV1:BORV0 = 00                4.18   4.54 4.90       V
Legend: Shading of rows is to assist in readability of of the table.
      * These parameters are characterized but not tested.
      † Data in “Typ” column is at 5V, 25°C unless otherwise stated. These parameters are for design guidance only
        and are not tested.
Note 1: This is the limit to which VDD can be lowered without losing RAM data.
     2: The supply current is mainly a function of the operating voltage and frequency. Other factors, such as I/O
        pin loading and switching rate, oscillator type, internal code execution pattern and temperature also have an
        impact on the current consumption.
                  The test conditions for all IDD measurements in active operation mode are:
                  OSC1 = external square wave, from-rail to-rail; all I/O pins tri-stated, pulled to VDD
                  MCLR = VDD; WDT enabled/disabled as specified.
     3: The power-down current in Sleep mode does not depend on the oscillator type. Power-down current is
        measured with the part in Sleep mode, with all I/O pins in high-impedance state and tied to VDD and VSS.
     4: For RC osc configuration, current through REXT is not included. The current through the resistor can be
        estimated by the formula Ir = VDD/2REXT (mA) with REXT in kΩ.
     5: Timer1 oscillator (when enabled) adds approximately 20 µA to the specification. This value is from
        characterization and is for design guidance only. This is not tested.
     6: The ∆ current is the additional current consumed when this peripheral is enabled. This current should be
        added to the base IDD or IPD measurement.
     7: When BOR is enabled, the device will operate correctly until the VBOR voltage trip point is reached.
 2003 Microchip Technology Inc.                 Preliminary                                      DS30498B-page 209
PIC16F7X7
18.2        DC Characteristics: Power-down and Supply Current
                                PIC16F7X7 (Industrial)
                                PIC16LF7X7 (Industrial)
PIC16LF7X7                               Standard Operating Conditions (unless otherwise stated)
   (Industrial)                          Operating temperature      -40°C ≤ TA ≤ +85°C for industrial
PIC16F7X7                                Standard Operating Conditions (unless otherwise stated)
   (Industrial)                          Operating temperature      -40°C ≤ TA ≤ +85°C for industrial
 Param
                    Device                Typ    Max     Units                               Conditions
  No.
            Power-down Current (IPD)(1)
                         PIC16LF7X7       0.1     0.4     µA         -40°C
                                          0.1     0.4     µA         +25°C          VDD = 2.0V
                                          0.4     1.5     µA         +85°C
                         PIC16LF7X7       0.3     0.5     µA         -40°C
                                          0.3     0.5     µA         +25°C          VDD = 3.0V
                                          0.7     1.7     µA         +85°C
                           All devices    0.6     1.0     µA         -40°C
                                          0.6     1.0     µA         +25°C          VDD = 5.0V
                                          1.2     5.0     µA         +85°C
Legend:      Shading of rows is to assist in readability of the table.
Note 1:      The power-down current in Sleep mode does not depend on the oscillator type. Power-down current is measured with
             the part in Sleep mode, with all I/O pins in high-impedance state and tied to VDD or VSS and all features that add delta
             current disabled (such as WDT, Timer1 Oscillator, BOR, etc.).
       2:    The supply current is mainly a function of operating voltage, frequency and mode. Other factors, such as I/O pin loading
             and switching rate, oscillator type and circuit, internal code execution pattern and temperature, also have an impact on
             the current consumption.
             The test conditions for all IDD measurements in active operation mode are:
                         OSC1 = external square wave, from rail-to-rail; all I/O pins tri-stated, pulled to VDD;
                         MCLR = VDD; WDT enabled/disabled as specified.
       3:    For RC oscillator configurations, current through REXT is not included. The current through the resistor can be estimated
             by the formula Ir = VDD/2REXT (mA) with REXT in kΩ.
DS30498B-page 210                                         Preliminary                                2003 Microchip Technology Inc.
                                                                                                       PIC16F7X7
18.2        DC Characteristics: Power-down and Supply Current
                                PIC16F7X7 (Industrial)
                                PIC16LF7X7 (Industrial) (Continued)
PIC16LF7X7                                Standard Operating Conditions (unless otherwise stated)
   (Industrial)                           Operating temperature      -40°C ≤ TA ≤ +85°C for industrial
PIC16F7X7                                 Standard Operating Conditions (unless otherwise stated)
   (Industrial)                           Operating temperature      -40°C ≤ TA ≤ +85°C for industrial
 Param
                     Device                Typ    Max     Units                               Conditions
  No.
            Supply Current (IDD)(2,3)
                          PIC16LF7X7        9      20      µA         -40°C
                                            7      15      µA         +25°C          VDD = 2.0V
                                            7      15      µA         +85°C
                          PIC16LF7X7        16     30      µA         -40°C
                                                                                                              FOSC = 32 kHZ
                                            14     25      µA         +25°C          VDD = 3.0V
                                                                                                              (LP Oscillator)
                                            14     25      µA         +85°C
                            All devices     32     40      µA         -40°C
                                            26     35      µA         +25°C          VDD = 5.0V
                                            26     35      µA         +85°C
                          PIC16LF7X7        72     95      µA         -40°C
                                            76     90      µA         +25°C          VDD = 2.0V
                                            76     90      µA         +85°C
                          PIC16LF7X7       138     175     µA         -40°C
                                                                                                              FOSC = 1 MHZ
                                           136     170     µA         +25°C          VDD = 3.0V
                                                                                                             (RC Oscillator)(3)
                                           136     170     µA         +85°C
                            All devices    310     380     µA         -40°C
                                           290     360     µA         +25°C          VDD = 5.0V
                                           280     360     µA         +85°C
                          PIC16LF7X7       270     315     µA         -40°C
                                           280     310     µA         +25°C          VDD = 2.0V
                                           285     310     µA         +85°C
                          PIC16LF7X7       460     610     µA         -40°C
                                                                                                              FOSC = 4 MHz
                                           450     600     µA         +25°C          VDD = 3.0V
                                                                                                             (RC Oscillator)(3)
                                           450     600     µA         +85°C
                            All devices    900    1060     µA         -40°C
                                           890    1050     µA         +25°C          VDD = 5.0V
                                           890    1050     µA         +85°C
Legend:       Shading of rows is to assist in readability of the table.
Note 1:       The power-down current in Sleep mode does not depend on the oscillator type. Power-down current is measured with
              the part in Sleep mode, with all I/O pins in high-impedance state and tied to VDD or VSS and all features that add delta
              current disabled (such as WDT, Timer1 Oscillator, BOR, etc.).
       2:     The supply current is mainly a function of operating voltage, frequency and mode. Other factors, such as I/O pin loading
              and switching rate, oscillator type and circuit, internal code execution pattern and temperature, also have an impact on
              the current consumption.
              The test conditions for all IDD measurements in active operation mode are:
                          OSC1 = external square wave, from rail-to-rail; all I/O pins tri-stated, pulled to VDD;
                          MCLR = VDD; WDT enabled/disabled as specified.
       3:     For RC oscillator configurations, current through REXT is not included. The current through the resistor can be estimated
              by the formula Ir = VDD/2REXT (mA) with REXT in kΩ.
 2003 Microchip Technology Inc.                           Preliminary                                            DS30498B-page 211
PIC16F7X7
18.2        DC Characteristics: Power-down and Supply Current
                                PIC16F7X7 (Industrial)
                                PIC16LF7X7 (Industrial) (Continued)
PIC16LF7X7                                Standard Operating Conditions (unless otherwise stated)
   (Industrial)                           Operating temperature      -40°C ≤ TA ≤ +85°C for industrial
PIC16F7X7                                 Standard Operating Conditions (unless otherwise stated)
   (Industrial)                           Operating temperature      -40°C ≤ TA ≤ +85°C for industrial
 Param
                     Device                Typ    Max     Units                               Conditions
  No.
            Supply Current (IDD)(2,3)
                            All devices    1.8     2.3     mA         -40°C
                                           1.6     2.2     mA         +25°C          VDD = 4.0V
                                           1.3     2.2     mA         +85°C                                   FOSC = 20 MHZ
                            All devices    3.0     4.2     mA         -40°C                                   (HS Oscillator)
                                           2.5     4.0     mA         +25°C          VDD = 5.0V
                                           2.5     4.0     mA         +85°C
Legend:       Shading of rows is to assist in readability of the table.
Note 1:       The power-down current in Sleep mode does not depend on the oscillator type. Power-down current is measured with
              the part in Sleep mode, with all I/O pins in high-impedance state and tied to VDD or VSS and all features that add delta
              current disabled (such as WDT, Timer1 Oscillator, BOR, etc.).
       2:     The supply current is mainly a function of operating voltage, frequency and mode. Other factors, such as I/O pin loading
              and switching rate, oscillator type and circuit, internal code execution pattern and temperature, also have an impact on
              the current consumption.
              The test conditions for all IDD measurements in active operation mode are:
                          OSC1 = external square wave, from rail-to-rail; all I/O pins tri-stated, pulled to VDD;
                          MCLR = VDD; WDT enabled/disabled as specified.
       3:     For RC oscillator configurations, current through REXT is not included. The current through the resistor can be estimated
              by the formula Ir = VDD/2REXT (mA) with REXT in kΩ.
DS30498B-page 212                                          Preliminary                                2003 Microchip Technology Inc.
                                                                                                       PIC16F7X7
18.2        DC Characteristics: Power-down and Supply Current
                                PIC16F7X7 (Industrial)
                                PIC16LF7X7 (Industrial) (Continued)
PIC16LF7X7                                Standard Operating Conditions (unless otherwise stated)
   (Industrial)                           Operating temperature      -40°C ≤ TA ≤ +85°C for industrial
PIC16F7X7                                 Standard Operating Conditions (unless otherwise stated)
   (Industrial)                           Operating temperature      -40°C ≤ TA ≤ +85°C for industrial
 Param
                     Device                Typ    Max     Units                               Conditions
  No.
            Supply Current (IDD)(2,3)
                          PIC16LF7X7        8      20      µA         -40°C
                                            7      15      µA         +25°C          VDD = 2.0V
                                            7      15      µA         +85°C
                          PIC16LF7X7        16     30      µA         -40°C                                  FOSC = 31.25 kHz
                                            14     25      µA         +25°C          VDD = 3.0V               (RC_RUN mode,
                                            14     25      µA         +85°C                                Internal RC Oscillator)
                            All devices     32     40      µA         -40°C
                                            29     35      µA         +25°C          VDD = 5.0V
                                            29     35      µA         +85°C
                          PIC16LF7X7       132     160     µA         -40°C
                                           126     155     µA         +25°C          VDD = 2.0V
                                           126     155     µA         +85°C
                          PIC16LF7X7       260     310     µA         -40°C                                    FOSC = 1 MHz
                                           230     300     µA         +25°C          VDD = 3.0V               (RC_RUN mode,
                                           230     300     µA         +85°C                                Internal RC Oscillator)
                            All devices    560     690     µA         -40°C
                                           500     650     µA         +25°C          VDD = 5.0V
                                           500     650     µA         +85°C
                          PIC16LF7X7       310     420     µA         -40°C
                                           300     410     µA         +25°C          VDD = 2.0V
                                           300     410     µA         +85°C
                          PIC16LF7X7       550     650     µA         -40°C                                    FOSC = 4 MHz
                                           530     620     µA         +25°C          VDD = 3.0V               (RC_RUN mode,
                                           530     620     µA         +85°C                                Internal RC Oscillator)
                            All devices    1.2     1.5     mA         -40°C
                                           1.1     1.4     mA         +25°C          VDD = 5.0V
                                           1.1     1.4     mA         +85°C
Legend:       Shading of rows is to assist in readability of the table.
Note 1:       The power-down current in Sleep mode does not depend on the oscillator type. Power-down current is measured with
              the part in Sleep mode, with all I/O pins in high-impedance state and tied to VDD or VSS and all features that add delta
              current disabled (such as WDT, Timer1 Oscillator, BOR, etc.).
       2:     The supply current is mainly a function of operating voltage, frequency and mode. Other factors, such as I/O pin loading
              and switching rate, oscillator type and circuit, internal code execution pattern and temperature, also have an impact on
              the current consumption.
              The test conditions for all IDD measurements in active operation mode are:
                          OSC1 = external square wave, from rail-to-rail; all I/O pins tri-stated, pulled to VDD;
                          MCLR = VDD; WDT enabled/disabled as specified.
       3:     For RC oscillator configurations, current through REXT is not included. The current through the resistor can be estimated
              by the formula Ir = VDD/2REXT (mA) with REXT in kΩ.
 2003 Microchip Technology Inc.                           Preliminary                                            DS30498B-page 213
PIC16F7X7
18.2        DC Characteristics: Power-down and Supply Current
                                PIC16F7X7 (Industrial)
                                PIC16LF7X7 (Industrial) (Continued)
PIC16LF7X7                                Standard Operating Conditions (unless otherwise stated)
   (Industrial)                           Operating temperature      -40°C ≤ TA ≤ +85°C for industrial
PIC16F7X7                                 Standard Operating Conditions (unless otherwise stated)
   (Industrial)                           Operating temperature      -40°C ≤ TA ≤ +85°C for industrial
 Param
                     Device                Typ    Max     Units                               Conditions
  No.
            Supply Current (IDD)(2,3)
                          PIC16LF7X7       .950    1.3     mA         -40°C
                                           .930    1.2     mA         +25°C          VDD = 3.0V
                                           .930    1.2     mA         +85°C                                    FOSC = 8 MHz
                                                                                                              (RC_RUN mode,
                            All devices    1.8     3.0     mA         -40°C                                Internal RC Oscillator)
                                           1.7     2.8     mA         +25°C          VDD = 5.0V
                                           1.7     2.8     mA         +85°C
                          PIC16LF7X7        9      13      µA         -10°C
                                            9      14      µA         +25°C          VDD = 2.0V
                                            11     16      µA         +70°C
                          PIC16LF7X7        12     34      µA         -10°C                                    FOSC = 32 kHz
                                            12     31      µA         +25°C          VDD = 3.0V              (SEC_RUN mode,
                                            14     28      µA         +70°C                                   Timer1 as Clock)
                            All devices     20     72      µA         -10°C
                                            20     65      µA         +25°C          VDD = 5.0V
                                            25     59      µA         +70°C
Legend:       Shading of rows is to assist in readability of the table.
Note 1:       The power-down current in Sleep mode does not depend on the oscillator type. Power-down current is measured with
              the part in Sleep mode, with all I/O pins in high-impedance state and tied to VDD or VSS and all features that add delta
              current disabled (such as WDT, Timer1 Oscillator, BOR, etc.).
       2:     The supply current is mainly a function of operating voltage, frequency and mode. Other factors, such as I/O pin loading
              and switching rate, oscillator type and circuit, internal code execution pattern and temperature, also have an impact on
              the current consumption.
              The test conditions for all IDD measurements in active operation mode are:
                          OSC1 = external square wave, from rail-to-rail; all I/O pins tri-stated, pulled to VDD;
                          MCLR = VDD; WDT enabled/disabled as specified.
       3:     For RC oscillator configurations, current through REXT is not included. The current through the resistor can be estimated
              by the formula Ir = VDD/2REXT (mA) with REXT in kΩ.
DS30498B-page 214                                          Preliminary                                2003 Microchip Technology Inc.
                                                                                                         PIC16F7X7
18.2           DC Characteristics: Power-down and Supply Current
                                   PIC16F7X7 (Industrial)
                                   PIC16LF7X7 (Industrial) (Continued)
PIC16LF7X7                                 Standard Operating Conditions (unless otherwise stated)
   (Industrial)                            Operating temperature      -40°C ≤ TA ≤ +85°C for industrial
PIC16F7X7                                  Standard Operating Conditions (unless otherwise stated)
   (Industrial)                            Operating temperature      -40°C ≤ TA ≤ +85°C for industrial
 Param
                        Device              Typ     Max     Units                               Conditions
  No.
               Module Differential Currents (∆IWDT, ∆IBOR, ∆ILVD, ∆IOSCB, ∆IAD)
D022                   Watchdog Timer       1.5     3.8      µA         -40°C
(∆IWDT)                                     2.2     3.8      µA         +25°C          VDD = 2.0V
                                            2.7     4.0      µA         +85°C
                                            2.3     4.6      µA         -40°C
                                            2.7     4.6      µA         +25°C          VDD = 3.0V
                                            3.1     4.8      µA         +85°C
                                            3.0     10.0     µA         -40°C
                                            3.3     10.0     µA         +25°C          VDD = 5.0V
                                            3.9     13.0     µA         +85°C
D022A                  Brown-out Reset       17      35      µA     -40°C to +85°C     VDD = 3.0V
(∆IBOR)                                      47      45      µA     -40°C to +85°C     VDD = 5.0V
                                             0       0       µA     -40°C to +85°C     VDD = 2.0V
                                                                                                            BOREN:BORSEN = 10
                                                                                       VDD = 3.0V
                                                                                                               in Sleep mode
                                                                                       VDD = 5.0V
D022B               Low-Voltage Detect       14      25      µA     -40°C to +85°C     VDD = 2.0V
(∆ILVD)                                      18      35      µA     -40°C to +85°C     VDD = 3.0V
                                             21      45      µA     -40°C to +85°C     VDD = 5.0V
D025                   Timer1 Oscillator    1.7     2.3      µA         -40°C
(∆IOSCB)                                    1.8     2.3      µA         +25°C          VDD = 2.0V
                                            2.0     2.3      µA         +85°C
                                            2.2     3.8      µA         -40°C
                                            2.6     3.8      µA         +25°C          VDD = 3.0V              32 kHz on Timer1
                                            2.9     3.8      µA         +85°C
                                            3.0     6.0      µA         -40°C
                                            3.2     6.0      µA         +25°C          VDD = 5.0V
                                            3.4     7.0      µA         +85°C
D026                      A/D Converter 0.001       2.0      µA     -40°C to +85°C     VDD = 2.0V
(∆IAD)                                     0.001    2.0      µA     -40°C to +85°C     VDD = 3.0V            A/D on, not converting
                                           0.003    2.0      µA     -40°C to +85°C     VDD = 5.0V
Legend:         Shading of rows is to assist in readability of the table.
Note 1:         The power-down current in Sleep mode does not depend on the oscillator type. Power-down current is measured with
                the part in Sleep mode, with all I/O pins in high-impedance state and tied to VDD or VSS and all features that add delta
                current disabled (such as WDT, Timer1 Oscillator, BOR, etc.).
          2:    The supply current is mainly a function of operating voltage, frequency and mode. Other factors, such as I/O pin loading
                and switching rate, oscillator type and circuit, internal code execution pattern and temperature, also have an impact on
                the current consumption.
                The test conditions for all IDD measurements in active operation mode are:
                            OSC1 = external square wave, from rail-to-rail; all I/O pins tri-stated, pulled to VDD;
                            MCLR = VDD; WDT enabled/disabled as specified.
          3:    For RC oscillator configurations, current through REXT is not included. The current through the resistor can be estimated
                by the formula Ir = VDD/2REXT (mA) with REXT in kΩ.
 2003 Microchip Technology Inc.                             Preliminary                                            DS30498B-page 215
PIC16F7X7
18.3      DC Characteristics:              Internal RC Accuracy
                                           PIC16F7X7 (Industrial, Extended)
                                           PIC16LF7X7 (Industrial)
PIC16LF7X7                              Standard Operating Conditions (unless otherwise stated)
   (Industrial)                         Operating temperature      -40°C ≤ TA ≤ +85°C for industrial
PIC16F7X7                               Standard Operating Conditions (unless otherwise stated)
   (Industrial, Extended)               Operating temperature      -40°C ≤ TA ≤ +85°C for industrial
 Param
                   Device                 Min      Typ       Max      Units                      Conditions
  No.
          INTOSC Accuracy @ Freq = 8 MHz, 4 MHz, 2 MHz, 1 MHz, 500 kHz, 250 kHz, 125 kHz(1)
                        PIC16LF7X7         -2       ±1        2        %            +25°C               VDD = 2.7V-3.3V
                                           -5       —         5        %       -10°C to +85°C           VDD = 2.7V-3.3V
                                          -10       —         10       %       -40°C to +85°C           VDD = 2.7V-3.3V
                            PIC16F7X7      -2       ±1        2        %            +25°C               VDD = 4.5V-5.5V
                                           -5       —         5        %       -10°C to +85°C           VDD = 4.5V-5.5V
                                          -10       —         10       %       -40°C to +85°C           VDD = 4.5V-5.5V
          INTRC Accuracy @ Freq = 31 kHz(2)
                        PIC16LF7X7 26.562           —       35.938    kHz      -40°C to +85°C           VDD = 2.7V-3.3V
                            PIC16F7X7 26.562        —       35.938    kHz      -40°C to +85°C           VDD = 4.5V-5.5V
Legend:     Shading of rows is to assist in readability of the table.
Note 1:     Frequency calibrated at 25°C. OSCTUNE register can be used to compensate for temperature drift.
     2:     INTRC is used to calibrate INTOSC.
DS30498B-page 216                                        Preliminary                             2003 Microchip Technology Inc.
                                                                                                    PIC16F7X7
18.4     DC Characteristics:           PIC16F737/747/767/777 (Industrial, Extended)
                                       PIC16LF737/747/767/777 (Industrial)
                                                   Standard Operating Conditions (unless otherwise stated)
                                                   Operating temperature     -40°C ≤ TA ≤ +85°C for industrial
DC CHARACTERISTICS                                                           -40°C ≤ TA ≤ +125°C for extended
                                                   Operating voltage VDD range as described in
                                                   Section 18.1 “DC Characteristics”.
Param
      Sym                Characteristic                    Min            Typ†    Max       Units           Conditions
 No.
         VIL    Input Low Voltage
                I/O ports:
D030                 with TTL buffer                       VSS             —     0.15 VDD    V      For entire VDD range
D030A                                                      VSS             —      0.8V       V      4.5V ≤ VDD ≤ 5.5V
D031                 with Schmitt Trigger buffer           VSS             —     0.2 VDD     V
D032            MCLR, OSC1 (in RC mode)                    VSS             —     0.2 VDD     V      (Note 1)
D033            OSC1 (in XT and LP mode)                   VSS             —      0.3V       V
                OSC1 (in HS mode)                          VSS             —     0.3 VDD     V
         VIH    Input High Voltage
                I/O ports:
D040                 with TTL buffer                       2.0             —       VDD       V      4.5V ≤ VDD ≤ 5.5V
D040A                                              0.25   VDD +   0.8 V    —       VDD       V      For entire VDD range
D041                 with Schmitt Trigger buffer      0.8 VDD              —       VDD       V      For entire VDD range
D042            MCLR                                  0.8 VDD              —       VDD       V
D042A           OSC1 (in XT and LP mode)                  1.6V             —       VDD       V
                OSC1 (in HS mode)                     0.7 VDD              —       VDD       V
D043            OSC1 (in RC mode)                     0.9 VDD              —       VDD       V      (Note 1)
D070     IPURB PORTB Weak Pull-up Current                  50             250      400       µA     VDD = 5V, VPIN = VSS
         IIL    Input Leakage Current (Notes 2, 3)
D060            I/O ports                                  —               —       ±1        µA     VSS ≤ VPIN ≤ VDD, pin at
                                                                                                    high-impedance
D061            MCLR, RE3/T0CKI                            —               —       ±5        µA     VSS ≤ VPIN ≤ VDD
D063            OSC1                                       —               —       ±5        µA     VSS ≤ VPIN ≤ VDD, XT, HS
                                                                                                    and LP osc configuration
      * These parameters are characterized but not tested.
      † Data in “Typ” column is at 5V, 25°C unless otherwise stated. These parameters are for design guidance
        only and are not tested.
Note 1: In RC oscillator configuration, the OSC1/CLKI pin is a Schmitt Trigger input. It is not recommended that the
        PIC16F7X7 be driven with external clock in RC mode.
     2: The leakage current on the MCLR pin is strongly dependent on the applied voltage level. The specified
        levels represent normal operating conditions. Higher leakage current may be measured at different input
        voltages.
     3: Negative current is defined as current sourced by the pin.
 2003 Microchip Technology Inc.                    Preliminary                                                DS30498B-page 217
PIC16F7X7
18.4    DC Characteristics:          PIC16F737/747/767/777 (Industrial, Extended)
                                     PIC16LF737/747/767/777 (Industrial) (Continued)
                                                Standard Operating Conditions (unless otherwise stated)
                                                Operating temperature     -40°C ≤ TA ≤ +85°C for industrial
DC CHARACTERISTICS                                                        -40°C ≤ TA ≤ +125°C for extended
                                                Operating voltage VDD range as described in
                                                Section 18.1 “DC Characteristics”.
Param
      Sym               Characteristic                Min        Typ†     Max     Units             Conditions
 No.
        VOL    Output Low Voltage
D080           I/O ports                               —           —       0.6     V      IOL = 8.5 mA, VDD = 4.5V,
                                                                                          -40°C to +125°C
D083           OSC2/CLKO (RC osc config)               —           —       0.6     V      IOL = 1.6 mA, VDD = 4.5V,
                                                                                          -40°C to +125°C
                                                       —           —       0.6     V      IOL = 1.2 mA, VDD = 4.5V,
                                                                                          -40°C to +125°C
        VOH    Output High Voltage
D090           I/O ports (Note 3)                  VDD – 0.7       —       —       V      IOH = -3.0 mA, VDD = 4.5V,
                                                                                          -40°C to +125°C
D092           OSC2/CLKO (RC osc config)           VDD – 0.7       —       —       V      IOH = -1.3 mA, VDD = 4.5V,
                                                                                          -40°C to +125°C
                                                   VDD – 0.7       —       —       V      IOH = -1.0 mA, VDD = 4.5V,
                                                                                          -40°C to +125°C
D150* VOD      Open-Drain High Voltage                 —           —       12      V      RA4 pin
               Capacitive Loading Specs on Output Pins
D100    COSC2 OSC2 pin                                 —           —       15      pF     In XT, HS and LP modes
                                                                                          when external clock is used
                                                                                          to drive OSC1
D101    CIO    All I/O pins and OSC2                   —           —       50      pF
               (in RC mode)
D102    CB     SCL, SDA in I2C mode                    —           —      400      pF
               Program Flash Memory
D130    EP     Endurance                              100        1000      —      E/W 25°C at 5V
D131    VPR    VDD for Read                            2.0         —       5.5     V
      * These parameters are characterized but not tested.
      † Data in “Typ” column is at 5V, 25°C unless otherwise stated. These parameters are for design guidance
        only and are not tested.
Note 1: In RC oscillator configuration, the OSC1/CLKI pin is a Schmitt Trigger input. It is not recommended that the
        PIC16F7X7 be driven with external clock in RC mode.
     2: The leakage current on the MCLR pin is strongly dependent on the applied voltage level. The specified
        levels represent normal operating conditions. Higher leakage current may be measured at different input
        voltages.
     3: Negative current is defined as current sourced by the pin.
DS30498B-page 218                                Preliminary                            2003 Microchip Technology Inc.
                                                                                                   PIC16F7X7
TABLE 18-1:       COMPARATOR SPECIFICATIONS
Operating Conditions: 3.0V < VDD < 5.5V, -40°C < TA < +85°C (unless otherwise stated).
 Param
            Sym                Characteristics               Min         Typ          Max           Units     Comments
  No.
D300      VIOFF      Input Offset Voltage                    —          ± 5.0         ± 10          mV
D301      VICM       Input Common Mode Voltage*               0           -       VDD – 1.5          V
D302      CMRR       Common Mode Rejection Ratio*            55           -            —             dB
300       TRESP      Response Time(1)*                       —           150           400           ns     PIC16F7X7
300A                                                                                   600           ns     PIC16LF7X7
301       TMC2OV     Comparator Mode Change to               —           —             10            µs
                     Output Valid*
      *     These parameters are characterized but not tested.
Note 1:     Response time measured with one comparator input at (VDD – 1.5)/2, while the other input transitions from
            VSS to VDD.
TABLE 18-2:       VOLTAGE REFERENCE SPECIFICATIONS
Operating Conditions: 3.0V < VDD < 5.5V, -40°C < TA < +85°C (unless otherwise stated).
 Param
            Sym             Characteristics            Min         Typ          Max         Units           Comments
  No.
D310      VRES       Resolution                       VDD/24       —          VDD/32         LSb
D311      VRAA       Absolute Accuracy                  —          —            1/4          LSb     Low Range (VRR = 1)
                                                        —          —            1/2          LSb     High Range (VRR = 0)
D312      VRUR       Unit Resistor Value (R)*           —          2k           —            Ω
310       TSET       Settling Time(1)*                  —          —            10           µs
      *     These parameters are characterized but not tested.
Note 1:     Settling time measured while VRR = 1 and VR<3:0> transitions from ‘0000’ to ‘1111’.
 2003 Microchip Technology Inc.                   Preliminary                                              DS30498B-page 219
PIC16F7X7
FIGURE 18-3:            LOW-VOLTAGE DETECT CHARACTERISTICS
                             VDD
                                                                                               (LVDIF can be
                                     VLVD                                                      cleared in software)
              (LVDIF set by hardware)
         LVDIF
TABLE 18-3:         LOW-VOLTAGE DETECT CHARACTERISTICS
PIC16LF7X7                                                         Standard Operating Conditions (unless otherwise stated)
   (Industrial)                                                    Operating temperature  -40°C ≤ TA ≤ +85°C for industrial
                                                                   Standard Operating Conditions (unless otherwise stated)
PIC16F7X7
                                                                   Operating temperature  -40°C ≤ TA ≤ +85°C for industrial
   (Industrial, Extended)
                                                                                          -40°C ≤ TA ≤ +125°C for extended
 Param
           Symbol                  Characteristic                    Min        Typ†   Max      Units           Conditions
  No.
D420                LVD Voltage on VDD Transition High to Low      Industrial
                                PIC16LF7X7 LVDL<3:0> = 0000          N/A        N/A     N/A       V      Reserved
                                              LVDL<3:0> = 0001       N/A        N/A     N/A       V      Reserved
                                              LVDL<3:0> = 0010       2.15       2.26   2.37       V
                                              LVDL<3:0> = 0011       2.33       2.45   2.58       V
                                              LVDL<3:0> = 0100       2.43       2.55   2.68       V
                                              LVDL<3:0> = 0101       2.63       2.77   2.91       V
                                              LVDL<3:0> = 0110       2.73       2.87   3.01       V
                                              LVDL<3:0> = 0111       2.91       3.07   3.22       V
                                              LVDL<3:0> = 1000       3.20       3.36   3.53       V
                                              LVDL<3:0> = 1001       3.39       3.57   3.75       V
                                              LVDL<3:0> = 1010       3.49       3.67   3.85       V
                                              LVDL<3:0> = 1011       3.68       3.87   4.07       V
                                              LVDL<3:0> = 1100       3.87       4.07   4.28       V
                                              LVDL<3:0> = 1101       4.06       4.28   4.49       V
                                              LVDL<3:0> = 1110       4.37       4.60   4.82       V
D420                LVD Voltage on VDD Transition High to Low      Industrial
                                 PIC16F7X7 LVDL<3:0> = 1011          3.68       3.87   4.07       V
                                              LVDL<3:0> = 1100       3.87       4.07   4.28       V
                                              LVDL<3:0> = 1101       4.06       4.28   4.49       V
                                              LVDL<3:0> = 1110       4.37       4.60   4.82       V
Legend:     Shading of rows is to assist in readability of the table.
       †    Production tested at TAMB = 25°C. Specifications over temperature limits ensured by characterization.
DS30498B-page 220                                       Preliminary                              2003 Microchip Technology Inc.
                                                                                                   PIC16F7X7
18.5      Timing Parameter Symbology
The timing parameter symbols have been created
using one of the following formats:
1. TppS2ppS                                                   3. TCC:ST         (I2C specifications only)
2. TppS                                                       4. Ts             (I2C specifications only)
T
  F         Frequency                                           T               Time
  Lowercase letters (pp) and their meanings:
pp
  cc        CCP1                                                osc             OSC1
  ck        CLKO                                                rd              RD
  cs        CS                                                  rw              RD or WR
  di        SDI                                                 sc              SCK
  do        SDO                                                 ss              SS
  dt        Data in                                             t0              T0CKI
  io        I/O port                                            t1              T1CKI
  mc        MCLR                                                wr              WR
  Uppercase letters and their meanings:
S
  F         Fall                                                P               Period
  H         High                                                R               Rise
  I         Invalid (Hi-impedance)                              V               Valid
  L         Low                                                 Z               High-impedance
I2C only
  AA           output access                                    High            High
  BUF          Bus free                                         Low             Low
  TCC:ST (I2C specifications only)
CC
  HD         Hold                                               SU              Setup
ST
  DAT        DATA input hold                                    STO             Stop condition
  STA        Start condition
FIGURE 18-4:           LOAD CONDITIONS
                          Load Condition 1                                      Load Condition 2
                                        VDD/2
                                                RL
                                                CL                                                 CL
                         pin                                              pin
                                         VSS                                                 VSS
           RL = 464Ω
           CL = 50 pF      for all pins except OSC2, but including PORTD and PORTE outputs as ports
                15 pF      for OSC2 output
           Note: PORTD and PORTE are not implemented on the PIC16F737/767 devices.
 2003 Microchip Technology Inc.                     Preliminary                                            DS30498B-page 221
PIC16F7X7
FIGURE 18-5:          EXTERNAL CLOCK TIMING
                        Q4              Q1              Q2              Q3             Q4                Q1
      OSC1
                                         1                          3        3          4         4
                                                               2
      CLKO
TABLE 18-4:       EXTERNAL CLOCK TIMING REQUIREMENTS
Param
          Symbol             Characteristic              Min       Typ†       Max      Units           Conditions
 No.
         FOSC       External CLKI Frequency              DC         —             1    MHz      XT Osc mode
                    (Note 1)                             DC         —            20    MHz      HS Osc mode
                                                         DC         —            32    kHz      LP Osc mode
                    Oscillator Frequency                 DC         —             4    MHz      RC Osc mode
                    (Note 1)                             0.1        —             4    MHz      XT Osc mode
                                                          4         —             20   MHz      HS Osc mode
                                                          5         —            200   kHz      LP Osc mode
1        TOSC       External CLKI Period                1000        —            —      ns      XT Osc mode
                    (Note 1)                              50        —            —      ns      HS Osc mode
                                                          5         —            —      ms      LP Osc mode
                    Oscillator Period                    250        —            —      ns      RC Osc mode
                    (Note 1)                             250        —        10,000     ns      XT Osc mode
                                                          50        —            250    ns      HS Osc mode
                                                          5         —            —      ms      LP Osc mode
2        TCY        Instruction Cycle Time               200       TCY           DC     ns      TCY = 4/FOSC
                    (Note 1)
3        TOSL,      External Clock in (OSC1)             500        —            —      ns      XT oscillator
         TOSH       High or Low Time                     2.5        —            —      ms      LP oscillator
                                                          15        —            —      ns      HS oscillator
4        TOSR,      External Clock in (OSC1)              —         —            25     ns      XT oscillator
         TOSF       Rise or Fall Time                     —         —            50     ns      LP oscillator
                                                          —         —            15     ns      HS oscillator
      † Data in “Typ” column is at 5V, 25°C unless otherwise stated. These parameters are for design guidance
        only and are not tested.
Note 1: Instruction cycle period (TCY) equals four times the input oscillator time base period. All specified values are
        based on characterization data for that particular oscillator type, under standard operating conditions, with
        the device executing code. Exceeding these specified limits may result in an unstable oscillator operation
        and/or higher than expected current consumption. All devices are tested to operate at “min.” values with an
        external clock applied to the OSC1/CLKI pin. When an external clock input is used, the “max.” cycle time
        limit is “DC” (no clock) for all devices.
DS30498B-page 222                                  Preliminary                               2003 Microchip Technology Inc.
                                                                                                        PIC16F7X7
FIGURE 18-6:                 CLKO AND I/O TIMING
                                Q4                               Q1                     Q2                          Q3
        OSC1
                                                   10                                                    11
        CLKO
                                                       13                                                 12
                                                                       19     18
                                                            14                                                   16
       I/O pin
       (Input)
                                                        17                               15
    I/O pin               Old Value                                                                             New Value
   (Output)
                                                             20, 21
      Note: Refer to Figure 18-4 for load conditions.
TABLE 18-5:             CLKO AND I/O TIMING REQUIREMENTS
Param
               Symbol                        Characteristic                        Min        Typ†       Max          Units Conditions
 No.
10*        TOSH2CKL OSC1 ↑ to CLKO ↓                                               —           75         200          ns   (Note 1)
11*        TOSH2CKH OSC1 ↑ to CLKO ↑                                               —           75         200          ns   (Note 1)
12*        TCKR           CLKO Rise Time                                           —           35         100          ns   (Note 1)
13*        TCKF           CLKO Fall Time                                           —           35         100          ns   (Note 1)
14*        TCKL2IOV       CLKO ↓ to Port Out Valid                                 —           —     0.5 TCY + 20      ns   (Note 1)
15*        TIOV2CKH       Port In Valid before CLKO ↑                          TOSC + 200      —          —            ns   (Note 1)
16*        TCKH2IOI       Port In Hold after CLKO ↑                                 0          —          —            ns   (Note 1)
17*        TOSH2IOV       OSC1 ↑ (Q1 cycle) to Port Out Valid                      —          100         255          ns
18*        TOSH2IOI       OSC1 ↑ (Q2 cycle) to          PIC16F7X7                  100         —          —            ns
                          Port Input Invalid (I/O in    PIC16LF7X7                 200         —          —            ns
                          hold time)
19*        TIOV2OSH Port Input Valid to OSC1 ↑ (I/O in setup time)                  0          —          —            ns
20*        TIOR           Port Output Rise Time         PIC16F7X7                  —           10         40           ns
                                                        PIC16LF7X7                 —           —          145          ns
21*        TIOF           Port Output Fall Time         PIC16F7X7                  —           10         40           ns
                                                        PIC16LF7X7                 —           —          145          ns
22††*      TINP           INT pin High or Low Time                                 TCY         —          —            ns
23††*      TRBP           RB7:RB4 Change INT High or Low Time                      TCY         —          —            ns
           *     These parameters are characterized but not tested.
           †     Data in “Typ” column is at 5V, 25°C unless otherwise stated. These parameters are for design guidance only and are not
                 tested.
         ††      These parameters are asynchronous events not related to any internal clock edges.
Note 1:          Measurements are taken in RC mode, where CLKO output is 4 x TOSC.
 2003 Microchip Technology Inc.                                  Preliminary                                       DS30498B-page 223
PIC16F7X7
FIGURE 18-7:                RESET, WATCHDOG TIMER, OSCILLATOR START-UP TIMER AND
                            POWER-UP TIMER TIMING
            VDD
        MCLR
                                                                                30
       Internal
          POR
                                33
        PWRT
      Time-out
                                             32
         OSC
      Time-out
       Internal
         Reset
     Watchdog
        Timer
        Reset
                                                                                                  31
                                                                          34
                                                                                                                  34
       I/O pins
      Note: Refer to Figure 18-4 for load conditions.
FIGURE 18-8:                BROWN-OUT RESET TIMING
      VDD                                                     VBOR
                                                                                     35
TABLE 18-6:            RESET, WATCHDOG TIMER, OSCILLATOR START-UP TIMER, POWER-UP TIMER
                       AND BROWN-OUT RESET REQUIREMENTS
Param
                Sym                  Characteristic              Min       Typ†           Max   Units            Conditions
 No.
30          TMCL       MCLR Pulse Width (low)                     2            —          —      µs     VDD = 5V, -40°C to +85°C
31*         TWDT       Watchdog Timer Time-out Period             7            18         33     ms     VDD = 5V, -40°C to +85°C
                       (no prescaler)
32          TOST       Oscillation Start-up Timer Period          —     1024 TOSC         —      —      TOSC = OSC1 period
33*         TPWRT      Power-up Timer Period                     28            72         132    ms     VDD = 5V, -40°C to +85°C
34          TIOZ       I/O High-Impedance from MCLR Low or        —            —          2.1    µs
                       Watchdog Timer Reset
35          TBOR       Brown-out Reset Pulse Width               100           —          —      µs     VDD ≤ VBOR (D005)
            *   These parameters are characterized but not tested.
            †   Data in “Typ” column is at 5V, 25°C unless otherwise stated. These parameters are for design guidance
                only and are not tested.
DS30498B-page 224                                          Preliminary                                 2003 Microchip Technology Inc.
                                                                                                         PIC16F7X7
FIGURE 18-9:              TIMER0 AND TIMER1 EXTERNAL CLOCK TIMINGS
        RA4/T0CKI/C1OUT
                                                           40                        41
                                                                         42
        RC0/T1OSO/T1CKI
                                                           45                        46
                                                                         47                                 48
              TMR0 or TMR1
      Note: Refer to Figure 18-4 for load conditions.
TABLE 18-7:          TIMER0 AND TIMER1 EXTERNAL CLOCK REQUIREMENTS
Param
            Symbol                        Characteristic                              Min         Typ†    Max     Units     Conditions
 No.
40*     TT0H           T0CKI High Pulse Width                   No Prescaler     0.5 TCY + 20      —      —        ns     Must also meet
                                                                With Prescaler        10           —      —        ns     parameter 42
41*     TT0L           T0CKI Low Pulse Width                    No Prescaler     0.5 TCY + 20      —      —        ns     Must also meet
                                                                With Prescaler        10           —      —        ns     parameter 42
42*     TT0P           T0CKI Period                             No Prescaler       TCY + 40        —      —        ns
                                                                With Prescaler    Greater of:      —      —        ns     N = prescale
                                                                                 20 or TCY + 40                           value (2, 4, ...,
                                                                                          N                               256)
45*     TT1H           T1CKI High Time Synchronous, Prescaler = 1                0.5 TCY + 20      —      —        ns     Must also meet
                                          Synchronous,        PIC16F7X7               15           —      —        ns     parameter 47
                                          Prescaler = 2, 4, 8 PIC16LF7X7              25           —      —        ns
                                          Asynchronous          PIC16F7X7             30           —      —        ns
                                                                PIC16LF7X7            50           —      —        ns
46*     TT1L           T1CKI Low Time     Synchronous, Prescaler = 1             0.5 TCY + 20      —      —        ns     Must also meet
                                          Synchronous,        PIC16F7X7               15           —      —        ns     parameter 47
                                          Prescaler = 2, 4, 8 PIC16LF7X7              25           —      —        ns
                                          Asynchronous          PIC16F7X7             30           —      —        ns
                                                                PIC16LF7X7            50           —      —        ns
47*     TT1P           T1CKI Input        Synchronous           PIC16F7X7         Greater of:      —      —        ns     N = prescale
                       Period                                                    30 or TCY + 40                           value (1, 2, 4, 8)
                                                                                          N
                                                                PIC16LF7X7        Greater of:                             N = prescale
                                                                                 50 or TCY + 40                           value (1, 2, 4, 8)
                                                                                          N
                                          Asynchronous          PIC16F7X7             60           —      —        ns
                                                                PIC16LF7X7            100          —      —        ns
        FT1            Timer1 Oscillator Input Frequency Range                        DC           —      200     kHz
                       (oscillator enabled by setting bit T1OSCEN)
48      TCKEZTMR1 Delay from External Clock Edge to Timer Increment                 2 TOSC         —     7 TOSC    —
        *     These parameters are characterized but not tested.
        †     Data in “Typ” column is at 5V, 25°C unless otherwise stated. These parameters are for design guidance only and are
              not tested.
 2003 Microchip Technology Inc.                           Preliminary                                             DS30498B-page 225
PIC16F7X7
FIGURE 18-10:          CAPTURE/COMPARE/PWM TIMINGS (CCP1 AND CCP2)
               RC1/T1OSI/CCP2
                 and RC2/CCP1
                 (Capture Mode)
                                                                 50                51
                                                                        52
              RC1/T1OSI/CCP2
                and RC2/CCP1
        (Compare or PWM Mode)
                                                53                            54
        Note: Refer to Figure 18-4 for load conditions.
TABLE 18-8:      CAPTURE/COMPARE/PWM REQUIREMENTS (CCP1 AND CCP2)
Param
      Symbol                           Characteristic                        Min        Typ† Max Units      Conditions
 No.
50*    TCCL       CCP1, CCP2 and        No Prescaler                    0.5 TCY + 20     —    —      ns
                  CCP3 Input Low                       PIC16F7X7             10          —    —      ns
                  Time                  With Prescaler PIC16LF7X7            20          —    —      ns
51*    TCCH       CCP1, CCP2 and        No Prescaler                    0.5 TCY + 20     —    —      ns
                  CCP3 Input High                          PIC16F7X7         10          —    —      ns
                  Time                  With Prescaler PIC16LF7X7            20          —    —      ns
52*    TCCP       CCP1, CCP2 and CCP3 Input Period                      3 TCY + 40       —    —      ns   N = prescale
                                                                            N                             value (1,4 or 16)
53*    TCCR       CCP1, CCP2 and CCP3 Output               PIC16F7X7         —          10    25     ns
                  Rise Time                                PIC16LF7X7        —          25    50     ns
54*    TCCF       CCP1, CCP2 and CCP3 Output               PIC16F7X7         —          10    25     ns
                  Fall Time                                PIC16LF7X7        —          25    45     ns
       * These parameters are characterized but not tested.
       † Data in “Typ” column is at 5V, 25°C unless otherwise stated. These parameters are for design guidance only and
         are not tested.
DS30498B-page 226                                         Preliminary                      2003 Microchip Technology Inc.
                                                                                              PIC16F7X7
FIGURE 18-11:             PARALLEL SLAVE PORT TIMING (PIC16F747/777 DEVICES ONLY)
              RE2/CS/AN7
              RE0/RD/AN5
             RE1/WR/AN6
                                                             65
     RD7/PSP7:RD0/PSP0
                                                                                         62
                                               64
                                                                                                 63
     Note: Refer to Figure 18-4 for load conditions.
TABLE 18-9:          PARALLEL SLAVE PORT REQUIREMENTS (PIC16F747/777 DEVICES ONLY)
Param
            Symbol                          Characteristic                 Min   Typ† Max     Units       Conditions
 No.
62        TDTV2WRH Data In Valid before WR ↑ or CS ↑ (setup time)          20    —      —      ns
                                                                           25    —      —      ns     Extended range only
63*       TWRH2DTI      WR ↑ or CS ↑ to Data In Invalid       PIC16F7X7    20    —      —      ns
                        (hold time)                           PIC16LF7X7   35    —      —      ns
64        TRDL2DTV      RD ↓ and CS ↓ to Data Out Valid                    —     —      80     ns
                                                                           —     —      90     ns     Extended range only
65        TRDH2DTI      RD ↑ or CS ↓ to Data Out Invalid                   10    —      30     ns
          * These parameters are characterized but not tested.
          † Data in “Typ” column is at 5V, 25°C unless otherwise stated. These parameters are for design guidance
            only and are not tested.
 2003 Microchip Technology Inc.                        Preliminary                                    DS30498B-page 227
PIC16F7X7
FIGURE 18-12:           SPI MASTER MODE TIMING (CKE = 0, SMP = 0)
   SS
                          70
   SCK
   (CKP = 0)
                                    71              72
                                                                                            78        79
   SCK
   (CKP = 1)
                                                                                            79        78
                                  80
   SDO                                         MSb                     bit 6 - - - - - -1             LSb
                                                            75, 76
   SDI                                     MSb In                          bit 6 - - - -1              LSb In
                                                74
                                          73
   Note: Refer to Figure 18-4 for load conditions.
FIGURE 18-13:           SPI MASTER MODE TIMING (CKE = 1, SMP = 1)
     SS
                          81
     SCK
     (CKP = 0)
                                    71              72
                                                                                                      79
                            73
     SCK
     (CKP = 1)
                                               80
                                                                                                      78
     SDO                          MSb                    bit 6 - - - - - -1                  LSb
                                               75, 76
     SDI                         MSb In                   bit 6 - - - -1                     LSb In
                                    74
     Note: Refer to Figure 18-4 for load conditions.
DS30498B-page 228                                             Preliminary                                        2003 Microchip Technology Inc.
                                                                                                                 PIC16F7X7
FIGURE 18-14:            SPI SLAVE MODE TIMING (CKE = 0)
    SS
                          70
    SCK
    (CKP = 0)                                                                                               83
                                    71            72
                                                                                         78           79
    SCK
    (CKP = 1)
                                                                                         79           78
                                 80
    SDO                                         MSb                     bit 6 - - - - - -1            LSb
                                                             75, 76                                              77
    SDI                                     MSb In                      bit 6 - - - -1                 LSb In
                                                 74
                                           73
    Note: Refer to Figure 18-4 for load conditions.
FIGURE 18-15:            SPI SLAVE MODE TIMING (CKE = 1)
                        82
     SS
                          70
     SCK
                                                                                                            83
     (CKP = 0)
                                      71           72
     SCK
     (CKP = 1)
                                                                              80
     SDO                           MSb                   bit 6 - - - - - -1                  LSb
                                                75, 76                                                           77
     SDI
                                 MSb In                  bit 6 - - - -1                      LSb In
                                      74
     Note: Refer to Figure 18-4 for load conditions.
 2003 Microchip Technology Inc.                              Preliminary                                             DS30498B-page 229
PIC16F7X7
TABLE 18-10: SPI MODE REQUIREMENTS
Param
              Symbol                           Characteristic                Min        Typ†     Max Units Conditions
 No.
70*         TSSL2SCH,     SS ↓ to SCK ↓ or SCK ↑ Input                       TCY         —        —        ns
            TSSL2SCL
71*         TSCH          SCK Input High Time (Slave mode)                TCY + 20       —        —        ns
72*         TSCL          SCK Input Low Time (Slave mode)                 TCY + 20       —        —        ns
73*         TDIV2SCH,     Setup Time of SDI Data Input to SCK Edge           100         —        —        ns
            TDIV2SCL
74*         TSCH2DIL,     Hold Time of SDI Data Input to SCK Edge            100         —        —        ns
            TSCL2DIL
75*         TDOR          SDO Data Output Rise Time PIC16F7X7                —           10       25       ns
                                                    PIC16LF7X7               —           25       50       ns
76*         TDOF          SDO Data Output Fall Time                          —           10       25       ns
77*         TSSH2DOZ      SS ↑ to SDO Output High-Impedance                  10          —        50       ns
78*         TSCR          SCK Output Rise Time              PIC16F7X7        —           10       25       ns
                          (Master mode)                     PIC16LF7X7       —           25       50       ns
79*         TSCF          SCK Output Fall Time (Master mode)                 —           10       25       ns
80*         TSCH2DOV,     SDO Data Output Valid after       PIC16F7X7        —           —       50        ns
            TSCL2DOV      SCK Edge                          PIC16LF7X7       —           —       145       ns
81*         TDOV2SCH, SDO Data Output Setup to SCK Edge                      TCY         —        —        ns
            TDOV2SCL
82*         TSSL2DOV      SDO Data Output Valid after SS ↓ Edge              —           —        50       ns
83*         TSCH2SSH,     SS ↑ after SCK Edge                            1.5 TCY + 40    —        —        ns
            TSCL2SSH
            * These parameters are characterized but not tested.
            † Data in “Typ” column is at 5V, 25°C unless otherwise stated. These parameters are for design guidance
              only and are not tested.
FIGURE 18-16:              I2C BUS START/STOP BITS TIMING
      SCL
                                          91                                                           93
                         90                                                               92
      SDA
                                Start                                                            Stop
                              Condition                                                        Condition
      Note: Refer to Figure 18-4 for load conditions.
DS30498B-page 230                                         Preliminary                      2003 Microchip Technology Inc.
                                                                                                 PIC16F7X7
TABLE 18-11: I2C BUS START/STOP BITS REQUIREMENTS
Param
      Symbol                        Characteristic               Min     Typ     Max Units              Conditions
 No.
90*         TSU:STA   Start condition         100 kHz mode       4700        —   —     ns    Only relevant for Repeated
                      Setup time              400 kHz mode       600         —   —           Start condition
91*         THD:STA   Start condition         100 kHz mode       4000        —   —     ns    After this period, the first clock
                      Hold time               400 kHz mode       600         —   —           pulse is generated
92*         TSU:STO   Stop condition          100 kHz mode       4700        —   —     ns
                      Setup time              400 kHz mode       600         —   —
93          THD:STO Stop condition            100 kHz mode       4000        —   —     ns
                      Hold time               400 kHz mode       600         —   —
        *     These parameters are characterized but not tested.
FIGURE 18-17:            I2C BUS DATA TIMING
                              103                    100                                              102
                                                                 101
         SCL
                         90
                                                           106         107
                                91                                                               92
         SDA
         In
                                                                                                            110
                                        109                      109
         SDA
         Out
         Note: Refer to Figure 18-4 for load conditions.
 2003 Microchip Technology Inc.                           Preliminary                                       DS30498B-page 231
PIC16F7X7
TABLE 18-12: I2C BUS DATA REQUIREMENTS
Param.
            Symbol                Characteristic                  Min       Max     Units             Conditions
 No.
100*        THIGH     Clock High Time      100 kHz mode           4.0         —       µs     Device must operate at a
                                                                                             minimum of 1.5 MHz
                                           400 kHz mode           0.6         —       µs     Device must operate at a
                                                                                             minimum of 10 MHz
                                           SSP module           1.5 TCY       —
101*        TLOW      Clock Low Time       100 kHz mode           4.7         —       µs     Device must operate at a
                                                                                             minimum of 1.5 MHz
                                           400 kHz mode           1.3         —       µs     Device must operate at a
                                                                                             minimum of 10 MHz
                                           SSP module           1.5 TCY       —
102*        TR        SDA and SCL Rise 100 kHz mode                —        1000      ns
                      Time             400 kHz mode           20 + 0.1 CB    300      ns     CB is specified to be from
                                                                                             10-400 pF
103*        TF        SDA and SCL Fall     100 kHz mode            —         300      ns
                      Time                 400 kHz mode       20 + 0.1 CB    300      ns     CB is specified to be from
                                                                                             10-400 pF
90*         TSU:STA   Start Condition      100 kHz mode           4.7         —       µs     Only relevant for Repeated
                      Setup Time           400 kHz mode           0.6         —       µs     Start
                                                                                             condition
91*         THD:STA   Start Condition Hold 100 kHz mode           4.0         —       µs     After this period, the first
                      Time                 400 kHz mode           0.6         —       µs     clock pulse is generated
106*        THD:DAT   Data Input Hold      100 kHz mode            0          —       ns
                      Time                 400 kHz mode            0         0.9      µs
107*        TSU:DAT   Data Input Setup     100 kHz mode           250         —       ns     (Note 2)
                      Time                 400 kHz mode           100         —       ns
92*         TSU:STO   Stop Condition       100 kHz mode           4.7         —       µs
                      Setup Time           400 kHz mode           0.6         —       µs
109*        TAA       Output Valid from    100 kHz mode            —        3500      ns     (Note 1)
                      Clock                400 kHz mode            —          —       ns
110*        TBUF      Bus Free Time        100 kHz mode           4.7         —       µs     Time the bus must be free
                                           400 kHz mode           1.3         —       µs     before a new transmission
                                                                                             can start
            CB        Bus Capacitive Loading                       —         400      pF
      *      These parameters are characterized but not tested.
Note 1:      As a transmitter, the device must provide this internal minimum delay time to bridge the undefined region
             (min. 300 ns) of the falling edge of SCL to avoid unintended generation of Start or Stop conditions.
       2:    A fast mode (400 kHz) I2C bus device can be used in a standard mode (100 kHz) I2C bus system, but the
             requirement, TSU:DAT ≥ 250 ns, must then be met. This will automatically be the case if the device does not
             stretch the LOW period of the SCL signal. If such a device does stretch the LOW period of the SCL signal,
             it must output the next data bit to the SDA line, TR max. + TSU:DAT = 1000 + 250 = 1250 ns (according to
             the standard mode I2C bus specification), before the SCL line is released.
DS30498B-page 232                                   Preliminary                             2003 Microchip Technology Inc.
                                                                                             PIC16F7X7
FIGURE 18-18:            USART SYNCHRONOUS TRANSMISSION (MASTER/SLAVE) TIMING
   RC6/TX/CK
          pin                       121
                                                          121
   RC7/RX/DT
          pin
                                    120
                                                                                    122
  Note: Refer to Figure 18-4 for load conditions.
TABLE 18-13: USART SYNCHRONOUS TRANSMISSION REQUIREMENTS
 Param
            Symbol                          Characteristic                   Min    Typ†     Max     Units     Conditions
  No.
120       TCKH2DTV SYNC XMIT (MASTER &                          PIC16F7X7
                   SLAVE)                                                    —       —       80          ns
                   Clock High to Data Out Valid                 PIC16LF7X7   —       —       100         ns
121       TCKRF         Clock Out Rise Time and Fall Time PIC16F7X7          —       —       45          ns
                        (Master mode)                     PIC16LF7X7         —       —       50          ns
122       TDTRF         Data Out Rise Time and Fall Time PIC16F7X7           —       —       45          ns
                                                                PIC16LF7X7   —       —       50          ns
         † Data in “Typ” column is at 5V, 25°C unless otherwise stated. These parameters are for design guidance
           only and are not tested.
FIGURE 18-19:            USART SYNCHRONOUS RECEIVE (MASTER/SLAVE) TIMING
          RC6/TX/CK
                 pin                                125
          RC7/RX/DT
                 pin
                                                                     126
         Note: Refer to Figure 18-4 for load conditions.
TABLE 18-14: USART SYNCHRONOUS RECEIVE REQUIREMENTS
Param
           Symbol                      Characteristic                 Min    Typ†     Max          Units       Conditions
 No.
125      TDTV2CKL       SYNC RCV (MASTER & SLAVE)
                        Data Setup before CK ↓ (DT setup time)        15      —          —          ns
126      TCKL2DTL       Data Hold after CK ↓ (DT hold time)           15      —          —          ns
         † Data in “Typ” column is at 5V, 25°C unless otherwise stated. These parameters are for design guidance
           only and are not tested.
 2003 Microchip Technology Inc.                            Preliminary                                    DS30498B-page 233
PIC16F7X7
TABLE 18-15: A/D CONVERTER CHARACTERISTICS: PIC16F7X7 (INDUSTRIAL, EXTENDED)
                                            PIC16LF7X7 (INDUSTRIAL)
Param
         Sym            Characteristic            Min         Typ†         Max        Units         Conditions
 No.
A01     NR      Resolution         PIC16F7X7       —            —          8 bits      bit    VREF = VDD = 5.12V,
                                                                                              VSS ≤ VAIN ≤ VREF
                                   PIC16LF7X7      —            —          8 bits      bit    VREF = VDD = 2.2V
A02     EABS    Total Absolute Error               —            —          < ±1       LSb VREF = VDD = 5.12V,
                                                                                          VSS ≤ VAIN ≤ VREF
A03     EIL     Integral Linearity Error           —            —          < ±1       LSb VREF = VDD = 5.12V,
                                                                                          VSS ≤ VAIN ≤ VREF
A04     EDL     Differential Linearity Error       —            —          < ±1       LSb VREF = VDD = 5.12V,
                                                                                          VSS ≤ VAIN ≤ VREF
A05     EFS     Full-Scale Error                   —            —          < ±1       LSb VREF = VDD = 5.12V,
                                                                                          VSS ≤ VAIN ≤ VREF
A06     EOFF    Offset Error                       —            —          < ±1       LSb VREF = VDD = 5.12V,
                                                                                          VSS ≤ VAIN ≤ VREF
A10     —       Monotonicity (Note 3)              —        guaranteed      —          —      VSS ≤ VAIN ≤ VREF
A20     VREF    Reference Voltage                  2.5          —           5.5        V      -40°C to +125°C
                                                   2.2          —           5.5        V      0°C to +125°C
A25     VAIN    Analog Input Voltage            VSS – 0.3       —        VREF + 0.3    V
A30     ZAIN    Recommended Impedance of           —            —          10.0        kΩ
                Analog Voltage Source
A40     IAD     A/D Conversion     PIC16F7X7       —           180          —          µA     Average current
                Current (VDD)      PIC16LF7X7      —           90           —          µA     consumption when A/D
                                                                                              is on (Note 1)
A50     IREF    VREF Input Current (Note 2)       N/A           —            ±5        µA     During VAIN acquisition.
                                                  —             —           500        µA     During A/D conversion
                                                                                              cycle.
      * These parameters are characterized but not tested.
      † Data in “Typ” column is at 5V, 25°C unless otherwise stated. These parameters are for design guidance
        only and are not tested.
Note 1: When A/D is off, it will not consume any current other than minor leakage current. The power-down current
        spec includes any such leakage from the A/D module.
     2: VREF current is from the RA3 pin or the VDD pin, whichever is selected as a reference input.
     3: The A/D conversion result never decreases with an increase in the input voltage and has no missing
        codes.
DS30498B-page 234                                Preliminary                           2003 Microchip Technology Inc.
                                                                                                                    PIC16F7X7
FIGURE 18-20:               A/D CONVERSION TIMING
          BSF ADCON0, GO                                                                                        1 TCY
                      134             (TOSC/2)(1)
                                                                               131
               Q4
                                                                               130
        A/D CLK       132
       A/D DATA                               7          6        5        4         3      2         1         0
         ADRES                                           OLD_DATA                                                       NEW_DATA
            ADIF
             GO                                                                                                          DONE
        SAMPLE                                                        SAMPLING STOPPED
      Note 1: If the A/D clock source is selected as RC, a time of TCY is added before the A/D clock starts. This allows the SLEEP instruction
              to be executed.
TABLE 18-16: A/D CONVERSION REQUIREMENTS
Param
      Sym               Characteristic                                  Min          Typ†    Max      Units               Conditions
 No.
130      TAD        A/D Clock Period              PIC16F7X7             1.6           —         —         µs     TOSC based, VREF ≥ 3.0V
                                                  PIC16LF7X7            2.0           —         —         µs     TOSC based,
                                                                                                                 2.0V ≤ VREF ≤ 5.5V
                                                  PIC16F7X7             2.0          4.0        6.0       µs     A/D RC mode
                                                  PIC16LF7X7            3.0          6.0        9.0       µs     A/D RC mode
131      TCNV Conversion Time (not including                             9            —         9         TAD
              S/H time) (Note 1)
132      TACQ Acquisition Time                                           5*           —         —         µs     The minimum time is the
                                                                                                                 amplifier settling time. This
                                                                                                                 may be used if the “new” input
                                                                                                                 voltage has not changed by
                                                                                                                 more than 1 LSb (i.e.,
                                                                                                                 20.0 mV @ 5.12V) from the
                                                                                                                 last sampled voltage (as
                                                                                                                 stated on CHOLD).
134      TGO        Q4 to A/D Clock Start                                —       TOSC/2         —         —      If the A/D clock source is
                                                                                                                 selected as RC, a time of TCY
                                                                                                                 is added before the A/D clock
                                                                                                                 starts. This allows the SLEEP
                                                                                                                 instruction to be executed.
      * These parameters are characterized but not tested.
      † Data in “Typ” column is at 5V, 25°C unless otherwise stated. These parameters are for design guidance
        only and are not tested.
Note 1: ADRES register may be read on the following TCY cycle.
     2: See Section 12.1 “A/D Acquisition Requirements” for minimum conditions.
 2003 Microchip Technology Inc.                              Preliminary                                                   DS30498B-page 235
PIC16F7X7
NOTES:
DS30498B-page 236   Preliminary    2003 Microchip Technology Inc.
                                                                  PIC16F7X7
19.0     DC AND AC
         CHARACTERISTICS GRAPHS
         AND TABLES
Graphs and tables are not available at this time.
 2003 Microchip Technology Inc.                    Preliminary      DS30498B-page 237
PIC16F7X7
NOTES:
DS30498B-page 238   Preliminary    2003 Microchip Technology Inc.
                                                                                            PIC16F7X7
20.0     PACKAGING INFORMATION
20.1     Package Marking Information
        28-Lead PDIP (Skinny DIP)                                    Example
                  XXXXXXXXXXXXXXXXX                                               PIC16F737-I/SP
                  XXXXXXXXXXXXXXXXX                                                   0310017
                     YYWWNNN
        28-Lead SOIC                                                 Example
          XXXXXXXXXXXXXXXXXXXX                                                PIC16F767-I/SO
          XXXXXXXXXXXXXXXXXXXX                                                     0310017
          XXXXXXXXXXXXXXXXXXXX
                 YYWWNNN
        28-Lead SSOP                                                 Example
           XXXXXXXXXXXX                                                     PIC16F737
           XXXXXXXXXXXX                                                     -I/SS
               YYWWNNN                                                          0310017
        28-Lead QFN                                                  Example
           XXXXXXXX                                                       16F737
           XXXXXXXX                                                       -I/ML
           YYWWNNN                                                        0310017
                Legend: XX...X      Customer specific information*
                        Y           Year code (last digit of calendar year)
                        YY          Year code (last 2 digits of calendar year)
                        WW          Week code (week of January 1 is week ‘01’)
                        NNN         Alphanumeric traceability code
                Note:    In the event the full Microchip part number cannot be marked on one line, it will
                         be carried over to the next line thus limiting the number of available characters
                         for customer specific information.
    *    Standard PICmicro device marking consists of Microchip part number, year code, week code, and
         traceability code. For PICmicro device marking beyond this, certain price adders apply. Please check
         with your Microchip Sales Office. For QTP devices, any special marking adders are included in QTP
         price.
 2003 Microchip Technology Inc.                    Preliminary                                       DS30498B-page 239
PIC16F7X7
Package Marking Information (Cont’d)
        40-Lead PDIP                            Example
               XXXXXXXXXXXXXXXXXX                          PIC16F777-I/P
               XXXXXXXXXXXXXXXXXX                             0310017
               XXXXXXXXXXXXXXXXXX
                  YYWWNNN
        44-Lead TQFP                            Example
           XXXXXXXXXX                                PIC16F777
           XXXXXXXXXX                                -I/PT
           XXXXXXXXXX                                    0310017
             YYWWNNN
        44-Lead QFN                             Example
          XXXXXXXXXX                                 PIC16F777
          XXXXXXXXXX                                 -I/ML
          XXXXXXXXXX                                  0310017
           YYWWNNN
DS30498B-page 240                      Preliminary                  2003 Microchip Technology Inc.
                                                                                                                  PIC16F7X7
20.2     Package Details
The following sections give the technical details of the
packages.
28-Lead Skinny Plastic Dual In-line (SP) – 300 mil (PDIP)
                        E1
                                 2
               n                 1                                                                                    α
                        E
                                                                                                                                  A2
                                                                                                                                  L
                                       c
                   β                           A1                     B1
                        eB                                            B                                           p
                                                Units                 INCHES*                                   MILLIMETERS
                                  Dimension Limits         MIN             NOM         MAX           MIN              NOM              MAX
       Number of Pins                           n                                28                                          28
       Pitch                                    p                            .100                                          2.54
       Top to Seating Plane                         A         .140           .150          .160          3.56              3.81          4.06
       Molded Package Thickness                    A2         .125           .130          .135          3.18              3.30          3.43
       Base to Seating Plane                        A1        .015                                       0.38
       Shoulder to Shoulder Width                   E         .300           .310          .325          7.62              7.87          8.26
       Molded Package Width                         E1        .275           .285          .295          6.99              7.24          7.49
       Overall Length                               D        1.345          1.365        1.385          34.16             34.67         35.18
       Tip to Seating Plane                         L         .125           .130          .135          3.18              3.30          3.43
       Lead Thickness                               c         .008           .012          .015          0.20              0.29          0.38
       Upper Lead Width                             B1        .040           .053          .065          1.02              1.33          1.65
       Lower Lead Width                             B         .016           .019          .022          0.41              0.48          0.56
       Overall Row Spacing                 §    eB            .320           .350          .430          8.13              8.89         10.92
       Mold Draft Angle Top                      α                5              10          15              5               10              15
       Mold Draft Angle Bottom                      β             5              10          15              5               10              15
        * Controlling Parameter
        § Significant Characteristic
        Notes:
        Dimension D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed
        .010” (0.254mm) per side.
        JEDEC Equivalent: MO-095
        Drawing No. C04-070
 2003 Microchip Technology Inc.                              Preliminary                                                         DS30498B-page 241
PIC16F7X7
28-Lead Plastic Small Outline (SO) – Wide, 300 mil (SOIC)
                                   E
                                   E1
                    p
              B
                                                 2
                     n                           1
                                    h
                                                                                                                      α
                         45°
              c
                                                                       A                                                   A2
                                                           φ
                               β                      L               A1
                                              Units                   INCHES*                          MILLIMETERS
                                   Dimension Limits       MIN           NOM       MAX           MIN        NOM            MAX
           Number of Pins                       n                            28                                 28
           Pitch                                p                         .050                                1.27
           Overall Height                       A              .093       .099        .104         2.36       2.50          2.64
           Molded Package Thickness             A2             .088        .091       .094         2.24       2.31          2.39
           Standoff §                           A1             .004       .008        .012         0.10       0.20          0.30
           Overall Width                        E              .394       .407        .420        10.01      10.34         10.67
           Molded Package Width                 E1             .288       .295        .299         7.32       7.49          7.59
           Overall Length                       D              .695       .704        .712        17.65      17.87         18.08
           Chamfer Distance                     h              .010       .020        .029         0.25       0.50          0.74
           Foot Length                          L              .016       .033        .050         0.41       0.84          1.27
           Foot Angle Top                        φ                0           4          8            0          4             8
           Lead Thickness                        c             .009        .011       .013         0.23       0.28          0.33
           Lead Width                           B              .014       .017        .020         0.36       0.42          0.51
           Mold Draft Angle Top                 α                 0          12         15            0         12            15
           Mold Draft Angle Bottom              β                 0          12         15            0         12            15
           * Controlling Parameter
           § Significant Characteristic
           Notes:
           Dimensions D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed
           .010” (0.254mm) per side.
           JEDEC Equivalent: MS-013
           Drawing No. C04-052
DS30498B-page 242                                          Preliminary                                     2003 Microchip Technology Inc.
                                                                                                              PIC16F7X7
28-Lead Plastic Shrink Small Outline (SS) – 209 mil, 5.30 mm (SSOP)
                                        E1
                    p
               B
                                                        2
                     n                                  1
                                                                                                                          α
                                                                            A
                c
                                                                                                                         A2
                                                             φ        A1
                                                             L
                        β
                                                Units                 INCHES                            MILLIMETERS*
                                     Dimension Limits       MIN         NOM        MAX           MIN        NOM      MAX
            Number of Pins                        n                         28                                   28
            Pitch                                 p                       .026                                 0.65
            Overall Height                       A            .068        .073         .078         1.73       1.85     1.98
            Molded Package Thickness             A2           .064        .068         .072         1.63       1.73     1.83
            Standoff §                           A1           .002        .006         .010         0.05       0.15     0.25
            Overall Width                        E            .299        .309         .319         7.59       7.85     8.10
            Molded Package Width                 E1            .201       .207         .212         5.11       5.25     5.38
            Overall Length                       D            .396        .402         .407        10.06      10.20    10.34
            Foot Length                          L            .022        .030         .037         0.56       0.75     0.94
            Lead Thickness                       c            .004        .007         .010         0.10       0.18     0.25
            Foot Angle                            φ               0          4            8         0.00     101.60   203.20
            Lead Width                           B            .010        .013         .015         0.25       0.32     0.38
            Mold Draft Angle Top                 α                0          5           10            0          5       10
            Mold Draft Angle Bottom              β                0          5           10            0          5       10
             * Controlling Parameter
             § Significant Characteristic
             Notes:
             Dimensions D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed
             .010” (0.254mm) per side.
             JEDEC Equivalent: MS-150
             Drawing No. C04-073
 2003 Microchip Technology Inc.                             Preliminary                                                DS30498B-page 243
PIC16F7X7
28-Lead Plastic Quad Flat No Lead Package (ML) 6x6 mm Body, Punch Singulated (QFN)
                                 E                                                     EXPOSED
                                                                                         METAL
                                E1                                                        PADS
                                                        D1        D         D2
                                                                                                                             p
                                                   2
                                                   1                                                                     B
                                            n
                                                                                   R
                                                                                                  E2
               CH X 45°                                                                                         L
                             TOP VIEW                                                        BOTTOM VIEW
                      α
                                                       A2             A
         A1
                                                             A3
                                         Units                        INCHES                          MILLIMETERS*
                              Dimension Limits         MIN              NOM            MAX       MIN       NOM         MAX
       Number of Pins                      n                                  28                                28
       Pitch                               p                          .026 BSC                           0.65 BSC
       Overall Height                       A                               .033         .039                 0.85           1.00
       Molded Package Thickness            A2                               .026         .031                 0.65           0.80
       Standoff                            A1               .000          .0004          .002      0.00       0.01           0.05
       Base Thickness                      A3                         .008 REF                           0.20 REF
       Overall Width                        E                         .236 BSC                           6.00 BSC
       Molded Package Width                E1                         .226 BSC                           5.75 BSC
       Exposed Pad Width                   E2               .140            .146         .152      3.55       3.70           3.85
       Overall Length                       D                         .236 BSC                           6.00 BSC
       Molded Package Length               D1                         .226 BSC                           5.75 BSC
       Exposed Pad Length                  D2               .140            .146         .152      3.55       3.70           3.85
       Lead Width                           B               .009            .011         .014      0.23       0.28           0.35
       Lead Length                          L               .020            .024         .030      0.50       0.60           0.75
       Tie Bar Width                        R               .005            .007         .010      0.13       0.17           0.23
       Tie Bar Length                      Q                .012            .016         .026      0.30       0.40           0.65
       Chamfer                             CH               .009            .017         .024      0.24       0.42           0.60
       Mold Draft Angle Top                 α                                             12°                                 12°
          *Controlling Parameter
          Notes:
            Dimensions D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not
            exceed .010" (0.254mm) per side.
            JEDEC equivalent: mMO-220
       Drawing No. C04-114
DS30498B-page 244                                           Preliminary                                 2003 Microchip Technology Inc.
                                                                                                              PIC16F7X7
40-Lead Plastic Dual In-line (P) – 600 mil (PDIP)
                          E1
                                     2                                                                                      α
                n                    1
                                                  A                                                                             A2
                                                                                                                                      L
                                          c
                    β                                                                   B1
                                                   A1
                         eB                                                             B                               p
                                               Units                 INCHES*                            MILLIMETERS
                                    Dimension Limits      MIN          NOM          MAX          MIN        NOM                 MAX
            Number of Pins                       n                         40                                    40
            Pitch                                p                       .100                                  2.54
            Top to Seating Plane                 A           .160        .175          .190         4.06       4.45                  4.83
            Molded Package Thickness            A2           .140        .150          .160         3.56       3.81                  4.06
            Base to Seating Plane               A1           .015                                   0.38
            Shoulder to Shoulder Width           E           .595         .600         .625        15.11      15.24              15.88
            Molded Package Width                E1           .530         .545         .560        13.46      13.84              14.22
            Overall Length                      D          2.045         2.058        2.065        51.94      52.26              52.45
            Tip to Seating Plane                 L           .120         .130         .135         3.05       3.30               3.43
            Lead Thickness                       c           .008         .012         .015         0.20       0.29               0.38
            Upper Lead Width                    B1           .030         .050         .070         0.76       1.27               1.78
            Lower Lead Width                     B           .014         .018         .022         0.36       0.46               0.56
            Overall Row Spacing           §     eB           .620         .650         .680        15.75      16.51              17.27
            Mold Draft Angle Top                 α              5           10            15           5         10                 15
            Mold Draft Angle Bottom              β              5           10            15           5         10                 15
             * Controlling Parameter
             § Significant Characteristic
             Notes:
             Dimensions D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed
             .010” (0.254mm) per side.
             JEDEC Equivalent: MO-011
             Drawing No. C04-016
 2003 Microchip Technology Inc.                             Preliminary                                                        DS30498B-page 245
PIC16F7X7
44-Lead Plastic Thin Quad Flatpack (PT) 10x10x1 mm Body, 1.0/0.10 mm Lead Form (TQFP)
                                          E
                                          E1
                                   #leads=n1
                                                                D1        D
                                                            2
                                                            1
            B
                                                      n
                                                                        CH x 45 °
                                                                                                                              α
                                                                                     A
                                                                φ
                 β                                                             A1                                        A2
                                                                    L
                                                                                               (F)
                                              Units                      INCHES                           MILLIMETERS*
                                   Dimension Limits       MIN              NOM           MAX         MIN       NOM        MAX
           Number of Pins                       n                               44                                  44
           Pitch                                p                             .031                                0.80
           Pins per Side                        n1                              11                                  11
           Overall Height                        A          .039             .043          .047        1.00       1.10             1.20
           Molded Package Thickness             A2          .037             .039           .041       0.95       1.00             1.05
           Standoff §                           A1          .002             .004          .006        0.05       0.10             0.15
           Foot Length                           L          .018             .024          .030        0.45       0.60             0.75
           Footprint (Reference)                (F)                          .039                      1.00
           Foot Angle                            φ             0               3.5            7           0        3.5                7
           Overall Width                        E           .463             .472          .482       11.75      12.00            12.25
           Overall Length                       D           .463             .472          .482       11.75      12.00            12.25
           Molded Package Width                 E1          .390             .394          .398        9.90      10.00            10.10
           Molded Package Length                D1          .390             .394          .398        9.90      10.00            10.10
           Lead Thickness                       c           .004             .006          .008        0.09       0.15             0.20
           Lead Width                           B           .012             .015          .017        0.30       0.38             0.44
           Pin 1 Corner Chamfer                CH           .025             .035          .045        0.64       0.89             1.14
           Mold Draft Angle Top                 α              5                10           15           5         10               15
           Mold Draft Angle Bottom              β              5                10           15           5         10               15
           * Controlling Parameter
           § Significant Characteristic
           Notes:
           Dimensions D1 and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed
           .010” (0.254mm) per side.
           JEDEC Equivalent: MS-026
           Drawing No. C04-076
DS30498B-page 246                                          Preliminary                                       2003 Microchip Technology Inc.
                                                                                                       PIC16F7X7
44-Lead Plastic Quad Flat No Lead Package (ML) 8x8 mm Body (QFN)
                                    E                                                EXPOSED
                                                                                       METAL
                                                                                         PAD
                                                             D           D2
                                                        2                                                              B
                                                        1
                                                   n      PIN 1
                    OPTIONAL PIN 1
                                                      INDEX ON                                  E2
                          INDEX ON
                                                  EXPOSED PAD                                                 L
                      TOP MARKING
                                           (PROFILE MAY VARY)
                              TOP VIEW                                                     BOTTOM VIEW
                                        DETAIL: CONTACT VARIANTS
                                                                    A
       A1
                                                            (A3)
                                         Units                       INCHES                          MILLIMETERS*
                           Dimension Limits            MIN             NOM           MAX       MIN        NOM       MAX
        Number of Contacts                  n                               44                                 44
        Pitch                               p                      .026 BSC      1                     0.65 BSC 1
        Overall Height                        A          .031            .035         .039       0.80        0.90      1.00
        Standoff                             A1         .000              .001        .002           0       0.02      0.05
        Base Thickness                      (A3)                   .010 REF      2                     0.25 REF 2
        Overall Width                         E         .309             .315          .321      7.85        8.00      8.15
        Exposed Pad Width                    E2         .246             .268         .274       6.25        6.80      6.95
        Overall Length                        D         .309             .315          .321      7.85        8.00      8.15
        Exposed Pad Length                   D2         .246             .268         .274       6.25        6.80      6.95
        Contact Width                         B         .008             .013         .013       0.20        0.33      0.35
        Contact Length                        L         .014             .016         .019       0.35        0.40      0.48
            *Controlling Parameter
            Notes:
              1. BSC: Basic Dimension. Theoretically exact value shown without tolerances.
                 See ASME Y14.5M
              2. REF: Reference Dimension, usually without tolerance, for information purposes only.
                 See ASME Y14.5M
              3. Contact profiles may vary.
              4. JEDEC equivalent: M0-220
        Drawing No. C04-103
 2003 Microchip Technology Inc.                            Preliminary                                           DS30498B-page 247
PIC16F7X7
NOTES:
DS30498B-page 248   Preliminary    2003 Microchip Technology Inc.
                                                                                          PIC16F7X7
APPENDIX A:              REVISION HISTORY                      APPENDIX B:           DEVICE
                                                                                     DIFFERENCES
Revision A (June 2003)
                                                               The differences between the devices in this data sheet
This is a new data sheet. However, these devices are           are listed in Table B-1.
similar to the PIC16C7X devices found in the
PIC16C7X Data Sheet (DS30390) or the PIC16F87X
devices (DS30292).
Revision B (November 2003)
This revision includes updates to the Electrical Specifi-
cations in Section 18.0 “Electrical Characteristics”
and minor corrections to the data sheet text.
TABLE B-1:          DEVICE DIFFERENCES
            Difference                  PIC16F737           PIC16F747           PIC16F767           PIC16F777
Flash Program Memory                         4K                 4K                  8K                   8K
(14-bit words)
Data Memory (bytes)                         368                 368                 368                 368
I/O Ports                                     3                  5                   3                    5
A/D                                     11 channels,        14 channels,       11 channels,         14 channels,
                                           10 bits             10 bits            10 bits              10 bits
Parallel Slave Port                          no                 yes                 no                  yes
Interrupt Sources                            16                 17                  16                   17
Packages                                28-pin PDIP         40-pin PDIP        28-pin PDIP          40-pin PDIP
                                        28-pin SOIC         44-pin QFN         28-pin SOIC           44-pin QFN
                                        28-pin SSOP         44-pin TQFP        28-pin SSOP          44-pin TQFP
                                         28-pin QFN                             28-pin QFN
 2003 Microchip Technology Inc.                     Preliminary                                  DS30498B-page 249
PIC16F7X7
APPENDIX C:             CONVERSION
                        CONSIDERATIONS
Considerations for converting from previous versions
of devices to the ones listed in this data sheet are listed
in Table C-1.
TABLE C-1:         CONVERSION CONSIDERATIONS
   Characteristic                 PIC16C7X                          PIC16F87X                     PIC16F7X7
Pins                                 28/40                             28/40                         28/40
Timers                                  3                                3                             3
Interrupts                          11 or 12                          13 or 14                      16 or 17
Communication                 PSP, USART, SSP                    PSP, USART, SSP            PSP, AUSART, MSSP
                               (SPI, I2C Slave)                (SPI, I2C Master/Slave)        (SPI, I2C Slave)
Frequency                           20 MHz                            20 MHz                        20 MHz
A/D                                   8-bit                            10-bit                        10-bit
CCP                                     2                                2                             3
Program Memory                  4K, 8K EPROM                        4K, 8K Flash                 4K, 8K Flash
                                                                 (1,000 E/W cycles)            (100 E/W cycles)
RAM                             192, 368 bytes                     192, 368 bytes                  368 bytes
EEPROM Data                          None                          128, 256 bytes                    None
Other                                  —                        In-Circuit Debugger,                   —
                                                              Low-Voltage Programming
DS30498B-page 250                                     Preliminary                         2003 Microchip Technology Inc.
                                                                                                                                        PIC16F7X7
INDEX
A                                                                                                  MSSP (SPI Mode) ...................................................... 93
                                                                                                   On-Chip Reset Circuit............................................... 172
A/D
                                                                                                   OSC1/CLKI/RA7 Pin................................................... 54
     A/D Converter Interrupt, Configuring ........................ 155
                                                                                                   OSC2/CLKO/RA6 Pin................................................. 53
     Acquisition Requirements ......................................... 156
                                                                                                   PIC16F737 and PIC16F767 ......................................... 6
     ADRESH Register..................................................... 154
                                                                                                   PIC16F747 and PIC16F777 ......................................... 7
     Analog Port Pins ......................................................... 68
                                                                                                   PORTC (Peripheral Output Override)
     Analog-to-Digital Converter....................................... 151
                                                                                                         RC<2:0>, RC<7:5> Pins..................................... 65
     Associated Registers ................................................ 160
                                                                                                   PORTC (Peripheral Output Override)
     Automatic Acquisition Time....................................... 157
                                                                                                         RC<4:3> Pins ..................................................... 65
     Calculating Acquisition Time..................................... 156
                                                                                                   PORTD (In I/O Port Mode) ......................................... 67
     Configuring Analog Port Pins.................................... 158
                                                                                                   PORTD and PORTE (Parallel Slave Port).................. 70
     Configuring the Module............................................. 155
                                                                                                   PORTE (In I/O Port Mode) ......................................... 68
     Conversion Clock...................................................... 157
                                                                                                   PWM Mode................................................................. 91
     Conversion Requirements ........................................ 235
                                                                                                   RA0/AN0:RA1/AN1 Pins............................................. 50
     Conversion Status (GO/DONE Bit) ........................... 154
     Conversions .............................................................. 159                RA2/AN2/VREF-/CVREF Pin ........................................ 51
                                                                                                   RA3/AN3/VREF+ Pin ................................................... 50
     Converter Characteristics ......................................... 234
                                                                                                   RA4/T0CKI/C1OUT Pin .............................................. 51
     Delays ....................................................................... 156
                                                                                                   RA5/AN4/LVDIN/SS/C2OUT Pin................................ 52
     Effects of a Reset...................................................... 160
                                                                                                   RB0/INT/AN12 Pin...................................................... 57
     Internal Sampling Switch (Rss) Impedance .............. 156
                                                                                                   RB1/AN10 Pin ............................................................ 57
     Operation During Sleep ............................................ 160
                                                                                                   RB2/AN8 Pin .............................................................. 58
     Operation in Power Managed Modes ....................... 158
                                                                                                   RB3/CCP2/AN9 Pin.................................................... 59
     Source Impedance.................................................... 156
                                                                                                   RB4/AN11 Pin ............................................................ 60
     Time Delays .............................................................. 156
                                                                                                   RB5/AN13/CCP3 Pin.................................................. 61
     Using the CCP Trigger.............................................. 160
                                                                                                   RB6/PGC Pin.............................................................. 62
Absolute Maximum Ratings .............................................. 207
                                                                                                   RB7/PGD Pin.............................................................. 63
ACKSTAT ......................................................................... 123
                                                                                                   Recommended MCLR Circuit................................... 173
ADCON0 Register
                                                                                                   System Clock.............................................................. 39
     GO/DONE Bit............................................................ 154
                                                                                                   Timer0/WDT Prescaler ............................................... 73
Addressable Universal Synchronous Asynchronous
                                                                                                   Timer1 ........................................................................ 79
     Receiver Transmitter. See USART.
                                                                                                   Timer2 ........................................................................ 85
ADRESL Register ............................................................. 154
                                                                                                   USART Receive ............................................... 140, 142
Application Notes
                                                                                                   USART Transmit ...................................................... 138
     AN552 (Implementing Wake-up on Key Stroke) ......... 56
                                                                                                   Watchdog Timer (WDT)............................................ 186
     AN556 (Implementing a Table Read) ......................... 29
                                                                                               BOR. See Brown-out Reset.
     AN607 (Power-up Trouble Shooting)........................ 173
                                                                                               BRG. See Baud Rate Generator.
Assembler
                                                                                               BRGH Bit .......................................................................... 135
     MPASM Assembler................................................... 201
                                                                                               Brown-out Reset (BOR).................... 169, 172, 173, 179, 180
Asynchronous Reception
                                                                                               Bus Collision During a Repeated Start Condition ............. 130
     Associated Registers ........................................ 141, 143
                                                                                               Bus Collision During a Start Condition.............................. 128
Asynchronous Transmission
                                                                                               Bus Collision During a Stop Condition.............................. 131
     Associated Registers ................................................ 139
B                                                                                              C
                                                                                               C Compilers
Banking, Data Memory ....................................................... 15
                                                                                                   MPLAB C17.............................................................. 202
Baud Rate Generator ........................................................ 119
                                                                                                   MPLAB C18.............................................................. 202
BF ..................................................................................... 123
                                                                                                   MPLAB C30.............................................................. 202
Block Diagrams
                                                                                               Capture/Compare/PWM (CCP) .......................................... 87
      A/D ............................................................................ 155
                                                                                                   Capture Mode............................................................. 89
      Analog Input Model ........................................... 156, 165
                                                                                                        Prescaler ............................................................ 89
      Baud Rate Generator................................................ 119
                                                                                                   CCP Pin Configuration ......................................... 89, 90
      Capture Mode Operation ............................................ 89
                                                                                                   Compare Mode........................................................... 89
      Comparator I/O Operating Modes............................. 162
                                                                                                        Software Interrupt Mode ..................................... 90
      Comparator Output ................................................... 164
                                                                                                        Special Event Trigger Output ............................. 90
      Comparator Voltage Reference ................................ 168
                                                                                                        Timer1 Mode Selection....................................... 90
      Compare ..................................................................... 89
                                                                                                   Example PWM Frequencies and Resolutions ............ 92
      Fail-Safe Clock Monitor............................................. 189
                                                                                                   Interaction of Two CCP Modules................................ 87
      In-Circuit Serial Programming Connections.............. 192
                                                                                                   PWM Duty Cycle ........................................................ 91
      Interrupt Logic ........................................................... 184
                                                                                                   PWM Mode................................................................. 91
      Low-Voltage Detect (LVD) ........................................ 175
                                                                                                   PWM Period ............................................................... 91
      Low-Voltage Detect (LVD) with External Input.......... 175
                                                                                                   Registers Associated with Capture,
      MSSP (I2C Master Mode) ......................................... 117
      MSSP (I2C Mode) ..................................................... 102                         Compare and Timer1.......................................... 90
                                                                                                   Registers Associated with PWM and Timer2 ............. 92
 2003 Microchip Technology Inc.                                                     Preliminary                                                       DS30498B-page 251
PIC16F7X7
     Setup for PWM Operation ........................................... 92               Demonstration Boards
     Special Event Trigger.................................................. 90                PICDEM 1................................................................. 204
     Timer Resources......................................................... 87               PICDEM 17............................................................... 204
CCP1 Module...................................................................... 87           PICDEM 18R PIC18C601/801.................................. 205
CCP2 Module...................................................................... 87           PICDEM 2 Plus......................................................... 204
CCP3 Module...................................................................... 87           PICDEM 3 PIC16C92X............................................. 204
CCPR1H Register ............................................................... 87             PICDEM 4................................................................. 204
CCPR1L Register................................................................ 87             PICDEM LIN PIC16C43X ......................................... 205
CCPxM<3:0> Bits................................................................ 88             PICDEM USB PIC16C7X5 ....................................... 205
CCPxX and CCPxY Bits...................................................... 88                  PICDEM.net Internet/Ethernet .................................. 204
Clock Sources ..................................................................... 37    Development Support ....................................................... 201
     Selection Using OSCCON Register ............................ 37                      Device Differences............................................................ 249
Clock Switching................................................................... 37     Device Overview................................................................... 5
     Modes (table) .............................................................. 47           Features ....................................................................... 5
     Transition and the Watchdog Timer ............................ 38                    Direct Addressing ............................................................... 30
Code Examples
     Call of a Subroutine in Page 1 from Page 0................ 29                        E
     Changing Between Capture Prescalers ...................... 89                        Electrical Characteristics .................................................. 207
     Changing Prescaler Assignment from                                                   Errata .................................................................................... 4
            WDT to Timer0.................................................... 76          Evaluation and Programming Tools.................................. 205
     Flash Program Read ................................................... 32            External Clock Input............................................................ 34
     Implementing a Real-Time Clock Using a                                               External Reference Signal ................................................ 163
            Timer1 Interrupt Service ..................................... 82
     Indirect Addressing ..................................................... 30
                                                                                          F
     Initializing PORTA ....................................................... 49        Fail-Safe Clock Monitor ............................................ 169, 189
     Loading the SSPBUF (SSPSR) Register .................... 96                          Firmware Instructions ....................................................... 193
     Reading a 16-bit Free Running Timer......................... 80                      FSR Register ...................................................................... 30
     Saving Status and W Registers in RAM ................... 185
                                                                                          G
     Writing a 16-bit Free Running Timer ........................... 80
Code Protection ........................................................ 169, 192         General Call Address Support .......................................... 116
Comparator Module .......................................................... 161          I
     Analog Input Connection Considerations.................. 165
                                                                                          I/O Ports.............................................................................. 49
     Associated Registers ................................................ 165
                                                                                          I2C Mode
     Configuration............................................................. 162
                                                                                               Registers .................................................................. 102
     Effects of a Reset...................................................... 165
                                                                                          I2C Mode........................................................................... 102
     Interrupts ................................................................... 164
                                                                                               ACK Pulse ........................................................ 106, 107
     Operation .................................................................. 163
                                                                                               Acknowledge Sequence Timing ............................... 126
     Operation During Sleep ............................................ 165
                                                                                               Baud Rate Generator ............................................... 119
     Outputs ..................................................................... 163
                                                                                               Bus Collision
     Reference ................................................................. 163
                                                                                                     Repeated Start Condition ................................. 130
     Response Time ......................................................... 163
                                                                                                     Start Condition.................................................. 128
Comparator Specifications ................................................ 219
                                                                                                     Stop Condition .................................................. 131
Comparator Voltage Reference ........................................ 167
                                                                                               Clock Arbitration ....................................................... 120
     Associated Registers ................................................ 168
                                                                                               Effect of a Reset ....................................................... 127
Computed GOTO ................................................................ 29
                                                                                               General Call Address Support .................................. 116
Configuration Bits.............................................................. 169
                                                                                               Master Mode............................................................. 117
Conversion Considerations ............................................... 250
                                                                                                     Operation.......................................................... 118
Crystal and Ceramic Resonators ........................................ 33
                                                                                                     Repeated Start Condition Timing ..................... 122
D                                                                                              Master Mode Reception............................................ 123
Data Memory....................................................................... 15          Master Mode Start Condition .................................... 121
     Bank Select (RP1:RP0 Bits) ....................................... 15                     Master Mode Transmission ...................................... 123
     General Purpose Registers......................................... 15                     Multi-Master Communication, Bus Collision
     Map for PIC16F737 and PIC16F767 .......................... 16                                   and Arbitration .................................................. 127
     Map for PIC16F747 and PIC16F777 .......................... 17                             Multi-Master Mode .................................................... 127
     Special Function Registers ......................................... 18                   Read/Write Bit Information (R/W Bit) ................ 106, 107
DC and AC Characteristics                                                                      Serial Clock (RC3/SCK/SCL).................................... 107
     Graphs and Tables ................................................... 237                 Slave Mode............................................................... 106
DC Characteristics .................................................... 209, 217                     Addressing........................................................ 106
     Internal RC Accuracy ................................................ 216                       Reception ......................................................... 107
     Power-down and Supply Current .............................. 210                                Transmission .................................................... 107
                                                                                               Sleep Operation........................................................ 127
                                                                                               Stop Condition Timing .............................................. 126
DS30498B-page 252                                                                Preliminary                                       2003 Microchip Technology Inc.
                                                                                                                                      PIC16F7X7
ID Locations .............................................................. 169, 192        Interrupts
In-Circuit Debugger ........................................................... 192               Exiting Sleep with ....................................................... 48
In-Circuit Serial Programming ........................................... 169                     Synchronous Serial Port Interrupt .............................. 25
In-Circuit Serial Programming (ICSP) ............................... 192                    Interrupts, Context Saving During..................................... 185
INDF Register ..................................................................... 30      Interrupts, Enable Bits
Indirect Addressing ............................................................. 30              Global Interrupt Enable (GIE Bit)........................ 23, 184
      FSR Register .............................................................. 15              Interrupt-on-Change (RB7:RB4) Enable
Instruction Format ............................................................. 193                    (RBIE Bit).......................................................... 185
Instruction Set ................................................................... 193           Peripheral Interrupt Enable (PEIE Bit)........................ 23
      ADDLW ..................................................................... 195             RB0/INT Enable (INT0IE Bit)...................................... 23
      ADDWF..................................................................... 195              TMR0 Overflow Enable (TMR0IE Bit)......................... 23
      ANDLW ..................................................................... 195       Interrupts, Flag Bits
      ANDWF..................................................................... 195              Interrupt-on Change (RB7:RB4) Flag
      BCF........................................................................... 195                (RBIF Bit)............................................................ 23
      BSF ........................................................................... 195         Interrupt-on-Change (RB7:RB4) Flag
      BTFSC ...................................................................... 195                  (RBIF Bit).............................................. 23, 56, 185
      BTFSS ...................................................................... 195            RB0/INT Flag (INT0IF Bit) .......................................... 23
      CALL ......................................................................... 196          TMR0 Overflow Flag (TMR0IF Bit) ........................... 185
      CLRF......................................................................... 196     INTRC Modes
      CLRW ....................................................................... 196            Adjustment.................................................................. 36
      CLRWDT................................................................... 196
      COMF ....................................................................... 196      L
      DECF ........................................................................ 196     Load Conditions................................................................ 221
      DECFSZ.................................................................... 197        Loading of PC ..................................................................... 29
      GOTO ....................................................................... 197      Low-Voltage Detect .......................................................... 174
      INCF.......................................................................... 197        Characteristics.......................................................... 220
      INCFSZ ..................................................................... 197          Effects of a Reset ..................................................... 178
      IORLW ...................................................................... 197          Operation.................................................................. 177
      IORWF ...................................................................... 197               Current Consumption ....................................... 178
      MOVF........................................................................ 198               Reference Voltage Set Point ............................ 178
      MOVLW .................................................................... 198            Operation During Sleep ............................................ 178
      MOVWF .................................................................... 198        Low-Voltage Detect (LVD) ................................................ 169
      NOP .......................................................................... 198    LVD. See Low-Voltage Detect.
      RETFIE ..................................................................... 198
      RETLW ..................................................................... 198
                                                                                            M
      RETURN ................................................................... 199        Master Clear (MCLR)
      RLF ........................................................................... 199       MCLR Reset, Normal Operation............... 172, 179, 180
      RRF........................................................................... 199        MCLR Reset, Sleep.................................. 172, 179, 180
      SLEEP ...................................................................... 199          Operation and ESD Protection ................................. 173
      SUBLW ..................................................................... 199       Master Synchronous Serial Port (MSSP). See MSSP.
      SUBWF ..................................................................... 199       MCLR/VPP/RE3 Pin .............................................................. 8
      SWAPF ..................................................................... 200       MCLR/VPP/RE3 Pin ............................................................ 11
      XORLW..................................................................... 200        Memory Organization ......................................................... 15
      XORWF..................................................................... 200            Data Memory .............................................................. 15
      Summary Table......................................................... 194                Program Memory........................................................ 15
INT Interrupt (RB0/INT). See Interrupt Sources.                                                 Program Memory and Stack Maps ............................. 15
INTCON Register                                                                             MPLAB ASM30 Assembler, Linker, Librarian ................... 202
      GIE Bit......................................................................... 23   MPLAB ICD 2 In-Circuit Debugger ................................... 203
      INT0IE Bit.................................................................... 23     MPLAB ICE 2000 High-Performance
      INT0IF Bit.................................................................... 23         Universal In-Circuit Emulator.................................... 203
      PEIE Bit....................................................................... 23    MPLAB ICE 4000 High-Performance
      RBIF Bit................................................................. 23, 56          Universal In-Circuit Emulator.................................... 203
      TMR0IE Bit.................................................................. 23       MPLAB Integrated Development
Inter-Integrated Circuit. See I2C.                                                              Environment Software .............................................. 201
Internal Oscillator Block ...................................................... 35         MPLINK Object Linker/MPLIB Object Librarian ................ 202
      INTRC Modes ............................................................. 36          MSSP ................................................................................. 93
Internal Reference Signal ................................................. 163                 I2C Mode. See I2C.
Interrupt Sources ...................................................... 169, 184               SPI Mode.................................................................... 93
      A/D Conversion Complete ........................................ 155                      SPI Mode. See SPI.
      Interrupt-on-Change (RB7:RB4) ................................. 56                    MSSP Mode
      RB0/INT Pin, External............................................... 185                  SPI Slave Mode.......................................................... 99
      TMR0 Overflow ......................................................... 185
      USART Receive/Transmit Complete ........................ 133
 2003 Microchip Technology Inc.                                                  Preliminary                                                        DS30498B-page 253
PIC16F7X7
MSSP Module                                                                                Pinout Descriptions
     Clock Stretching ........................................................ 112             PIC16F737/PIC16F767 .......................................... 8–10
          10-bit Slave Receive Mode (SEN = 1) .............. 112                               PIC16F747/PIC16F777 ........................................ 11–14
          10-bit Slave Transmit Mode .............................. 112                    PMADR Register ................................................................ 31
          7-bit Slave Receive Mode (SEN = 1) ................ 112                          POP .................................................................................... 29
          7-bit Slave Transmit Mode ................................ 112                   POR. See Power-on Reset.
     Clock Synchronization and the CKP Bit .................... 113                        PORTA ........................................................................... 8, 11
     Control Registers (General) ........................................ 93                   Associated Registers .................................................. 55
     Operation .................................................................. 106          PORTA Register ......................................................... 49
     Overview ..................................................................... 93         TRISA Register........................................................... 49
     SPI Master Mode ........................................................ 98           PORTA Register ................................................................. 49
     SSPBUF...................................................................... 98       PORTB ........................................................................... 9, 12
     SSPSR ........................................................................ 98         Associated Registers .................................................. 64
Multi-Master Mode ............................................................ 127             PORTB Register ......................................................... 56
                                                                                               Pull-up Enable (RBPU Bit).......................................... 22
O                                                                                              RB0/INT Edge Select (INTEDG Bit) ........................... 22
Opcode Field Descriptions ................................................ 193                 RB0/INT Pin, External............................................... 185
OPTION_REG Register                                                                            RB7:RB4 Interrupt-on-Change ................................. 185
     INTEDG Bit ................................................................. 22           RB7:RB4 Interrupt-on-Change Enable
     PS2:PS0 Bits .............................................................. 22                    (RBIE Bit).......................................................... 185
     PSA Bit........................................................................ 22        RB7:RB4 Interrupt-on-Change Flag
     RBPU Bit ..................................................................... 22                 (RBIF Bit).............................................. 23, 56, 185
     T0CS Bit...................................................................... 22         TRISB Register........................................................... 56
     T0SE Bit ...................................................................... 22    PORTB Register ................................................................. 56
OSC1/CLKI/RA7 Pin ....................................................... 8, 11            PORTC ......................................................................... 10, 13
OSC2/CLKO/RA6 Pin ..................................................... 8, 11                  Associated Registers .................................................. 66
Oscillator Configuration....................................................... 33             PORTC Register......................................................... 65
     ECIO ........................................................................... 33       RC3/SCK/SCL Pin .................................................... 107
     EXTRC ...................................................................... 179          RC6/TX/CK Pin......................................................... 134
     HS ....................................................................... 33, 179        RC7/RX/DT Pin................................................. 134, 135
     INTIO1 ........................................................................ 33        TRISC Register................................................... 65, 133
     INTIO2 ........................................................................ 33    PORTC Register................................................................. 65
     INTRC ....................................................................... 179     PORTD ............................................................................... 14
     LP........................................................................ 33, 179        Associated Registers .................................................. 67
     RC ......................................................................... 33, 35       Parallel Slave Port (PSP) Function............................. 67
     RCIO ........................................................................... 33       PORTD Register......................................................... 67
     XT ....................................................................... 33, 179        TRISD Register........................................................... 67
Oscillator Control Register                                                                PORTD Register................................................................. 67
     Modifying IRCF Bits .................................................... 39           PORTE ............................................................................... 14
           Clock Transition Sequence ................................. 40                      Analog Port Pins ......................................................... 68
Oscillator Delay upon Power-up, Wake-up                                                        Associated Registers .................................................. 68
     and Clock Switching.................................................... 40                Input Buffer Full Status (IBF Bit) ................................. 69
Oscillator Start-up Timer (OST) ................................ 169, 173                      Input Buffer Overflow (IBOV Bit)................................. 69
Oscillator Switching............................................................. 37           PORTE Register ......................................................... 68
                                                                                               PSP Mode Select (PSPMODE Bit) ....................... 67, 68
P                                                                                              RE0/RD/AN5 Pin ........................................................ 68
Packaging ......................................................................... 239        RE1/WR/AN6 Pin........................................................ 68
     Marking ..................................................................... 239         RE2/CS/AN7 Pin......................................................... 68
Paging, Program Memory ................................................... 29                  TRISE Register........................................................... 68
Parallel Slave Port                                                                        PORTE Register ................................................................. 68
     Associated Registers .................................................. 71            Postscaler, WDT
Parallel Slave Port (PSP) .............................................. 67, 70                Assignment (PSA Bit) ................................................. 22
     RE0/RD/AN5 Pin......................................................... 68                Rate Select (PS2:PS0 Bits) ........................................ 22
     RE1/WR/AN6 Pin ........................................................ 68            Power Managed Modes...................................................... 41
     RE2/CS/AN7 Pin......................................................... 68                RC_RUN..................................................................... 41
     Select (PSPMODE Bit) ......................................... 67, 68                     SEC_RUN................................................................... 42
PCL Register....................................................................... 29         SEC_RUN/RC_RUN to Primary Clock Source........... 43
PCLATH Register................................................................ 29         Power-down Mode. See Sleep.
PCON Register ................................................................. 178        Power-on Reset (POR)..................... 169, 172, 173, 179, 180
     POR Bit ....................................................................... 28        POR Status (POR Bit) ................................................ 28
Peripheral Interrupt (PEIE Bit)............................................. 23                Power Control (PCON) Register............................... 178
PICkit 1 Flash Starter Kit................................................... 205              Power-down (PD Bit) ................................................ 172
PICSTART Plus Development Programmer ..................... 203                                 Time-out (TO Bit) ................................................ 21, 172
DS30498B-page 254                                                                 Preliminary                                      2003 Microchip Technology Inc.
                                                                                                                                        PIC16F7X7
Power-up Timer (PWRT) .......................................... 169, 173                    RD1/PSP1 Pin .................................................................... 14
PR2 Register....................................................................... 85       RD2/PSP2 Pin .................................................................... 14
Prescaler, Timer0                                                                            RD3/PSP3 Pin .................................................................... 14
    Assignment (PSA Bit) ................................................. 22                RD4/PSP4 Pin .................................................................... 14
    Rate Select (PS2:PS0 Bits) ........................................ 22                   RD5/PSP5 Pin .................................................................... 14
PRO MATE II Universal Device Programmer ................... 203                              RD6/PSP6 Pin .................................................................... 14
Program Counter                                                                              RD7/PSP7 Pin .................................................................... 14
    Reset Conditions....................................................... 179              RE0/RD/AN5 Pin ................................................................ 14
Program Memory                                                                               RE1/WR/AN6 Pin................................................................ 14
    Flash                                                                                    RE2/CS/AN7 Pin................................................................. 14
           Associated Registers .......................................... 32                Read-Modify-Write Operations ......................................... 193
    Interrupt Vector ........................................................... 15          Register File........................................................................ 15
    Memory and Stack Maps ............................................ 15                    Registers
    Operation During Code-Protect .................................. 32                           ADCON0 (A/D Control 0).......................................... 152
    Organization................................................................ 15               ADCON1 (A/D Control 1).......................................... 153
    Paging......................................................................... 29            CCPxCON (CCPx Control)......................................... 88
    PMADR Register......................................................... 31                    CMCON (Comparator Control) ................................. 161
    PMADRH Register ...................................................... 31                     CVRCON (Voltage Reference Control) .................... 167
    Reading....................................................................... 31             Initialization Conditions (table).......................... 180–181
    Reading Flash............................................................. 32                 INTCON (Interrupt Control) ........................................ 23
    Reading, PMADR Register ......................................... 31                          LVDCON (LVD Control)............................................ 176
    Reading, PMADRH Register....................................... 31                            OPTION_REG ...................................................... 22, 75
    Reading, PMCON1 Register....................................... 31                            OSCCON (Oscillator Control)..................................... 38
    Reading, PMDATA Register ....................................... 31                           OSCTUNE (Oscillator Tuning).................................... 36
    Reading, PMDATH Register ....................................... 31                           PCON (Power Control) ............................................... 28
    Reset Vector ............................................................... 15               PIE1 (Peripheral Interrupt Enable 1) .......................... 24
Program Verification ......................................................... 192                PIE2 (Peripheral Interrupt Enable 2) .......................... 26
Programming, Device Instructions .................................... 193                         PIR1 (Peripheral Interrupt Request 1) ........................ 25
PUSH .................................................................................. 29        PIR2 (Peripheral Interrupt Request 2) ........................ 27
                                                                                                  PMCON1 (Program Memory Control 1) ..................... 31
R                                                                                                 RCSTA (Receive Status and Control) ...................... 134
RA0/AN0 Pin ................................................................... 8, 11             Special Function, Summary.................................. 18–20
RA1/AN1 Pin ................................................................... 8, 11             SSPCON (MSSP Control) Register 1
RA2/AN2/VREF-/CVREF Pin............................................. 8, 11                               (I2C Mode) ........................................................ 104
RA3/AN3/VREF+ Pin........................................................ 8, 11                   SSPCON (MSSP Control) Register 1
RA4/T0CKI/C1OUT Pin .................................................. 8, 11                             (SPI Mode) ......................................................... 95
RA5/AN4/LVDIN/SS/C2OUT Pin .................................... 8, 11                             SSPCON2 (MSSP Control) Register 2
RAM. See Data Memory.                                                                                    (I2C Mode) ........................................................ 105
RB0/INT/AN12 Pin .......................................................... 9, 12                 SSPSTAT (MSSP Status), I2C Mode ....................... 103
RB1/AN10 Pin ................................................................. 9, 12              SSPSTAT (MSSP Status), SPI Mode......................... 94
RB2/AN8 Pin ................................................................... 9, 12             Status ......................................................................... 21
RB3/CCP2/AN9 Pin ........................................................ 9, 12                   T1CON (Timer1 Control) ............................................ 78
RB4/AN11 Pin ................................................................. 9, 12              T2CON (Timer2 Control) ............................................ 86
RB5/AN13/CCP3 Pin ...................................................... 9, 12                    TRISE ......................................................................... 69
RB6/PGC Pin .................................................................. 9, 12              TXSTA (Transmit Status and Control)...................... 133
RB7/PGD Pin .................................................................. 9, 12              WDTCON (WDT Control) ......................................... 187
RC0/T1OSO/T1CKI Pin ................................................ 10, 13                  Reset ........................................................................ 169, 172
RC1/T1OSI/CCP2 Pin................................................... 10, 13                      Brown-out Reset (BOR). See Brown-out Reset (BOR).
RC2/CCP1 Pin .............................................................. 10, 13                MCLR Reset. See MCLR.
RC3/SCK/SCL Pin ........................................................ 10, 13                   Power-on Reset (POR). See Power-on Reset (POR).
RC4/SDI/SDA Pin ......................................................... 10, 13                  Reset Conditions for All Registers.................... 180, 181
RC5/SDO Pin ................................................................ 10, 13               Reset Conditions for PCON Register ....................... 179
RC6/TX/CK Pin ............................................................. 10, 13                Reset Conditions for Program Counter .................... 179
RC7/RX/DT Pin ............................................................. 10, 13                Reset Conditions for Status Register ....................... 179
RCIO Oscillator ................................................................... 35            WDT Reset. See Watchdog Timer (WDT).
RCSTA Register                                                                               Revision History................................................................ 249
    ADDEN Bit ................................................................ 134
    CREN Bit................................................................... 134          S
    FERR Bit ................................................................... 134         SCI. See USART.
    OERR Bit .................................................................. 134          SCK .................................................................................... 93
    RX9 Bit...................................................................... 134        SDI...................................................................................... 93
    RX9D Bit ................................................................... 134         SDO .................................................................................... 93
    SPEN Bit ........................................................... 133, 134            Serial Clock, SCK ............................................................... 93
    SREN Bit................................................................... 134          Serial Communication Interface. See USART.
RD0/PSP0 Pin .................................................................... 14
 2003 Microchip Technology Inc.                                                   Preliminary                                                          DS30498B-page 255
PIC16F7X7
Serial Data In, SDI .............................................................. 93           Timer0................................................................................. 73
Serial Data Out, SDO.......................................................... 93                    Associated Registers .................................................. 76
Serial Peripheral Interface. See SPI.                                                                Clock Source Edge Select (T0SE Bit) ........................ 22
Slave Select Synchronization.............................................. 99                        Clock Source Select (T0CS Bit).................................. 22
Slave Select, SS ................................................................. 93                External Clock............................................................. 74
Sleep ................................................................. 169, 172, 190                Interrupt ...................................................................... 73
Software Simulator (MPLAB SIM)..................................... 202                              Operation .................................................................... 73
Software Simulator (MPLAB SIM30)................................. 202                                Overflow Enable (TMR0IE Bit).................................... 23
Special Features of the CPU............................................. 169                         Overflow Flag (TMR0IF Bit) ...................................... 185
Special Function Registers ..................................... 18, 18–20                           Overflow Interrupt ..................................................... 185
SPI Mode ...................................................................... 93, 99               Prescaler .................................................................... 74
     Associated Registers ................................................ 101                       T0CKI ......................................................................... 74
     Bus Mode Compatibility ............................................ 101                    Timer1................................................................................. 77
     Effects of a Reset...................................................... 101                    Associated Registers .................................................. 83
     Enabling SPI I/O ......................................................... 97                   Asynchronous Counter Mode ..................................... 80
     Master Mode ............................................................... 98                        Reading and Writing ........................................... 80
     Master/Slave Connection ............................................ 97                         Capacitor Selection..................................................... 81
     Serial Clock ................................................................. 93               Counter Operation ...................................................... 79
     Serial Data In .............................................................. 93                Operation .................................................................... 77
     Serial Data Out ........................................................... 93                  Operation in Synchronized Counter Mode.................. 79
     Slave Select ................................................................ 93                Operation in Timer Mode ............................................ 79
     Slave Select Synchronization ..................................... 99                           Oscillator..................................................................... 81
     Sleep Operation ........................................................ 101                    Oscillator Layout Considerations ................................ 81
     SPI Clock .................................................................... 98               Prescaler .................................................................... 82
     Typical Connection ..................................................... 97                     Resetting Timer1 Register Pair................................... 82
SS ....................................................................................... 93        Resetting Timer1 Using a CCP Trigger Output .......... 81
SSP                                                                                                  Use as a Real-Time Clock .......................................... 82
     SPI Master/Slave Connection ..................................... 97                       Timer2................................................................................. 85
SSPIF Bit............................................................................. 25            Associated Registers .................................................. 86
SSPOV.............................................................................. 123              Output ......................................................................... 85
SSPSTAT Register                                                                                     Postscaler ................................................................... 85
     R/W Bit .............................................................. 106, 107                 Prescaler .................................................................... 85
Stack ................................................................................... 29         Prescaler and Postscaler............................................ 85
     Overflows .................................................................... 29          Timing Diagrams
     Underflow .................................................................... 29               A/D Conversion......................................................... 235
Status Register                                                                                      Acknowledge Sequence ........................................... 126
     C Bit ............................................................................ 21           Asynchronous Master Transmission......................... 139
     DC Bit.......................................................................... 21             Asynchronous Master Transmission
     IRP Bit ......................................................................... 21                  (Back to Back) .................................................. 139
     PD Bit .................................................................. 21, 172               Asynchronous Reception.......................................... 140
     TO Bit .................................................................. 21, 172               Asynchronous Reception with
     Z Bit............................................................................. 21                 Address Byte First ............................................ 143
Synchronous Master Reception                                                                         Asynchronous Reception with
     Associated Registers ................................................ 146                             Address Detect ................................................. 143
Synchronous Master Transmission                                                                      Baud Rate Generator with Clock Arbitration............. 120
     Associated Registers ................................................ 145                       BRG Reset Due to SDA Arbitration During
Synchronous Serial Port Interrupt Flag Bit (SSPIF) ............ 25                                         Start Condition.................................................. 129
Synchronous Slave Reception                                                                          Brown-out Reset ....................................................... 224
     Associated Registers ................................................ 149                       Bus Collision During a Repeated Start
Synchronous Slave Transmission                                                                             Condition (Case 1)............................................ 130
     Associated Registers ................................................ 148                       Bus Collision During a Repeated Start
                                                                                                           Condition (Case 2)............................................ 130
T                                                                                                    Bus Collision During a Stop Condition
T1CKPS0 Bit ....................................................................... 78                     (Case 1)............................................................ 131
T1CKPS1 Bit ....................................................................... 78               Bus Collision During a Stop Condition
T1OSCEN Bit ...................................................................... 78                      (Case 2)............................................................ 131
T1SYNC Bit......................................................................... 78               Bus Collision During Start Condition
T2CKPS0 Bit ....................................................................... 86                     (SCL = 0) .......................................................... 129
T2CKPS1 Bit ....................................................................... 86               Bus Collision During Start Condition
TAD .................................................................................... 157               (SDA Only) ....................................................... 128
Time-out Sequence........................................................... 178                     Bus Collision for Transmit and Acknowledge ........... 127
                                                                                                     Capture/Compare/PWM (CCP1 and CCP2)............. 226
DS30498B-page 256                                                                     Preliminary                                       2003 Microchip Technology Inc.
                                                                                                                                  PIC16F7X7
    CLKO and I/O ........................................................... 223              Timer0 ...................................................................... 225
    Clock Synchronization .............................................. 113                  Timer1 ...................................................................... 225
    External Clock........................................................... 222             Timer1 Incrementing Edge ......................................... 79
    Fail-Safe Clock Monitor............................................. 189                  Transition Between SEC_RUN/RC_RUN
    First Start Bit ............................................................. 121              and Primary Clock .............................................. 44
    I2C Bus Data ............................................................. 231            Two-Speed Start-up ................................................. 188
    I2C Bus Start/Stop Bits.............................................. 230                 USART Synchronous Receive
    I2C Master Mode (Reception,                                                                    (Master/Slave) .................................................. 233
          7-bit Address) ................................................... 125              USART Synchronous Transmission
    I2C Master Mode (Transmission,                                                                 (Master/Slave) .................................................. 233
          7 or 10-bit Address) .......................................... 124                 Wake-up from Sleep via Interrupt............................. 191
    I2C Slave Mode (Transmission,                                                             Watchdog Timer ....................................................... 224
          10-bit Address) ................................................. 111               XT, HS, LP, EC, EXTRC to RC_RUN Mode .............. 41
    I2C Slave Mode (Transmission,                                                        Timing Parameter Symbology .......................................... 221
          7-bit Address) ................................................... 109         Timing Requirements
    I2C Slave Mode with SEN = 0 (Reception,                                                   Capture/Compare/PWM (CCP1 and CCP2)............. 226
          10-bit Address) ................................................. 110               CLKO and I/O ........................................................... 223
    I2C Slave Mode with SEN = 0 (Reception,                                                   External Clock .......................................................... 222
          7-bit Address) ................................................... 108              I2C Bus Data............................................................. 232
    I2C Slave Mode with SEN = 1 (Reception,                                                   I2C Bus Start/Stop Bits ............................................. 231
          10-bit Address) ................................................. 115               Parallel Slave Port .................................................... 227
    I2C Slave Mode with SEN = 1 (Reception,                                                   Reset, Watchdog Timer, Oscillator
          7-bit Address) ................................................... 114                   Start-up Timer, Power-up Timer
    Low-Voltage Detect................................................... 177                      and Brown-out Reset........................................ 224
    LP Clock to Primary System Clock after                                                    SPI Mode.................................................................. 230
          Reset (EC, RC, INTRC) ...................................... 46                     Timer0 and Timer1 External Clock ........................... 225
    LP Clock to Primary System Clock after                                                    USART Synchronous Receive ................................. 233
          Reset (HS, XT, LP) ............................................. 45                 USART Synchronous Transmission ......................... 233
    Parallel Slave Port .................................................... 227         TMR1CS Bit........................................................................ 78
    Parallel Slave Port Read............................................. 71             TMR1ON Bit ....................................................................... 78
    Parallel Slave Port Write ............................................. 71           TMR2ON Bit ....................................................................... 86
    Power-up Timer ........................................................ 224          TOUTPS<3:0> Bits ............................................................. 86
    PWM Output ............................................................... 91        TRISA Register................................................................... 49
    Repeat Start Condition.............................................. 122             TRISB Register................................................................... 56
    Reset......................................................................... 224   TRISC Register................................................................... 65
    Slave Mode General Call Address Sequence                                             TRISD Register................................................................... 67
          (7 or 10-bit Address Mode) ............................... 116                 TRISE Register................................................................... 68
    Slave Synchronization ................................................ 99                 IBF Bit......................................................................... 69
    Slow Rise Time (MCLR Tied to VDD                                                          IBOV Bit...................................................................... 69
          Through RC Network) ....................................... 183                     PSPMODE Bit ...................................................... 67, 68
    SPI Master Mode (CKE = 0, SMP = 0) ..................... 228                         Two-Speed Clock Start-up Mode...................................... 188
    SPI Master Mode (CKE = 1, SMP = 1) ..................... 228                         Two-Speed Start-up.......................................................... 169
    SPI Mode (Master Mode)............................................ 98                TXSTA Register
    SPI Mode (Slave Mode with CKE = 0) ...................... 100                             BRGH Bit .................................................................. 133
    SPI Mode (Slave Mode with CKE = 1) ...................... 100                             CSRC Bit .................................................................. 133
    SPI Slave Mode (CKE = 0) ....................................... 229                      TRMT Bit .................................................................. 133
    SPI Slave Mode (CKE = 1) ....................................... 229                      TX9 Bit...................................................................... 133
    Start-up Timer ........................................................... 224            TX9D Bit ................................................................... 133
    Stop Condition Receive or Transmit Mode ............... 126                               TXEN Bit ................................................................... 133
    Switching to SEC_RUN Mode .................................... 42
    Synchronous Reception                                                                U
          (Master Mode, SREN) ...................................... 147                 USART ............................................................................. 133
    Synchronous Transmission....................................... 145                     Address Detect Enable (ADDEN Bit)........................ 134
    Synchronous Transmission (Through TXEN) ........... 145                                 Asynchronous Mode................................................. 138
    Time-out Sequence on Power-up (MCLR                                                     Asynchronous Receive (9-bit Mode) ........................ 142
          Tied to VDD Through Pull-up Resistor) ............. 182                           Asynchronous Receive with Address Detect.
    Time-out Sequence on Power-up (MCLR                                                           See Asynchronous Receive (9-bit Mode).
          Tied to VDD Through RC Network): Case 1 ...... 182                                Asynchronous Receiver............................................ 140
    Time-out Sequence on Power-up (MCLR                                                     Asynchronous Reception.......................................... 141
          Tied to VDD Through RC Network): Case 2 ...... 182                                Asynchronous Transmitter........................................ 138
 2003 Microchip Technology Inc.                                               Preliminary                                                        DS30498B-page 257
PIC16F7X7
    Baud Rate Generator (BRG)..................................... 135              V
         Associated Registers ........................................ 135
                                                                                    Voltage Reference Specifications..................................... 219
         Baud Rate Formula........................................... 135
         Baud Rates, Asynchronous Mode                                              W
              (BRGH = 0) ............................................... 136        Wake-up from Sleep ................................................. 169, 190
         Baud Rates, Asynchronous Mode                                                  Interrupts .......................................................... 179, 180
              (BRGH = 1) ............................................... 136            MCLR Reset ............................................................. 180
         High Baud Rate Select (BRGH Bit)................... 133                        WDT Reset ............................................................... 180
         INTRC Baud Rates, Asynchronous Mode                                        Wake-up Using Interrupts ................................................. 191
              (BRGH = 0) ............................................... 137        Watchdog Timer (WDT)............................................ 169, 186
         INTRC Baud Rates, Asynchronous Mode                                            Associated Registers ................................................ 187
              (BRGH = 1) ............................................... 137            WDT Reset, Normal Operation................. 172, 179, 180
         Sampling ........................................................... 135       WDT Reset, Sleep .................................... 172, 179, 180
    Clock Source Select (CSRC Bit) ............................... 133              WCOL ............................................................... 121, 123, 126
    Continuous Receive Enable (CREN Bit) ................... 134                    WCOL Status Flag............................................................ 121
    Framing Error (FERR Bit) ......................................... 134          WWW, On-Line Support ....................................................... 4
    Overrun Error (OERR Bit) ......................................... 134
    Receive Data, 9th bit (RX9D Bit) .............................. 134
    Receive Enable, 9-bit (RX9 Bit) ................................ 134
    Serial Port Enable (SPEN Bit)........................... 133, 134
    Single Receive Enable (SREN Bit) ........................... 134
    Synchronous Master Mode ....................................... 144
    Synchronous Master Reception ................................ 146
    Synchronous Master Transmission........................... 144
    Synchronous Slave Mode ......................................... 148
    Synchronous Slave Reception .................................. 149
    Synchronous Slave Transmit .................................... 148
    Transmit Data, 9th Bit (TX9D)................................... 133
    Transmit Enable (TXEN Bit)...................................... 133
    Transmit Enable, Nine-bit (TX9 Bit) .......................... 133
    Transmit Shift Register Status (TRMT Bit)................ 133
DS30498B-page 258                                                          Preliminary                                  2003 Microchip Technology Inc.
                                                                                       PIC16F7X7
ON-LINE SUPPORT                                              SYSTEMS INFORMATION AND
Microchip provides on-line support on the Microchip          UPGRADE HOT LINE
World Wide Web site.                                         The Systems Information and Upgrade Line provides
The web site is used by Microchip as a means to make         system users a listing of the latest versions of all of
files and information easily available to customers. To      Microchip's development systems software products.
view the site, the user must have access to the Internet     Plus, this line provides information on how customers
and a web browser, such as Netscape® or Microsoft®           can receive the most current upgrade kits. The Hot Line
Internet Explorer. Files are also available for FTP          Numbers are:
download from our FTP site.                                  1-800-755-2345 for U.S. and most of Canada, and
                                                             1-480-792-7302 for the rest of the world.
Connecting to the Microchip Internet
Web Site                                                                                                  042003
The Microchip web site is available at the following
URL:
                 www.microchip.com
The file transfer site is available by using an FTP
service to connect to:
               ftp://ftp.microchip.com
The web site and file transfer site provide a variety of
services. Users may download files for the latest
Development Tools, Data Sheets, Application Notes,
User's Guides, Articles and Sample Programs. A vari-
ety of Microchip specific business information is also
available, including listings of Microchip sales offices,
distributors and factory representatives. Other data
available for consideration is:
• Latest Microchip Press Releases
• Technical Support Section with Frequently Asked
  Questions
• Design Tips
• Device Errata
• Job Postings
• Microchip Consultant Program Member Listing
• Links to other useful web sites related to
  Microchip Products
• Conferences for products, Development Systems,
  technical information and more
• Listing of seminars and events
 2003 Microchip Technology Inc.                     Preliminary                                DS30498B-page 259
PIC16F7X7
READER RESPONSE
It is our intention to provide you with the best documentation possible to ensure successful use of your Microchip prod-
uct. If you wish to provide your comments on organization, clarity, subject matter, and ways in which our documentation
can better serve you, please FAX your comments to the Technical Publications Manager at (480) 792-4150.
Please list the following information, and use this outline to provide us with your comments about this document.
    To:     Technical Publications Manager                                Total Pages Sent ________
    RE:     Reader Response
    From: Name
            Company
            Address
            City / State / ZIP / Country
            Telephone: (_______) _________ - _________                 FAX: (______) _________ - _________
    Application (optional):
    Would you like a reply?      Y         N
    Device: PIC16F7X7                          Literature Number: DS30498B
    Questions:
    1. What are the best features of this document?
    2. How does this document meet your hardware and software development needs?
    3. Do you find the organization of this document easy to follow? If not, why?
    4. What additions to the document do you think would enhance the structure and subject?
    5. What deletions from the document could be made without affecting the overall usefulness?
    6. Is there any incorrect or misleading information (what and where)?
    7. How would you improve this document?
DS30498B-page 260                                  Preliminary                           2003 Microchip Technology Inc.
                                                                                                             PIC16F7X7
PIC16F7X7 PRODUCT IDENTIFICATION SYSTEM
To order or obtain information, e.g., on pricing or delivery, refer to the factory or the listed sales office.
       PART NO.              X                /XX           XXX
                                                                                        Examples:
            Device    Temperature          Package        Pattern                       a)    PIC16F777-I/P 301 = Industrial temp., PDIP
                        Range                                                                 package, normal VDD limits, QTP pattern #301.
                                                                                        b)    PIC16LF767-I/SO = Industrial temp., SOIC
                                                                                              package, extended VDD limits.
                                                                                        c)    PIC16F747-E/P = Extended temp., PDIP
  Device                 PIC16F7X7(1), PIC16F7X7T(1); VDD range 4.0V to 5.5V                  package, normal VDD limits.
                         PIC16LF7X7(1), PIC16LF7X7T(1); VDD range 2.0V to 5.5V
  Temperature Range      I       =   -40°C to +85°C (Industrial)
                         E       =   -40°C to +125°C (Extended)
                                                                                        Note 1:    F = CMOS Flash
                                                                                                   LF = Low-Power CMOS Flash
  Package                ML      =   QFN (Micro Lead Frame)                                   2:   T = in tape and reel – SOIC, SSOP,
                         PT      =   TQFP (Thin Quad Flatpack)                                          TQFP packages only.
                         SO      =   SOIC
                         SP      =   Skinny Plastic DIP
                         P       =   PDIP
                         SS      =   SSOP
  Pattern                QTP, SQTP, Code or Special Requirements
                         (blank otherwise)
 2003 Microchip Technology Inc.                                   Preliminary                                          DS30498B-page 261
                                     WORLDWIDE SALES AND SERVICE
AMERICAS                                  ASIA/PACIFIC                               Korea
                                                                                     168-1, Youngbo Bldg. 3 Floor
Corporate Office                          Australia
                                                                                     Samsung-Dong, Kangnam-Ku
2355 West Chandler Blvd.                  Suite 22, 41 Rawson Street
                                                                                     Seoul, Korea 135-882
Chandler, AZ 85224-6199                   Epping 2121, NSW
                                                                                     Tel: 82-2-554-7200 Fax: 82-2-558-5932 or
Tel: 480-792-7200                         Australia
                                                                                     82-2-558-5934
Fax: 480-792-7277                         Tel: 61-2-9868-6733
Technical Support: 480-792-7627           Fax: 61-2-9868-6755                        Singapore
Web Address: http://www.microchip.com                                                200 Middle Road
                                          China - Beijing
                                                                                     #07-02 Prime Centre
Atlanta                                   Unit 915
                                                                                     Singapore, 188980
3780 Mansell Road, Suite 130              Bei Hai Wan Tai Bldg.
                                                                                     Tel: 65-6334-8870 Fax: 65-6334-8850
Alpharetta, GA 30022                      No. 6 Chaoyangmen Beidajie
                                          Beijing, 100027, No. China                 Taiwan
Tel: 770-640-0034
                                          Tel: 86-10-85282100                        Kaohsiung Branch
Fax: 770-640-0307
                                          Fax: 86-10-85282104                        30F - 1 No. 8
Boston                                                                               Min Chuan 2nd Road
                                          China - Chengdu
2 Lan Drive, Suite 120                                                               Kaohsiung 806, Taiwan
Westford, MA 01886                        Rm. 2401-2402, 24th Floor,                 Tel: 886-7-536-4818
Tel: 978-692-3848                         Ming Xing Financial Tower                  Fax: 886-7-536-4803
Fax: 978-692-3821                         No. 88 TIDU Street
                                          Chengdu 610016, China                      Taiwan
Chicago                                   Tel: 86-28-86766200                        Taiwan Branch
333 Pierce Road, Suite 180                Fax: 86-28-86766599                        11F-3, No. 207
Itasca, IL 60143                                                                     Tung Hua North Road
                                          China - Fuzhou                             Taipei, 105, Taiwan
Tel: 630-285-0071
                                          Unit 28F, World Trade Plaza                Tel: 886-2-2717-7175 Fax: 886-2-2545-0139
Fax: 630-285-0075
                                          No. 71 Wusi Road
Dallas                                    Fuzhou 350001, China                       EUROPE
4570 Westgrove Drive, Suite 160           Tel: 86-591-7503506
                                                                                     Austria
Addison, TX 75001                         Fax: 86-591-7503521
Tel: 972-818-7423                                                                    Durisolstrasse 2
                                          China - Hong Kong SAR                      A-4600 Wels
Fax: 972-818-2924                         Unit 901-6, Tower 2, Metroplaza            Austria
Detroit                                   223 Hing Fong Road                         Tel: 43-7242-2244-399
Tri-Atria Office Building                 Kwai Fong, N.T., Hong Kong                 Fax: 43-7242-2244-393
32255 Northwestern Highway, Suite 190     Tel: 852-2401-1200                         Denmark
Farmington Hills, MI 48334                Fax: 852-2401-3431                         Regus Business Centre
Tel: 248-538-2250                         China - Shanghai                           Lautrup hoj 1-3
Fax: 248-538-2260                         Room 701, Bldg. B                          Ballerup DK-2750 Denmark
Kokomo                                    Far East International Plaza               Tel: 45-4420-9895 Fax: 45-4420-9910
2767 S. Albright Road                     No. 317 Xian Xia Road                      France
Kokomo, IN 46902                          Shanghai, 200051                           Parc d’Activite du Moulin de Massy
Tel: 765-864-8360                         Tel: 86-21-6275-5700                       43 Rue du Saule Trapu
Fax: 765-864-8387                         Fax: 86-21-6275-5060                       Batiment A - ler Etage
                                          China - Shenzhen                           91300 Massy, France
Los Angeles
                                          Rm. 1812, 18/F, Building A, United Plaza   Tel: 33-1-69-53-63-20
18201 Von Karman, Suite 1090              No. 5022 Binhe Road, Futian District       Fax: 33-1-69-30-90-79
Irvine, CA 92612                          Shenzhen 518033, China
Tel: 949-263-1888                                                                    Germany
                                          Tel: 86-755-82901380                       Steinheilstrasse 10
Fax: 949-263-1338                         Fax: 86-755-8295-1393                      D-85737 Ismaning, Germany
Phoenix                                   China - Shunde                             Tel: 49-89-627-144-0
2355 West Chandler Blvd.                  Room 401, Hongjian Building                Fax: 49-89-627-144-44
Chandler, AZ 85224-6199                   No. 2 Fengxiangnan Road, Ronggui Town      Italy
Tel: 480-792-7966                         Shunde City, Guangdong 528303, China       Via Quasimodo, 12
Fax: 480-792-4338                         Tel: 86-765-8395507 Fax: 86-765-8395571    20025 Legnano (MI)
San Jose                                  China - Qingdao                            Milan, Italy
2107 North First Street, Suite 590        Rm. B505A, Fullhope Plaza,                 Tel: 39-0331-742611
San Jose, CA 95131                        No. 12 Hong Kong Central Rd.               Fax: 39-0331-466781
Tel: 408-436-7950                         Qingdao 266071, China                      Netherlands
Fax: 408-436-7955                         Tel: 86-532-5027355 Fax: 86-532-5027205    P. A. De Biesbosch 14
Toronto                                   India                                      NL-5152 SC Drunen, Netherlands
6285 Northam Drive, Suite 108             Divyasree Chambers                         Tel: 31-416-690399
Mississauga, Ontario L4V 1X5, Canada      1 Floor, Wing A (A3/A4)                    Fax: 31-416-690340
Tel: 905-673-0699                         No. 11, O’Shaugnessey Road                 United Kingdom
Fax: 905-673-6509                         Bangalore, 560 025, India                  505 Eskdale Road
                                          Tel: 91-80-2290061 Fax: 91-80-2290062      Winnersh Triangle
                                          Japan                                      Wokingham
                                          Benex S-1 6F                               Berkshire, England RG41 5TU
                                          3-18-20, Shinyokohama                      Tel: 44-118-921-5869
                                          Kohoku-Ku, Yokohama-shi                    Fax: 44-118-921-5820
                                          Kanagawa, 222-0033, Japan
                                          Tel: 81-45-471- 6166 Fax: 81-45-471-6122                                         07/28/03
DS30498B-page 262                                     Preliminary                             2003 Microchip Technology Inc.
This datasheet has been download from:
      www.datasheetcatalog.com
Datasheets for electronics components.