4.0Reading Program Memory............................................................................................... .... ........................................41
9.0Synchronous Serial Port (SSP) Module.......................................................................................................................61
12.0Special Featur e s of th e CPU........................................... ............ ............. ............. ...................................................... 95
13.0Instruction Set Summary ...........................................................................................................................................111
16.0DC and AC Characteristics Graphs and Tables ........................................................................................................147
Index .................................................................................................................................................................................................. 159
It is our intention to provide our valued customers with t he best documen tation possible to ensure successf ul use of your Mic rochip 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.m ic rochip.com or fax the Reader Response Form in the back of this data sheet to (480) 786-
7578. 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) 786-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.
DS30325A-page 4Advance Information 2000 Microchip Technology Inc.
PIC16F7X
1.0DEVICE OVERVIEW
This document contains device specific information.
Additional information m ay be found in the PICm ic ro™
Mid-Range Reference Manual (DS33023), which may
be obtained from your local Microchip Sales Representative or downloaded from the Microchip web site. The
Reference Manual should be considered a complementary documen t to thi s dat a she et, and is hig hly re commended reading for a better understanding of the
device architecture and operation of the peripheral
There are four devices (PIC16F73, PIC16F74,
PIC16F76 an d PIC1 6F77) co vered by this data sheet .
The PIC16F76/73 dev ices are availab le in 28 -pin p ackages and the PIC16F77/74 devices are available in
40-pin packages. The 28-pin devices do not have a
Parallel Slave Port implemented.
The following two figures are device block diagrams
sorted by pin number; 28-pin for Figure 1-1 and 40-pin
for Figure 1-2. The 28-pin and 40-pin pinouts are li sted
in Table 1-1 and Table 1-2, respectively.
Note 1: Higher order bits are from the STATUS register.
Synchronous
Serial Port
USART
DS30325A-page 6Advance Information 2000 Microchip Technology Inc.
TABLE 1-1:PIC16F73 AND PIC16F76 PINOUT DESCRIPTION
PIC16F7X
Pin Name
OSC1/CLKIN99IST/CMOS
OSC2/CLKOUT1010O—Oscillator crystal output. Connec ts to crystal or resonator in Crys-
MCLR
/VPP11I/PSTMaster clear (RESET) input or programming voltage input or High
RA0/AN022I/OTTLRA0 can also be analog input0.
RA1/AN133I/OTTLRA1 can also be analog input1.
RA2/AN244I/OTTLRA2 can also be analog input2.
RA3/AN3/V
RA4/T0CKI66I/OSTRA4 ca n also be th e cloc k input t o the T ime r0 module. Ou tput
RC0/T1OSO/T1CKI1111I/OSTRC0 can also be the Timer1 oscillator output or Timer1 clock
RC1/T1OSI/CCP21212I/OSTRC1 can also be the Time r1 oscillator i nput or Capture2 in put/
RC2/CCP11313I/OSTRC2 can also be the Capture1 input/Comp are1 outpu t/PWM1
RC3/SCK/SCL1414I/OSTRC3 can also be the synchr onous seri al clock inpu t/ou tput for
RC4/SDI/SDA1515I/OSTRC4 can also be the SPI Data In (SPI mode) or
RC5/SDO1616I/OSTRC5 can also be the SPI Data Out (SPI mode).
RC6/TX/CK1717I/OSTRC6 can also be the USART Asynchronous Transmit or
RC7/RX/DT1818I/OSTRC7 can also be the USART Asynchronous Receive or
V
SS8, 198, 19P—Ground reference for logic and I/O pins.
V
DD2020P—Positive supply for logic and I/O pins.
Legend: I = inputO = outputI/O = input/outputP = power
Note 1: This buffer is a Schmitt Trigger input when configured as the external interrupt.
REF55I/OTTLRA3 can also be analog input3 or analog ref erence voltage.
AN477I/OTTLRA5 can also be analog input4 or the slave select for the
2: This buffer is a Schmitt Tri gger 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 ot herwise.
TABLE 1-2:PIC16F74 AND PIC16F77 PINOUT DESCRIPTION
DIP
Pin Name
OSC1/CLKIN131430I
OSC2/CLKOUT141531O—Oscillator crystal output. Connects to crystal or resonator in
MCLR
/VPP1218I/PSTMaster clear (RESET) input or programming v oltage input or
RA0/AN02319I/OTTLRA0 can also be analog input0.
RA1/AN13420I/OTTLRA1 can also be analog input1.
RA2/AN24521I/OTTLRA2 can also be analog input2.
RA3/AN3/V
RA4/T0CKI6723I/OSTRA4 can also be the clock input to the Timer0 timer/
DS30325A-page 10Advance Information 2000 Microchip Technology Inc.
PIC16F7X
2.0MEMORY ORGANIZATION
There are two memory blocks in each of these
PICmicro
Memory have separate buses so that concurrent
access can oc cur and is detailed in this section. The
Program Mem ory can be read i ntern ally by user co de
(see Section 4.0).
Additional informa tion on devi ce memory may be found
in the PICmicro Mid-Range Reference Manual,
(DS33023).
2.1Program Memory Organization
The PIC16F7X devices have a 13-bit program counter
capable of addressing an 8K x 14 program memory
space. The PIC 16F77 /7 6 devic es have 8K x 14 wo rds
of FLASH program memory and the PIC16F73/74
devices have 4K x 14. Ac cess ing a lo cati on ab ove t he
physically implemented address will cause a wraparound.
The RESET Ve ctor is at 0000h an d the Interrup t V ector
is at 0004h.
The Data Memory is partitioned into multiple banks,
which contain the General Purpose Registers and the
Special Function Registers. Bits RP1 (STATUS<6>)
and RP0 (STATUS<5>) are the bank select bits.
RP1:RP0Bank
000
011
102
113
Each bank extends up to 7Fh (128 bytes). The lower
locations of each bank are reserved for the Special
Function Registers. Above the Special Function Registers are Gener al Purpose Registers, implemented as
static RAM. All implemented banks contain Special
Function Registers. Some frequently used Special
Function Registers from one bank may be mirrored in
another bank for code reduction and quicker access.
2.2.1GENERAL PURPOSE REGISTER FILE
The register file can be acces sed either directly, or indi-
rectly, through the File Select Register FSR.
DS30325A-page 12Advance Information 2000 Microchip Technology Inc.
Note 1: These registers are not implemented on 28-pin devices.
DS30325A-page 14Advance Information 2000 Microchip Technology Inc.
General
Purpose
Register
96 Bytes
Bank 1
FFh
accesses
20h-7Fh
Bank 2
16Fh
170h
17Fh
accesses
A0h - FFh
1EFh
1F0h
1FFh
Bank 3
PIC16F7X
2.2.2SPECIAL FUNCTION REGISTERS
The Special Function Registers are registers used by
the CPU and peripheral modules for controlling the
desired operation of the device. These registers are
implemented as static RAM. A list of these registers is
The Special Function Registers can be classified into
two sets: core (CPU) and peripheral. Those registers
associated with the core functions are described in
detail in this section. Those related to the operation of
the peripheral features are described in detail in the
peripheral feature section.
given in Table 2-1.
TABLE 2-1:SPECIAL FUNCTION REGISTER SUMMARY
AddressNameBit 7Bit 6Bit 5Bit 4Bit 3Bit 2 Bit 1Bit 0
05hPORTA——PORTA Data Latch when written: PORTA pins when read
06hPORTBPORTB Data Latch when written: PORTB pins when readxxxx xxxx uuuu uuuu
07hPORTCPORTC Data Latch when written: PORTC pins when readxxxx xxxx uuuu uuuu
08h
09h
0Ah
0Bh
0ChPIR1
0DhPIR2———————CCP2IF
0EhTMR1LHolding register for the Least Significant Byte of the 16-bit TMR1 Registerxxxx xxxx uuuu uuuu
0FhTMR1HHolding register for the Most Significant Byte of the 16-bit TMR1 Registerxxxx xxxx uuuu uuuu
10hT1CON——T1CKPS1 T1CKPS0 T1OSCEN T1SYNC TMR1CS TMR1ON
11hTMR2Timer2 Module’s Register
12hT2CON—TOUTPS3 TOUTPS2TOUTPS TOUTPS0 TMR2ON T2CKPS1 T2CKPS0
13hSSPBUFSynchronous Serial Port Receive Buffer/Transmit Register
14hSSPCONWCOLSSPOVSSPENCKPSSPM3SSPM2SSPM1SSPM0
15hCCPR1LCapture/Compare/PWM Register1 (LSB)xxxx xxxx uuuu uuuu
16hCCPR1HCapture/Compare/PWM Register1 (MSB)
17hCCP1CON——CCP1XCCP1YCCP1M3 CCP1M2 CCP1M1 CCP1M0
18hRCSTASPENR X9SRENCREN—FERROERRRX9D
19hTXREGUSART Transmit Data Register
1AhRCREGUSART Receive Data Register
1BhCCPR2LCapture/Compare/PWM Register2 (LSB)xxxx xxxx uuuu uuuu
1ChCCPR2HCapture/Compare/PWM Register2 (MSB)xxxx xxxx uuuu uuuu
1DhCCP2CON——CCP2XCCP2YCCP2M3 CCP2M2 CCP2M1 CCP2M0
1EhADRESA/D Result Register Byte
1FhADCON0ADCS1ADCS0CHS2CHS1CHS0
Legend: x = unknown, u = unchanged, q = value depe nds on condition, - = unimplemented read as '0', r = reserved.
Note 1: The upper byte of the program counter is not directly accessible. PCLATH is a holding register for the PC<12:8>, whose
INDFAddressing this location uses contents of FSR to address data memory (not a physical register)
(4)
PCLProgram Counter's (PC) Least Significant Byte0000 0000 0000 0000
(4)
STATUSIRPRP1RP0TOPDZDCC
(4)
FSRIndirect data memory address pointerxxxx xxxx uuuu uuuu
(5)
PORTDPORTD Data Latch when written: PORTD pins when readxxxx xxxx uuuu uuuu
(5)
PORTE—————RE2RE1RE0
(1,4)
PCLATH———Write Buffer for the upper 5 bits of the Program Counter---0 0000 ---0 0000
(4)
INTCONGIE PEIET0IEINTERBIET0IFINTFRBIF
(3)
PSPIF
Shaded locations are unimple mented, read as ‘0’.
contents are tran sf erred to the upper byte of the pr ogram counter.
2: Other (non power-up) RESETS include external RESET through MCLR
3: Bits PSPI E an d PSPIF are reser v e d on the 28-pin dev i ce s ; al w ays maintain th es e bi ts cle a r.
4: These registers can be addressed from any ban k.
5: PORTD, PORTE, TRISD, and TRISE are not physically implement ed on the 28-pin devices, read as ‘0’.
6: This bit always reads as a ‘1’.
Legend: x = unknown, u = unchanged, q = value depe nds on condition, - = unimplemented read as '0', r = reserved.
Shaded locations are unimple mented, 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.
2: Other (non power-up) RESETS include external RESET through MCLR
and Watchdog Timer Reset.
3: Bits PSPI E an d PSPIF are reser v e d on the 28-pin dev i ce s ; al w ays maintain th es e bi ts cle a r.
4: These registers can be addressed from any ban k.
5: PORTD, PORTE, TRISD, and TRISE are not physically implemented on the 28-pin devices, read as ‘0’.
6: This bit always reads as a ‘1’.
Value on
all other
RESETS
(2)
DS30325A-page 16Advance Information 2000 Microchip Technology Inc.
PIC16F7X
TABLE 2-1:SPECIAL FUNCTION REGISTER SUMMARY (CONTINUED)
AddressNameBit 7Bit 6Bit 5Bit 4Bit 3Bit 2 Bit 1Bit 0
POR,
BOR
Value on:
Bank 2
(4)
100h
INDFAddressing this location uses contents of FSR to address data memory (not a physical register)
101hTMR0Timer0 Module’s Register
(4)
102h
103h
104h
PCLProgram Counter's (PC) Least Significant Byte
(4)
STATUSIRPRP1RP0TOPDZDCC0001 1xxx 000q quuu
(4)
FSRIndirect Data Memory Address Pointer
105h—Unimplemented
106hPORTBPORTB Data Latch when written: PORTB pins when read
107h—Unimplemented
108h—Unimplemented
0000 00000000 0000
xxxx xxxx uuuu uuuu
0000 0000 0000 0000
xxxx xxxx uuuu uuuu
——
xxxx xxxx uuuu uuuu
——
——
109h—Unimplemented——
10Ah
10Bh
(1,4)
PCLATH———Write Buffer for the upper 5 bits of the Program Counter
(4)
INTCONGIE PEIET0IEINTERBIET0IFINTFRBIF
---0 0000 ---0 0000
0000 000x 0000 000u
10ChPMDATAData Register Low Bytexxxx xxxx uuuu uuuu
10DhPMADRAddress Register Low Byte
10EhPMDATH——Data Register High Byte
10FhPMADRH———Address Register High Byte
xxxx xxxx uuuu uuuu
xxxx xxxx uuuu uuuu
xxxx xxxx uuuu uuuu
Bank 3
(4)
180h
181h
182h
183h
184h
INDFAddressing this location uses contents of FSR to address data memory (not a physical register)
OPTION_
REG
(4)
PCLProgram Counter's (PC) Least Significant Byte0000 0000 0000 0000
(4)
STATUSIRPRP1RP0TOPDZDCC
(4)
FSRIndirect Data Memory Address Pointerxxxx xxxx uuuu uuuu
RBPUINTEDGT0CST0SEPSAPS2PS1PS0
185h—Unimplemented
186hTRISBPORTB Data Direction Register
187h—Unimplemented——
188h—Unimplemented
189h—Unimplemented
(1,4)
18Ah
18Bh
PCLATH———
(4)
INTCONGIEPEIET0IEINTERBIET0IFINTFRBIF
18ChPMCON1
—
(6)
——————RD
Write Buffer for the upper 5 bits of the Program Counter
18Dh—Unimplemented——
18Eh—Reserved maintain clear0000 0000 0000 0000
18Fh—Reserved maintain clear
Legend: x = unknown, u = unchanged, q = value depe nds on condition, - = unimplemented read as '0', r = reserved.
Shaded locations are unimple mented, 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 tran sf erred to the upper byte of the pr ogram counter.
2: Other (non power-up) RESETS include external RESET through MCLR
and Watchdog Timer Reset.
3: Bits PSPI E an d PSPIF are reser v e d on the 28-pin dev i ce s ; al w ays maintain th es e bi ts cle a r.
4: These registers can be addressed from any ban k.
5: PORTD, PORTE, TRISD, and TRISE are not physically implement ed on the 28-pin devices, read as ‘0’.
6: This bit always reads as a ‘1’.
2.2.2.1STATUS Register
The STATUS register contains the arithmetic status of
the ALU, the RESET statu s and the b ank sele ct bit s for
data memory.
The STATUS register can be the destination for any
instruction, as with any other register. If the STATUS
register is the destination for an instruction that affects
the Z, DC, or C bits, then the wri te to thes e three bi ts is
disabled. These bit s are set or cleared ac cording to the
device logic. Furthermore, the TO
writable, therefore, the result of an instruction with the
STATUS r egister as dest ination may be di fferent than
intended.
and PD bits are not
For example, CLRF STATUS will clear the upper-three
bits and set the Z bit. This le aves the STATUS register
as 000u u1uu (where u = unchanged).
It is recommended, therefore, that only BCF, BSF,SWAPF and MOVWF instructions are used to alter the
STATUS register, because these instructions do not
affect the Z, C, or DC bits from the STATUS register.
For other in s tru ct i o ns no t aff ec t in g an y s tat us b its, s ee
the "Instruction Set Summary."
Note 1: The C and DC bits operate as a borrow
and digit borrow bit, respectively, in subtraction. See the SUBLW and SUBWF
instructions for examples.
REGISTER 2-1: STATUS REGISTER (ADDRESS 03h, 83h, 103h, 183h)
R/W-0R/W-0R/W-0R-1R-1R/W-xR/W-xR/W-x
IRPRP1RP0TO
bit 7bit 0
bit 7IRP: Register Bank Select bit (used for indirec t addressing)
1 = Bank 2, 3 (100h - 1FFh)
0 = Bank 0, 1 (00h - FFh)
bit 6-5RP1: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 4TO
bit 3PD: Pow er-down bit
bit 2Z: Zero bit
bit 1DC: Digit carry/borrow bit (ADDWF, ADDLW, SUBLW, SUBWF instructions)
bit 0C: Carry/borrow bit (ADDWF, ADDLW, SUBLW, SUBWF instructions)
: Time-out bit
1 = After power-up, CLRWDT instruction, or SLEEP instruction
0 = A WDT time-out occurred
1 = After power-up or by the CLRWDT instruction
0 = By execution of the SLEEP instruction
1 = The result of an arithmetic or logic operation is zero
0 = The result of an arithmetic or logic operation is not zero
(for borrow
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
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
the polarity is reversed)
PDZDCC
Note:For borrow
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 bitW = Writable bitU = Unimplemented bit, read as ‘0’
- n = Value at POR reset’1’ = Bit is set’0’ = Bit is clearedx = Bit is unknown
DS30325A-page 18Advance Information 2000 Microchip Technology Inc.
, the polarity is reversed. A subtraction is executed by adding the two’s
2.2.2.2OPTION_REG Register
The OPTION_REG register is a readable and writable
register , which cont ains various contr ol bits to conf igure
Note:To achieve a 1:1 prescaler assignment for
the TMR0 register, assign the prescaler to
the Watchdog Timer.
the TMR0 prescaler/WDT postscaler (single assignable register k nown als o as th e presca ler), t he Externa l
INT Interrupt, TMR0 and the w eak pull-up s on POR TB.
2.2.2.3 INTCON R egister
The INTCON register is a readable and writable regis-
ter, which contains various enable and flag bits for the
TMR0 register overflow, RB Port change and External
RB0/INT pin interrupts.
Note:Interrupt flag bits are set whe n an interrupt
condition occurs, re gardless of the sta t e of
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.
2.2.2.5PIR1 Regi ster
Note:Interrupt flag bits are set when an interrupt
The PIR1 register contains the individual flag bits for
the periph eral interrupts.
REGISTER 2-5: PIR1 REGISTER (ADDRESS 0Ch)
R/W-0R/W-0R-0R-0R/W-0R/W-0R/W-0R/W-0
(1)
PSPIF
bit 7bit 0
bit 7PSPIF
bit 6ADIF: A/D Converter Interrupt Flag bit
bit 5RCIF: USART Receive Interrupt Flag bit
bit 4TXIF: USART Transmit Interrupt Flag bit
bit 3SSPIF: Synchronous Serial Port (SSP) Interrupt Flag
bit 2CCP1IF: CCP1 Interrupt Flag bit
bit 1TMR2IF: TMR2 to PR2 Match Interrupt Flag bit
bit 0TMR1IF: TMR1 Overflow Interrupt Flag bit
(1)
1 = A read or a write operat ion has taken place (must be clea red in software)
0 = No read or write has oc cur r ed
1 = An A/D conversion completed
0 = The A/D conversion is not complete
1 = The USART receive buffer is full
0 = The USART receive buffer is empty
1 = The USART transmit buffer is empty
0 = The USART transmit buffer is full
1 = The SSP interrupt condition has occ urre d, and mu st be cle are d in so ftware befor e
returning from the Interrupt Service Routine. The conditions that will set this bit are:
SPI
A transmission/recept i on has taken place.
2
I
C Slave
A transmission/recept i on has taken place.
2
C Master
I
A transmission/recept i on 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 interrup t condition has occurred.
Capture Mode
1 = A TMR1 register ca pt ur e occurred (must be clear ed i n software)
0 = No TMR1 register capt ur e occurred
Compare Mode
1 = A TMR1 register co m pare m at ch occurred (must be cleared in software)
0 = No TMR1 register compare match occurred
PWM Mode
Unused in this mode
1 = TMR2 to PR2 match oc cur re d ( must be cleared in software)
0 = No TMR2 to PR2 match occurred
1 = TMR1 register over flow ed (must be cleared in so ftwa re )
0 = TMR1 register did no t ov er f low
Note 1: PSPIF is reserved on 28-pin dev i ces ; a lwa ys maintain this bit clear.
ADIFRCIFT XIFSSPIFCCP1IFTMR2IFTMR1IF
: Parallel Slave Port Read/Write Interrupt Flag bit
condition occurs, regardless of the state of
its corresponding enable bit or the global
enable bit, GIE (INTCON<7>). User software should en sure the approp riate interrup t
bits are cle ar pri or to en ab li ng an i nte rru pt.
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
- n = Value at POR reset’1’ = Bit is set’0’ = Bit is cl ear edx = Bit is unknown
DS30325A-page 22Advance Information 2000 Microchip Technology Inc.
2.2.2.6PIE2 Register
The PIE2 register cont ains the ind ividual enab le bits for
the CCP2 peripheral interrupt.
REGISTER 2-6: PIE2 REGISTER (ADDRESS 8Dh)
U-0U-0U-0U-0U-0U-0U-0R/W-0
———————CCP2IE
bit 7bit 0
bit 7-1Unimplemented: Read as ’0’
bit 0CCP2IE: CCP2 Interrupt Enable bit
1 = Enables the CCP2 interrupt
0 = Disables the CCP2 interrupt
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
- n = Value at POR reset’1’ = Bit is set’0’ = Bit is clearedx = Bit is unknown
The PIR2 register contains the flag bits for the CCP2
interrupt.
.
Note:Interrupt flag bits are set whe n an interrupt
REGISTER 2-7: PIR2 REGISTER (ADDRESS 0Dh)
U-0U-0U-0U-0U-0U-0U-0R/W-0
———————CCP2IF
bit 7bit 0
bit 7-1Unimplemented: Read as '0'
bit 0CCP2IF: 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
condition occurs, re gardless of the sta t e of
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.
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
- n = Value at POR reset’1’ = Bit is set’0’ = Bit is clearedx = Bit is unknown
DS30325A-page 24Advance Information 2000 Microchip Technology Inc.
PIC16F7X
2.2.2.8PCON Register
The Power Control (PCON) register contains flag bits
to allow differentiation between a Power-on Reset
(POR), a Brown-out Reset (BOR), a Watchdog Reset
(WDT) and an external MCLR
Reset.
Note:BOR is unknown on POR. It mus t be set by
REGISTER 2-8: PCON REGISTER (ADDRESS 8Eh)
U-0U-0U-0U-0U-0U-0R/W-0R/W-1
——————PORBOR
bit 7bit 0
bit 7-2Unimplemented: Read as '0'
bit 1POR
bit 0BOR: Brown-out Reset Status bit
: 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)
1 = No Brown-out Reset occurred
0 = A Brown-out Reset occurred (must be set in software after a Brown-out Reset occurs)
the user and checked on subsequent
RESETS to see if BOR is clear, indicating
a brown-out has occurre d. The BOR st atus
bit is a don’t care and is not predictable if
the brown-out circuit is disabled (by clearing the BODEN bit in the configuration
word).
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
- n = Value at POR reset’1’ = Bit is set’0’ = Bit is clearedx = Bit is unknown
The program counter (PC) is 13-bits wid e. The low byte
comes from the PCL register, which is a readable and
writable register. The upper bits (PC<12:8>) are not
readable, but are indirectly writable through the
PCLA TH reg is ter. On any RESET, the up per bi t s of the
PC will be cleared. Fig ure2-5 shows the two situations
for the loading of the PC. The up per ex ample in th e figure shows how the PC is loaded on a write to PCL
(PCLATH<4:0> → PCH). The lower exam pl e i n th e fi gure shows how the PC is loaded during a CALL or GOTO
instruction (PCLATH<4:3> → PCH).
FIGURE 2-5:LOADING OF PC IN
DIFFERENT SITUATIONS
PCHPCL
128 70
PC
PCLATH<4:0>
5
PCLATH
PCHPCL
12 11 100
PC
2
87
PCLATH<4:3>
PCLATH
11
2.3.1COMPUTED GOTO
A computed GOTO is accomplish ed by adding an of fs et
to the progr am counter (ADDWF PCL). When doing a
table read using a computed GOTO method, care
should be exercise d i f the t able loca tio n cros ses a PCL
memory boundary (each 256 byte block). Refer to the
application note, “Implementing a Table Read"
(AN556).
2.3.2STACK
The PIC16F7X fami ly has an 8 -level de ep x 13-bi t wide
hardware s tack. The stack space is not part of either
program or data space and the stack pointer is not
readable or writabl e. The PC i s PUSHed onto th e stac k
when a CALL instruction is executed, or an interrupt
causes a branch. The st ac k is POPed in the ev en t of a
RETURN,RETLW or a RETFIE instruction execution.
PCLATH is not affected by a PUSH or POP operation.
The stack opera tes as a circular buf fer . This means that
after the st ack h as be en PUSHed ei ght ti mes, th e nin th
push overwrites the v alue tha t was stored fro m the first
push. The tenth pus h ov erwri t es the se co nd p us h (an d
so on).
8
Instruction with
PCL as
Destination
ALU
GOTO,CALL
Opcode <10:0>
Note 1: There are no status bits to indicate stack
overflow or stack underflow conditions.
2: There are no instructions/mnemonics
called PUSH or POP. These are actions
that occur from the execution of the
CALL, RETURN, RETLW and RETFIE
instructions or th e vectoring to an interrupt
address.
2.4Program Memory Paging
PIC16F7X devices are cap able of add ressi ng a conti nuous 8K word block of program memory. The CALL and
GOTO instructions provide only 11 bits of address to
allow branching within any 2K program memory page.
When doing a CALL or GOTO instruction , the upper 2
bits of the address are provided by PCLATH<4:3>.
When doing a CALL or GOTO instruct ion, the user must
ensure that t he page select bits are progr ammed so
that the desired prog ram memory pa ge is addre ssed. If
a return from a CALL instruction (or interrupt) is executed, the entire 13-bit PC is popped off the stack.
Therefore, manipulation of the PCLATH<4:3> bits are
not required for the return instruction s (which POPs the
address from the stack).
Note:The contents of the PCLATH are
unchanged after a RETURN or RETFIE
instruction is executed. The user must
setup the PCLATH for any subsequent
CALLS or GOTOS.
Example 2-1 shows the calling of a subroutine in
page 1 of the program memory . This e xample assu mes
that PCLATH is saved and restored by the Interrupt
Service Routine
:;called subroutine
:;page 1 (800h-FFFh)
:
RETURN;return to Call subroutine
;in page 0 (000h-7FFh)
DS30325A-page 26Advance Information 2000 Microchip Technology Inc.
PIC16F7X
2.5Indirect Addressing, INDF and FSR
Registers
The INDF register is not a physi cal register. Addressing
the INDF register will cause indirect addressing.
Indirect addressing is possible by using the INDF register. Any instruc tion using the INDF register actual ly
accesses the register pointed to by the File Sele ct Register, FSR. Reading the INDF register itself indirectly
(FSR = ’0’) will read 00h. Writing to the INDF register
indirectly result s in a no-operation (altho ugh status bits
may be affected ). An ef fective 9- bit add ress is obt ained
by concatenating the 8 -bit FSR regi ster and the IRP b it
(STATUS<7>), as sh own in Figure 2-6.
A simple program to clear RAM locations 20h-2Fh
using indirect addressing is shown in Example 2-2.
FIGURE 2-6:DIRECT/INDIRECT ADDRESSING
RP1:RP06
from opcode
0
EXAMPLE 2-2:INDIRECT ADDRESS ING
movlw0x20;initialize pointer
NEXTclrfINDF;clear INDF register
CONTINUE
movwfFSR;to RAM
incfFSR,F;inc pointer
btfssFSR,4;all done?
gotoNEXT;no clear next
:;yes continue
Indirect AddressingDirect Addressing
IRPFSR register
7
0
bank selectlocation select
00011011
00h
Data
(1)
Memory
7Fh
Bank 0Bank 1Bank 2Bank 3
Note 1: For register file map detail see Figure 2-3.
DS30325A-page 28Advance Information 2000 Microchip Technology Inc.
PIC16F7X
3.0I/O PORTS
Some pins for th ese I/O ports are multiplexed with an
alternate function for the peripheral features on the
device. In general, when a peripheral is enabled, that
pin may not be used as a general purpose I/O pin.
Additional inform atio n o n I/O ports ma y b e f oun d i n the
PICmicro™ Mid-Range Reference Manual,
(DS33023).
3.1PORTA and the TRISA Register
PORTA is a 6-bit wide, bi-directional port. The corresponding data direction register is TRISA. Setting a
TRISA bit (=1) will make t he co rrespon ding POR TA pin
an input (i.e., put the corresponding output driver in a
hi-impedance mode). Clearing a TRISA bit (=0) will
make the correspondin g POR TA pin an output (i.e., put
the contents of the output latch on the selected pin).
Reading the PORTA register reads the status of the
pins, whereas writing to i t will wri te to th e po rt latch. All
write operations are read-modify-write operations.
Therefore, a write to a port implies that the port pins are
read, the value is modified and then written to the port
data latch.
Pin RA4 is multiplexed with the Ti mer0 module clock
input to become the RA4/T0CKI pin. The RA4/T0CKI
pin is a Schmitt Trigger input and an open drain o utput.
All other PORTA pins have TTL input levels and full
CMOS output drivers.
Other PORTA pins are multiplexed with analog inputs
and analog V
selected by clearing/setting the control bits in the
ADCON1 register (A/D Control Register1).
Note:On a Power-on Reset, these pins are con-
The TRISA register controls the direction of the RA
pins, even when they are be ing us ed as ana lo g inputs.
The user must ensure the bits in the TRISA regi ster are
maintained set, when using them as analog inputs.
EXAMPLE 3-1:INITIALIZING PORTA
BCFSTATUS, RP0;
BCFSTATUS, RP1; Bank0
CLRFPORTA; Initialize PORTA by
BSFSTATUS, RP0; Select Bank 1
MOVLW0x06; Configure all pins
MOVWFADCON1; as digital inputs
MOVLW0xCF; Value used to
MOVWFTRISA; Set RA<3:0> as inputs
REF input. The operation of each pin is
figured as analog inputs and read as '0'.
; clearing output
; data latches
; initialize data
; direction
; RA<5:4> as outputs
; TRISA<7:6> are always
; read as ’0’.
FIGURE 3-1:BLOCK DIAGRAM OF
RA3:RA0 AND RA5 PINS
Data
Bus
WR
Port
Data Latch
WR
TRIS
TRIS Latch
RD PORT
To A/D Converter
Note 1: I/O pins have protection diodes to VDD and VSS.
CK
CK
QD
Q
QD
Q
RD TRIS
QD
Analog
Input
Mode
EN
VDD
P
N
V
I/O pin
SS
TTL
Input
Buffer
FIGURE 3-2:BLOCK DIAGRAM OF RA4/
T0CKI PIN
Data
Bus
WR
PORT
WR
TRIS
RD PORT
TMR0 clock input
Note 1: I/O pin has protection diodes to VSS only.
RA0/AN0bit0TTLInput/output or analog input.
RA1/AN1bit1TTLInput/output or analog input.
RA2/AN2bit2TTLInput/output or analog input.
RA3/AN3/V
RA4/T0CKIbit4STInput/output or external clock input for Timer0. Output is open drain type.
RA5/SS/AN4bit5TTLInput/output or slave select input for synchronous serial port or analog input.
Legend: TTL = TTL input, ST = Schmitt Trigge r input
TABLE 3-2:SUMMARY OF REGISTERS ASSOCIATED WITH PORTA
05hPORTA
85hTRISA——PORTA Data Direction Register
9FhADCON1—————PCFG2 PCFG1 PCFG0
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.
——RA5RA4RA3RA2RA1RA0
--0x 0000 --0u 0000
--11 1111 --11 1111
---- -000 ---- -000
DS30325A-page 30Advance Information 2000 Microchip Technology Inc.
Loading...
+ 138 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.