12.0 Special Features of the CPU............................................................................................................................125
13.0 Instruction Set Summary...................................................................................................................................141
14.0 Development Support.......................................................................................................................................149
Revision History ........................................................................................................................................................189
Index .......................................................................................................................................................................... 191
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.
New Customer Notification System
Register on our web site (www.microchip.com/cn) to receive the most current information on our products.
Errata
An errata sheet may exist for current devices, describing minor operational differences (from the data sheet) and recommended
workarounds. As device/documentation issues become known to us, w e will pub lish an errata sheet. The errata will specify the re vision 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 fo llowing:
• 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 liter-
ature number) you are using.
Corrections to this Data Sheet
We constantly strive to improve the quality of all our products and documentation. We have spent a great deal of time to ensure
that this document is correct. However , w e realize that we ma y have missed a few things. If you fi nd any inf ormation that is missing
or appears in error, please:
• Fill out and mail in the reader response form in the back of this data sheet.
• E-mail us at webmaster@microchip.com.
We appreciate your assistance in making this a better document.
1999 Microchip Technology Inc.
Advanced InformationDS41120A-page 3
PIC16C717/770/771
NOTES:
DS41120A-page 4Advanced Information
1999 Microchip Technology Inc.
PIC16C717/770/771
1.0DEVICE OVERVIEW
This document contains device-specific information.
Additional information may be found in the PICmicro
Mid-Range Reference Manual, (DS33023), which may
be obtained from your local Microchip Sales Representative or downloaded from the Microchip website. The
Reference Manual should be considered a complementary document to this data she et, and is h ighly recommended reading for a better understanding of the
device architecture and operation of the peripheral
modules.
FIGURE 1-1:PIC16C717 BLOCK DIAGRAM
13
Program Counter
8 Level Stack
(13-bit)
Program Memory
Read (PMR)
Direct Addr
8
Power-up
Timer
Oscillator
Start-up Tim er
Power-on
Reset
Watchdog
Timer
Brown-out
Reset
Program
Bus
Internal
4MHz, 37KHz
and ER mode
OSC1/CLKIN
OSC2/CLKOUT
EPROM
Program
Memory
2K x 14
14
Instruction reg
Instruction
Decode &
Control
Timing
Generation
DD, VSS
V
TM
7
3
8
There are three devices (PIC16C717, PIC16C770 and
PIC16C771) covered by this datasheet. The
PIC16C717 device comes in 18/20-pin packages and
the PIC16C770/771 devices come in 20-pin packages.
The following two fig u r es ar e device block di agr am s o f
the PIC16C717 and the PIC16C770/771.
There are two memory blocks in each of these
PICmicro
gram Memory and Data Memory) has its own bu s,
so that concurrent access can occur.
Additional inf ormation on de vice m emory may be f ound
in the PICmicro Mid-Range Reference Manual,
(DS33023).
2.1Program Memory Organization
The PIC16C717/770/771 devices have a 13-bit program counter capable of addressing an 8K x 14 program memory space. The PIC16C717 and the
PIC16C770 have 2K x 14 words of program memory.
The PIC16C771 has 4K x 14 words of program memory. Accessing a location above the physically implemented address will cause a wraparound.
The reset vector is at 0000h and the interrupt vector is
at 0004h.
FIGURE 2-1:PROGRAM MEMORY MAP
®
microcontrollers. Each block (Pro-
AND STACK OF THE
PIC16C717 AND PIC16C770
PC<12:0>
CALL, RETURN
RETFIE, RETLW
13
FIGURE 2-2:PROGRAM MEMORY MAP
AND STACK OF THE
PIC16C771
PC<12:0>
CALL, RETURN
RETFIE, RETLW
On-chip
Program
Memory
Stack Level 1
Stack Level 2
Stack Level 8
Reset Vector
Interrupt Vector
Page 0
Page 1
13
0000h
0004h
0005h
07FFh
0800h
0FFFh
1000h
On-chip
Program
Memory
Stack Level 1
Stack Level 2
Stack Level 8
Reset Vector
Interrupt Vector
Page 0
0000h
0004h
0005h
07FFh
3FFFh
3FFFh
2.2Data Memory Organization
The data memory is partitioned into multiple banks,
which contain the General Purpose Registers and the
Special Function Registers. Bits RP1 and RP0 are the
bank select bits.
Each bank extends up to 7Fh (128 bytes). The lower
locations of each bank are reserved for the Special
Function Registers . Abo v e the Spec ial Fun ction Re gisters are General Purpose Registers, implemented as
static RAM. All implemented banks contain special
function registers. Some frequently used special function registers from one bank are mirrored in another
bank for code reduction and quicker access.
2.2.1GENERAL PURPOSE REGISTER FILE
1999 Microchip Technology Inc.
The register file can be a ccessed ei ther direc tly, or indirectly, through the File Select Register FSR.
The special fu nction re gisters can b e classifi ed into two
sets; core (CPU) and periphe ral. Those registers asso-
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
given in Table 2-1.
ciated 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 that
peripheral feature section.
TABLE 2-1:PIC16C717/770/771 SPECIAL FUNCTION REGISTER SUMMARY
105h—Unimplemented——
106hPORTBPORTB Data Latch when written: PORTB pins when readxxxx xx00uuuu uu00
107h—Unimplemented——
108h—Unimplemented——
109h—Unimplemented——
Write Buffer for the upper 5 bits of the Program Counter
---0 0000---0 0000
Legend:x = unknown, u = unchanged, q = value depends on condition, - = unimplemented read as ’0’.
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 con-
tents 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: These registers can be addressed from any bank.
Value on all
other resets
(2)
1999 Microchip Technology Inc.
Advanced InformationDS41120A-page 15
PIC16C717/770/771
2.2.2.1STATUS REGISTER
The STATUS register, shown in Register 2-1, contains
the arithmetic status of th e ALU , the RE SET status an d
the bank select bits 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 write to these three bits is
disabled. The se bi ts ar e set or c leared accordi ng to the
device logic. Fur th er more, the TO
writable. Therefore, the result of an instruction with the
STATUS regi ster as destina tion may be different th an
intended.
and PD bits are not
For example, CLRF STATUS will clear the up p er- t h ree
bits and set th e Z bi t. T his l ea v es 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 b its from the STA TU S regist er . F or
other instructions not affecting any status bits, see the
"Instruction Set Summary."
Note 2: The C and DC bits oper ate as a borro w and
digit borrow
See the SUBLW and SUBWF instructions for
examples.
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: RP<1:0>: 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
bit 3:PD
bit 2:Z: Zero bit
bit 1:DC: Digit carry/borrow
bit 0:C: Carry/borrow
: Time-out bit
1 = After power-up, CLRWDT instruction, or SLEEP instruction
0 = A WDT time-out occurred
: Power-down bit
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
bit (ADDWF, ADDLW,SUBLW,SUBWF instructions) (for borrow the p ol arity is reversed)
1 = A carry-out from the 4th low order bit of the result occurr ed
0 = No carry-out from the 4th low order bit of the result
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
PDZDCCR = Readable bit
bit, respectively , in subtraction.
W = Writable bit
U = Unimplemented bit,
read as ‘0’
- n = Value at POR reset
Note:For borrow, the polarity is reversed. A subtraction is executed by adding the two’s complement of the sec-
ond operand. For rotate (RRF, RLF) instructions, this bit is loaded with either the high or low order bit of
the source register.
DS41120A-page 16Advanced Information
1999 Microchip Technology Inc.
PIC16C717/770/771
2.2.2.2OPTION_REG REGISTER
The OPTION_REG register is a readable and writable
register , which contai ns various c ontrol bits to c onfigure
the TMR0 prescaler/WDT postscaler (single assignable regist er kno wn also as the prescale r), the Ext ernal
INT Interrupt, TMR0 and the w eak pul l-ups on PO R TB .
the TMR0 register, assign the prescaler to
the Watchdog Timer.
W = Writable bit
U = Unimplemented bit,
read as ‘0’
- n = Value at POR reset
Note 1: Individual weak pull-up on RB pins can be enabled/disabled from the weak pull-up PORTB Register
(WPUB).
1999 Microchip Technology Inc.
Advanced InformationDS41120A-page 17
PIC16C717/770/771
2.2.2.3INTCON REGISTER
The INTCON Regi ster i s a rea dab le a nd w ritabl e regi s-
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 get set when an interrupt
condition occurs , regardless of the sta te 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.
REGISTER 2-3:INTERRUPT CONTROL REGISTER (INTCON: 0Bh, 8Bh, 10Bh, 18Bh)
R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-x
GIEPEIET0IEINTERBIET0IFINTFRBIFR = Readable bit
bit7bit0
bit 7:GIE: Global Interrupt Enable bit
1 = Enables all un-masked interrupts
0 = Disables all interrupts
bit 6:PEIE: Peripheral Interrupt Enable bit
1 = Enables all un-masked peripheral interrupts
0 = Disables all peripheral interrupts
bit 5:T0IE: TMR0 Overflow Interrupt Enable bit
1 = Enables the TMR0 interrupt
0 = Disables the TMR0 interrupt
bit 4:INTE: 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)
1 = Enables the RB port change interrupt
0 = Disables the RB port change interrupt
bit 2:T0IF: TMR0 Overflow Interrupt Flag bit
1 = TMR0 register has overflowed (must be cleared in software)
0 = TMR0 register did not overflow
bit 1:INTF: 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
(1)
1 = At least one of the RB<7:0> pins changed state (must be cleared in software)
0 = None of the RB<7:0> pins have changed state
W = Writable bit
U = Unimplemented bit,
read as ‘0’
- n = Value at POR reset
Note 1: Individual RB pin interrupt on change can be enabled/disabled from the Interrupt on Change PORTB register (IOCB).
DS41120A-page 18Advanced Information
1999 Microchip Technology Inc.
PIC16C717/770/771
2.2.2.4PIE1 REGISTER
This register contains the individual enable bits for the
bit 7:Unimplemented: Read as ’0’
bit 6:ADIE: A/D Converter Interrupt Enable bit
1 = Enables the A/D interrupt
0 = Disables the A/D interrupt
bit 5-4: Unimplemented: Read as ’0’
bit 3:SSPIE: Synchronous Serial Port Interrupt Enable bit
1 = Enables the SSP interrupt
0 = Disables the SSP interrupt
bit 2:CCP1 IE: 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
W = Writable bit
U = Unimplemented bit,
read as ‘0’
- n = Value at POR reset
1999 Microchip Technology Inc.
Advanced InformationDS41120A-page 19
PIC16C717/770/771
2.2.2.5PIR1 R EGISTER
This register contains the individual flag bits for the
peripheral interrupts.
Note:Interrupt flag bits get set when an interrupt
condition occurs , regardless of the sta te 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.
bit 7:Unimplemen ted: Read as ‘0’.
bit 6:ADIF : A/D Converter Interrupt Flag bit
1 = An A/D conversion completed
0 = The A/D conversion is not complete
bit 5-4: Unimplemented: Read as ‘0’.
bit 3:SSPIF: Synchronous Serial Port (SSP) Interrupt Flag
1 = The SSP interrupt condition has o ccurred, an d mu st be clea red in s oftw are bef o re returning from the
interrupt service routine. The conditions that will set this bit are:
SPI
A transmission/reception has taken place.
2
C Slave / Master
I
A transmission/reception has taken place.
I2C Master
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 (Multimaster system).
A stop condition occurred while the SSP module was idle (Multimaster system).
0 = No SSP interrupt condition has occurred.
bit 2:CCP1 IF: CCP1 Interrupt Flag bit
Capture Mode
1 = A TMR1 register capture occurred (must be cleared in software)
0 = No TMR1 register captur e occurred
ompare Mode
C
1 = A TMR1 register compare match occurred (must be cleared in software)
0 = No TMR1 register compare match occurred
WM Mode
P
Unused in this mode
bit 1:TMR2IF: TMR2 to PR2 Match Interrupt Flag bit
1 = TMR2 to PR2 match occur red (must be cleared in sof tware)
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
SSPIFCCP1IFTMR2IFTM R1IFR = Readable bit
W = Writable bit
U = Unimplemented bit,
read as ‘0’
- n = Value at POR reset
DS41120A-page 20Advanced Information
1999 Microchip Technology Inc.
PIC16C717/770/771
2.2.2.6PIE2 REGISTER
This register contains the individual enable bits for the
SSP bus collision and low voltage detect interrupts.
bit 7:LVDIE: Low-voltage Detect Interrupt Enable bit
bit 6-4: Unimplemented: Read as ’0’
bit 3:BCLI E: Bus Collision Interrupt Enable bit
bit 2-0: Unimplemented: Read as ’0’
———BCLIE ———R = Readable bit
1 = LVD Interrupt is enabled
0 = LVD Interrupt is disabled
1 = Bus Collision interrupt is enabled
0 = Bus Collision interrupt is disabled
W = Writable bit
U = Unimplemented bit,
read as ‘0’
- n = Value at POR reset
1999 Microchip Technology Inc.
Advanced InformationDS41120A-page 21
PIC16C717/770/771
2.2.2.7PIR2 R EGISTER
This register contains the SSP Bus Collision and low-
voltage detect interrupt flag bits.
.
Note:Interrupt flag bits get set when an interrupt
condition occurs , regardless of the sta te 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.
bit 7:LVDIF: Low-voltage Detect Interrupt Flag bit
bit 6-4: Unimplemented: Read as ’0’
bit 3:BCLI F: Bus Collision Interrupt Flag bit
bit 2-0: Unimplemented: Read as ’0’
———BCLIF ———R = Readable bit
1 = The supply voltage has fallen below the specified LVD voltage (must be cleared in software)
0 = The supply voltage is greater than the specified LVD voltage
1 = A bus collision has occurred while the SSP module configured in I
(must be cleared in software)
0 = No bus collision occurred
W = Writable bit
U = Unimplemented bit,
read as ‘0’
- n = Value at POR reset
2
C Master was transmitting
DS41120A-page 22Advanced Information
1999 Microchip Technology Inc.
PIC16C717/770/771
2.2.2.8PCON REGISTER
The Power Control (PCON) register contains a flag bit
to allow differentiation between a Power-on Reset
(POR) to an external MCLR Reset or WDT Reset.
Those devices with brown-out detection circuitry contain an additional bit to differentiate a Brown-out Reset
condition from a Power-on Reset condition.
The PCON register also contains the frequency select
bit of the INTRC or ER oscillator.
Note:BOR is unknown on Power-on Reset. It
must then be set by the user and checked
on subsequent resets to see if BOR is
clear , i ndi ca ting a brown-out has o ccurre d.
The BOR status bit is a don’t care and is
not necessarily predictab le if the brow n-out
circuit is disabled (by clearing the BODEN
bit in the Configuration word).
REGISTER 2-8:POWER CONTROL REGISTER (PCON: 8Eh)
U-0U-0U-0U-0R/W-1U-0R/W-qR/W-q
————OSCF—PORBORR = Readable bit
bit7bit0
bit 7-4,2:Unimplemented: Read as ’0’
bit 3:OSCF: Oscillator speed
INTRC Mode
1 = 4 MHz nominal
0 = 37 KHz nominal
ER Mode
1 = Oscillator frequency depends on the external resistor value on the OSC1 pin.
0 = 37 KHz nominal
All other modes
x = Ignored
bit 1:POR
bit 0:BO
: 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)
R: Brown-out Reset Status bit
1 = No Brown-ou t Reset occurr ed
0 = A Brown-out Reset occurred (must be set in softwar e after a Brown- out Reset occurs)
W = Writable bit
U = Unimplemented bit,
- n = Value at POR reset
read as ‘0’
1999 Microchip Technology Inc.
Advanced InformationDS41120A-page 23
PIC16C717/770/771
2.3PCL and PCLATH
The program counter (PC) specifies the address of the
instruction to fetch for execution. The PC is 13 bits
wide. The low byte is called the PCL register. This register is readable and writable. The high byte is called
the PCH register. This register contains the PC<12:8>
bits and is not dir ect ly read able or writable. All updates
to the PCH register occ ur through the PCLATH register .
2.3.1PROGRAM MEMORY PAGING
PIC16C717/770/771 devices are capable of address-
ing a continuous 8K word block of program memory.
The CALL and GOTO instructions prov ide 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>. Wh en doing a CALL or GOTO instruction, the user must ensure that the page select bits are
programmed so that the desired program memory
page is addressed. A return instruction pops a PC
address off the stack onto the PC register. Therefore,
manipulation of the PCLA TH<4:3> bits are not required
for the return instructions (which POPs the address
from the stack).
2.4Stack
The stack al lows a co mbinatio n of up to 8 pro gram ca lls
and interrupts to occur. The stack contains the return
address from this branch in program execution.
Mid-range devices have an 8-level deep x 13-bit wide
hardware stack. The stack space is not part of either
program or data space and the stack pointer is not
readable or writab le. The PC is PUSHed onto the stac k
when a CALL instruction is executed or an interrupt
causes a branch. The stack is POPed in the event of a
RETURN, RETLW or a RETFIE instruction execution.
PCLATH is not modified when the stack is PUSHed or
POPed.
After the stack has been PUSHed eight times, the ninth
push ov erwrites th e value that was stored from the first
push. The tenth push overwrites the sec ond pus h (an d
so on).
DS41120A-page 24Advanced Information
1999 Microchip Technology Inc.
PIC16C717/770/771
The INDF register is not a physical r e gis ter. Addressing INDF actually addresses the register whose
address is contained in the FSR register (FSR is a
pointer
). This is indirect ad dressi ng .
Reading INDF itself indirectly (FSR = 0) will produce
00h. Writing to the INDF register indirectly results in a
no-operation (although STATUS bits may be affected).
A simple program to clear RAM locations 20h-2Fh
using indirect addressing is shown in Example 2-1.
FIGURE 2-4:DIRECT/INDIRECT ADDRESSING
RP1:RP06
bank selectlocation select
from opcode
0
00011011
00h
80h
EXAMPLE 2-1:HOW TO CLEAR RAM
USING INDIRECT
ADDRESSING
movlw 0x20 ;initialize pointer
movwf FSR ; to RAM
NEXT clrf INDF ;clear INDF register
incf FSR ;inc pointer
btfss FSR,4 ;all done?
goto NEXT ;NO, clear next
CONTINUE
: ;YES, continue
An effective 9-bit add res s is obtained by c on ca tena tin g
the 8-bit FSR register an d the IRP b it (STATUS<7>), as
shown in Figure 2-4.
Indirect AddressingDirect Addressing
7
location select
100h
IRPFSR register
bank select
180h
0
Data
(1)
Memory
7Fh
Bank 0Bank 1Bank 2Bank 3
Note 1: For register file map detail see Figure 2-3.
FFh
17Fh
1FFh
1999 Microchip Technology Inc.
Advanced InformationDS41120A-page 25
PIC16C717/770/771
NOTES:
DS41120A-page 26Advanced Information
1999 Microchip Technology Inc.
PIC16C717/770/771
3.0I/O PORTS
Some pins for these 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 information on I/O ports ma y be found i n th e
PICmicro™ Mid-Range Reference Manual,
(DS33023).
3.1I/O Port Analog/Digital Mode
The PIC16C717/770/771 have two I/O ports: PORTA
and PORTB . Some of thes e port pins are mix ed-si gnal
(can be digital or analog). When an analog signal is
present on a pin, the pin must be co nfigured as an analog input to prev e nt unneces sary current dr a w from the
power supply. The Analog Select Register (ANSEL)
allows the user to individually select the digital/analog
mode on these pins. When the analog mode is active,
the port pin will always read 0.
Note 1: On a P o wer-on Reset , the ANSEL reg ister
configures these mixed-signal pins as
analog mode.
2: If a pin is configured as analog mode, the
pin will always read '0', even if the digital
output is active.
REGISTER 3-1:ANALOG SELECT REGISTER (ANSEL: 9Dh)
R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1
ANS5ANS4ANS3ANS2ANS1ANS0R = Readable bit
bit7bit0
bit 7-6: Reserved: Do not use
bit 5-0: ANS<5:0>: Analog Select between analog or digital function on pins AN<5:0>, respectively.
0 = Digital I/O. Pin is assigned to port or special function.
1 = Analog Input. Pin is assigned as analog input.
W = Writable bit
U = Unimplemented bit, read as
‘0’
-n = Value at POR reset
Note:Setting a pin to an analog input disables digital inputs and any pull-up that may be present. The corre-
sponding TRIS bit should be set to input mode when using pins as analog inputs.
3.2PORTA and the TRISA Register
PORTA is a 8-bit wide bi-directional port. The corresponding data direction register is TRISA. Setting a
TRISA bit (=1) will m ake the correspo ndi ng PO RTA pin
an input, i.e., put the corresponding output driver in a
hi-impedance mode. Clearing a TRISA bit (=0) will
make the corre sp ond ing PORTA pin an output, i.e., p ut
the contents of the output latch on the selected pin.
Reading the PORTA register reads the status of the
pins, whereas writing to it will write to th e p ort latch. All
write operations are read-modify-write operations.
Therefore , a write to a port implies that the port pins are
read, this val ue is modifie d, and then written to th e port
data latch.
Pins RA<3:0> are multiplexed with analog functions,
such as analog inputs to the A/D converter, analog
VREF inputs, and the on-board b andgap ref erence outputs. When the analog peripherals are using any of
these pins as analog input/output, the ANSEL register
must have the proper value to individually select the
analog mode of the corresponding pins.
Note:Upon reset, the ANSEL register configures
the RA<3:0> pins as analog inputs. All
RA<3:0> pins will read as ’0’.
Pin RA4 is multiplexed with the Timer0 module clock
input to become the RA4/T0CKI pin. The RA4/T0CKI
pin is a Schmitt Trigger input and an open d ra in output.
Pin RA5 is multiplexed with the device reset (MCLR
and programming input (V
/VPP input only pin has a Schmitt Trigger input
MCLR
buffer . All other RA port pins hav e Schmitt Trigger input
buffers and full CMOS output buffers.
Pins RA6 and RA7 are multiplexed with the oscillator
input and output functions.
The TRISA register controls the direction of the RA
pins, even when they are being used as analog inputs.
The user must ensure the bi ts in the TRISA registe r are
maintained set when using them as analog inputs.
PP) functions. The RA5/
)
1999 Microchip Technology Inc.
Advanced InformationDS41120A-page 27
PIC16C717/770/771
EXAMPLE 3-1:INITIALIZING PORTA
BCF STATUS, RP0 ; Select Bank 0
CLRF PORTA ; Initialize PORTA by
; clearing output
; data latches
BSF STATUS, RP0 ; Select Bank 1
MOVLW 0Fh ; Value used to
; initialize data
; direction
MOVWF TRISA ; Set RA<3:0> as inputs
; RA<7:4> as outputs. RA<7:6>availability depends on oscillator selection.
MOVLW 03 ; Set RA<1:0> as analog inputs, RA<7:2> are digital I/O
MOVWF ANSEL
BCF STATUS, RP0 ; Return to Bank 0
FIGURE 3-1:BLOCK DIAGRAM OF RA0/AN0, RA1/AN1/LVDIN
Data
Bus
WR
PORT
WR
TRIS
RD
TRIS
WR
ANSEL
Data Latch
CK
TRIS Mode
CK
Analog Select
CK
Q
Q
Q
QD
VDD
P
QD
QD
N
SS
V
Schmitt
Trigger
VDD
VSS
QD
EN
RD
PORT
To A/D Converter input or LVD Module input
DS41120A-page 28Advanced Information
1999 Microchip Technology Inc.
PIC16C717/770/771
FIGURE 3-2:BLOCK DIAGRAM OF RA2/AN2/VREF-/VRL AND RA3/AN3/VREF+/VRH
Data
Bus
WR
PORT
WR
TRIS
RD
TRIS
WR
ANSEL
RD
PORT
Data Latch
CK
TRIS Mode
CK
Analog Select
CK
Q
Q
Q
QD
VDD
P
QD
QD
QD
EN
N
SS
V
Schmitt
Trigger
VDD
VSS
To A/D Converter input
and Vref+, Vref- inputs
1999 Microchip Technology Inc.
VRH, VRL outputs
(From Vref-LVD-BO R Module)
VRH, VRL output enable
Sense input for
VRH, VRL amplifier
Advanced InformationDS41120A-page 29
PIC16C717/770/771
FIGURE 3-3:BLOCK DIAGRAM OF RA4/T0CKI
Data
Bus
WR
Port
WR
TRIS
RD
TRIS
Data Latch
CK
TRIS Latch
CK
QD
Q
QD
Q
QD
N
SS
V
VSS
Schmitt Trigger
Input Buffer
RD
PORT
TMR0 clock input
EN
DS41120A-page 30Advanced Information
1999 Microchip Technology Inc.
Loading...
+ 170 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.