Operating Frequency6 MHz or 24 MHz6 MHz or 24 MHz
Resets (and Delays)POR, BOR (PWRT, OST)POR, BOR (PWRT, OST)
Program Memory (14-bit words)8K8K
Data Memory (bytes)256256
Dual Port Ram6464
Interrupt Sources1112
I/O Ports22 (Ports A, B, C)33 (Ports A, B, C, D, E)
Timers33
Capture/Compare/PWM modules22
Analog-to-Digital Converter Module5 channel x 8 bit8 channel x 8 bit
Parallel Slave Port—Yes
Serial CommunicationUSB, USART/SCIUSB, USART/SCI
Brown Out Detect ResetYesYes
10.0 Universal Serial Bus............................................................................................................................................57
13.0 Special Features of the CPU..............................................................................................................................95
14.0 Instruction Set Summary...................................................................................................................................109
15.0 Development Support.......................................................................................................................................117
Index ..........................................................................................................................................................................151
Product Identification System .....................................................................................................................................157
To Our V alued Customers
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 ver sion number. e.g., DS30000A is version A of document DS30000.
New Customer Notification System
Register on our web site (www.microchip.com/ cn) to rece ive 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 deter mine 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 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 y ou find 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 InformationDS41124A-page 3
PIC16C745/765
NOTES:
DS41124A-page 4Advanced Information
1999 Microchip Technology Inc.
PIC16C745/765
1.0GENERAL DESCRIPTION
The PIC16C745/765 devices are lo w-cost, high-perf or-
mance, CMOS, fully-static, 8-bit microcontrollers in the
PIC16CXX mid-range family.
®
All PICmicro
RISC architecture. The PIC16CXX micro controller family has enhanced core features, eight-level deep stack
and multiple internal and external interrupt sources.
The separate instruction and data buses of the Harvard
architecture allow a 14-bit wide instruction word with
the separate 8-bit wide data. The two stage instruction
pipeline allows all instructions to execute in a single
cycle, except for program branches, which require two
cycles. A total of 35 instructions (reduced instruction
set) are avai lable. Ad ditionally, a large register set giv es
some of the architectu ral inno v ations us ed to achie v e a
very high performance.
The PIC16C745 device has 22 I/O pins. The
PIC16C765 device has 33 I/O pins. Each device has
256 bytes of RAM. In addition, several peripheral features are available including: three timer/counters, two
Capture/Compare/PWM modules and two serial ports.
The Universal Serial Bus (USB 1.1) peripheral provides bus communications. The Universal Synchronous Asynchronous Receiver Transmitter (USART) is
also known as the Serial Communications Interface or
SCI. Also, a 5-channel high-speed 8-bit A/D is provided on the PIC16C745, while the PIC16C765 offers
8 channels. The 8-bit resolution is ideally suited for
applications requiring a low-cost analog interface,
(e.g., thermostat control, pressure sensing, etc).
The PIC16C745/765 devices have special features to
reduce external components, thus reducing cost,
enhancing system reliability and reducing power consumption. There are 4 o scillato r options , of whic h EC is
for the external regulated clock source, E4 is for the
external regulated clock source with PLL, HS is for the
high speed crystals/resonators and H4 is for high
speed crystals/resontators with PLL. The SLEEP
(power-down) feature provides a power-saving mode.
The user can wake up the chip from SLEEP through
several external and internal interrupts and resets.
microcontrollers employ an advanced
A highly reliable Watchdog Timer (WDT), with a dedicated on-chip RC oscill ator, pr ovides protec tion against
software lock-up, and also provides one way of waking
the device from SLEEP.
A UV erasable CERDIP packaged version is ideal for
code development, while the cost-effective One-TimeProgrammable (OTP) version is suitable for production
in any volume.
The PIC16C745/765 devices fit nicely in many applications ranging from security and remote sensors to appliance controls and automotives. The EPROM
technology makes customization of application programs (data loggers, industrial controls, UPS) extremely
fast and convenient. The small footprint packages make
this microcontroller series perfect for all applications
with space limitations. Low cost, low power, high performance, ease of use and I/O flexibility make the
PIC16C745/765 devices very versatile, even in areas
where no microcontroller use has been considered
before (e.g., timer functions, serial communication, capture and compare, PWM functions and coprocessor
applications).
1.1Family and Upward Compatibility
Users familiar with the PIC16C5X microcontroller family will realize that this is an enhanced version of the
PIC16C5X architecture. Code written for the
PIC16C5X can be easil y p orted to the PIC16 CXX family of devices.
1.2Development Support
PICmicro® devices are supported by the complete line
of Microchip Development tools.
Please refer to Section 15.0 for more details about
Microchip’s development tools.
1999 Microchip Technology Inc.
Advanced InformationDS41124A-page 5
PIC16C745/765
NOTES:
DS41124A-page 6Advanced Information
1999 Microchip Technology Inc.
PIC16C745/765
2.0PIC16C745/765 DEVICE
VARIETIES
A variety of frequency ranges and packaging options
are avai lable . Dependin g on applicati on and production
requirements, th e proper de vice option ca n be selected
using the information in the PIC16C745/765 Product
Identification System section at the end of this data
sheet. When placing orders, please use that page of
the data sheet to specify the correct part number.
2.1UV Erasable Devices
The UV erasable version, offered in windowed CERDIP
packages (600 mil), is optimal for prototype development and pilot programs. This version can be erased
and reprogrammed to any of the supported oscillator
modes.
Microchip’s PICSTART
programmers both support programming of the
PIC16C745/765.
2.2One-Time-Programmable (OTP)
Devices
The availability of OTP devices is especially useful for
customers who need the flexibility for frequent code
updates and small volume applications.
The OTP devices, packaged in plastic packages, permit the user to program them once. In addition to the
program memory, the configuration bits must also be
programmed.
Plus and PROMATEII
2.3Quick-Turnaround-Production (QTP)
Devices
Microchip offers a QTP Programming Service for factory production orders. This service is made available
for users who choose not to program a medium to high
quantity of units and whose code patterns have stabilized. The devices are identical to the OTP devices but
with all EPROM locations and configuration options
already programmed by the factory. Certain code and
prototype verification procedures apply before production shipments are available. Please contact your local
Microchip Technology sales office for more details.
2.4Serialized Quick-Turnaround
Production (SQTPSM) Devices
Microchip offers a unique programming service where
a few user-defined locations in each device are programmed with different serial numbers. The serial numbers may be rando m, ps eudo-random or sequential.
Serial programming allows each device to have a
unique number, which can serve as an entry-code,
password or ID number.
1999 Microchip Technology Inc.
Advanced InformationDS41124A-page 7
PIC16C745/765
NOTES:
DS41124A-page 8Advanced Information
1999 Microchip Technology Inc.
PIC16C745/765
3.0ARCHITECTURAL OVERVIEW
The high performance of the PIC16CXX family can be
attributed to a number of architectural features commonly found in RISC microprocessor s. To begi n with,
the PIC16CXX uses a Har vard architecture, in which
program and data are accessed from separate memories using separate buses. This improves bandwidth
over tr aditional von Neu mann archi tecture in wh ich program and data are fetched from the same memory
using the same bus. Separating program and data
buses further allows instructions to be sized differently
than the 8-bit wide data word. Instruction opcodes are
14-bits wid e maki ng it po ssible to have all singl e word
instructions. A 14-bit wide program memory access
bus fet ches a 14 -bit ins tructio n in a sing le cycle . A twostage pipeline overlaps fetch and execution of instructions (Example 3-1). Consequently, most instructions
execute in a single cycle (166.6667 ns @ 24 MHz)
except for program branches.
Memory
Device
PIC16C7458K2562885
PIC16C7658K2564088
Program
x14
Data
x8
Pins
The PIC16CXX can directly or indirectly address its
register files or data memory. Al l s pec ia l function registers, including the program counter, are mapped in the
data memory . The PIC16CXX has an orthogonal (symmetrical) ins tr ucti on s et th at m akes it po ssible to c arr y
out any operatio n on any reg ister usin g any add ressin g
mode. This symmetrical nature and lack of ‘special
optimal situations’ make programming with the
PIC16CXX simple yet e fficient. In addition, the learning
curve is reduced signifi c antly.
A/D
Resolution
A/D
Channels
PIC16CXX devices contain an 8-bit ALU and working
register. The ALU is a general purpose arithmetic unit.
It performs arithmetic and Boolean functions between
the data in the working register and any register file.
The ALU is 8-bits wide and capable of addition, subtraction, shift and logical operations. Unless otherwise
mentioned, arithmetic operations are two's complement in nature. In two-operand instructions, typically
one operand is the working register (W register). The
other operand is a file register or an immediate constant. In single operand instructions, the operand is
either the W register or a file register.
The W register is an 8-bit working register use d for ALU
operations. It is not an addressable register.
Depending on the instruction executed, the ALU may
affect the v alu es of th e Ca rry (C), Digit Carry (DC), an d
Zero (Z) bits in th e STATUS register. The C and DC bits
operate as a borrow
bit and a digit borrow out bit,
respectively, in subtraction. See the SUBLW and SUBWF
instructions for examples.
RB1RB1TTLCMOSBi-directional I/O
RB2RB2TTLCMOSBi-directional I/O
RB3RB3TTLCMOSBi-directional I/O
RB4RB4TTLCMOSBi-directional I/O with Interrupt on Change
RB5RB5TTLCMOSBi-directional I/O with Interrupt on Change
RDTTL—Parallel Sl ave Port control input
AN5AN—A/D Input
RE1STCMOSBi-directional I/O
(2)
(2)
WRTTL—Parallel Slave Port control input
AN6AN—A/D Input
RE2STCMOSBi-directional I/O
(2)
(2)
CSTTL—Parallel Slave Port data input
AN7AN—A/D Input
(2)
(2)
(2)
(2)
(2)
(2)
(2)
(2)
(2)
(2)
(2)
(2)
VDDVDDPower—Power
SSVSSPower—Ground
V
DDAVDDPower—Analog Power
AV
SSAVSSPower—Analog Ground
AV
Legend:OD = open drain, ST = Schmitt Trigger
Note 1: Weak pull-ups. PORT B pull-ups are byte wide programmable.
2: PIC16C765 only.
DS41124A-page 12Advanced Information
1999 Microchip Technology Inc.
PIC16C745/765
3.1Clocking Scheme/Instruction Cycle
The clock input feeds an on-chip PLL. The clock output
from the PLL (F
INT) is internally divided by four to gen-
erate four non-overlapping quadrature clocks namely,
Q1, Q2, Q3 and Q4. Internally, the program counter
(PC) is incremented e very Q1, the instruction is f etched
from the program memory and latched into the instruction register in Q4. The ins truction is decod ed and executed during the following Q1 through Q4. The clocks
and instruction execution flow is shown in Figure 3-2.
FIGURE 3-2:CLOCK/INSTRUCTION CYCLE
Q2Q3Q4
OSC2/CLKOUT
(EC mode)
FINT
Q1
Q2
Q3
Q4
PC
Q1
PCPC+1PC+2
Fetch INST (PC)
Execute INST (PC-1)Fetch INST (PC+1)
Q1
3.2Instruction Flow/Pipelining
An “Instruction Cycle” consists of four Q cycles (Q1,
Q2, Q3 and Q4). The instruction fetch and execute are
pipelined such that fetch takes one instruction cycle,
while decode and execute takes another instruction
cycle. However, due to the pipelining, each instruction
effectively executes in one cycle. If an instruction
causes the program counter to change (e.g., GOTO),
then two cycles are required t o complete t he instruction
(Example 3-1).
A fetch cycle begins with the program counter (PC)
incrementing in Q1.
In the ex ecu tion cycle , t he f etched i nstruction i s latche d
into the “Instruction Register" (IR) in cycle Q1. This
instruction is then decoded and executed during the
Q2, Q3 and Q4 cycles . Data mem ory is read during Q2
(operand read) and written during Q4 (destination
write).
Q2Q3Q4
Execute INST (PC)Fetch INST (PC+2)
Q2Q3Q4
Q1
Execute INST (PC+1)
Internal
phase
clock
EXAMPLE 3-1:INSTRUCTION PIPELINE FLOW
TCY0TCY1TCY2TCY3TCY4TCY5
1. MOVLW 55h
2. MOVWF PORTB
3. CALL SUB_1
4. BSF PORTA, BIT3 (Forced NOP)
5. Instruction @ address SUB_1
Note:All instructions are single cycle, except for any program branches. These take two cycles, since the fetch
instruction is “flushed” from the pipeline, while the new instruction is being fetched and then executed.
1999 Microchip Technology Inc.
Fetch 1Execute 1
Fetch 2Execute 2
Fetch 3Execute 3
Fetch 4Flush
Fetch SUB_1 Execute SUB_1
Advanced InformationDS41124A-page 13
PIC16C745/765
NOTES:
DS41124A-page 14Advanced Information
1999 Microchip Technology Inc.
PIC16C745/765
4.0MEMORY ORGANIZATION
4.1Program Memory Organization
The PIC16C745/765 has a 13-bit program counter
capable of addressing an 8K x 14 program memory
space. All devices covered by this datasheet have 8K x
14 bits of program memory. The address range is
0000h - 1FFFh for all devices.
The reset vector is at 0000h and the interrupt vector is
at 0004h.
FIGURE 4-1:PIC16C745/765 PROGRAM
MEMORY MAP AND STACK
PC<12:0>
CALL, RETURN
RETFIE, RETLW
Stack Level 1
Stack Level 2
Stack Level 8
13
4.2Data Memory Organization
The data memory is partitioned into multiple banks
which contain the General Purpose Registers (GPR)
and the Special Function Registers (SFR). 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 SFRs.
Above the SFRs are GPRs, implemented as static
RAM.
All implemented ban ks co ntain SF Rs. Some “h igh us e”
SFRs from one bank may be mirrored in another bank
for code reduction and quicker access.
4.2.1GENERAL PURPOSE REGISTER FILE
The register file can b e access ed eithe r dire ctly o r indi-
rectly through the File Select Register (FSR)
(Section 4.5).
PORTE
PCLATH0AhPCLATH8AhPCLATH10AhPCLATH18Ah
INTCON0BhINTCON8BhINTCON10BhINTCON18B h
PIR10ChPIE18Ch
PIR20DhPIE28Dh
TMR1L0EhPCON8Eh
TMR1H0Fh
T1CON10h
TMR211h
T2CON12hPR292h
CCPR1L15h
CCPR1H16h
CCP1CON17h
RCSTA18hTXSTA98h
TXREG19hSPBRG99h
RCREG1Ah
CCPR2L1B h
CCPR2H1Ch9Ch11Ch
CCP2CON1Dh9Dh11Dh
ADRESH1Eh9Eh11Eh
ADCON01FhADCON19Fh11Fh
General
Purpose
Register
96 Bytes
Address
08h
09h
13h93h113hUEIE193h
14h94h114hUSTAT194h
20hGeneral
Bank 1File
(2)
TRISD
(2)
TRISE
Purpose
Register
80 Bytes
Address
88h108h188h
89h109h189h
8Fh10Fh18Fh
90h110hUIR190h
91h111hUIE191h
95h115hUCTRL195h
96h116hUADDR196h
97h117h
9Ah11AhU EP 219Ah
9Bh11Bh
A0hGeneral
Bank 2File
Address
105h185h
107h187h
10Ch18Ch
10Dh18Dh
10Eh18Eh
112hUEIR192h
118hUEP0198h
119hUEP1199h
120hUSB Dual Port
Purpose
Register
80 Bytes
Bank 3File
USWSTAT
Memory
64 Bytes
(1)
Address
197h
(1)
19Bh
(1)
19Ch
(1)
19Dh
(1)
19Eh
(1)
19Fh
1A0h
EFh16Fh1EFh
accesses
7FhFFh17Fh1FFh
Unimplemented data memory locations, read as ‘0’.
*Not a physical register.
Note 1: Reserved registers may contain USB state information.
2: Parallel slave ports (PORTD and PORTE) not implemented on PIC16C745; always maintain these bits clear.
DS41124A-page 16Advanced Information
70h-7Fh
F0haccesses
70h-7Fh
170haccesses
1DFh
1E0h
1F0h
70h-7Fh
1999 Microchip Technology Inc.
PIC16C745/765
4.2.2SPECIAL FUNCTION REGISTERS
The Special Function Registers can be classified into
two sets (core and periphe ral). Those registers associ-
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.
ated with the “core” func tions are described i n this section, and those related to the operation of the peripheral
features are described in the section of that peripheral
feature.
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 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: These registers can be addressed from either bank.
4: The Parallel Slav e Port (PORTD and PORTE) is not implemented on the PIC16C745, always maintain these bits clear.
Value on all
other resets
(2)
1999 Microchip Technology Inc.
Advanced InformationDS41124A-page 17
PIC16C745/765
TABLE 4-1: SPECIAL FUNCTION REGISTER SUMMARY (CONTINUED)
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 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: These registers can be addressed from either bank.
4: The Parallel Slav e Port (PORTD and PORTE) is not implemented on the PIC16C745, always maintain these bits clear.
Value on all
other resets
(2)
DS41124A-page 18Advanced Information
1999 Microchip Technology Inc.
PIC16C745/765
TABLE 4-1: SPECIAL FUNCTION REGISTER SUMMARY (CONTINUED)
106hPORTBPORTB Data Latch when written: PORTB pins when readxxxx xxxx uuuu uuuu
107h—Unimplemented——
108h—Unimplemented——
109h—Unimplemented——
10Ah
10Bh
10Ch-
11Fh
INDF
(3)
PCL
ST ATUS
(3)
FSR
PCLATH
INTCON
Addressing this location uses contents of FSR to address data memory (not a physical register)0000 0000 0000 0000
Program Counter's (PC) Least Significant Byte0000 0000 0000 0000
(3)
IRPRP1RP0TOPDZDCC0001 1xxx 000q quuu
Indirect data memory address pointerxxxx xxxx uuuu uuuu
(1,3)
———Write Buffer for the upper 5 bits of the Program Counter---0 0000 ---0 0000
(3)
GIE PEIET0IEINTERBIET0IFINTF RBIF0000 000x 0000 000u
—Unimplemented——
Value on:
POR,
BOR
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 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: These registers can be addressed from either bank.
4: The Parallel Slav e Port (PORTD and PORTE) is not implemented on the PIC16C745, always maintain these bits clear.
Value on all
other resets
(2)
1999 Microchip Technology Inc.
Advanced InformationDS41124A-page 19
PIC16C745/765
TABLE 4-1: SPECIAL FUNCTION REGISTER SUMMARY (CONTINUED)
Write Buffer for the upper 5 bits of the Program Counter
Value on:
POR,
BOR
---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 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: These registers can be addressed from either bank.
4: The Parallel Slav e Port (PORTD and PORTE) is not implemented on the PIC16C745, always maintain these bits clear.
Legend:x = unknown, u = unchanged, q = value depends on condition, - = unimplemented read as ’0’.
Shaded locations are unimplemented, read as ‘0’.
Value on all
other resets
(2)
1999 Microchip Technology Inc.
Advanced InformationDS41124A-page 21
PIC16C745/765
4.2.2.1STATUS REGISTER
The STATUS register, shown in Register 4-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
and PD bits are not
writable. Therefore, the result of an instruction with the
STATUS register as desti nation may be different th an
intended.
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 that only BCF, BSF, SWAPF and
MOVWF instruct io ns be used to alter t he S TATUS register. Thes e in stru cti on s do not affect the Z, C or DC bits
in the STATUS register. For other instructions which do
not affect status bits, see the "Instruction Set Summary."
Note 1: The C and DC bits operate as borrow and
digit borrow
tion. See the SUBLW and SUBWF instruc-
tions 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)
00 = Bank 0 (00h - 7Fh)
01 = Bank 1 (80h - FFh)
10 = Bank 2 (100h - 17Fh)
11 = Bank 3 (180h - 1FFh)
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
(1)
C
(1)
bits, respectively, in subtrac-
R = Readable bit
W = Writable bit
U = Unimplemented bit,
read as ‘0’
- n = Value at POR reset
(1)
Note1: For borrow
the polarity is reversed. A subtraction is executed by adding the two’s complement of the second operand. F or rotate (RRF, RLF) instructions, this bit is loade d with eithe r the high or lo w ord er bit of the
source register.
DS41124A-page 22Advanced Information
1999 Microchip Technology Inc.
PIC16C745/765
4.2.2.2OPTION REGISTER
Note:To achieve a 1:1 prescaler as signmen t for
The OPTION_REG register is a readable and writable
register , which contai ns various c ontrol bits to c onfigure
the TMR0/WDT prescaler, the external INT Interrupt,
TMR0 and the weak pull-ups on PORTB.
the TMR0 register, assign the prescaler to
the watchdog timer.
W = Writable bit
U = Unimplemented bit,
read as ‘0’
-n = Value at POR reset
1999 Microchip Technology Inc.
Advanced InformationDS41124A-page 23
PIC16C745/765
4.2.2.3INTCON REGISTER
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 when an interrupt
condition occurs , regardless of the state 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
interrup t
.
REGISTER 4-3: INTERRUPT CONTROL REGISTER (INTCON: 10Bh, 18Bh)
R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-x
GIEPEIET0IEINTERBIET0IFINTFRBIF
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 = 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 = At least one of the RB<7:4> pins changed state (must be cleared in software)
0 = None of the RB<7:4> pins have changed state
R = Readable bit
W = Writable bit
U = Unimplemented bit,
-n = Value at POR reset
read as ‘0’
DS41124A-page 24Advanced Information
1999 Microchip Technology Inc.
PIC16C745/765
4.2.2.4PIE1 REGISTER
This register contains the individual enable bits for the
bit 3:USBIE: Universal Serial Bus Interrupt Enable bit
bit 2:CCP1IE: CCP1 Interrupt Enable bit
bit 1:TMR2IE: TMR2 to PR2 Match Interrupt Enable bit
bit 0:TMR1IE: TMR1 Overflow Interrupt Enable bit
ADIERCIETXIEUSBIECCP1IETMR2IETMR1IE
(1)
: Parallel Slave Port Read/Write Interrupt Enable bit
1 = Enables the PSP read/write interrupt
0 = Disables the PSP read/write interrupt
1 = Enables the A/D interrupt
0 = Disables the A/D interrupt
1 = Enables the USART receive interrupt
0 = Disables the USART receive interrupt
1 = Enables the USART transmit interrupt
0 = Disables the USART transmit interrupt
1 = Enables the USB interrupt
0 = Disables the USB interrupt
1 = Enables the CCP1 interrupt
0 = Disables the CCP1 interrupt
1 = Enables the TMR2 to PR2 match interrupt
0 = Disables the TMR2 to PR2 match interrupt
1 = Enables the TMR1 overflow interrupt
0 = Disables the TMR1 overflow interrupt
R = Readable bit
W = Writable bit
U = Unimplemented bit,
-n = Value at POR reset
read as ‘0’
Note 1: PIC16C745 device does not have a parallel slave port implemented; always maintain this bit clear.
1999 Microchip Technology Inc.
Advanced InformationDS41124A-page 25
PIC16C745/765
4.2.2.5PIR1 REGISTER
This register contains the individual flag bits for the
peripheral interrupts.
Note:Interrupt flag bits are set when an interrupt
condition occurs , regardless of the state 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.
1 = A read or a write operation has taken pl ace (must be cleared in software)
0 = No read or write has occurred
bit 6:ADIF: A/D Converter Interrupt Flag bit
1 = An A/D conversion completed (must be cleared in software)
0 = The A/D conversion is not complet e
bit 5:RCIF: USART Receive Interrupt Flag bit
1 = The USART receive buffer is full (clear by reading RCREG)
0 = The USART receive buffer is empty
bit 4:TXIF: USART Transmit Interrupt Flag bit
1 = The USART transmit buffer is empty (clear by writing to TXREG)
0 = The USART transmit buffer is full
bit 3:USBIF: Universal Serial Bus (USB) Interrupt Flag
1 = A USB interrupt condition has oc cu rred. The specific cause can be found by examining the contents
of the UIR and UIE registers.
0 = No USB interrupt conditions that are enabled have 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
RCIFTXIFUSBIFCCP1IFTMR 2IFTMR1IF
(1)
: Parallel Slave Port Read/Write Interrupt Flag bit
R = Readable bit
W = Writable bit
U = Unimplemented bit,
read as ‘0’
-n = Value at POR reset
Note 1: PIC16C745 device does not hav e a par al lel sla v e port implement ed. This bit locati on is res erved on thi s
device. Always maintain this bit clear.
DS41124A-page 26Advanced Information
1999 Microchip Technology Inc.
PIC16C745/765
4.2.2.6PIE2 REGISTER
This register contains the individual enable bit for the
bit 7-1: Unimplemented: Read as ’0’
bit 0:CCP2IE: CCP2 Interrupt Enable bit
1 = Enables the CCP2 interrupt
0 = Disables the CCP2 interrupt
4.2.2.7PIR2 REGISTER
This register contains the CCP2 interrupt flag bit. .
R = Readable bit
W = Writable bit
U = Unimplemented bit,
-n = Value at POR reset
read as ‘0’
Note:Interrupt flag bits are set when an in terrupt
condition occur s , rega rdle ss of the state 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-1: Unimplemented: Read as ’0’
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
R = Readable bit
W = Writable bit
U = Unimplemented bit,
read as ‘0’
-n = Value at POR reset
PWM Mode
Unused
1999 Microchip Technology Inc.
Advanced InformationDS41124A-page 27
PIC16C745/765
4.2.2.8PCON REGISTER
The Po wer Control (PCO N) register contains flag bits to
allow diff erentia tion be tween a Power-on Reset (POR),
a Brown-out Reset (BOR), a Watch-dog Reset (WDT)
and an external MCLR
Reset.
Note:BOR is unknown on POR. It must be set by
the user and checked on subsequent
resets to se e if BOR
brown-out ha s occurred. The BO R
bit is a “don't care” and is not predictable if
the brown-out ci rcuit i s disabled (by clea ring the BODEN bit in the configuration
word).
REGISTER 4-8: POWER CONTROL REGISTER REGSTER (PCON: 8Eh)
U-0U-0U-0U-0U-0U-0R/W-0R/W-q
——————
bit7bit0
bit 7-2: Unimplemented: Read as ’0’
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-out reset occurred
0 = A brown-out reset occurred (must be set in software after a brown-out reset occurs)
POR
BOR
is clear, indicating a
status
R = Readable bit
W = Writable bit
U = Unimplemented bit,
read as ‘0’
-n = Value at POR reset
DS41124A-page 28Advanced Information
1999 Microchip Technology Inc.
PIC16C745/765
4.3PCL and PCLATH
The program coun ter (PC) is 13-bits wide . The low b yte
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
PCLATH register. On any reset, the upper bits o f the PC
will be cleared. Figure4-3 shows the two situations for
the loading of the PC. The upper example in the figure
shows how the PC is loaded on a write to PCL
(PCLATH<4:0> → PCH). The lower example in the fig-
ure shows ho w the PC is loaded during a CALL or GOTO
instruction (PCLATH<4:3> → PCH).
FIGURE 4-3: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
4.3.1COMPUTED GOTO
A computed GOTO is accomplished by adding an offset
to the progra m counter (ADDWF PCL). When doing a
table read using a computed GOTO method, care
should be exercised if the tabl e loc ati on crosses a PCL
memory boundary (each 256 by te block). Refer to the
application note
“Implementing a Table Read"
4.3.2STACK
8
Instruction with
PCL as
Destination
ALU
GOTO,CALL
Opcode <10:0>
(AN556).
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 acti ons that
occur from the execution of the CALL,RETURN, RETLW, and RETFIE instructions, or the vectoring to an interrupt
address.
4.4Program Memory Paging
PIC16CXX devices are capab le of addressing a co ntinuous 8K word bl ock of p rogram me mory . 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 instructio n, th e u ser m ust
ensure that the page select bits are programmed so
that the desired pro gram memory page is addressed. If
a return from a CALL instruction (or interrupt) is executed, the entire 13-bit PC is pushed onto the stack.
Therefore , manipulation of the PC LA TH <4:3> bits is not
required for the return instructions (which POPs the
address from the stack).
Example 4-1 shows the calling of a subroutine in
page 1 of the program m emory . Th is ex ample assu mes
that PCLATH is saved and restored b y the interrupt service routine
:;called subroutine
:;page 1 (800h-FFFh)
:
RETURN;return to Call subroutine
;in page 0 (000h-7FFh)
The PIC16CXX f amily ha s an 8-le ve l deep x 13 -bit wide
hardware stack. T he 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 affected by a PUSH or POP operation.
The stack oper ates as a circular b uffer . This means that
after the stack has been PUSHed e ight ti mes , th e nin th
push overw rites th e value that was stored from the firs t
push. The tenth push overwrites the second push (and
so on).
1999 Microchip Technology Inc.
Advanced InformationDS41124A-page 29
PIC16C745/765
4.5Indirect Addressing, INDF and FSR
Registers
The INDF register is not a ph ysi cal register . Add ressing
the INDF register will cause indirect addressing.
Indirect addressing is possible by using the INDF register. Any instruction using the INDF register actually
accesses the register pointed to by the File Select Register, FSR. Reading the INDF register itself indirectly
(FSR = ’0’) will read 00h. Writing to the INDF register
indirectly results in a no-o per atio n (althou gh statu s bits
may be affected). An effectiv e 9-b it ad dress is o btaine d
by concatena tin g the 8 - bit FS R re gis ter an d the IRP bit
(STATUS<7>), as shown in Figure 4-4.
A simple program to clear RAM locations 20h-2Fh
using indirect addressing is shown in Example 4-2.
FIGURE 4-4:DIRECT/INDIRECT ADDRESSING
RP<1:0>6
bank selectlocation select
from opcode
0
00011011
00h
80h
EXAMPLE 4-2:INDIRECT ADDRESSING
movlw0x20;initialize pointer
NEXTclrfINDF;clear INDF register
CONTINUE
100h
180h
movwfFSR;to RAM
incfFSR,F;inc pointer
btfssFSR,4;all done?
gotoNEXT;no clear next
:;yes continue
Indirect AddressingDirect Addressing
IRPFSR register
bank select
7
0
location select
Data
Memory
7Fh
FFh
17Fh
Bank 0Bank 1Bank 2Bank 3
Note:For register file map detail see Figure 4-2.
1FFh
DS41124A-page 30Advanced Information
1999 Microchip Technology Inc.
Loading...
+ 128 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.