The Microchip name, logo, PIC, PICmicro, PICMASTER, PICSTART, PRO MATE, K
EELOQ, SEEVAL, MPLAB and The
Embedded Control Solutions Company are registered trademarks of Microchip Technology Incorporated in the U.S.A. and
other countries.
Total Endurance, ICSP, In-Circuit Serial Programming, FilterLab, MXDEV, microID, FlexROM, fuzzyLAB, MPASM,
MPLINK, MPLIB, PICDEM, ICEPIC, Migratable Memory,
FanSense, ECONOMONITOR, SelectMode and microPort
are trademarks of Microchip Technology Incorporated in the
U.S.A.
Serialized Quick T erm Programming (SQTP) is a service mark
of Microchip Technology Incorporated in the U.S.A.
All other trademarks mentioned herein are property of their
respective companies.
Microchip received QS-9000 quality system
certification for its worldwide headquarters,
design and wafer fabrication facilities in
Chandler and Tempe, Arizona in July 1999. The
Company’s quality system processes and
procedures are QS-9000 compliant for its
PICmicro
devices, Serial EEPROMs and microperipheral
products. In addition, Microchip’s quality
system for the design and manufacture of
development systems is ISO 9001 certified.
®
8-bit MCUs, KEELOQ
®
code hoppin g
DS39544A - page iiPreliminary 2001 Microchip Technology Inc.
PIC16C925/926
64/68-Pin CMOS Microcontrollers with LCD Driver
High Performance RISC CPU:
• Only 35 single word instructions to learn
• All single cycle instructions except for program
branches which are two-cycle
• Operating speed: DC - 20 MHz clock input
DC - 200 ns instruction cycle
• Up to 8K x 14-bit words of EPROM program memory,
336 bytes general purpose registe r s (SRA M),
60 special function registers
• Pinout compatible with PIC16C923/924
Peripheral Features:
• 25 I/O pins with individual direction control and
25-27 input only pins
• Timer0 module: 8-bit timer/counter with program-
mable 8-bit prescaler
• Timer1 module: 16-bit timer/counte r, can be incre-
mented during SLEEP via external cryst al/clo ck
• Timer2 module: 8-bit timer/counter with 8-bit
period register, prescaler, and postscaler
• One Capture, Compare, PWM module
• Synchronous Serial Port (SSP) module with
two modes of operation:
- 3-wire SPI™ (supports all 4 SPI modes)
2
C™ Slave mode
-I
• Programmable LCD timing module:
- Multiple LCD timing sources available
- Can drive LCD panel while in SLEEP mode
- Static, 1/2, 1/3, 1/4 multiplex
- Static drive and 1/3 bias capability
- 16 bytes of dedicated LCD RAM
- Up to 32 segments, up to 4 commons
Analog Features:
• 10-bit 5-channel Analog -to-Digital Converter (A/D)
• Brown-out Reset (BOR)
Special Microcontroller Features:
• Power-on Reset (POR)
• Power-up Timer (PWRT) and Oscillator Start-up
Timer (OST)
• Watchdog Timer (WDT) with its own on-chip RC
oscillator for reliable operation
3.0Reading Program Memory.................................................................................................................................. 27
9.0Synchronous Serial Port (SSP) Module ..............................................................................................................59
12.0 Special Features of the CPU............................................................................................................................... 97
13.0 Instruction Set Summary ...................................................................................................................................113
14.0 Development Support .......................... ...... ..... ........................................ ..... ...... ...... .........................................133
16.0 DC and AC Characteristics Graphs and Tables ................................................................................................159
17.0 Packaging Information ......................................................................................................................................161
Index .......................................................................................................................................................................... 169
PIC16C925/926 Product Identifica tio n Syst em........................................... ....................................... ........................ 177
TO OUR VALUED CUSTOMERS
It is our intention to provide our valued customers with the best documentation possible to ensure successful use of your Microchip
products. To this end, we will continue to improve our publications to better suit your needs. Our publications will be refined and
enhanced as new volumes and updates are introduced.
If you have any questions or c omm ents regarding th is publication, p lease c ontact the M a rketing Communications Department via
E-mail at docerrors@mail.microchip.com or fax the Reader Response Form in the back of this data sheet to (480) 792-4150.
We welcome your feedback.
Most Current Data Sheet
To obtain the most up-to-date version of this data sheet, please register at our Worldwide Web site at:
http://www.microchip.com
You can determine the version of a data sheet by examining its literature number found on the bottom outside corner of any page.
The last character of the literature number is the version number, (e.g., DS30000A is version A of document DS30000).
Errata
An errata sheet, describing minor operational differences from the data sheet and recommended workarounds, may exist for current
devices. As device/documentation issues become known to us, we will publish an errata sheet. The errata will specify the revision
of silicon and revision of document to which it applies.
To determine if an errata sheet exists for a particular device, please check with one of the following:
• Microchip’s Worldwide Web site; http://www.microchip.com
• Your local Microchip sales office (see last page)
• The Microchip Corporate Literature Center; U.S. FAX: (480) 792-7277
When contacting a sales office or the literature center, please specify which device, revision of silicon and data sheet (include literature number) you are using.
Customer Notification System
Register on our web site at www.microchip.com/cn to receive the most current information on all of our products.
DS39544A-page 4Preliminary 2001 Microchip Technology Inc.
PIC16C925/926
1.0DEVICE OVERVIEW
This document cont a ins dev ice -sp ec ifi c info rm ation for
the following devices:
1.PIC16C925
2.PIC16C926
The PIC16C925/926 series is a family of low cost, high
performanc e, CM OS , f u ll y stati c, 8 -b it m ic roc o nt ro ll ers
with an integrated LCD Driver module, in the
PIC16CXXX mid-range family.
For the PIC16C925/926 family, there are two device
“types” as indicated in the device number:
1.C, as in PIC16C926. These devices operate
over the standard voltage range.
2.LC, as in PIC16LC926. These devices operate
over an extended volta ge rang e.
TABLE 1-1:PIC16C925/926 DEVICE FEATURES
FeaturesPIC16C925PIC16C926
Operating FrequencyDC-20 MHzDC-20 MHz
EPROM Program Memory (words) 4K8K
Data Memory (bytes)176336
Timer Module(s)TMR0,TMR1,TMR2TMR0,TMR1,TMR2
Capture/Compa re/PW M Mo dul e(s )11
Serial Port(s)
2
C, USART)
(SPI/I
Parallel Slave Port——
A/D Converter (10-bit) Channels55
LCD Module4 Com, 32 Seg4 Com, 32 Seg
Interrupt Sources99
I/O Pins2525
Input Pins2727
Voltage Range (V)2.5-5.52.5-5.5
In-Circuit Serial ProgrammingYesYes
Brown-out ResetYesYes
Packages
68-pin CLCC (CERQUAD)
These devices c ome in 64-pin and 68-pin p ackages, as
well as die form. Both configurations offer identical
peripheral devices and other features. The only difference between the PIC16C925 and PIC16C926 is the
additional EPROM and data memory offered in the latter. An overview of features is presented in Table 1-1.
A UV-erasab le, CERQUAD package d version (compa tible with PLCC) is also available for both the
PIC16C925 and PIC16C926. This version is ideal for
cost effective code development.
A block diagram for the PIC16C925/926 family architecture is presented in Figure 1-1.
DS39544A-page 6Preliminary 2001 Microchip Technology Inc.
TABLE 1-2:PIC16C925/926 PINOUT DESCRIPTION
PIC16C925/926
PLCC,
Pin Name
OSC1/CLKIN2414IST/CMOSOscillator crystal input or external clock source input. This
OSC2/CLKOUT2515O—Oscillator crystal output. Connects to crystal or resonator in
/VPP257I/PSTMaster Clear (Reset) input or programming voltage input. This
MCLR
RA0/AN0560I/OTTLRA0 can also be Analog input0.
RA1/AN1661I/OTTLRA1 can also be Analog input1.
RA2/AN2863I/OTTLRA2 can also be Analog input2.
RA3/AN3/V
RA4/T0CKI101I/OSTRA4 can also be the clock input to the Timer0
RA5/AN4/SS
RB0/INT134I/OTTL/STRB0 can also be the external interrupt pin. This buffer is a
RB1123I/OTTL
RB2459I/OTTL
RB3358I/OTTL
RB46856I/OTTLInterrupt-on-change pin.
RB56755I/OTTLInterrupt-on-change pin.
RB66553I/OTTL/STInterrupt-on-change pin. Serial programming clock. This
RB76654I/OTTL/STInterrupt-on-change pin. Serial programming data. This
RC0/T1OSO/T1CKI2616I/OSTRC0 can also be the Timer1 oscillator output or Timer1
RC1/T1OSI2717I/OSTRC1 can also be the Timer1 oscillator input.
RC2/CCP12818I/OSTRC2 can also be the Capture1 input/Compare1
RC3/SCK/SCL145I/OSTRC3 can also be the synchronous serial clock input/
RC4/SDI/SDA156I/OSTRC4 can also be the SPI Data In (SPI mode) or
RC5/SDO167I/OSTRC5 can also be the SPI Data Out (SPI mode).
C1178PLCD Voltage Generation.
C2189PLCD Voltage Generation.
COM06351LComm on Driver0.
Legend: I = inputO = outputP = powerL = LCD Driver
REF964I/OTTLRA3 can also be Analog input3 or A/D Voltage
RF0/SEG124433I/LSTSegm ent Driver 12.
RF1/SEG134534I/LSTSegm ent Driver 13.
RF2/SEG144635I/LSTSegm ent Driver 14.
RF3/SEG154736I/LSTSegm ent Driver 15.
RF4/SEG164837I/LSTSegm ent Driver 16.
RF5/SEG174938I/LSTSegm ent Driver 17.
RF6/SEG185039I/LSTSegm ent Driver 18.
RF7/SEG195140I/LSTSegm ent Driver 19.
PORTD is a digital input/output port. These pins are also used
as LCD Segment and/or Common Drivers.
PORTE is a Digital input or LCD Segment Driver port.
PORTF is a Digital input or LCD Segment Driver port.
PORTG is a Digital input or LCD Segment Driver port.
left unconnected.
DS39544A-page 8Preliminary 2001 Microchip Technology Inc.
PIC16C925/926
1.1Clocking Scheme/Instruction
Cycle
The clock input (from OSC1) is internally divided by
four to generate 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
are shown in Figure1-2.
FIGURE 1-2:CLOCK/INSTRUCTION CYCLE
Q2Q3Q4
OSC1
Q1
Q2
Q3
Q4
PC
OSC2/CLKOUT
(RC mode)
Q1
PCPC+1PC+2
Fetch INST (PC)
Execute INST (PC-1)Fetch INST (PC+1)
Q1
Execute INST (PC)Fetch INST (PC+2)
1.2Instruction Flow/Pipelining
An “Instruction Cycle” consists of four Q cycles (Q1,
Q2, Q3 and Q4). The instruc tio n 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 req uired to c omplete the ins truction
(Example 1-1).
A fetch cycle begins with the program counter (PC)
incrementing in Q1.
In the execution cy cle, the fetch ed instruction i s latched
into the “Instruction Register” 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
Q2Q3Q4
Q1
Execute INST (PC+1)
Internal
Phase
Clock
EXAMPLE 1-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
All instructions are s ingle cycle, exce pt for any program br anches. These t ake two cycl es, since the fetch in struction
is “flushed” from the pipeline while the new instruction is being fetched and then executed.
DS39544A-page 10Preliminary 2001 Microchip Technology Inc.
2.0MEMORY ORGANIZATION
2.1Program Memory Organization
The PIC16C925/926 family has a 13-bit program
counter capable of addressing an 8K x 14 program
memory space.
For the PIC16C925, only the first 4K x 14 (0000h0FFFh) are physically implemented. Accessing a location above the physically implemented addresses will
cause a wraparound. The RESET vector is at 0000h
and the interrupt vector is at 0004h.
The data memory is partitioned into four banks which
contain the General Purpose Reg isters a nd the Special
Function Registers. Bits RP1 and RP0 are the bank
select bits.
RP1:RP0
(STATUS<6:5>)
11
10
01
00
The lower locations of each Bank are reserved for the
Special Function Registers. Above the Special Function Registers are General Purpose Registers implemented as static RAM. All four banks contain special
function registers. Some “high use” special function
registers are mirrored in other banks for code reduc tion
and quicker access.
Bank
3 (180h-1FFh)
2 (100h-17Fh)
1 (80h-FFh)
0 (00h-7Fh )
2.2.1GENERAL PURPOSE REGISTER
FILE
The register file can be acces sed either directly, or indirectly through the File Select Register FSR
(Section 2.6).
The following General Purp ose Register s are not physically implemented:
• F0h-FFh of Bank 1
• 170h-17Fh of Bank 2
• 1F0h-1FFh of Bank 3
These locations are used for common access across
banks.
DS39544A-page 12Preliminary 2001 Microchip Technology Inc.
DS39544A-page 14Preliminary 2001 Microchip Technology Inc.
PIC16C925/926
2.3Special Function Registers
The Special Function Registers (SFRs) are registers
used by the CPU and Peripheral Modules for controlling the desired operation of the device. These registers are implemented as static RAM.
The special function regi sters can be classified into tw o
sets, core and peripheral. Those registers associated
with the “core” functions are described in this section.
Those related to the operation of the peripheral
features are described in the section of that peripheral
feature.
Bank 0
00hINDFAddressing this location uses contents of FSR to address data memory (not a physical register)
01hTMR0Timer0 Module Register
02hPCLProgram Counter (PC) Least Significant Byte
03hSTATUSIRPRP1RP0TOPDZDCC
04hFSRIndirect Data Memory Address Pointer
05hPORTA
06hPORTBPORTB Data Latch when writt en: PORTB pins when read
07hPORTC
08hPORTDPORTD Data Latch when written: PORTD pins when read
09hPORTEPORTE pins when read
0AhPCLATH
0BhINTCONGIE PEIETMR0IEINTE RBIETMR0IFINTF RBIF
0ChPIR1LCDIFADIF
0Dh—Unimplemented——
0EhTMR1LHolding register for the Least Significant Byte of the 16-bit TMR1 Register
0FhTMR1HHolding register for the Most Significant Byte of the 16-bit TMR1 Register
10hT1CON
11hTMR2Timer2 Module Register
12hT2CON
13hSSPBUFSynchronous Ser i al Po rt Receive Buffer/Transmit Register
14hSSPCONWCOLSSPOVSSPENCKPSSPM3SSPM2SSPM1SSPM0
15hCCPR1LCapture/Compare/PWM Register (LSB)
16hCCPR1HCapture/Compare/PWM Register (MSB)
17hCCP1CON
18h—Unimplemented——
19h—Unimplemented——
1Ah—Unimplemented——
1Bh—Unimplemented——
1Ch—Unimplemented——
1Dh—Unimplemented——
1EhADRESHA/D Result Register High
1FhADCON0ADCS1ADCS0CHS2CHS1CHS0GO/DONE
Legend:
Note 1: These pixels do not display, but can be used as general purpose RAM.
x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as '0'.
Shaded locations are unimplemented, read as ‘0’.
——PORTA Data Latch when written: PORTA pins when read--0x 000029
——PORTC Data Latch when written: PORTC pins when read--xx xxxx33
———Write Buffer for the upper 5 bits of the Program Counter---0 000025
80hINDFAddressing this location uses contents of FSR to address data memory (not a physical register)
81hOPTIONRBPUINTEDGT0CST0SEPSAPS2PS1PS0
82hPCLProgram Counter (PC) Least Significant Byte
83hSTATUSIRPRP1RP0TOPDZDCC
84hFSRIndirect Data Memory Address Pointer
85hTRISA
86hTRISBPORTB Data Direction Register
87hTRISC
88hTRISDPORTD Data Direction Register
89hTRISEPORTE Data Direction Register
8AhPCLATH
8BhINTCONGIEPEIETMR0IEINTERBIETMR0IFINTFRBIF
8ChPIE1LCDIEADI E
8Dh—Unimplemented——
8EhPCON
8Fh—Unimplemented——
90h—Unimplemented——
91h—Unimplemented——
92hPR2Timer2 Period Register
93hSSPADDSynchronous Serial Port (I
100hINDFAddressing this location uses contents of FSR to address data memory (not a physical register)
101hTMR0Timer0 Module Register
102hPCLProgram Counter (PC) Least Significant Byte
103hSTATUSIRPRP1RP0TOPDZDCC
104hFSRIndirect Data Memory Address Pointer
105h—Unimplemented——
106hPORTBPORTB Data Latch when writt en: PORTB pins when read
107hPORTFPORTF pins when read
108hPORTGPORTG pins when read
109h—Unimplemented——
10AhPCLATH
10BhINTCONGIEPEIETMR0IEINTERBIETMR0IFINTFRBIF
10ChPMCON1
180hINDFAddressing this location uses contents of FSR to address data memory (not a physical register)
181hOPTIONRBPUINTEDGT0CST0SEPSAPS2PS1PS0
182hPCLProgram Counter’s (PC) Least Significant Byte
183hSTATUSIRPRP1RP0TOPDZDCC
184hFSRIndirect Data Memory Address Pointer
185h—Unimplemented——
186hTRISBPORTB Data Direction Register
187hTRISFPORTF Data Directi on Register
188hTRISGPORTG Data Direction Register
189h—Unimplemented——
18AhPCLATH
18BhINTCONGIEPEIETMR0IEINTERBIETMR0IFINTFRBIF
18ChPMDATAData Register Low Byte
DS39544A-page 18Preliminary 2001 Microchip Technology Inc.
PIC16C925/926
2.3.1STATUS REGISTER
The STATUS register, shown in Register2-1, contains
the arithmetic st atus of th e ALU, the RE SET statu s and
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. These bit s are set or cleared ac cording to the
device logic. Furthermore, the TO
writable. Therefore, the result of an instruction with the
STATUS register as dest ination may be di fferent than
intended.
and PD bits are not
For example, CLRF STATUS will clear the upper-three
bits and set the Z bit. This leaves the STATUS register
as 000u u1uu (where u = unchanged).
It is recommended, therefore, that only BCF, BSF,SWAPF and MOVWF instructions are used to alter the
STATUS register because these instructions do not
affect the Z, C or DC bits from the ST ATUS reg ister . For
other instructions, no t affecting any status bi ts, see the
“Instruction Set Summary.”
Note:The C and DC bits operate as a borrow
and digit borrow bit, respectively, in subtraction. See the SUBLW and SUBWF
instructions for examples.
The OPTION register is a readable and writable register, which contains various control bits to configure the
TMR0/WDT prescaler, the external RB0/INT pin interrupt, TMR0, and the weak pull-ups on PORTB.
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
- n = Value at POR’1’ = Bit is set’0’ = Bit is clearedx = Bit is unknown
DS39544A-page 20Preliminary 2001 Microchip Technology Inc.
PIC16C925/926
2.3.3INTCON REGISTER
The INTCON Register is a readabl e and writ able register which contains various enable and flag bits for the
TMR0 register overflow, RB Port change and external
RB0/INT pin interrupts.
Note:Interrupt flag bit s are set whe n an in terrupt
condition occurs, regardless of the state of
its corresponding enable bit or the global
enable bit, GIE (INTCON<7>).
This register contains the individual enable bits for the
peripheral interrupts.
REGISTER 2-4:PIE1 REGISTER (ADDRESS 8Ch)
R/W-0R/W-0U-0U-0R/W-0R/W-0R/W-0R/W-0
LCDIEADIE
bit 7bit 0
bit 7LCDIE: LCD Interrupt Enable bit
1 = Enables the LCD interrupt
0 = Disables the LCD interrupt
bit 6ADIE: A/D Converter Interrupt Enable bit
1 = Enables the A/D interrupt
0 = Disables the A/D interrupt
bit 5-4Unimplemented: Read as ‘0’
bit 3SSPIE: Synchronous Serial Port Interrupt Enable bit
1 = Enables the SSP interrupt
0 = Disables the SSP interrupt
bit 2CCP1IE: CCP1 Interrupt Enable bit
1 = Enables the CCP1 interrupt
0 = Disables the CCP1 interrupt
bit 1TMR2IE: TMR2 to PR2 Match Interrupt Enable bit
1 = Enables the TMR2 to PR2 match interrupt
0 = Disables the TMR2 to PR2 match interrupt
bit 0TMR1IE: TMR1 Overflow Interrupt Enable bit
1 = Enables the TMR1 overflow interrupt
0 = Disables the TMR1 overflow interrupt
——SSPIECCP1IETMR2IETMR1IE
Note:Bit PEIE (INTCON<6>) must be set to
enable any peripheral interrupt.
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
- n = Value at POR’1’ = Bit is set’0’ = Bit is clearedx = Bit is unknown
DS39544A-page 22Preliminary 2001 Microchip Technology Inc.
2.3.5PIR1 REGISTER
This register contains the individual flag bits for the
peripheral interrupts.
Note:Interrupt flag bits are se t w he n an interrupt
condition occurs, re gardless 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 2-5:PIR1 REGISTER (ADDRESS 0Ch)
R/W-0R/W-0U-0U-0R/W-0R/W-0R/W-0R/W-0
LCDIFADIF
bit 7bit 0
bit 7LCDIF: LCD Interrupt Flag bit
1 = LCD interrupt has occurred (must be cleared in software)
0 = LCD interrupt did not occur
bit 6ADIF: A/D Converter Interrupt Flag bit
1 = An A/D conversion completed (must be cleared in software)
0 = The A/D conversion is not complete
bit 5-4Unimplemented: Read as ‘0’
bit 3SSPIF: Master Synchronous Serial Port Interrupt Flag bit
1 = The transmission/reception is complete (must be cleared in software)
0 = Waiting to transmit/receive
bit 2CCP1IF: 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 1TMR2IF: 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 0TMR1IF: TMR1 Overflow Interrupt Flag bit
1 = TMR1 register overflowed (must be cleared in software)
0 = TMR1 register did not overflow
——SSPIFCCP1IFTMR2IFTMR1IF
PIC16C925/926
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
- n = Value at POR rese t’1’ = Bit is set’0’ = Bit is clearedx = Bit is unknown
The Power Control (PCON) register contains a flag bit
to allow differentiation between a Power-on Reset
(POR) to an external MCLR
For various RESET conditions, see Table 12-4 and
Table 12-5.
REGISTER 2-6:PCON REGISTER (ADDRESS 8Eh)
bit 7-2Unimplemented: Read as '0'
bit 1POR
bit 0BOR
Reset or WDT Reset.
U-0U-0U-0U-0U-0U-0R/W-0R/W-1
——————PORBOR
bit 7bit 0
: 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)
: Brown-out Reset Status bit
1 = No Brown-out Reset occurred
0 = A Brown-out Reset occurred (must be set in software after a Brown-out Reset occurs)
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
- n = Value at POR’1’ = Bit is set’0’ = Bit is clearedx = Bit is unknown
DS39544A-page 24Preliminary 2001 Microchip Technology Inc.
PIC16C925/926
2.4PCL and PCLATH
The program counter (PC) is 13-bits wid e. The low byte
comes from the PCL register, which is a readable and
writable register. The upper bits (PC<12:8>) are not
readable, but are indirectly writable through the
PCLA TH reg is ter. On any RESET, the up per bi t s of the
PC will be cleared. Fig ure2-5 shows the two situations
for the loading of the PC. The up per ex ample in th e figure shows how the PC is loaded on a write to PCL
(PCLATH<4:0> → PCH). The lower exampl e i n th e fi gure shows how the PC is loaded during a CALL or GOTO
instruction (PCLATH<4:3> → PCH).
FIGURE 2-5:LOADING OF PC IN
DIFFERENT SITUATIONS
PCHPCL
128 70
PC
PCLATH<4:0>
5
PCLATH
PCHPCL
12 11 100
PC
2
87
PCLATH<4:3>
PCLATH
11
2.4.1COMPUTED GOTO
A computed GOTO is accomplish ed by adding an offset
to the program counter (ADDWF PCL). When doing a
table read using a computed GOTO method, care
should be exercise d i f the t able loca tio n cros ses a PCL
memory boundary (each 256 byte block). Refer to the
application note “I mplementing a Table Read” (AN556).
2.4.2STACK
The PIC16CXXX family has 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 writable. The PC is PUSHed onto the stack
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 opera tes as a circular buf fer . This means that
after the st ack h as be en PUSHed ei ght ti mes, th e nin th
push overwrites the v alue tha t was stored fro m the first
push. The tenth pus h ov erwri t es the se co nd p us h (an d
so on).
8
Instruction with
PCL as
Destination
ALU Result
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.
2.5Program Memory Paging
PIC16C925/926 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 ensu re tha t the p age 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 en tire 13-bit PC is pushed
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).
Note:The contents of the PCLATH register are
unchanged after a RETURN or RETFIE
instruction is executed. The user must
rewrite the PCLATH for any subsequent
CALL or GOTO instructions.
Example 2-1 shows the calling of a subroutine in
page 1 of the prog ram memory. This example assumes
that PCLATH is saved and restored by the Interrupt
Service Routine (if interrupts are used).
The INDF register is not a physi cal register. Addressing
the INDF register will cause indirect addressing.
Indirect addressing is possible by using the INDF register. Any instruc tion using the INDF register actual ly
accesses the register pointed to by the File Sele ct Register (FSR). Reading the INDF register itself, indirectly
(FSR = ’0’), w ill produc e 00h . W rit ing to the INDF re gister indirectly results in a no operation (although status
bits may be affected). An effective 9-bit address is
obtained by co ncatenating the 8-bit FSR re gister and
the IRP bit (STATUS<7>), as shown in Figure 2-6.
FIGURE 2-6:DIRECT/INDIRECT ADDRESSING
RP1:RP06
Bank SelectLocation Select
From Opcode
00h
0
00011011
A simple program to clear RAM locations 20h-2Fh
using indirect addressing is shown in Example 2-2.
EXAMPLE 2-2:INDIRECT ADDRESSING
MOVLW 0x20;initialize pointer
NEXTCLRFINDF;clear INDF register
CONTINUE
MOVWF FSR;to RAM
INCFFSR,F;inc pointer
BTFSS FSR,4;all done?
GOTONEXT;no clear next
:;yes continue
Indirect AddressingDirect Addressing
IRPFSR Register
Bank Select
7
Location Select
00h
0
Data
Memory
7Fh
Bank 0Bank 1Bank 2Bank 3
Note: For memory map detail, see Figure 2-3.
7Fh
DS39544A-page 26Preliminary 2001 Microchip Technology Inc.
PIC16C925/926
3.0READING PROGRAM MEMORY
The Program Memory is readable during normal operation over the entire V
addressed through Special Function R egisters ( SFR).
Up to 14-bit numbers can be stored in memory for use
as calibration param eters, serial nu mbers, packe d 7-bit
ASCII, etc. Executing a pro gram m em ory location containing data tha t forms an inval id instructi on result s in a
NOP.
There are five SFRs used to read the program and
memory. These registers are:
• PMCON1
• PMDATA
• PMDATH
• PMADR
• PMADRH
The program memory allows word reads. Program
memory access allows for checksum calculation and
reading calibration t abl es .
DD range. It is indirectly
When interfacing to the program memory block, the
PMDATH:PMDATA registers form a two-byte word,
which holds the 14-bit data for reads. The
PMADRH:PMADR registers form a two-byte word,
which holds the 13-bit address of the location being
accessed. These devices can have from 4K words to
8K words of program memory, with an address range
from 0h to 3FFFh.
The unused upper bits in both the PMDATH and
PMADRH registers are not implemented and read as
“0’s”.
3.1PMADR
The address registers can address up to a maxim um of
8K words of program memory.
When selecting a program address value, the MSByte
of the address is written to the PMADRH register and
the LSByte is written to the PMADR regi ster . The upper
MSbits of PMADRH must always be clear.
3.2PMCON1 Register
PMCON1 is the control register for memory accesses.
The control bit RD initiates read operations. This bit
cannot be cleared, only set , in sof tware. It is cleared in
hardware at the completion of the read operation.
REGISTER 3-1: PMCON1 REGISTER (ADDRESS 10Ch)
R-1U-0U-0U-0U-xU-0U-0R/S-0
r——————RD
bit 7bit 0
bit 7Reserved: Read as ‘1’
bit 6-1Unimplemented: Read as ‘0’
bit 0RD: Read Control bit
1 = Initiates a read, RD is cleared in hardware. The RD bit can only be set (not cleared)
in software.
0 = Does not initiate a read
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
- n = Value at POR reset’1’ = Bit is set’0’ = Bit is clearedx = Bit is unknown
A program memory loca tion may be read by wri ting two
bytes of the address to the PMADR and PMADRH registers, and then setting control bit RD (PMCON1<0>).
Once the read control bit is set, the microcontroller will
data is available in the PMDATA and PMDATH registers after the NOP instruction. Therefore, it can be read
as two bytes in the f ollowin g instruct ions. The PMDATA
and PMDA TH re gisters w ill hold this value unti l another
read operation.
use the next two instruction cy cles to read the data. The
EXAMPLE 3-1:PROGRAM READ
BSFSTATUS, RP1;
BSFSTATUS, RP0; Bank 3
MOVLWMS_PROG_PM_ADDR;
MOVWFPMADRH; MS Byte of Program Address to read
MOVLWLS_PROG_PM_ADDR;
MOVWFPMADR; LS Byte of Program Address to read
BCFSTATUS, RP0; Bank 2
BSFPMCON1, RD; PM Read
;
BSFSTATUS, RP0; Bank 3
;
NOP; Any instructions here are ignored as program
;
MOVFPMDATA, W; W = LS Byte of Program PMDATA
MOVFPMDATH, W; W = MS Byte of Program PMDATA
; First instruction after BSF PMCON1,RD executes normally
; memory is read in second cycle after BSF PMCON1,RD
3.4Operation During Code Protect
If the progra m memory is not co de prot ected, the pro gram memory control can read anywhere within the
program memory.
If the entire program memory is code protected, the
program memory control can re ad anywh ere within the
program memory.
TABLE 3-1:REGISTERS ASSOCIATED WITH PROGRAM MEMORY
AddressNameBit 7Bit 6Bit 5Bit 4B it 3Bit 2Bit 1Bit 0
10ChPMCON1(1)
18ChPMDATA Data Register Low Bytexxxx xxxx uuuu uuuu
18DhPMADRAddress Register Low Bytexxxx xxxx uuuu uuuu
18EhPMDATH——Data Register High Bytexxxx xxxx uuuu uuuu
18FhPMADRH———Address Register High Bytexxxx xxxx uuuu uuuu
Legend: x = unknown, u = unchanged, r = reserved, - = unimplemented, read as '0'.
Shaded cells are not used during FLASH access.
Note 1: This bit always reads as a ‘1’.
——————RD1--- ---0 1--- ---0
If only part of the program memory is code protected,
the program memory control can read the unprotected
segment and cannot read the protected segment. The
protected area cannot be read, because it may be
possible to write a downloading routine into the
unprotected segment.
Value o n:
POR, BOR
Value on
all other
RESETS
DS39544A-page 28Preliminary 2001 Microchip Technology Inc.
Loading...
+ 152 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.