13.0 Special Features of the CPU .............................................................................................................................. 99
14.0 Instruction Set Summary................................................................................................................................... 113
15.0 Development Support ....................................................................................................................................... 121
Index .......................................................................................................................................................................... 157
Product Identification System ..................................................................................................................................... 163
To Our Valued 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 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 fo r current devic es, describin g minor opera tional difference s (from the data sheet) and reco mmended
workarounds. 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.
Corrections to this Data Sheet
We constantly strive t o impro ve the qualit y of all our pro ducts and do cumen tation. We have spent a grea t deal o f time to ens ure
that this document is correct. However, we realize that we may have missed a few things. If you find any information 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.
DS41124C-page 4Preliminary 2000 Microchip Technology Inc.
PIC16C745/765
1.0GENERAL DESCRIPTION
The PIC16C745/765 devices are low cost, high-perfor-
mance, CMOS, fully-static, 8-bit microcontrollers in the
PIC16CXX mid-range family.
All PICmicro
RISC architecture. The PIC16C745 /765 microcontroller family has enhanced core features, eight-level deep
stack and multiple internal and external interrupt
sources. The separate instruction and data bu ses 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 instructio ns to exec ute in
a single cycle, except for program branches, which
require two cycles. A total of 35 instructions (reduced
instruction set) are available. Additionally, a large register set gives some of the architectural innovations
used to achieve a very high performance.
The PIC16C745 device has 22 I/O pins. The
PIC16C765 device has 33 I/O pins. Ea ch device has
256 bytes of RAM. In addition, sev eral peripheral features are available including: three timer/counters, two
Capture/Compare/PWM modules and two serial ports.
The Universal Serial Bus (USB 1.1) low speed 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 res olution is
ideally sui t ed f or ap pl i c at i on s r e qu i ri n g a lo w c o s t an alog interface (e.g. , thermosta t control, press ure sensing, etc.).
The PIC16C745/765 devices have special features to
reduce external components, thus reducing cost,
enhancing system reliability and r educing power consumption. There are 4 oscillator options, of which EC is
for the external regulated clock source, E4 is for the
external regulated clock source with the PLL enabled,
HS is for the high speed crystal s/resona tors an d H 4 is
for high speed crystals/resonators with the PLL
enabled. 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 oscillator, provides protection 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 re mote sensors to appl iance controls and automotives. The EPROM
technology makes customization of application programs (data loggers, industrial controls, UPS)
extremely fast and conveni ent. The small footp rint packages make this microcontroller series perfect for all
applications with space limitations. Low-cost, lowpower, high-per fo rmanc e, ease of us e and I/O fl exibility
make the PIC16C745/765 devices very versatile, even
in areas where no microcontroll er use ha s been consid ered before (e.g., timer functions , serial communicati on,
capture and compare, PWM fun ct ions a nd c oproc esso r
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 easily ported to the PIC16C745/765
family of devices.
1.2Development Support
PICmicro® devices are supported by the comp lete l ine
of Microchip Development tools.
Please refer to Section 15.0 for more details about
Microchip’s development tools.
DS41124C-page 6Preliminary 2000 Microchip Technology Inc.
PIC16C745/765
2.0PIC16C745/765 DEVICE
VARIETIES
A variety of frequency ranges and packaging options
are available. Depending on application and production
requirements, the proper device option can be selected
using the information in the PIC16C7 45/765 Product
Identification System section at the end o f 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, 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 pack ages, permit the user to program them once. In addition to the
program memory, the configuration bits must also be
programmed.
Plus and PRO MATEII
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 patter ns 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 pr oduction 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 random, pseudo-random or sequential.
Serial programming allows each device to have a
unique number, which can serve as an entry-code,
password or ID number.
DS41124C-page 8Preliminary 2000 Microchip Technology Inc.
PIC16C745/765
3.0ARCHITECTURAL OVERVIEW
The high performance of the PIC16C745/765 family
can be attributed to a number of architectural features
commonly found in RISC microprocessors. To begin
with, the PIC16C745/765 uses a Harvard architecture,
in which program and data are accessed from separate
memories using separate buses. This improves bandwidth over traditional von Neumann architecture in
which program and data are fetched from the same
memory using the same bus. Separating pr ogram and
data buses further allows instructions to be sized differently than the 8-bit wide data word. Instruction opcodes
are 14-bits wide making it possible to have all sing le
word instructions. A 14-bit wide program memory
access bus fetches a 14-bit instr uction in a single cycl e.
A two-stage pipeline overlaps fetch and execution of
instructions (Example 3-1). Consequently, most
instructions execute in a sin gle cycle (166.6667 ns @
24 MHz) except for program branches.
Memory
Device
PIC16C7458K2562885
PIC16C7658K2564088
Program
x14
Data
x8
The PIC16C745/765 can directly or indirectly address
its register files or data memory. All special function
registers, including the program counter, are mapped in
the data memory. The PIC16C745/765 has an orthogonal (symmetrical ) instructi on set that make s it possibl e
to carry out any operation on any register using any
addressing mode. This symmetrical nature and lack of
‘special optimal situations’ make programming with the
PIC16C745/765 simple yet efficient. In addition, the
learning curve is reduced significantly.
Pins
A/D
Resolution
A/D
Channels
PIC16C745/765 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 ca pable of addition, subtraction, shift and logical operations. Unless otherwise
mentioned, arithmetic operations are two's complement in nature. In two-operand instructions, typi cally
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 used for ALU
operations. It is not an addressable register.
Depending on the instruction executed, the ALU may
affect the values of the Carry (C), Digit Carry (DC), and
Zero (Z) bits in the STA TUS 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.
TX—CMOS USART Async Transmit
CKSTCMOS USART Master Out/Slave In Clock
RC7STCMOS Bi-directional I/O
RXST—USART Async Receive
DTSTCMOS USART Data I/O
Output
Type
Description
RD0/PSP0
RD1/PSP1
RD2/PSP2
RD3/PSP3
RD4/PSP4
RD5/PSP5
RD6/PSP6
RD7/PSP7
RE0/RD/AN5
RE1/WR/AN6
RE2/CS/AN7
RD0TTLCMOS Bi-directional I/O
(2)
PSP0TTL—Parallel Slave Port Data Input
RD1TTLCMOS Bi-directional I/O
(2)
PSP1TTL—Parallel Slave Port Data Input
RD2TTLCMOS Bi-directional I/O
(2)
PSP2TTL—Parallel Slave Port Data Input
RD3TTLCMOS Bi-directional I/O
(2)
PSP3TTL—Parallel Slave Port Data Input
RD4TTLCMOS Bi-directional I/O
(2)
PSP4TTL—Parallel Slave Port Data Input
RD5TTLCMOS Bi-directional I/O
(2)
PSP5TTL—Parallel Slave Port Data Input
RD6TTLCMOS Bi-directional I/O
(2)
PSP6TTL—Parallel Slave Port Data Input
RD7TTLCMOS Bi-directional I/O
(2)
PSP7TTL—Parallel Slave Port Data Input
RE0STCMOS Bi-directional I/O
(2)
RDTTL—Parallel Slave Port Control Input
AN5AN—A/D Input
RE1STCMOS Bi-directional I/O
(2)
(2)
WRTTL—Parallel Slave Port Control Input
AN6AN—A/D Input
RE2STCMOS Bi-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
V
SSVSSPower—Ground
Legend:OD = open drain, ST = Schmitt Trigger
Note 1: Weak pull-ups. PORT B pull-ups are byte wide programmable.
2: PIC16C765 only.
DS41124C-page 12Preliminary 2000 Microchip Technology Inc.
PIC16C745/765
3.1Clocking Scheme/Instruction Cycle
The clock input feeds either an on-chip PLL, or directly
INT). The clock output from either the PLL or
drives (F
direct drive (F
INT) is internally divided by four to gener-
ate four non-overlapping quadrature clocks namely,
Q1, Q2, Q3 and Q4. Internally, the program counter
(PC) is incremented every Q1, the instruction is fetched
from the program memory and latched into the instruction register in Q4. The instruction is decoded 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
Q1
Q2
Q3
Q4
PC
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 c hange (e.g., GOTO),
then two cycles are required to complete the instruction
(Example 3-1).
A fetch cycle begins with the pr ogram counter (PC)
incrementing in Q1.
In the execution cycle, the fetched instruction is latched
into the “Instruction Register" (IR) in cycle Q1. This
instruction is then decoded and executed during the
Q2, Q3 and Q4 cycles. Data memory 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.
DS41124C-page 14 Preliminary 2000 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 data sheet 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
CALL, RETURN
RETFIE, RETLW
On-chip
Program
Memory
MEMORY MAP AND ST ACK
PC<12:0>
13
Stack Level 1
Stack Level 2
Stack Level 8
Reset Vector
Interrupt Vector
Page 0
Page 1
Page 2
Page 3
0000h
0004h
0005h
07FFh
0800h
0FFFh
1000h
17FFh
1800h
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 banks contain SFRs. Some “high use”
SFRs from one bank may be mirrored in another bank
for code reduction and quicker access.
4.2.1GEN ERAL PURPOSE REGISTER FILE
The register file can be accessed either directly or indi-
rectly through the File Select Register (FSR)
(Section 4.5).
CCPR2H1Ch9Ch11Ch
CCP2CON1Dh9Dh11Dh
ADRES1Eh9Eh11Eh
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
9Ah11AhUEP219Ah
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
1DFh
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.
DS41124C-page 16Preliminary 2000 Microchip Technology Inc.
70h-7Fh
EFh16Fh1EFh
F0haccesses
70h-7Fh
170haccesses
70h-7Fh
1E0h
1F0h
PIC16C745/765
4.2.2SPECIAL FUNCTION REGISTERS
The Special Function Registers are registers used by
the CPU and Peripheral Modules for controlling the
desired operation of the devic e. These registers are
implemented as static RAM.
The Special Function Registers can be classified into
two sets (core and peripheral). Those registers associated with the “core” functions are described in this section, and those related to the operation of the peripheral
features are described in the section of that p eripher al
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 any bank.
4: The Parallel Slave 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’.
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 any bank.
4: The Parallel Slave Port (PORTD and PORTE) is not implemented on the PIC16C745, always maintain these bits clear.
POR,
BOR
Value on all
other resets
(2)
DS41124C-page 18Preliminary 2000 Microchip Technology Inc.
PIC16C745/765
TABLE 4-1: SPECIAL FUNCTION REGISTER SUMMARY (CONTINUED)
100h
101hTMR0Timer0 module’s registerxxxx xxxx uuuu uuuu
102h
103h
104h
105h—Unimplemented——
106hPORTBPORTB Data Latch when written: PORTB pins when readxxxx xxxx uuuu uuuu
107h—Unimplemented——
108h—Unimplemented——
109h—Unimplemented——
10Ah
10Bh
10Ch-
11Fh
(3)
INDF
PCL
STATUS
FSR
PCLATH
INTCON
Addressing th is location u ses contents of FSR to address d ata memory (not a physical register)0000 0000 0000 0000
(3)
Program Counter's (PC) Least Significant Byte0000 0000 0000 0000
(3)
IRPRP1RP0TOPDZDCC0001 1xxx 000q quuu
(3)
Indirect data memory address pointerxxxx xxxx uuuu uuuu
(1,3)
———Write Buffer for the upper 5 bits of the Program Co unter---0 0000 ---0 0000
(3)
GIE PEIET0IEINTERBIET0IFINTF RBIF0000 000x 0000 000u
—Unimplemented——
Value on:
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 any bank.
4: The Parallel Slave Port (PORTD and PORTE) is not implemented on the PIC16C745, always maintain these bits clear.
Write Buffer for the upper 5 bits of the Program Counter
Value on:
---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 any bank.
4: The Parallel Slave Port (PORTD and PORTE) is not implemented on the PIC16C745, always maintain these bits clear.
POR,
BOR
Value on all
other resets
(2)
DS41124C-page 20Preliminary 2000 Microchip Technology Inc.
4.2.2.1STATUS REGISTER
The STATUS register, shown in Register 4-1, contains
the arithmetic status of the ALU, the RESET status and
the bank select bits for data memory.
The STATUS register can be the destination for any
instruction, as with any other r egister. 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. These bits are set or cleared according to the
device logic. Furthermore, the TO
writable. Therefore, the result of an instruction with the
STATUS register as destination may be different than
intended.
and PD bits are not
For example, CLRF STATUS will clear the upper three
bits and set the Z bit. This leaves the ST ATUS register
as 000u u1uu (where u = unchanged).
It is recommended that only BCF, BSF, SWAPF and
MOVWF instructions be used to alter the STATUS register. These instructions 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 instructions for examples.
REGISTER 4-1: STATUS REGISTER (STATUS: 03h, 83h, 103h, 183h)
R/W-0R/W-0R/W-0R-1R-1R/W-xR/W-xR/W-x
IRPRP1RP0TO
bit7bit0
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
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)
1 = A carry-out from the 4th low order bit of the result occurred
0 = No carry-out from the 4th low o rder 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
PDZDC
(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
ond operand. For rotate (RRF, RLF) instructions, this bit is loaded with either the high or low order bit of the
source register.
DS41124C-page 22Preliminary 2000 Microchip Technology Inc.
the polarity is reversed. A subtraction is executed by adding the two’s complement of the sec-
PIC16C745/765
4.2.2.2OPTION REGISTER
The OPTION_REG register is a readable and writable
register, which contains various control bits to configure
Note:To achieve a 1:1 prescaler assignment for
the TMR0 register, assign the prescaler to
the Watchdog Timer.
the TMR0/WDT prescaler, the external INT Interrupt,
TMR0 and the weak pull-ups on PORTB.
4.2.2.3INTCON REGISTER
The INTCON register is a readable and wr itabl e 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
interrupt
.
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:
bit 6:PEIE: Peripheral Interrupt Enable bit
bit 5:T0IE: TMR0 Overflow Interrupt Enable bit
bit 4:INTE: RB0/INT External Interrupt Enable bit
bit 3:RBIE: RB Port Change Interrupt Enable bit
bit 2:T0IF: TMR0 Overflow Interrupt Flag bi t
bit 1:INTF: RB0/INT External Interrupt Flag bit
bit 0:RBIF: RB Port Change Interrupt Flag bit
Global Interrupt Enable bit
1 = Enables all un-masked interrupts
0 = Disables all interrupts
1 = Enables all un-masked peripheral interrupts
0 = Disables all peripheral interrupts
1 = Enables the TMR0 interrupt
0 = Disables the TMR0 interrupt
1 = Enables the RB0/INT external interrupt
0 = Disables the RB0/INT external interrupt
1 = Enables the RB port change interrupt
0 = Disables the RB port change interrupt
1 = TMR0 register has overflowed (must be cleared in software)
0 = TMR0 register did not overflow
1 = The RB0/INT external interrupt occurred (must be cleared in software)
0 = The RB0/INT external interrupt did not occur
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’
DS41124C-page 24Preliminary 2000 Microchip Technology Inc.
PIC16C745/765
4.2.2.4PIE1 REGISTER
This register contains the individual enable bits for the
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.
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.
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.
4.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 must be set by
the user and checked on subsequent
RESETS to see if BOR
a brown-out has occurred.
REGISTER 4-8: POWER CONTR OL REGISTER REGISTER (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
R = Readable bit
W = Writable bit
U = Unimplemented bit,
read as ‘0’
-n = Value at POR reset
DS41124C-page 28Preliminary 2000 Microchip Technology Inc.
PIC16C745/765
4.3PCL and PCLATH
The program counter (PC) is 13-bits wide. 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
PCLATH register. On any RESET, the upper bits of the
PC will be cleared. Figure 4-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 figure shows how 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
4.3.1COMPUTED GOTO
A computed GOTO is accomplished by adding an offset
to the program counter ( ADDWF PCL). When doing a
table read using a computed GOTO method, care
should be exercised if the table location crosses a PCL
memory boundary (each 256 byte block). Refer to the
application note “Implementing a Table Read" (AN556).
4.3.2STACK
The PIC16C745/765 family has an 8-le vel 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 writable. The PC is PUSHed onto the
stack when a CALL instruction i s exec uted or a n i nterrupt 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 operates as a circular buffer. This means that
after the stack has been PUSHed eight times, the ninth
push overwrites the value that was stored from the first
push. The tenth push overwrites the second push (and
so on).
11
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 the vectoring to an interrupt
address.
4.4Program Memory Paging
PIC16CXX devices are capable of addressing a continuous 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 instruction, the user must
ensure that the page select bits are programmed so
that the desired program memory page is addressed. If
a return from a CALL instruction (or interrupt) is executed, the entire 13-bit PC is p ushed onto the stack.
Therefore, manipulation of the PCLATH<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 memory. This example assumes
that PCLATH is saved and restored by the interrupt service routine
The INDF register is not a physical register. Addressing
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-operation (although status bits
may be affected). An effective 9-bit address is obtained
by concatenating the 8-bit FSR register and the IRP bit
(STATUS<7>), as shown in Figure 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
movlw 0x20;initialize pointer
NEXTclrfINDF;clear INDF register
CONTINUE
100h
movwf FSR;to RAM
incfFSR,F ;inc pointer
btfss FSR,4;all done?
gotoNEXT;no clear next
:;yes continue
Indirect AddressingDirect Addressing
IRPFSR register
180h
7
bank select
0
location select
Data
Memory
7Fh
FFh
17Fh
1FFh
Bank 0Bank 1Bank 2Bank 3
Note:For register file map detail see Figure 4-2.
DS41124C-page 30Preliminary 2000 Microchip Technology Inc.
Loading...
+ 135 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.