Professional Documents
Culture Documents
In-Circuit Serial Programming (Icsp) Guide: 2003 Microchip Technology Inc
In-Circuit Serial Programming (Icsp) Guide: 2003 Microchip Technology Inc
(ICSP) Guide
Note the following details of the code protection feature on Microchip devices:
Microchip products meet the specification contained in their particular Microchip Data Sheet.
Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip's Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
Microchip is willing to work with the customer who is concerned about the integrity of their code.
Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as unbreakable.
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break microchips code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Trademarks
The Microchip name and logo, the Microchip logo, KEELOQ,
MPLAB, PIC, PICmicro, PICSTART, PRO MATE and
PowerSmart are registered trademarks of Microchip
Technology Incorporated in the U.S.A. and other countries.
FilterLab, microID, MXDEV, MXLAB, PICMASTER, SEEVAL
and The Embedded Control Solutions Company are
registered trademarks of Microchip Technology Incorporated
in the U.S.A.
Accuron, Application Maestro, dsPIC, dsPICDEM,
dsPICDEM.net, ECONOMONITOR, FanSense, FlexROM,
fuzzyLAB, In-Circuit Serial Programming, ICSP, ICEPIC,
microPort, Migratable Memory, MPASM, MPLIB, MPLINK,
MPSIM, PICC, PICkit, PICDEM, PICDEM.net, PowerCal,
PowerInfo, PowerMate, PowerTool, rfLAB, rfPIC, Select
Mode, SmartSensor, SmartShunt, SmartTel and Total
Endurance are trademarks of Microchip Technology
Incorporated in the U.S.A. and other countries.
Serialized Quick Turn 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.
2003, Microchip Technology Incorporated, Printed in the
U.S.A., All Rights Reserved.
Printed on recycled paper.
DS30277D - page ii
Table of Contents
PAGE
SECTION 1
INTRODUCTION
In-Circuit Serial Programming (ICSP) Guide ............................................................................................. 1-1
SECTION 2
TECHNICAL BRIEFS
How to Implement ICSP Using PIC12C5XX OTP MCUs ............................................................................. 2-1
How to Implement ICSP Using PIC16CXXX OTP MCUs ............................................................................. 2-9
How to Implement ICSP Using PIC17CXXX OTP MCUs ........................................................................... 2-15
How to Implement ICSP Using PIC16F8X FLASH MCUs .......................................................................... 2-21
SECTION 3
PROGRAMMING SPECIFICATIONS
In-Circuit Serial Programming for PIC12C5XX OTP MCUs ............................................................................. 3-1
In-Circuit Serial Programming for PIC12C67X and PIC12CE67X OTP MCUs .............................................. 3-15
In-Circuit Serial Programming for PIC14000 OTP MCUs ............................................................................... 3-27
In-Circuit Serial Programming for PIC16C55X OTP MCUs ............................................................................ 3-39
Programming Specifications for PIC16C6XX/7XX/9XX OTP MCUs .............................................................. 3-51
In-Circuit Serial Programming for PIC17C7XX OTP MCUs ........................................................................... 3-75
In-Circuit Serial Programming for PIC18CXXX OTP MCUs ......................................................................... 3-101
PIC16F8X EEPROM Memory Programming Specification .......................................................................... 3-147
PIC16F62X EEPROM Memory Programming Specification ........................................................................ 3-161
PIC16F87X EEPROM Memory Programming Specification ........................................................................ 3-181
SECTION 4
APPLICATION NOTES
In-Circuit Serial Programming (ICSP) of Calibration Parameters
Using a PICmicro Microcontroller ................................................................................................................... 4-1
DS30277D-page iii
NOTES:
DS30277D-page iv
IN-CIRCUIT SERIAL
PROGRAMMING GUIDE
Section 1 Introduction
IN-CIRCUIT SERIAL PROGRAMMING (ICSP) GUIDE ................................................................... 1-1
DS30277D-page 1-i
apPMOTTa-page 1-ii
INTRODUCTION
In-Circuit Serial Programming (ICSP) Guide
WHAT IS IN-CIRCUIT SERIAL
PROGRAMMING (ICSP)?
In-Circuit Serial Programming and ICSP are trademarks of Microchip Technology Inc. SQTP is a service mark of Microchip Technology Inc.
DS30277D-page 1-1
Introduction
In fact, this capability is so important to many of our
customers that Microchip offers a factory programming service called Serialized Quick Turn Programming (SQTPSM), where each PICmicro MCU device is
coded with up to 16 bytes of unique code.
PROGRAMMING TIME
CONSIDERATIONS
Programming time can be significantly different
between OTP and FLASH MCUs. OTP (EPROM) bytes
typically program with pulses in the order of several
hundred microseconds. FLASH, on the other hand,
require several milliseconds or more per byte (or word)
to program.
Figure 1 and Figure 2 below illustrate the programming
time differences between OTP and FLASH MCUs.
Figure 1 shows programming time in an ideal programmer or tester, where the only time spent is actually programming the device. This is only important to illustrate
the minimum time required to program such devices,
where the programmer or the tester is fully optimized.
Figure 2 is a more realistic programming time comparison, where the overhead time for programmer or a
tester is built in. The programmer often requires 3 to 5
times the theoretically minimum programming time.
FIGURE 1:
40
Typical
Typical
FLASH Flash
MCU
MCU
35
30
25
20
15
Microchip
Microchip
OTP
OTPMCU
MCU
10
5
0
0
1K
2K
4K
8K
16K
DS30277D-page 1-2
Introduction
FIGURE 2:
240
220
200
Typical
Typical
Flash
FLASHMCU
MCU
180
160
140
120
100
80
60
Microchip
Microchip
OTP
MCU
OTP MCU
40
20
0
0
1K
2K
4K
8K
16K
Ramifications
Development Tools
Products
Microchip offers the broadest line of ICSP-capable
MCUs:
Technical support
Microchip has been delivering ICSP capable MCUs
since 1992. Many of our customers are using ICSP
capability in full production. Our field and factory application engineers can help you implement ICSP in your
product.
DS30277D-page 1-3
Introduction
NOTES:
DS30277D-page 1-4
IN-CIRCUIT SERIAL
PROGRAMMING GUIDE
Section 2 Technical Briefs
HOW TO IMPLEMENT ICSP USING PIC12C5XX OTP MCUS ........................................................... 2-1
HOW TO IMPLEMENT ICSP USING PIC16CXXX OTP MCUS .......................................................... 2-9
HOW TO IMPLEMENT ICSP USING PIC17CXXX OTP MCUS ........................................................ 2-15
HOW TO IMPLEMENT ICSP USING PIC16F8X FLASH MCUS ....................................................... 2-21
DS30277D-page 2-i
apPMOTTa-page 2-ii
TB017
How to Implement ICSP Using PIC12C5XX OTP MCUs
Author:
Thomas Schmidt
Microchip Technology Inc.
INTRODUCTION
The technical brief describes how to implement in-circuit serial programming (ICSP) using the
PIC12C5XX OTP PICmicro MCU.
Application Circuit
During the initial design phase of the application circuit,
certain considerations have to be taken into account.
Figure 1 shows and typical circuit that addresses the
details to be considered during design. In order to
implement ICSP on your application board you have to
put the following issues into consideration:
1.
FIGURE 1:
2.
3.
4.
5.
VDD VDD
GP3/MCLR/VPP
ICSP Connector
VDD
VSS
GP0
GP1
To application circuit
Isolation circuits
PICmicro, PRO MATE and PICSTART are registered trademarks of Microchip Technology Inc.
In-Circuit Serial Programming and ICSP are trademarks of Microchip Technology Inc.
=OMMP=j=q=fK
Preliminary
apVNMNT_J~=OJN
TB017
Isolation of the GP3/MCLR/VPP Pin from the
Rest of the Circuit
apVNMNT_J~=OJO
Preliminary
=OMMP=j=q=fK
TB017
THE PROGRAMMER
PIC12C5XX MCUs only use serial programming and,
therefore, all programmers supporting these devices
will support the ICSP. One issue with the programmer
is the drive capability. As discussed before, it must be
able to provide the specified rise rates on the ICSP signals and also provide enough current to power the
application circuit. It is recommended that you buffer
the programming signals.
Another point of consideration for the programmer is
what VDD levels are used to verify the memory contents
of the PICmicro MCU. For instance, the PRO MATE II
verifies program memory at the minimum and maximum VDD levels for the specified device and is therefore considered a production quality programmer. On
the other hand, the PICSTART Plus only verifies at 5V
and is for prototyping use only. The PIC12C5XX programming specifications state that the program memory contents should be verified at both the minimum
and maximum VDD levels that the application circuit will
be operating. This implies that the application circuit
must be able to handle the varying VDD voltages.
There are also several third-party programmers that
are available. You should select a programmer based
on the features it has and how it fits into your programming environment. The Microchip Development Systems Ordering Guide (DS30177) provides detailed
information on all our development tools. The Microchip Third Party Guide (DS00104) provides information
on all of our third party development tool developers.
Please consult these two references when selecting a
programmer. Many options exist including serial or parallel PC host connection, stand-alone operation, and
single or gang programmers.
OTHER BENEFITS
ICSP provides several other benefits such as calibration and serialization. If program memory permits, it
would be cheaper and more reliable to store calibration
constants in program memory instead of using an
external serial EEPROM.
PROGRAMMING ENVIRONMENT
The programming environment will affect the type of
programmer used, the programmer cable length, and
the application circuit interface. Some programmers
are well suited for a manual assembly line while others
are desirable for an automated assembly line. A gang
programmer should be chosen for programming multiple MCUs at one time. The physical distance between
the programmer and the application circuit affects the
load capacitance on each of the programming signals.
This will directly affect the drive strength needed to provide the correct signal rise rates and current. Finally,
the application circuit interface to the programmer
depends on the size constraints of the application circuit itself and the assembly line. A simple header can
be used to interface the application circuit to the programmer. This might be more desirable for a manual
assembly line where a technician plugs the
programmer cable into the board.
A different method is the uses spring loaded test pins
(often referred as pogo-pins). The application circuit
has pads on the board for each of the programming signals. Then there is a movable fixture that has pogo pins
=OMMP=j=q=fK
Preliminary
apVNMNT_J~=OJP
TB017
EXAMPLE 1:
MOVWF OSCAL
0X001
GOTO MAIN1
RESET VECTOR
UNPROGRAMMED
0X040
MAIN1
MAIN1 ROUTINE
0X080
UNPROGRAMMED
0X1FF
MOVLW XX
CALIBRATION VALUE
apVNMNT_J~=OJQ
Preliminary
=OMMP=j=q=fK
TB017
EXAMPLE 2:
PROGRAM MEMORY
0X000
MOVWF OSCAL
0X001
0X002
NOP
GOTO MAIN2
RESET VECTOR
UNPROGRAMMED
0X040
MAIN1
MAIN1 ROUTINE
0X080
UNPROGRAMMED
0X10E
MAIN2
MAIN2 ROUTINE
0X136
0X1FF
MOVLW XX
CALIBRATION VALUE
=OMMP=j=q=fK
Preliminary
apVNMNT_J~=OJR
TB017
Since the program memory of the PIC12C5XX devices
is organized in 256 x 12 word pages, placement of such
information as look-up tables and CALL instructions
must be taken into account. For further information,
please refer to application note AN581, Implementing
Long Calls and application note AN556, Implementing
a Table Read.
apVNMNT_J~=OJS
CONCLUSION
Microchip Technology Inc. is committed to supporting
your ICSP needs by providing you with our many years
of experience and expertise in developing in-circuit
system programming solutions. Anyone can create a
reliable in-circuit system programming station by coupling our background with some forethought to the circuit design and programmer selection issues
previously mentioned. Your local Microchip representative is available to answer any questions you have
about the requirements for ICSP.
Preliminary
=OMMP=j=q=fK
VCC
=OMMP=j=q=fK
Vmm_IN
Preliminary
GND_IN
FROM
PROGRAMMER
FROM
PROGRAMMER
GP1_IN
FROM
PROGRAMMER
Vaa_IN
FROM
PROGRAMMER
U1B
7
U1D
14
TLE2144A
10k
R4
TLE2144A
33k
R2
GND_OUT
TO CIRCUIT
R21
100k
12
13
R12
100k
V``
15V
C4
1NF
C1
1NF
GP1_OUT
TO CIRCUIT
100
R19
100
R10
Note:
100
R18
100
R9
R22
5k
Q4
2N2222
VCC
Q3
2N3906
TO CIRCUIT
GP0_OUT
R17
100
R13
5k
Q2
2N2222
VCC
Q1
2N3906
TLE2144A
U1C
8
4 TLE2144A
1 U1A
1
FROM
PROGRAMMER
GP0_IN
D2
6.2V
10
D1
12.7V
R9
100
C6
0.1F
R15
C3
0.1F
R6
Vaa_OUT
TO CIRCUIT
TO CIRCUIT
Vmm_OUT
TB017
apVNMNT_J~=OJT
TB017
NOTES:
apVNMNT_J~=OJU
Preliminary
=OMMP=j=q=fK
TB013
How to Implement ICSP Using PIC16CXXX OTP MCUs
Author:
Application Circuit
Rodger Richey
Microchip Technology Inc.
INTRODUCTION
In-Circuit Serial Programming (ICSP) is a great way
to reduce your inventory overhead and time-to-market
for your product. By assembling your product with a
blank Microchip microcontroller (MCU), you can stock
one design. When an order has been placed, these
units can be programmed with the latest revision of
firmware, tested, and shipped in a very short time. This
method also reduces scrapped inventory due to old
firmware revisions. This type of manufacturing system
can also facilitate quick turnarounds on custom orders
for your product.
Most people would think to use ICSP with PICmicro
OTP MCUs only on an assembly line where the device
is programmed once. However, there is a method by
which an OTP device can be programmed several
times depending on the size of the firmware. This
method, explained later, provides a way to field
upgrade your firmware in a way similar to EEPROM- or
Flash-based devices.
FIGURE 1:
1.
2.
3.
4.
5.
6.
The MCLR/VPP pin is normally connected to an RC circuit. The pull-up resistor is tied to VDD and a capacitor
is tied to ground. This circuit can affect the operation of
ICSP depending on the size of the capacitor. It is, therefore, recommended that the circuit in Figure 1 be used
when an RC is connected to MCLR/VPP. The diode
should be a Schottky-type device. Another issue with
MCLR/VPP is that when the PICmicro MCU device is
programmed, this pin is driven to approximately 13V
and also to ground. Therefore, the application circuit
must be isolated from this voltage provided by the
programmer.
Vdd Vdd
MCLR/Vpp
ICSP Connector
Vdd
Vss
RB7
RB6
To application circuit
Isolation circuits
=OMMP=j=q=fK
Preliminary
apVNMNP_J~=OJV
TB013
Pins RB6 and RB7 are used by the PICmicro MCU for
serial programming. RB6 is the clock line and RB7 is
the data line. RB6 is driven by the programmer. RB7 is
a bidirectional pin that is driven by the programmer
when programming, and driven by the PICmicro MCU
when verifying. These pins must be isolated from the
rest of the application circuit so as not to affect the signals during programming. You must take into consideration the output impedance of the programmer when
isolating RB6 and RB7 from the rest of the circuit. This
isolation circuit must account for RB6 being an input on
the PICmicro MCU, and for RB7 being bidirectional
(can be driven by both the PICmicro MCU and the programmer). For instance, PRO MATE II has an output
impedance of 1k. If the design permits, these pins
should not be used by the application. This is not the
case with most applications so it is recommended that
the designer evaluate whether these signals need to be
buffered. As a designer, you must consider what type
of circuitry is connected to RB6 and RB7 and then
make a decision on how to isolate these pins. Figure 1
does not show any circuitry to isolate RB6 and RB7 on
the application circuit because this is very application
dependent.
The total capacitance on the programming pins affects
the rise rates of these signals as they are driven out of
the programmer. Typical circuits use several hundred
microfarads of capacitance on VDD which helps to
dampen noise and ripple. However, this capacitance
requires a fairly strong driver in the programmer to
meet the rise rate timings for VDD. Most programmers
are designed to simply program the PICmicro MCU
itself and dont have strong enough drivers to power the
application circuit. One solution is to use a driver board
between the programmer and the application circuit.
The driver board requires a separate power supply that
is capable of driving the VPP and VDD pins with the
correct rise rates and should also provide enough current to power the application circuit. RB6 and RB7 are
not buffered on this schematic but may require buffering depending upon the application. A sample driver
board schematic is shown in Appendix A.
Note:
apVNMNP_J~=OJNM
Programmer
The second consideration is the programmer.
PIC16CXXX MCUs only use serial programming and
therefore all programmers supporting these devices
will support ICSP. One issue with the programmer is the
drive capability. As discussed before, it must be able to
provide the specified rise rates on the ICSP signals and
also provide enough current to power the application
circuit. Appendix A shows an example driver board.
This driver schematic does not show any buffer circuitry for RB6 and RB7. It is recommended that an
evaluation be performed to determine if buffering is
required. Another issue with the programmer is what
VDD levels are used to verify the memory contents of
the PICmicro MCU. For instance, the PRO MATE II verifies program memory at the minimum and maximum
VDD levels for the specified device and is therefore considered a production quality programmer. On the other
hand, the PICSTART Plus only verifies at 5V and is for
prototyping use only. The Microchip programming
specifications state that the program memory contents
should be verified at both the minimum and maximum
VDD levels that the application circuit will be operating.
This implies that the application circuit must be able to
handle the varying VDD voltages.
Preliminary
=OMMP=j=q=fK
TB013
There are also several third party programmers that are
available. You should select a programmer based on
the features it has and how it fits into your programming
environment. The Microchip Development Systems
Ordering Guide (DS30177) provides detailed information on all our development tools. The Microchip Third
Party Guide (DS00104) provides information on all of
our third party tool developers. Please consult these
two references when selecting a programmer. Many
options exist including serial or parallel PC host connection, stand-alone operation, and single or gang programmers. Some of the third party developers include
Advanced Transdata Corporation, BP Microsystems,
Data I/O, Emulation Technology and Logical Devices.
Programming Environment
The programming environment will affect the type of
programmer used, the programmer cable length, and
the application circuit interface. Some programmers
are well suited for a manual assembly line while others
are desirable for an automated assembly line. You may
want to choose a gang programmer to program multiple systems at a time.
The physical distance between the programmer and
the application circuit affects the load capacitance on
each of the programming signals. This will directly
affect the drive strength needed to provide the correct
signal rise rates and current. This programming cable
must also be as short as possible and properly
terminated and shielded, or the programming signals
may be corrupted by ringing or noise.
Finally, the application circuit interface to the programmer depends on the size constraints of the application
circuit itself and the assembly line. A simple header can
be used to interface the application circuit to the programmer. This might be more desirable for a manual
assembly line where a technician plugs the
programmer cable into the board. A different method is
the use of spring loaded test pins (commonly referred
to as pogo pins). The application circuit has pads on the
board for each of the programming signals. Then there
is a fixture that has pogo pins in the same configuration
as the pads on the board. The application circuit or fixture is moved into position such that the pogo pins
come into contact with the board. This method might be
more suitable for an automated assembly line.
After taking into consideration the issues with the application circuit, the programmer, and the programming
environment, anyone can build a high quality, reliable
manufacturing line based on ICSP.
=OMMP=j=q=fK
Other Benefits
ICSP provides other benefits, such as calibration and
serialization. If program memory permits, it would be
cheaper and more reliable to store calibration constants in program memory instead of using an external
serial EEPROM. For example, your system has a thermistor which can vary from one system to another.
Storing some calibration information in a table format
allows the microcontroller to compensate in software
for external component tolerances. System cost can be
reduced without affecting the required performance of
the system by using software calibration techniques.
But how does this relate to ICSP? The PICmicro MCU
has already been programmed with firmware that performs a calibration cycle. The calibration data is transferred to a calibration fixture. When all calibration data
has been transferred, the fixture places the PICmicro
MCU in programming mode and programs the
PICmicro MCU with the calibration data. Application
note AN656, In-Circuit Serial Programming of Calibration Parameters Using a PICmicro Microcontroller,
shows exactly how to implement this type of calibration
data programming.
The other benefit of ICSP is serialization. Each individual system can be programmed with a unique or random serial number. One such application of a unique
serial number would be for security systems. A typical
system might use DIP switches to set the serial number. Instead, this number can be burned into program
memory, thus reducing the overall system cost and
lowering the risk of tampering.
Preliminary
apVNMNP_J~=OJNN
TB013
EXAMPLE 1:
apVNMNP_J~=OJNO
Preliminary
=OMMP=j=q=fK
TB013
The example shows that to program the PICmicro MCU
a second time the memory location 0x0000, originally
goto Main (0x2808), is reprogrammed to all 0s which
happens to be a nop instruction. This location cannot
be reprogrammed to the new opcode (0x2860)
because the bits that are 0s cannot be reprogrammed
to 1s, only bits that are 1s can be reprogrammed to
0s. The next memory location 0x0001 was originally
blank (all 1s) and now becomes a goto Main
(0x2860). When a reset condition occurs, the PICmicro
MCU executes the instruction at location 0x0000 which
is the nop, a completely benign instruction, and then
executes the goto Main to start the execution of code.
The example also shows that all program memory locations after 0x005A are blank in the original program so
that the second time the PICmicro MCU is programmed, the revised code can be programmed at
these locations. The same descriptions can be given
for the interrupt vector at location 0x0004.
CONCLUSION
Microchip Technology Inc. is committed to supporting
your ICSP needs by providing you with our many years
of experience and expertise in developing ICSP
solutions. Anyone can create a reliable ICSP programming station by coupling our background with some
forethought to the circuit design and programmer
selection issues previously mentioned. Your local
Microchip representative is available to answer any
questions you have about the requirements for ICSP.
movlw <page>
movwf PCLATH
goto ISR
=OMMP=j=q=fK
Preliminary
apVNMNP_J~=OJNP
VCC
apVNMNP_J~=OJNQ
Vmm_IN
Preliminary
GND_IN
FROM
PROGRAMMER
FROM
PROGRAMMER
RB6_IN
FROM
PROGRAMMER
Vaa_IN
FROM
PROGRAMMER
U1D
14
TLE2144A
10k
R4
TLE2144A
U1B
7
GND_OUT
TO CIRCUIT
R21
100k
12
13
R12
100k
33k
R2
C4
1NF
C1
1NF
RB6_OUT
TO CIRCUIT
100
R19
100
R10
Note:
100
R18
100
R9
R22
5k
Q4
2N2222
VCC
Q3
2N3906
TO CIRCUIT
RB7_OUT
R17
100
R13
5k
Q2
2N2222
VCC
Q1
2N3906
TLE2144A
U1C
8
4 TLE2144A
1 U1A
1
FROM
PROGRAMMER
RB7_IN
D2
6.2V
10
D1
12.7V
R9
100
C6
0.1F
R15
C3
0.1F
R6
Vaa_OUT
TO CIRCUIT
TO CIRCUIT
Vmm_OUT
APPENDIX A:
V``
15V
TB013
SAMPLE DRIVER BOARD SCHEMATIC
=OMMP=j=q=fK
TB015
How to Implement ICSP Using PIC17CXXX OTP MCUs
Author:
Implementation
Stan DSouza
Microchip Technology Inc.
INTRODUCTION
PIC17CXXX microcontroller (MCU) devices can be
serially programmed using an RS-232 or equivalent
serial interface. As shown in Figure 1, using just three
pins, the PIC17CXXX can be connected to an external
interface and programmed. In-Circuit Serial Programming (ICSP) allows for a greater flexibility in an application as well as a faster time to market for the user's
product.
This technical brief will demonstrate the practical
aspects associated with ICSP using the PIC17CXXX. It
will also demonstrate some key capabilities of OTP
devices when used in conjunction with ICSP.
FIGURE 1:
SYSTEM BOARD
I/O
Data
Memory
13V Enable
Program
Memory
VPP
13V
Data H:Data L
Data L
Data H
Boot
Code
TX
USART
RX
Level Converter
In-Circuit
Programming
Connector
PRO MATE and PICSTART are registered trademarks and ICSP is a trademark of Microchip Technology Inc.
Preliminary
DS91015B-page 2-15
TB015
FIGURE 2:
+5V
VDD
7805
2N3905
13V
MCLR
RA2
Programming Header
+5V
SERIAL PORT RX
TX
RX
MAX232
SERIAL PORT TX
VSS
a long write operation, which disables further code execution. Code execution is resumed when an internal
interrupt occurs. This delay ensures that the programming pulse width of 1 ms (max.) is met. Once a location
is written, RA2 is driven high to disable further writes
and a verify operation is done using the Table read
instruction. If the result is good, an acknowledge is sent
to the host. This process is repeated till all desired locations are programmed.
In normal operation, when the ICSP header is not connected, the boot code would still execute and the
PIC17CXXX would send out a request to the host.
However it would not get a response from the host, so
it would abort the boot code and start normal code
execution.
FIGURE 3:
DS91015B-page 2-16
Preliminary
0x700
Boot Code
0x7FF
Configure USART
and send request
Received Hosts
ACK?
No
Time-out complete?
Yes
Yes
Prepare to receive
ICSP data
No
No
Start Code
Execution
Received Address
and Data info?
Yes
Do Table Write
operation
No
Interrupt?
Yes
Read Program
Location
Program location
verified correctly?
No
Signal Programming
Error
Yes
END
No
Last Data/Address
sequence?
Yes
Preliminary
DS91015B-page 2-17
TB015
USING THE ICSP FEATURE ON
PIC17CXXX OTP DEVICES
FIGURE 5:
2.
~
~
~
~
~
~
~
~
0x0000
0x0000
Parameter 1.2
0xFFFF
0x0000
Parameter 1.3
0xFFFF
0xFFFF
0xFFFF
0xFFFF
0xFFFF
0x0000
0x0000
Parameter 2.1
DS91015B-page 2-18
~
~
~
~
Parameter 1.1
~
~
Field Calibrate #2
Field Calibrate #1
0xFFFF
Parameter 2.2
0xFFFF
0xFFFF
0xFFFF
0xFFFF
~
~
~
~
0x0000
Parameter 2.3
0xFFFF
~
~
Preliminary
~
~
~
~
4.
5.
FIGURE 6:
Production Program
Goto Main2
0xFFFF
~~
~~
Main2
Boot
~~
~~
~~
~~
Goto Main
~~
~~
~~
Main1
Main1
Boot
0x0000
Main
Goto Main1
0xFFFF
0xFFFF
~~
Main
0x0000
Goto Boot
0x0000
Goto Boot
~~
~~
3.
~~
2.
~~
1.
Goto Main
Preliminary
DS91015B-page 2-19
TB015
NOTES:
DS91015B-page 2-20
Preliminary
TB016
How to Implement ICSP Using PIC16F8X FLASH MCUs
Author:
Application Circuit
Rodger Richey
Microchip Technology Inc.
INTRODUCTION
In-Circuit Serial Programming (ICSP) with
PICmicro FLASH microcontrollers (MCU) is not only a
great way to reduce your inventory overhead and timeto-market for your product, but also to easily provide
field upgrades of firmware. By assembling your product
with a Microchip FLASH-based MCU, you can stock
the shelf with one system. When an order has been
placed, these units can be programmed with the latest
revision of firmware, tested, and shipped in a very short
time. This type of manufacturing system can also facilitate quick turnarounds on custom orders for your product. You dont have to worry about scrapped inventory
because of the FLASH-based program memory. This
gives you the advantage of upgrading the firmware at
any time to fix those features that pop up from time to
time.
1.
2.
3.
4.
5.
6.
The MCLR/VPP pin is normally connected to an RC circuit. The pull-up resistor is tied to VDD and a capacitor
is tied to ground. This circuit can affect the operation of
ICSP depending on the size of the capacitor. It is, therefore, recommended that the circuit in Figure 1 be used
when an RC is connected to MCLR/VPP. The diode
should be a Schottky-type device. Another issue with
MCLR/VPP is that when the PICmicro MCU device is
programmed, this pin is driven to approximately 13V
and also to ground. Therefore, the application circuit
must be isolated from this voltage provided by the
programmer.
FIGURE 1:
Vdd
Vdd
MCLR/smm
ICSP Connector
Vdd
Vss
RB7
RB6
To application circuit
Isolation circuits
PICmicro, PRO MATE, and PICSTART are registered trademarks of Microchip Technology Inc.
In-Circuit Serial Programming and ICSP are trademarks of Microchip Technology Inc.
=OMMP=j=q=fK
apVNMNS_J~=OJON
TB016
Pins RB6 and RB7 are used by the PICmicro MCU for
serial programming. RB6 is the clock line and RB7 is
the data line. RB6 is driven by the programmer. RB7 is
a bidirectional pin that is driven by the programmer
when programming, and driven by the PICmicro MCU
when verifying. These pins must be isolated from the
rest of the application circuit so as not to affect the signals during programming. You must take into consideration the output impedance of the programmer when
isolating RB6 and RB7 from the rest of the circuit. This
isolation circuit must account for RB6 being an input on
the PICmicro MCU and for RB7 being bidirectional (can
be driven by both the PICmicro MCU and the programmer). For instance, PRO MATE II has an output
impedance of 1k. If the design permits, these pins
should not be used by the application. This is not the
case with most applications so it is recommended that
the designer evaluate whether these signals need to be
buffered. As a designer, you must consider what type
of circuitry is connected to RB6 and RB7 and then
make a decision on how to isolate these pins. Figure 1
does not show any circuitry to isolate RB6 and RB7 on
the application circuit because this is very application
dependent.
The total capacitance on the programming pins affects
the rise rates of these signals as they are driven out of
the programmer. Typical circuits use several hundred
microfarads of capacitance on VDD which helps to
dampen noise and ripple. However, this capacitance
requires a fairly strong driver in the programmer to
meet the rise rate timings for VDD. Most programmers
are designed to simply program the PICmicro MCU
itself and dont have strong enough drivers to power the
application circuit. One solution is to use a driver board
between the programmer and the application circuit.
The driver board requires a separate power supply that
is capable of driving the VPP and VDD pins with the correct rise rates and should also provide enough current
to power the application circuit. RB6 and RB7 are not
buffered on this schematic but may require buffering
depending upon the application. A sample driver board
schematic is shown in Appendix A.
Note:
apVNMNS_J~=OJOO
Programmer
The second consideration is the programmer.
PIC16F8X MCUs only use serial programming and
therefore all programmers supporting these devices
will support ICSP. One issue with the programmer is the
drive capability. As discussed before, it must be able to
provide the specified rise rates on the ICSP signals and
also provide enough current to power the application
circuit. Appendix A shows an example driver board.
This driver schematic does not show any buffer circuitry for RB6 and RB7. It is recommended that an
evaluation be performed to determine if buffering is
required. Another issue with the programmer is what
VDD levels are used to verify the memory contents of
the PICmicro MCU. For instance, the PRO MATE II verifies program memory at the minimum and maximum
VDD levels for the specified device and is therefore considered a production quality programmer. On the other
hand, the PICSTART Plus only verifies at 5V and is for
prototyping use only. The Microchip programming
specifications state that the program memory contents
should be verified at both the minimum and maximum
VDD levels that the application circuit will be operating.
This implies that the application circuit must be able to
handle the varying VDD voltages.
=OMMP=j=q=fK
TB016
There are also several third party programmers that are
available. You should select a programmer based on
the features it has and how it fits into your programming
environment. The Microchip Development Systems
Ordering Guide (DS30177) provides detailed information on all our development tools. The Microchip Third
Party Guide (DS00104) provides information on all of
our third party tool developers. Please consult these
two references when selecting a programmer. Many
options exist including serial or parallel PC host connection, stand-alone operation, and single or gang programmers. Some of the third party developers include
Advanced Transdata Corporation, BP Microsystems,
Data I/O, Emulation Technology and Logical Devices.
Programming Environment
The programming environment will affect the type of
programmer used, the programmer cable length, and
the application circuit interface. Some programmers
are well suited for a manual assembly line while others
are desirable for an automated assembly line. You may
want to choose a gang programmer to program multiple systems at a time.
The physical distance between the programmer and
the application circuit affects the load capacitance on
each of the programming signals. This will directly
affect the drive strength needed to provide the correct
signal rise rates and current. This programming cable
must also be as short as possible and properly terminated and shielded or the programming signals may be
corrupted by ringing or noise.
Finally, the application circuit interface to the programmer depends on the size constraints of the application
circuit itself and the assembly line. A simple header can
be used to interface the application circuit to the programmer. This might be more desirable for a manual
assembly line where a technician plugs the
programmer cable into the board. A different method is
the use of spring loaded test pins (commonly referred
to as pogo pins). The application circuit has pads on the
board for each of the programming signals. Then there
is a fixture that has pogo pins in the same configuration
as the pads on the board. The application circuit or fixture is moved into position such that the pogo pins
come into contact with the board. This method might be
more suitable for an automated assembly line.
After taking into consideration the issues with the application circuit, the programmer, and the programming
environment, anyone can build a high quality, reliable
manufacturing line based on ICSP.
Other Benefits
ICSP provides other benefits, such as calibration and
serialization. If program memory permits, it would be
cheaper and more reliable to store calibration constants in program memory instead of using an external
serial EEPROM. For example, your system has a thermistor which can vary from one system to another.
Storing some calibration information in a table format
allows the microcontroller to compensate in software
for external component tolerances. System cost can be
reduced without affecting the required performance of
the system by using software calibration techniques.
But how does this relate to ICSP? The PICmicro MCU
has already been programmed with firmware that performs a calibration cycle. The calibration data is transferred to a calibration fixture. When all calibration data
has been transferred, the fixture places the PICmicro
MCU in programming mode and programs the
PICmicro MCU with the calibration data. Application
note AN656, In-Circuit Serial Programming of Calibration Parameters Using a PICmicro Microcontroller,
shows exactly how to implement this type of calibration
data programming.
The other benefit of ICSP is serialization. Each individual system can be programmed with a unique or random serial number. One such application of a unique
serial number would be for security systems. A typical
system might use DIP switches to set the serial number. Instead, this number can be burned into program
memory thus reducing the overall system cost and lowering the risk of tampering.
CONCLUSION
Microchip Technology Inc. is committed to supporting
your ICSP needs by providing you with our many years
of experience and expertise in developing ICSP
solutions. Anyone can create a reliable ICSP programming station by coupling our background with some
forethought to the circuit design and programmer
selection issues previously mentioned. Your local
Microchip representative is available to answer any
questions you have about the requirements for ICSP.
=OMMP=j=q=fK
apVNMNS_J~=OJOP
Vcc
apVNMNS_J~=OJOQ
smm_IN
GND_IN
FROM
PROGRAMMER
FROM
PROGRAMMER
RB6_IN
FROM
PROGRAMMER
Vdd_IN
FROM
PROGRAMMER
U1D
14
TLE2144A
10k
R4
TLE2144A
U1B
7
GND_OUT
TO CIRCUIT
R21
100k
12
13
R12
100k
33k
R2
C4
1NF
C1
1NF
RB6_OUT
TO CIRCUIT
100
R19
100
R10
Note:
100
R18
100
R9
TLE2144A
U1C
8
4 TLE2144A
1 U1A
1
R22
5k
Q4
2N2222
Vcc
Q3
2N3906
To Circuit
RB7_OUT
R17
100
R13
5k
Q2
2N2222
Vcc
Q1
2N3906
from
programmer
RB7_IN
D2
6.2V
10
D1
12.7V
R9
100
C6
0.1mF
R15
C3
0.1mF
R6
Vaa_OUT
TO CIRCUIT
TO CIRCUIT
Vmm_OUT
APPENDIX A:
Vcc
15V
TB016
SAMPLE DRIVER BOARD SCHEMATIC
=OMMP=j=q=fK
IN-CIRCUIT SERIAL
PROGRAMMING GUIDE
Section 3 Programming Specifications
IN-CIRCUIT SERIAL PROGRAMMING FOR PIC12C5XX OTP MCUs .................................................. 3-1
IN-CIRCUIT SERIAL PROGRAMMING FOR PIC12C67X AND PIC12CE67X OTP MCUs ................. 3-15
IN-CIRCUIT SERIAL PROGRAMMING FOR PIC14000 OTP MCUs ................................................... 3-27
IN-CIRCUIT SERIAL PROGRAMMING FOR PIC16C55X OTP MCUs ................................................ 3-39
IN-CIRCUIT SERIAL PROGRAMMING FOR PIC16C6XX/7XX/9XX OTP MCUs ................................ 3-51
IN-CIRCUIT SERIAL PROGRAMMING FOR PIC17C7XX OTP MCUs ................................................ 3-71
IN-CIRCUIT SERIAL PROGRAMMING FOR PIC18CXXX OTP MCUs ................................................ 3-97
IN-CIRCUIT SERIAL PROGRAMMING FOR PIC16F62X FLASH MCUs .......................................... 3-135
IN-CIRCUIT SERIAL PROGRAMMING FOR PIC16F8X FLASH MCUs ............................................ 3-149
IN-CIRCUIT SERIAL PROGRAMMING FOR PIC16F8XX FLASH MCUs .......................................... 3-165
DS30277D-page 3-i
apPMOTTa-page 3-ii
PIC12C5XX
In-Circuit Serial Programming for PIC12C5XX OTP MCUs
This document includes the programming
specifications for the following devices:
Hardware Requirements
1.2
VSS
GP0
GP1
GP2/T0CKI
GP5/OSC1/CLKIN
GP4/OSC2/CLKOUT
GP3/j`io/smm
1
2
3
4
5
6
7
8
9
18
17
16
15
14
13
12
11
10
VSS
GP0
GP1
GP2/T0CKI
XTAL
LF
NC
VSSRF
ANT1
20
19
18
17
16
15
14
13
12
11
VSS
GP0
GP1
GP2/T0CKI
FSKOUT
DATAFSK
LF
NC
VSSRF
ANT1
PROGRAMMING THE
PIC12C5XX
1.1
saa
rfPIC12C509AF
1.0
PIC12CE518
PIC12CE519
rfPIC12C509AG
PIC12C508
PIC12C508A
PIC12C509
PIC12C509A
rfPIC12C509AG
rfPIC12C509AF
PDIP, SOIC, JW
PIC12C5XX
PIC12C5XXA
PIC12CE5XXA
Pin Diagram
Programming Mode
CERDIP, SOIC
VDD
GP5/OSC1/CLKIN
GP4/OSC2
GP3/MCLR/VPP
RFENIN
CLKOUT
PS/DATAASK
VDDRF
ANT2
CERDIP, SSOP
VDD
GP5/OSC1/CLKIN
GP4/OSC2
GP3/MCLR/VPP
XTAL
RFENIN
CLKOUT
PS/DATAASK
VDDRF
ANT2
1
2
3
4
5
6
7
8
9
10
DS30557G-page 3-1
PIC12C5XX
2.0
5.
6.
2.1.2
SYSTEM REQUIREMENTS
If the program counter has reached the last user program location and is incremented again, the on-chip
special EPROM area will be addressed. (See Figure 22 to determine where the special EPROM area is
located for the various PIC12C5XX devices.)
2.1
Programming Method
The programming technique is described in the following section. It is designed to ensure good programming
margins. It does, however, require a variable power
supply for VCC.
2.1.1
Note:
a)
b)
3.
4.
DS30557G-page 3-2
2.1.3
Any programmer not meeting the programmable VDD requirement and the verify at
VDDMAX and VDDMIN requirement, may
only be classified as a prototype or
development programmer, but not a
production programmer.
SOFTWARE REQUIREMENTS
2.2
Pulse width.
Maximum number of pulses, present limit 8.
Number of over-programming pulses: should be
= (A N) + B, where N = number of pulses
required in regular programming. In our current
algorithm A = 11, B = 0.
PIC12C5XX
FIGURE 2-1:
No
Pass?
Yes
Program 1 Location
@ VPP = 13.0V to 13.25V
VDD = VDDP
No
Pass?
No
N > 8?
N=N+1
(N = # of program pulses)
Yes
Increment PC to point to
next location, N = 0
No
All
locations
done?
Yes
No
Pass?
Yes
Verify all locations
VDD
max.
@VDD
VDD= =
VDDMAX
No
Pass?
Yes
Now program
Configuration Word
Done
DS30557G-page 3-3
PIC12C5XX
FIGURE 2-2:
NNN
Bit Number
TTT
ID0
TTT + 1
0
0
0
0
ID1
ID2
ID3
TTT + 2
TTT + 3
TTT + 3F
(FFF)
NNN Highest normal EPROM memory address. NNN = 0x1FF for PIC12C508/CE518.
NNN = 0x3FF for PIC12C509/CE519.
Note that some versions will have an oscillator calibration value programmed at NNN.
TTT Start address of special EPROM area and ID locations.
DS30557G-page 3-4
PIC12C5XX
2.3
2.3.1
EXAMPLE 2-1:
0000
0000
0000
0000
0000
0000
0000
0000
1101
0001
1110
0010
2.4
All other locations in PICmicro MCU configuration memory are reserved and
should not be programmed.
Program/Verify Mode
DS30557G-page 3-5
PIC12C5XX
2.4.1
PROGRAM/VERIFY OPERATION
The GP1 pin is used as a clock input pin, and the GP0
pin is used for entering command bits and data input/
output during serial operation. To input a command, the
clock pin (GP1) is cycled six times. Each command bit
is latched on the falling edge of the clock with the Least
Significant bit (LSb) of the command being input first.
The data on pin GP0 is required to have a minimum
setup and hold time (see AC/DC specs), with respect to
the falling edge of the clock. Commands that have data
associated with them (read and load) are specified to
have a minimum delay of 1 s between the command
and the data. After this delay, the clock pin is cycled 16
times with the first cycle being a START bit and the last
cycle being a STOP bit. Data is also input and output
LSb first. Therefore, during a read operation, the LSb
will be transmitted onto pin GP0 on the rising edge of
the second cycle, and during a load operation, the LSb
will be latched on the falling edge of the second cycle.
A minimum 1 s delay is also specified between consecutive commands.
TABLE 2-1:
COMMAND MAPPING
Command
Data
Load Data
0, data(14), 0
Read Data
0, data(14), 0
Increment Address
Begin programming
End Programming
Note:
DS30557G-page 3-6
PIC12C5XX
2.4.1.1
Load Data
2.4.1.2
Read Data
2.4.1.3
Increment Address
2.4.1.4
2.5
Begin Programming
2.4.1.5
End Programming
After receiving this command, the chip stops programming the memory (configuration program memory or
user program memory) that it was programming at the
time.
DS30557G-page 3-7
PIC12C5XX
3.0
CONFIGURATION WORD
The PIC12C5XX family members have several configuration bits. These bits can be programmed (reads '0'),
or left unprogrammed (reads '1'), to select various
device configurations. Figure 3-1 provides an overview
of configuration bits.
FIGURE 3-1:
Bit
Number:
PIC12C5XX
11
10
MCLRE
CP
=3:
=2:
DS30557G-page 3-8
PIC12C5XX
4.0
CODE PROTECTION
The program code written into the EPROM can be protected by writing to the CP bit of the configuration word.
4.1
To allow portability of code, the programmer is required to read the configuration word and ID locations from the HEX
file when loading the HEX file. If configuration word information was not present in the HEX file, then a simple warning
message may be issued. Similarly, while saving a HEX file, configuration word and ID information must be included.
An option to not include this information may be provided.
Microchip Technology Inc. feels strongly that this feature is important for the benefit of the end customer.
TABLE 4-1:
CODE PROTECTION
PIC12C508
To code protect:
(CP enable pattern: XXXXXXXX0XXX)
Program Memory Segment
[0x00:0x3F]
[0x40:0x1FF]
PIC12C508A
To code protect:
(CP enable pattern: XXXXXXXX0XXX)
Program Memory Segment
[0x00:0x3F]
[0x40:0x1FE]
PIC12C509
To code protect:
(CP enable pattern: XXXXXXXX0XXX)
Program Memory Segment
[0x00:0x3F]
[0x40:0x3FF]
DS30557G-page 3-9
PIC12C5XX
PIC12C509A
To code protect:
(CP enable pattern: XXXXXXXX0XXX)
Program Memory Segment
[0x00:0x3F]
[0x40:0x3FE]
PIC12CE518
To code protect:
(CP enable pattern: XXXXXXXX0XXX)
Program Memory Segment
[0x00:0x3F]
[0x40:0x1FE]
PIC12CE519
To code protect:
(CP enable pattern: XXXXXXXX0XXX)
Program Memory Segment
[0x00:0x3F]
[0x40:0x3FF]
DS30557G-page 3-10
PIC12C5XX
4.2
4.2.1
Checksum
CHECKSUM CALCULATIONS
TABLE 4-2:
CHECKSUM COMPUTATION
Code
Protect
Checksum*
Blank
Value
0x723 at
0 and Max
Address
PIC12C508
OFF
ON
EE20
EDF7
DC68
D363
PIC12C508A
OFF
ON
EE20
EDF7
DC68
D363
PIC12C509
OFF
ON
EC20
EBF7
DA68
D163
PIC12C509A
OFF
ON
EC20
EBF7
DA68
D163
PIC12CE518
OFF
ON
EE20
EDF7
DC68
D363
PIC12CE519
OFF
ON
EC20
EBF7
DA68
D163
rfPIC12C509AG
OFF
ON
EC20
EBF7
DA68
D163
rfPIC12C509AF
OFF
ON
EC20
EBF7
DA68
D163
Device
DS30557G-page 3-11
PIC12C5XX
5.0
TABLE 5-1:
AC/DC CHARACTERISTICS
TIMING REQUIREMENTS FOR PROGRAM/VERIFY MODE
Sym.
Characteristic
Min.
Typ.
Max.
Units
4.75
5.0
5.25
20
mA
Conditions
General
PD1
PD2
IDDP
PD3
VDDMIN
VDDMAX
(Note 1)
PD4
12.75
13.25
(Note 2)
PD5
VDD + 4.0
13.5
PD6
IPP
PD9
VIH1
0.8 VDD
PD8
VIL1
0.2 VDD
50
mA
TR
8.0
P2
Tf
8.0
P3
100
P4
100
ns
P5
1.0
P6
1.0
P7
200
ns
P8
ns
Note 1: Program must be verified at the minimum and maximum VDD limits for the part.
2: VIHH must be greater than VDD + 4.5V to stay in Programming/Verify mode.
DS30557G-page 3-12
PIC12C5XX
FIGURE 5-1:
VIHH
MCLR/VPP
P8
GP1
(Clock)
100ns
1
GP0
(Data)
P6
100ns
0
1s min. 1
15
0
P5
P3
P3
1s min.
P4
P4
}
}
}
}
100ns
min.
100ns
min.
Program/Verify Mode
RESET
FIGURE 5-2:
VIHH
MCLR/VPP
P8
GP1
(Clock)
GP0
(Data)
100ns
1
P6
0
P3
100ns
1
P4
1s min. 1
15
P7
P5
1s min.
}
}
100ns
min.
Program/Verify Mode
RESET
FIGURE 5-3:
MCLR/VPP
GP0
Input
GP0 = Output
GP1
(Clock)
GP0
(Data)
P6
1s min.
Next Command
N
P5
P3 P4
1s min.
100ns
min
RESET
Program/Verify Mode
DS30557G-page 3-13
PIC12C5XX
NOTES:
DS30557G-page 3-14
1.0
PROGRAMMING THE
PIC12C67X AND PIC12CE67X
The PIC12C67X and PIC12CE67X can be programmed using a serial method. In Serial mode, the
PIC12C67X and PIC12CE67X can be programmed
while in the users system. This allows for increased
design flexibility.
1.1
PDIP, SOIC, JW
VDD
GP5/OSC1/CLKIN
GP4/OSC2/AN3/
CLKOUT
GP3/MCLR/VPP
3
4
VSS
GP0/AN0
GP1/AN1/VREF
GP2/T0CKI/
AN2/INT
PIC12CE67X
PIC12C671
PIC12C672
PIC12CE673
PIC12CE674
PIC12C67X
Pin Diagrams:
VSS
GP0/AN0
GP1/AN1/VREF
GP2/T0CKI/
AN2/INT
PDIP, JW
VDD
GP5/OSC1/CLKIN
GP4/OSC2/AN3/
CLKOUT
GP3/MCLR/VPP
3
4
Hardware Requirements
The PIC12C67X and PIC12CE67X require two programmable power supplies, one for VDD (2.0V to 6.0V
recommended) and one for VPP (12V to 14V). Both
supplies should have a minimum resolution of 0.25V.
1.2
Programming Mode
DS40175C-page 3-15
2.1
TABLE 2-1:
IMPLEMENTATION OF
PROGRAM MEMORY IN THE
PIC12C67X
Device
PIC12C671/
PIC12CE673
PIC12C672/
PIC12CE674
When the PC reaches the last location of the implemented program memory, it will wrap around and
address a location within the physically implemented
memory (see Figure 2-1).
In Programming mode, the program memory space
extends from 0x0000 to 0x3FFF, with the first half
(0x0000-0x1FFF) being user program memory and the
second half (0x2000-0x3FFF) being configuration
memory. The PC will increment from 0x0000 to 0x1FFF
and wrap to 0x000 or 0x2000 to 0x3FFF and wrap
around to 0x2000 (not to 0x0000). Once in configuration memory, the highest bit of the PC stays a '1', thus
always pointing to the configuration memory. The only
way to point to user program memory is to reset the
part and reenter Program/Verify mode, as described in
Section 2.2.
DS40175C-page 3-16
2000
ID Location
2001
ID Location
2002
ID Location
2003
ID Location
BFF
C00
2004
Reserved
FFF
1000
2005
Reserved
2006
Reserved
1KW
2KW
Implemented
Implemented
1FF
3FF
400
7FF
800
Implemented
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
2100
3FFF
DS40175C-page 3-17
Program/Verify Mode
2.2.1
PROGRAM/VERIFY OPERATION
The GP1 pin is used as a clock input pin, and the GP0
pin is used for entering command bits and data input/
output during serial operation. To input a command, the
clock pin (GP1) is cycled six times. Each command bit
is latched on the falling edge of the clock with the least
significant bit (LSb) of the command being input first.
The data on pin GP0 is required to have a minimum
setup and hold time (see AC/DC specs), with respect to
the falling edge of the clock. Commands that have data
associated with them (read and load) are specified to
have a minimum delay of 1s between the command
and the data. After this delay, the clock pin is cycled 16
times with the first cycle being a START bit and the last
cycle being a STOP bit. Data is also input and output
LSb first. Therefore, during a read operation, the LSb
will be transmitted onto pin GP0 on the rising edge of
the second cycle, and during a load operation, the LSb
will be latched on the falling edge of the second cycle.
A minimum 1s delay is also specified between consecutive commands.
2.2.1.1
Load Configuration
TABLE 2-2:
COMMAND MAPPING
Command
Data
Load Configuration
0, data(14), 0
Load Data
0, data(14), 0
Read Data
0, data(14), 0
Increment Address
Begin programming
=====
End Programming
=====
DS40175C-page 3-18
N=0
No
N > 25
Program Cycle
Read Data
Command
N=N+1
N = # of Program Cycles
No
Increment Address
Command
Data Correct?
Yes
Program Cycle
Apply 3N Additional
Program Cycles
No
Load Data
Command
Begin Programming
Command
Yes
Verify all Locations
@ VDDMIN*
VPP = VIHH2
Wait 100 s
No
Data Correct?
Report Verify
@ VDDMIN Error
End Programming
Command
Yes
Verify all Locations
@ VDDMAX
VPP = VIHH2
No
Data Correct?
Report Verify
@ VDDMAX Error
Yes
Done
*VDDP = VDD range for programming (typically 4.75V - 5.25V).
VDDMIN = Minimum VDD for device operation.
VDDMAX = Maximum VDD for device operation.
DS40175C-page 3-19
Load Configuration
Command
N=0
No
Program ID Loc?
Yes
Read Data
Command
Program Cycle
Increment Address
Command
N=N+1
N = # of Program
Cycles
No
Data Correct?
Yes
No
Address = 2004
No
N > 25
Yes
Yes
Increment Address
Command
ID/Configuration
Error
Apply 3N
Program Cycles
Program Cycle
100 Cycles
Read Data
Command
Increment Address
Command
Increment Address
Command
No
Data Correct?
Yes
Report Program
ID/Config. Error
No
Done
DS40175C-page 3-20
Yes
Data Correct?
No
Data Correct?
DDMIN
Set VDD = V
Vddmin
Read Data Command
Set VPP = VIHH2
Yes
Set VDD = VVddmax
DDMAX
Read Data Command
Set VPP = VIHH2
Load Data
2.2.1.3
Read Data
2.2.1.4
Increment Address
2.2.1.5
Begin Programming
2.2.1.6
2.3
End Programming
After receiving this command, the chip stops programming the memory (configuration program memory or
user program memory) that it was programming at the
time.
DS40175C-page 3-21
CONFIGURATION WORD
FIGURE 3-1:
CONFIGURATION WORD
Bit Number:
13
12
11
10
4
PWRTE
Register:
Address
CONFIG
2007h
bit 4
bit 3
bit 2-0
Note 1: All of the CP1:CP0 pairs have to be given the same value to enable the code protection scheme listed.
2: 07FFh is always uncode protected on the PIC12C672 and 03FFh is always uncode protected on the PIC12C671.
This location contains the RETLW xx calibration instruction for the INTRC.
DS40175C-page 3-22
CODE PROTECTION
The program code written into the EPROM can be protected by writing to the CP0 and CP1 bits of the configuration word.
For PIC12C67X and PIC12CE67X devices, once code
protection is enabled, all protected segments read '0's
(or garbage values) and are prevented from further
programming. All unprotected segments, including ID
and configuration word locations, and calibration word
location read normally and can be programmed.
4.1
To allow portability of code, the programmer is required to read the configuration word and ID locations from the HEX
file when loading the HEX file. If configuration word information was not present in the HEX file then a simple warning
message may be issued. Similarly, while saving a HEX file, configuration word and ID information must be included.
An option to not include this information may be provided.
Microchip Technology Inc. feels strongly that this feature is important for the benefit of the end customer.
TABLE 4-1:
CONFIGURATION WORD
PIC12C671, PIC12CE673
To code protect:
Protect all memory
Protect 0200h-07FFh
No code protection
PIC12C672, PIC12CE674
To code protect:
Protect all memory
Protect 0200h-07FFh
Protect 0400h-07FFh
No code protection
00
01
10
11
0000
0101
1010
1111
X00X
X01X
X10X
X11X
XXXX
XXXX
XXXX
XXXX
DS40175C-page 3-23
Checksum
CHECKSUM CALCULATIONS
TABLE 4-2:
CHECKSUM COMPUTATION
Device
Code
Protect
Checksum*
Blank
Value
Ox25E6 at
0 and max
address
PIC12C671
PIC12CE673
OFF
1/2
ALL
FC00
0FBF
FC9F
C7CE
C174
C86D
PIC12C672
PIC12CE674
OFF
1/2
3/4
ALL
F800
1EDF
0BBF
F89F
C3CE
D094
BD74
C46D
DS40175C-page 3-24
TABLE 5-1:
AC/DC CHARACTERISTICS
TIMING REQUIREMENTS FOR PROGRAM/VERIFY TEST MODE
Sym.
Characteristic
Min.
Typ.
Max.
Units
4.75
5.0
5.25
20
mA
Conditions
General
PD1
PD2
IDDP
PD3
VDDMIN
VDDMAX
(Note 1)
PD4
12.75
13.25
(Note 2)
PD5
VDD + 4.0
13.5
PD6
IPP
PD9
VIH1
0.8 VDD
PD8
VIL1
0.2 VDD
50
mA
TR
8.0
P2
Tf
8.0
P3
100
ns
P4
100
ns
P5
1.0
P6
1.0
P7
200
ns
P8
P9
Note 1: Program must be verified at the minimum and maximum saa limits for the part.
2: sfee must be greater than saa + 4.5V to stay in Programming/Verify mode.
DS40175C-page 3-25
VIHH
j`ioLVPP
100ns
P8 1
P6
GP1
(Clock)
GP0
(Data)
100ns
0
1s min.
15
0
P5
P3
P3
1s min.
P4
P4
}
}
}
}
100ns
min.
100ns
min.
Program/Verify Mode
RESET
FIGURE 5-2:
VIHH
MCLR/VPP
100ns
P8
P6
1s min.
GP1
(Clock)
GP0
(Data)
100ns
1
15
P7
0
P5
P4
1s min.
P3
}
100ns
min.
RB7
input
RB7 = output
Program/Verify Mode
RESET
FIGURE 5-3:
P9
VIHH
MCLR/VPP
P6
1s min.
Next Command
1
GP1
(CLOCK)
GP0
(DATA)
P5
P3 P4
1s min.
100ns
min
Program/Verify Mode
Reset
DS40175C-page 3-26
PIC14000
In-Circuit Serial Programming for PIC14000 OTP MCUs
This document includes the programming
specifications for the following devices:
PIC14000
1.1
Hardware Requirements
28
RA2/AN2
RA0/AN0
27
RA3/AN3
RD3/REFB
26
RD4/AN4
RD2/CMPB
25
RD5/AN5
RD1/SDAB
24
RD6/AN6
RD0/SCLB
23
RD7/AN7
OSC2/CLKOUT
22
CDAC
OSC1/PBTN
21
SUM
VDD
20
VSS
19
RC0/REFA
PIC14000
1.0
PIN DIAGRAM
VREG
10
RC7/SDAA
11
18
RC1/CMPA
RC6/SCLA
12
17
RC2
RC5
13
16
RC3/T0CKI
MCLR/VPP
14
15
RC4
The PIC14000 requires two programmable power supplies, one for VDD (2.0V to 6.5V recommended) and
one for VPP (12V to 14V).
1.2
Programming Mode
The programming mode for the PIC14000 allows programming of user program memory, configuration
word, and calibration memory.
=OMMP=j=q=fK
apPMRRR_J~=PJOT
PIC14000
2.0
2.1
TABLE 2-1:
IMPLEMENTATION OF
PROGRAM AND
CALIBRATION MEMORY IN
THE PIC14000P
Area
Memory Space
Access to
Memory
Program
Calibration
0x000-0xFBF
0xFC0 -0xFFF
PC<12:0>
PC<12:0>
apPMRRR_J~=PJOU
=OMMP=j=q=fK
PIC14000
FIGURE 2-1:
0
Program
2000
ID Location
2001
ID Location
2002
ID Location
2003
ID Location
2004
Reserved
2005
Reserved
2006
Reserved
0FBF
0FC0
Calibration
0FFF
Reserved
1FFF
2000
Test
20FF
Reserved
3FFF
=OMMP=j=q=fK
apPMRRR_J~=PJOV
PIC14000
2.2
Program/Verify Mode
2.2.1
PROGRAM/VERIFY OPERATION
The RB6 pin is used as a clock input pin, and the RB7
pin is used for entering command bits and data input/
output during serial operation. To input a command, the
clock pin (RC6) is cycled six times. Each command bit
is latched on the falling edge of the clock with the least
significant bit (LSB) of the command being input first.
The data on pin RC7 is required to have a minimum
setup and hold time (see AC/DC specs) with respect to
the falling edge of the clock. Commands that have data
associated with them (read and load) are specified to
TABLE 2-1:
LOAD CONFIGURATION
COMMAND MAPPING
Command
Data
Load Configuration
0, data(14), 0
Load Data
0, data(14), 0
Read Data
0, data(14), 0
Increment Address
Begin programming
End Programming
Note:
The CPU clock must be disabled during in-circuit programming (to avoid incrementing the PC).
apPMRRR_J~=PJPM
=OMMP=j=q=fK
PIC14000
FIGURE 2-2:
6WDUW
6HW9'' 9''3
1
1R
3URJUDP&\FOH
1!
5HDG'DWD
&RPPDQG
,QFUHPHQW$GGUHVV
&RPPDQG
'DWD&RUUHFW"
<HV 5HSRUW3URJUDPPLQ
)DLOXUH
1 11
RI3URJUDP&\FOHV
1R
<HV
$SSO\1$GGLWLRQDO
3URJUDP&\FOHV
3URJUDP&\FOH
1R
/RDG'DWD
&RPPDQG
$OO/RFDWLRQV'RQH"
<HV
%HJLQ3URJUDPPLQJ
&RPPDQG
9HULI\DOO/RFDWLRQV
#9''PLQ
933 9,++
:DLWV
'DWD&RUUHFW"
1R
5HSRUW9HULI\
#9''PLQ(UURU
<HV
(QG3URJUDPPLQJ
&RPPDQG
9HULI\DOO/RFDWLRQV
#9''PD[
933 9,++
'DWD&RUUHFW"
1R
5HSRUW9HULI\
#9''PD[(UURU
<HV
'RQH
=OMMP=j=q=fK
apPMRRR_J~=PJPN
PIC14000
FIGURE 2-3:
Start
Load Configuration
Command
N=0
No
Program ID Loc?
Yes
Read Data
Command
Program Cycle
Increment Address
Command
N=N+1N=#
of Program Cycles
No
Data Correct?
Yes
No
Address = 2004
No
N > 25
Yes
Yes
Increment Address
Command
Report ID
Configuration Error
Apply 3N
Program Cycles
Program Cycle
100 Cycles
Read Data
Command
Increment Address
Command
Increment Address
Command
No
Data Correct?
Yes
Report Program
ID/Config. Error
No
Done
apPMRRR_J~=PJPO
Yes
Data Correct?
No
Data Correct?
Yes
Set VDD = VVDD
aamax
max
Read Data Command
Set VPP = VIHH2
=OMMP=j=q=fK
PIC14000
2.2.1.2
LOAD DATA
READ DATA
INCREMENT ADDRESS
BEGIN PROGRAMMING
2.3
The PIC14000 uses an intelligent algorithm. The algorithm calls for program verification at VDDmin as well as
VDDmax. Verification at VDDmin guarantees good
erase margin. Verification at VDDmax guarantees
good program margin.
The actual programming must be done with VDD in the
VDDP range (4.75 - 5.25V).
VDDP
END PROGRAMMING
After receiving this command, the chip stops programming the memory (configuration program memory or
user program memory) that it was programming at the
time.
=OMMP=j=q=fK
apPMRRR_J~=PJPP
PIC14000
3.0
CONFIGURATION WORD
FIGURE 3-1:
Bit
Number:
13
PIC14000 CPC
12
11
10
CPP1
CPP0
CPP0
CPP1
CPC
CPC
CPP1
CPP0
PWRTE
WDTE
FOSC
CPP<1:0>
11: All Unprotected
10: N/A
01: N/A
00: All Protected
bit 1,6: F Internal trim, factory programmed. DO NOT CHANGE! Program as 1. Note 1.
bit 3: PWRTE, Power Up Timer Enable Bit
0 = Power up timer enabled
1 = Power up timer disabled (unprogrammed)
bit 2:
bit 0:
apPMRRR_J~=PJPQ
=OMMP=j=q=fK
PIC14000
4.0
CODE PROTECTION
4.1
Calibration Space
The data in the calibration space has its own checksum. When properly programmed, the calibration
memory will always checksum to 0x0000. When this
4.2
To allow portability of code, the programmer is required to read the configuration word and ID locations from the hex
file when loading the hex file. If configuration word information was not present in the hex file then a simple warning
message may be issued. Similarly, while saving a hex file, configuration word and ID information must be included.
An option to not include this information may be provided.
Microchip Technology Inc. feels strongly that this feature is important for the benefit of the end customer.
TABLE 4-1:
=OMMP=j=q=fK
apPMRRR_J~=PJPR
PIC14000
4.3
Checksum
4.3.1
CHECKSUM CALCULATIONS
TABLE 4-2:
CHECKSUM COMPUTATION
Code
Protect
OFF
OFF OTP
ON
Checksum*
Blank
Value
0x25E6 at
0 and max
address
0x2FFD
0x0E7D
0x300A
0xFBCB
0xDA4B
0xFBD8
apPMRRR_J~=PJPS
=OMMP=j=q=fK
PIC14000
5.0
TABLE 5-1:
AC/DC CHARACTERISTICS
AC/DC TIMING REQUIREMENTS FOR PROGRAM/VERIFY MODE
Sym.
Characteristic
Min.
Typ.
Max.
Units
Conditions
4.75
5.0
5.25
20
mA
VDDmax
Note 1
13.25
Note 2
General
PD1
PD2
IDDP
PD3
VDDmin
PD4
12.75
PD5
PD6
IPP
PD9
VIH1
PD8
VIL1
VDD + 4.0
13.5
50
mA
0.8 VDD
0.2 VDD
8.0
ms
TR
Tf
8.0
ms
P3
100
ns
P4
100
ns
P5
1.0
ms
P6
1.0
ms
P7
200
ns
P8
ms
Note 1: Program must be verified at the minimum and maximum VDD limits for the part.
Note 2: VIHH must be greater than VDD + 4.5V to stay in programming/verify mode.
=OMMP=j=q=fK
apPMRRR_J~=PJPT
PIC14000
FIGURE 5-1:
VIHH
j`ioLVPP
100ns
P8
P6
100ns
0
RC6
(CLOCK)
RC7
(DATA)
1s min. 1
15
0
P5
P3
P3
1s min.
P4
P4
}
}
}
}
100ns
min.
Reset
FIGURE 5-2:
100ns
min.
VIHH
j`io/VPP
100ns
P8
P6
100ns
1
RC6
(CLOCK)
RC7
(DATA)
1s min. 1
15
P7
0
P5
P4
1s min.
P3
}
}
100ns
min.
Reset
FIGURE 5-3:
j`ioLsmm
RC7
input
RC7 = output
o`S
E`il`hF
o`T
Ea^q^F
Next Command
1s min.
P5
P3 P4
1s min.
100ns
min
apPMRRR_J~=PJPU
=OMMP=j=q=fK
PIC16C55X
In-Circuit Serial Programming for PIC16C55X OTP MCUs
This document includes the programming
specifications for the following devices:
PROGRAMMING THE
PIC16C55X
1.1
Hardware Requirements
1.2
Programming Mode
RA2
RA3
RA4/T0CKI
MCLR
VSS
RB0/INT
RB1
RB2
RB3
1
2
3
4
5
6
7
8
9
18
17
16
15
14
13
12
11
10
RA1
RA0
OSC1/CLKIN
OSC2/CLKOUT
VDD
RB7
RB6
RB5
RB4
PIC16C55X
1.0
PIC16C55X
PIC16C554
PIC16C556
PIC16C558
PIN Diagrams
20
19
18
17
16
15
14
13
12
11
RA1
RA0
OSC1/CLKIN
OSC2/CLKOUT
VDD
VDD
RB7
RB6
RB5
RB4
SSOP
RA2
RA3
RA4/T0CKI
MCLR
VSS
VSS
RB0/INT
RB1
RB2
RB3
1
2
3
4
5
6
7
8
9
10
The programming mode for the PIC16C55X allows programming of user program memory, special locations
used for ID, and the configuration word for the
PIC16C55X.
=OMMP=j=q=fK
apPMOSN`J~=PJPV
PIC16C55X
2.0
2.1
TABLE 2-1:
Device
IMPLEMENTATION OF
PROGRAM MEMORY IN THE
PIC16C55X
Program Memory Size
Access to
Program
Memory
PIC16C554
PC<8:0>
PIC16C556
PC<9:0>
PIC16C558
PC<10:0>
When the PC reaches the last location of the implemented program memory, it will wrap around and
address a location within the physically implemented
memory (see Figure 2-1).
In programming mode the program memory space
extends from 0x0000 to 0x3FFF, with the first half
(0x0000-0x1FFF) being user program memory and the
second half (0x2000-0x3FFF) being configuration
memory. The PC will increment from 0x0000 to 0x1FFF
and wrap to 0x000 or 0x2000 to 0x3FFF and wrap
around to 0x2000 (not to 0x0000). Once in configuration memory, the highest bit of the PC stays a '1', thus
always pointing to the configuration memory. The only
way to point to user program memory is to reset the
part and reenter program/verify mode, as described in
Section 2.2.
In the configuration memory space, 0x2000-0x20FF
are utilized. When in a configuration memory, as in the
user memory, the 0x2000-0x2XFF segment is repeatedly accessed as the PC exceeds 0x2XFF (see
Figure 2-1).
A user may store identification information (ID) in four
ID locations. The ID locations are mapped in [0x2000:
0x2003]. It is recommended that the user use only the
four least significant bits of each ID location. In some
devices, the ID locations read-out in a scrambled fashion after code protection is enabled. For these devices,
it is recommended that ID location is written as 11 1111
1000 bbbb where 'bbbb' is ID information.
Note:
apPMOSN`J~=PJQM
=OMMP=j=q=fK
PIC16C55X
FIGURE 2-1:
1KW
2KW
Implemented
Implemented
0
2000
ID Location
2001
ID Location
2002
2003
ID Location
ID Location
2004
Reserved
2005
Reserved
2006
Reserved
1FF
3FF
400
Implemented
Implemented
7FF
800
BFF
C00
FFF
1000
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
2100
3FFF
=OMMP=j=q=fK
apPMOSN`J~=PJQN
PIC16C55X
2.2
Program/Verify Mode
2.2.1
The commands
in Table 2-1.
2.2.1.1
are
available
are
The RB6 pin is used as a clock input pin, and the RB7
pin is used for entering command bits and data input/
output during serial operation. To input a command, the
clock pin (RB6) is cycled six times. Each command bit
is latched on the falling edge of the clock with the least
significant bit (LSB) of the command being input first.
The data on pin RB7 is required to have a minimum
LOAD CONFIGURATION
COMMAND MAPPING
Command
Data
Load Configuration
0, data(14), 0
Load Data
0, data(14), 0
Read Data
0, data(14), 0
Increment Address
Begin programming
End Programming
Note:
listed
PROGRAM/VERIFY OPERATION
TABLE 2-1:
that
apPMOSN`J~=PJQO
=OMMP=j=q=fK
PIC16C55X
FIGURE 2-2:
6HW9'' 9''3
1
1R
3URJUDP&\FOH
1!
5HDG'DWD
&RPPDQG
,QFUHPHQW$GGUHVV
&RPPDQG
'DWD&RUUHFW"
<HV 5HSRUW3URJUDPPLQ
)DLOXUH
1 11
RI3URJUDP&\FOHV
1R
<HV
$SSO\1$GGLWLRQDO
3URJUDP&\FOHV
3URJUDP&\FOH
1R
/RDG'DWD
&RPPDQG
$OO/RFDWLRQV'RQH"
<HV
%HJLQ3URJUDPPLQJ
&RPPDQG
9HULI\DOO/RFDWLRQV
#9''PLQ
933 9,++
:DLWV
'DWD&RUUHFW"
1R
5HSRUW9HULI\
#9''PLQ(UURU
<HV
(QG3URJUDPPLQJ
&RPPDQG
9HULI\DOO/RFDWLRQV
#9''PD[
933 9,++
'DWD&RUUHFW"
1R
5HSRUW9HULI\
#9''PD[(UURU
<HV
'RQH
=OMMP=j=q=fK
apPMOSN`J~=PJQP
PIC16C55X
FIGURE 2-3:
Start
Load Configuration
Command
N=0
No
Program ID Loc?
Yes
Read Data
Command
Program Cycle
Increment Address
Command
N=N+1N=#
of Program Cycles
No
Data Correct?
Yes
No
Address = 2004
No
N > 25
Yes
Yes
Increment Address
Command
ID/Configuration
Error
Apply 3N
Program Cycles
Program Cycle
100 Cycles
Read Data
Command
Increment Address
Command
Increment Address
Command
No
Data Correct?
Yes
Report Program
ID/Config. Error
No
Done
apPMOSN`J~=PJQQ
Yes
Data Correct?
No
Data Correct?
Yes
Set VDD = VVDD
aamax
max
Read Data Command
Set VPP = VIHH2
=OMMP=j=q=fK
PIC16C55X
2.2.1.2
LOAD DATA
READ DATA
INCREMENT ADDRESS
BEGIN PROGRAMMING
2.3
END PROGRAMMING
After receiving this command, the chip stops programming the memory (configuration program memory or
user program memory) that it was programming at the
time.
=OMMP=j=q=fK
apPMOSN`J~=PJQR
PIC16C55X
3.0
CONFIGURATION WORD
The PIC16C55X family members have several configuration bits. These bits can be programmed (reads '0')
or left unprogrammed (reads '1') to select various
device configurations. Figure 3-1 provides an overview
of configuration bits.
FIGURE 3-1:
Bit
Number:
13
12
11
10
PIC16C554/556/558
CP1
CP0
CP1
CP0
CP1
CP0
CP1
CP0
PWRTE
WDTE
FOSC1
FOSC0
CP1 CP0
Code Protection
PIC16C554
0
0
1
0
1
0
1
0
0
1
1
1
0
1
0
1
0
0
0
1
1
1
0
1
PIC16C556
PIC16C558
apPMOSN`J~=PJQS
=OMMP=j=q=fK
PIC16C55X
4.0
CODE PROTECTION
4.1
The program code written into the EPROM can be protected by writing to the CP0 & CP1 bits of the configuration word.
4.2
To allow portability of code, the programmer is required to read the configuration word and ID locations from the hex
file when loading the hex file. If configuration word information was not present in the hex file then a simple warning
message may be issued. Similarly, while saving a hex file, configuration word and ID information must be included.
An option to not include this information may be provided.
Microchip Technology Inc. feels strongly that this feature is important for the benefit of the end customer.
TABLE 4-1:
CONFIGURATION WORD
PIC16C554
To code protect:
Protect all memory
No code protection
0000001000XXXX
1111111011XXXX
PIC16C556
To code protect:
Protect all memory
0000001000XXXX
Protect upper 1/2 memory 0101011001XXXX
No code protection
1111111011XXXX
Program Memory Segment
PIC16C558
To code protect:
Protect all memory
Protect upper 3/4 memory
Protect upper 1/2 memory
No code protection
0000001000XXXX
0101011001XXXX
1010101010XXXX
1111111011XXXX
=OMMP=j=q=fK
apPMOSN`J~=PJQT
PIC16C55X
4.3
Checksum
4.3.1
CHECKSUM CALCULATIONS
TABLE 4-2:
CHECKSUM COMPUTATION
Code
Protect
Checksum*
Blank
Value
0x25E6 at
0 and max
address
PIC16C554
OFF
ALL
3D3F
3D4E
090D
091C
PIC16C556
OFF
1/2
ALL
3B3F
4E5E
3B4E
070D
0013
071C
PIC16C558
OFF
1/2
3/4
ALL
373F
5D6E
4A5E
374E
030D
0F23
FC13
031C
Device
apPMOSN`J~=PJQU
=OMMP=j=q=fK
PIC16C55X
5.0
TABLE 5-1:
AC/DC CHARACTERISTICS
TIMING REQUIREMENTS FOR PROGRAM/VERIFY TEST MODE
Sym.
Characteristic
PD1
VDDP
PD2
IDDP
Min.
Typ.
Max.
Units
4.75
5.0
5.25
20
mA
Conditions
General
PD3
VDDV
VDDmin
VDDmax
Note 1
PD4
VIHH1
12.75
13.25
Note 2
PD5
VIHH2
13.5
PD6
IPP
50
mA
PD9
VIH1
0.8 VDD
PD8
VIL1
0.2 VDD
8.0
ms
TR
P2
Tf
8.0
ms
P3
Tset1
100
ns
P4
Thld1
100
ns
P5
Tdly1
1.0
ms
P6
Tdly2
1.0
ms
P7
Tdly3
200
ns
P8
Thld0
ms
Tpw
10
100
1000
ms
Note 1: Program must be verified at the minimum and maximum VDD limits for the part.
2: VIHH must be greater than VDD + 4.5V to stay in programming/verify mode.
=OMMP=j=q=fK
apPMOSN`J~=PJQV
PIC16C55X
FIGURE 5-1:
VIHH
j`ioLVPP
100ns
P8
P6
100ns
0
RB6
(CLOCK)
RB7
(DATA)
1s min. 1
15
0
P5
P3
P3
1s min.
P4
P4
}
}
}
}
100ns
min.
Reset
FIGURE 5-2:
100ns
min.
VIHH
j`io/VPP
100ns
P8
P6
100ns
1
RB6
(CLOCK)
RB7
(DATA)
1s min. 1
15
P7
0
P5
P4
1s min.
P3
}
}
100ns
min.
Reset
FIGURE 5-3:
j`ioLsmm
RB7
input
RB7 = output
o_S
E`il`hF
o_T
Ea^q^F
Next Command
1s min.
P5
P3 P4
1s min.
100ns
min
o
apPMOSN`J~=PJRM
=OMMP=j=q=fK
PIC16C6XX/7XX/9XX
Programming Specifications for PIC16C6XX/7XX/9XX OTP MCUs
This document includes the
programming specifications for the
following devices:
PIC16C61
PIC16C62
PIC16C62A
PIC16C62B
PIC16C63
PIC16C63A
PIC16C64
PIC16C64A
PIC16C65
PIC16C65A
PIC16C65B
PIC16C66
PIC16C67
PIC16C71
PIC16C72
1.0
PIC16C72A
PIC16C73
PIC16C73A
PIC16C73B
PIC16C74
PIC16C74A
PIC16C74B
PIC16C76
PIC16C77
PIC16C620
PIC16C620A
PIC16C621
PIC16C621A
PIC16C622
PIC16C622A
PIC16CE623
PIC16CE624
PIC16CE625
PIC16C710
PIC16C711
PIC16C712
PIC16C716
PIC16C745
PIC16C765
PIC16C773
PIC16C774
PIC16C923
PIC16C924
PIC16C925
PIC16C926
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
RB7
RB6
RB5
RB4
RB3
RB2
RB1
RB0/INT
VDD
VSS
RD7
RD6
RD5
RD4
RC7
RC6
RC5
RC4
RD3
RD2
Programming Mode
28
RB7
RA0
27
RB6
RA1
26
RB5
RA2
25
RB4
RA3
24
RB3
RA4/T0CKI
23
RB2
RA5
22
RB1
Vss
21
RB0/INT
OSC1/CLKIN
20
VDD
19
VSS
18
RC7
17
RC6
16
RC5
15
RC4
MCLR/VPP
OSC2/CLKOUT
10
RC0
11
RC1
12
RC2
13
RC3
14
PIC16C62/62A/63/66/72/72A
PIC16C73/73A/73B/76/745
Hardware Requirements
1.2
MCLR/VPP
RA0
RA1
RA2
RA3
RA4/T0CKI
RA5
RE0
RE1
RE2
VDD
VSS
OSC1/CLKIN
OSC2/CLKOUT
RC0
RC1
RC2
RC3
RD0
RD1
PROGRAMMING THE
PIC16C6XX/7XX/9XX
1.1
PIC16C64/64A/65/65A/67
PIC16C74/74A/74B/77/765
Pin Diagrams
DS30228K-page 3-51
PIC16C6XX/7XX/9XX
Pin Diagrams (Cont)
PDIP, SOIC, Windowed CERDIP
1
18
RA1
RA3
17
RA0
RA4/T0CKI
16
OSC1/CLKIN
MCLR/VPP
15
OSC2/CLKOUT
14
VDD
13
RB7
12
RB6
VSS
PIC16C710/711
PIC16C61/71
PIC16C62X
RA2
RB0/INT
RB1
RB2
11
RB5
RB3
10
RB4
28
RB7
27
RB6
RA1/AN1
26
RB5
RA2/AN2/VREF-/VRL
25
RB4
RA3/AN3/VREF+/VRH
24
RB3/AN9/LVDIN
RA4/T0CKI
23
RB2/AN8
AVDD
AVSS
7
8
22
21
RB1/SS
RB0/INT
OSC1/CLKIN
PIC16C773
RA0/AN0
20
VDD
OSC2/CLKOUT
10
19
VSS
RC0/T1OSO/T1CKI
11
18
RC7/RX/DT
RC1/T1OSI/CCP2
12
17
RC6/TX/CK
RC2/CCP1
13
16
RC5/SDO
RC3/SCK/SCL
14
15
RC4/SDI/SDA
PIC16C712
PIC16C716
RA4/T0CKI
MCLR/VPP
VSS
RB0/INT
RB1/T1OSO/T1CKI
RB2/T1OSI
RB3/CCP1
1
2
3
4
5
6
7
8
9
18
17
16
15
14
13
12
11
10
RA1/AN1
RA0/AN0
OSC1/CLKIN
OSC2/CLKOUT
VDD
RB7
RB6
RB5
RB4
20-pin SSOP
RA2/AN2
RA3/AN3/VREF
DS30228K-page 3-52
PIC16C712
PIC16C716
RA4/T0CKI
MCLR/VPP
VSS
VSS
RB0/INT
RB1/T1OSO/T1CKI
RB2/T1OSI
RB3/CCP1
1
2
3
4
5
6
7
8
9
10
20
19
18
17
16
15
14
13
12
11
RA1/AN1
RA0/AN0
OSC1/CLKIN
OSC2/CLKOUT
VDD
VDD
RB7
RB6
RB5
RB4
PIC16C6XX/7XX/9XX
Pin Diagrams (Cont)
9
8
7
6
5
4
3
2
1
68
67
66
65
64
63
62
61
RA3/AN3/VREF
RA2/AN2
VSS
RA1/AN1
RA0/AN0
RB2
RB3
MCLR/VPP
NC
RB4
RB5
RB7
RB6
VDD
COM0
RD7/SEG31/COM1
RD6/SEG30/COM2
PLCC, CLCC
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
PIC16C92X
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
RD5/SEG29/COM3
RG6/SEG26
RG5/SEG25
RG4/SEG24
RG3/SEG23
RG2/SEG22
RG1/SEG21
RG0/SEG20
RG7/SEG28
RF7/SEG19
RF6/SEG18
RF5/SEG17
RF4/SEG16
RF3/SEG15
RF2/SEG14
RF1/SEG13
RF0/SEG12
RC1/T1OSI
RC2/CCP1
VLCD1
VLCDADJ
RD0/SEG00
RD1/SEG01
RD2/SEG02
RD3/SEG03
RD4/SEG04
RE7/SEG27
RE0/SEG05
RE1/SEG06
RE2/SEG07
RE3/SEG08
RE4/SEG09
RE5/SEG10
RE6/SEG11
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
RA4/T0CKI
RA5/AN4/SS
RB1
RB0/INT
RC3/SCK/SCL
RC4/SDI/SDA
RC5/SDO
C1
C2
VLCD2
VLCD3
AVDD
VDD
VSS
OSC1/CLKIN
OSC2/CLKOUT
RC0/T1OSO/T1CKI
DS30228K-page 3-53
PIC16C6XX/7XX/9XX
2.0
2.1
TABLE 2-1:
IMPLEMENTATION OF
PROGRAM MEMORY IN THE
PIC16C6XX/7XX/9XX
Device
Program Memory
Size
PIC16C61
PIC16C620/620A
PIC16C621/621A
PIC16C622/622A
PIC16C62/62A/62B
PIC16C63/63A
PIC16C64/64A
PIC16C65/65A/65B
PIC16CE623
PIC16CE624
PIC16CE625
PIC16C71
PIC16C710
PIC16C711
PIC16C712
PIC16C716
PIC16C72/72A
PIC16C73/73A/73B
PIC16C74/74A/74B
PIC16C66
PIC16C67
PIC16C76
PIC16C77
PIC16C745
PIC16C765
PIC16C773
PIC16C774
PIC16C923/924/925
PIC16C926
DS30228K-page 3-54
When the PC reaches the last location of the implemented program memory, it will wrap around and
address a location within the physically implemented
memory (see Figure 2-1).
Once in configuration memory, the highest bit of the PC
stays a '1', thus, always pointing to the configuration
memory. The only way to point to user program memory is to reset the part and re-enter Program/Verify
mode, as described in Section 2.2.
A user may store identification information (ID) in four
ID locations. The ID locations are mapped in [0x2000:
0x2003]. It is recommended that the user use only the
four Least Significant bits of each ID location. In some
devices, the ID locations read-out in a scrambled
fashion after code protection is enabled. For these
devices, it is recommended that ID location is written
as 11 1111 1bbb bbbb, where 'bbbb' is ID
information.
Note:
PIC16C6XX/7XX/9XX
FIGURE 2-1:
2000h
ID Location
0h
1FFh Implemented
3FFh
400h
2001h
ID Location
2002h
ID Location
7FFh
800h
ID Location
BFFh
C00h
Reserved
FFFh
1000h
2003h
2004h
2005h
2006h
2007h
1K
words
2K
words
4K
words
8K
words
Implemented
Implemented
Implemented
Implemented
Implemented
Implemented
Implemented
Implemented
Implemented
Implemented
Implemented
Reserved
Reserved
Reserved
Reserved
Reserved
Configuration
Word
Implemented
Reserved
Implemented
Implemented
1FFFh
Implemented
2008h
2100h
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
3FFFh
DS30228K-page 3-55
PIC16C6XX/7XX/9XX
2.2
Program/Verify Mode
The commands
in Table 2-2.
2.2.1
2.2.1.1
PROGRAM/VERIFY OPERATION
are
available
listed
Load Configuration
COMMAND MAPPING
Command
Data
Load Configuration
0, data(14), 0
Load Data
0, data(14), 0
Read Data
0, data(14), 0
Increment Address
Begin programming
End Programming
Note:
are
The RB6 pin is used as a clock input pin, and the RB7
pin is used for entering command bits and data
input/output during serial operation. To input a command, the clock pin (RB6) is cycled six times. Each
command bit is latched on the falling edge of the clock
with the Least Significant bit (LSb) of the command
being input first. The data on pin RB7 is required to
have a minimum setup and hold time (see AC/DC
specs), with respect to the falling edge of the clock.
TABLE 2-2:
that
DS30228K-page 3-56
PIC16C6XX/7XX/9XX
FIGURE 2-2:
N=1
No
Program Cycle
N > 25?
Read Data
Command
Increment Address
Command
Data correct?
Yes
Report Programming
Failure
N=N+1 N=#
of Program Cycles
No
Yes
Apply 3N Additional
Program Cycles
Program Cycle
No
Load Data
Command
Begin Programming
Command
Data correct?
No
Wait 100 s
Report verify
@ VDDMIN Error
Yes
End Programming
Command
Data correct?
No
Report verify
@ VDDMAX Error
Yes
Done
DS30228K-page 3-57
PIC16C6XX/7XX/9XX
FIGURE 2-3:
Load Configuration
Command
N=1
No
Program ID Loc?
Yes
Read Data
Command
Program Cycle
Increment Address
Command
N=N+1 N=#
of Program Cycles
No
Data Correct?
Yes
No
Address = 2004
No
N > 25
Yes
Yes
Increment Address
Command
Report ID
Configuration Error
Apply 3N
Program Cycles
Program Cycle
100 Cycles
Read Data
Command
Increment Address
Command
Increment Address
Command
No
Data Correct?
Yes
Report Program
ID/Config. Error
No
No
Done
Yes
Data Correct?
Data Correct?
Yes
Set VDD = VVDDMAX
DDmax
Read Data Command
Set VPP = VIHH2
DS30228K-page 3-58
PIC16C6XX/7XX/9XX
2.2.1.2
Load Data
2.2.1.3
Read Data
2.2.1.4
Increment Address
2.2.1.5
Begin Programming
2.2.1.6
2.3
VDDMIN
End Programming
After receiving this command, the chip stops programming the memory (configuration program memory or
user program memory) that it was programming at the
time.
DS30228K-page 3-59
PIC16C6XX/7XX/9XX
3.0
CONFIGURATION WORD
Note:
The PIC16C6XX/7XX/9XX family members have several configuration bits. For all devices, these are part of
the Configuration Word, located at address 2007h.
These bits can be programmed (reads '0'), or left
unprogrammed (reads '1'), to select various device
configurations.
Because the PIC16C6XX/7XX/9XX family spans so
many devices, there are a number of different bit configurations possible for the Configuration Word. Registers 3-1 through 3-7 provide details for each of the
seven distinct groups. Table 3-1 provides a cross-index
of a particular device name to its appropriate Configuration Word listing.
TABLE 3-1:
Device
Register
Page
Device
Register
Page
Device
Register
Page
PIC16C61
3-1
61
PIC16C72A
3-3
62
PIC16CE623
3-3
62
PIC16C62
3-2
61
PIC16C73
3-2
61
PIC16CE624
3-3
62
PIC16C62A
3-3
62
PIC16C73A
3-3
62
PIC16CE625
3-3
62
PIC16C62B
3-3
62
PIC16C73B
3-3
62
PIC16C710
3-4
63
PIC16C63
3-3
62
PIC16C74
3-2
61
PIC16C711
3-4
63
PIC16C63A
3-3
62
PIC16C74A
3-3
62
PIC16C712
3-3
62
PIC16C64
3-2
61
PIC16C74B
3-3
62
PIC16C716
3-3
62
PIC16C64A
3-3
62
PIC16C76
3-3
62
PIC16C745
3-6
65
PIC16C65
3-2
61
PIC16C77
3-3
62
PIC16C765
3-6
65
PIC16C65A
3-3
62
PIC16C620
3-3
62
PIC16C773
3-5
64
PIC16C65B
3-3
62
PIC16C620A
3-3
62
PIC16C774
3-5
64
PIC16C66
3-3
62
PIC16C621
3-3
62
PIC16C923
3-6
65
PIC16C67
3-3
62
PIC16C621A
3-3
62
PIC16C924
3-6
65
PIC16C71
3-1
61
PIC16C622
3-3
62
PIC16C925
3-7
66
PIC16C72
3-3
62
PIC16C622A
3-3
62
PIC16C926
3-7
66
DS30228K-page 3-60
PIC16C6XX/7XX/9XX
REGISTER 3-1:
CP0
PWTREN WDTEN
F0SC1
bit13
bit0
bit 13-5
Unimplemented: Read as 1
bit 4
bit 3
bit 2
bit 1-0
REGISTER 3-2:
F0SC0
bit13
CP1
CP0
PWTREN WDTEN
F0SC1
F0SC0
bit0
bit 13-6
Unimplemented: Read as 1
bit 5-4
bit 3
bit 2
bit 1-0
DS30228K-page 3-61
PIC16C6XX/7XX/9XX
REGISTER 3-3:
CP1
CP0
CP1
CP1
CP0
BOREN
CP1
CP0
PWTREN WDTEN
bit13
F0SC1
F0SC0
bit0
bit 13-8
bit 5-4
bit 7
Unimplemented: Read as 1
bit 6
bit 3
bit 2
bit 1-0
DS30228K-page 3-62
PIC16C6XX/7XX/9XX
REGISTER 3-4:
CP0
CP0
CP0
CP0
CP0
CP0
BOREN
CP0
CP0
PWTREN WDTEN
bit13
F0SC1
F0SC0
bit0
bit 13-7
bit 5-4
bit 6
bit 3
bit 2
bit 1-0
DS30228K-page 3-63
PIC16C6XX/7XX/9XX
REGISTER 3-5:
CP1
CP0
BORV1
BORV0
CP1
CP0
BOREN
CP1
CP0
PWTREN WDTEN
F0SC1
F0SC0
bit13
bit0
bit 13-7
bit 9-8
bit 5-4
bit 11-10
bit 6
bit 3
bit 2
bit 1-0
DS30228K-page 3-64
PIC16C6XX/7XX/9XX
REGISTER 3-6:
CP1
CP0
CP1
CP1
CP0
CP1
bit13
CP0
PWTREN WDTEN
F0SC1
F0SC0
bit0
bit 13-8
bit 5-4
bit 7-6
Unimplemented: Read as 1
bit 3
bit 2
bit 1-0
DS30228K-page 3-65
PIC16C6XX/7XX/9XX
REGISTER 3-7:
BOREN
CP1
CP0
PWTREN
WDTEN
F0SC1
bit13
F0SC0
bit0
bit 13-7
Unimplemented: Read as 1
bit 6
bit 5-4
bit 3
bit 2
bit 1-0
DS30228K-page 3-66
PIC16C6XX/7XX/9XX
3.1
To allow portability of code, the programmer is required to read the configuration word and ID locations from the HEX
file when loading the HEX file. If configuration word information was not present in the HEX file, then a simple warning
message may be issued. Similarly, while saving a HEX file, configuration word and ID information must be included.
An option to not include this information may be provided.
Microchip Technology Inc. feels strongly that this feature is beneficial to the end customer.
3.2
Checksum
3.2.1
CHECKSUM CALCULATIONS
TABLE 3-2:
Device
CHECKSUM COMPUTATION
Code
Protect
Checksum*
Blank
Value
0x25E6 at
0 and
Max
Address
PIC16C61
OFF
ON
0x3BFF
0xFC6F
0x07CD
0xFC15
PIC16C620
OFF
ON
0x3D7F
0x3DCE
0x094D
0x099C
PIC16C620A
OFF
ON
0x3D7F
0x3DCE
0x094D
0x099C
PIC16C621
OFF
1/2
ALL
0x3B7F
0x4EDE
0x3BCE
0x074D
0x0093
0x079C
PIC16C621A
OFF
1/2
ALL
0x3B7F
0x4EDE
0x3BCE
0x074D
0x0093
0x079C
DS30228K-page 3-67
PIC16C6XX/7XX/9XX
TABLE 3-2:
Device
Checksum*
Blank
Value
0x25E6 at
0 and
Max
Address
PIC16C622
OFF
1/2
3/4
ALL
0x377F
0x5DEE
0x4ADE
0x37CE
0x034D
0x0FA3
0xFC93
0x039C
PIC16C622A
OFF
1/2
3/4
ALL
0x377F
0x5DEE
0x4ADE
0x37CE
0x034D
0x0FA3
0xFC93
0x039C
PIC16CE623
OFF
ON
0x3D7F
0x3DCE
0x094D
0x099C
PIC16CE624
OFF
1/2
ALL
0x3B7F
0x4EDE
0x3BCE
0x074D
0x0093
0x079C
PIC16CE625
OFF
1/2
3/4
ALL
0x377F
0x5DEE
0x4ADE
0x37CE
0x034D
0x0FA3
0xFC93
0x039C
PIC16C62
OFF
1/2
3/4
ALL
0x37BF
0x37AF
0x379F
0x378F
0x038D
0x1D69
0x1D59
0x3735
PIC16C62A
OFF
1/2
3/4
ALL
0x377F
0x5DEE
0x4ADE
0x37CE
0x034D
0x0FA3
0xFC93
0x039C
PIC16C62B
OFF
1/2
3/4
ALL
0x377F
0x5DEE
0x4ADE
0x37CE
0x034D
0x0FA3
0xFC93
0x039C
PIC16C63
OFF
1/2
3/4
ALL
0x2F7F
0x51EE
0x40DE
0x2FCE
0xFB4D
0x03A3
0xF293
0xFB9C
PIC16C63A
OFF
1/2
3/4
ALL
0x2F7F
0x51EE
0x40DE
0x2FCE
0xFB4D
0x03A3
0xF293
0xFB9C
PIC16C64
OFF
1/2
3/4
ALL
0x37BF
0x37AF
0x379F
0x378F
0x038D
0x1D69
0x1D59
0x3735
DS30228K-page 3-68
PIC16C6XX/7XX/9XX
TABLE 3-2:
Device
Checksum*
Blank
Value
0x25E6 at
0 and
Max
Address
PIC16C64A
OFF
1/2
3/4
ALL
0x377F
0x5DEE
0x4ADE
0x37CE
0x034D
0x0FA3
0xFC93
0x039C
PIC16C65
OFF
1/2
3/4
ALL
0x2FBF
0x2FAF
0x2F9F
0x2F8F
0xFB8D
0x1569
0x1559
0x2F35
PIC16C65A
OFF
1/2
3/4
ALL
0x2F7F
0x51EE
0x40DE
0x2FCE
0xFB4D
0x03A3
0xF293
0xFB9C
PIC16C65B
OFF
1/2
3/4
ALL
0x2F7F
0x51EE
0x40DE
0x2FCE
0xFB4D
0x03A3
0xF293
0xFB9C
PIC16C66
OFF
1/2
3/4
ALL
0x1F7F
0x39EE
0x2CDE
0x1FCE
0xEB4D
0xEBA3
0xDE93
0xEB9C
PIC16C67
OFF
1/2
3/4
ALL
0x1F7F
0x39EE
0x2CDE
0x1FCE
0xEB4D
0xEBA3
0xDE93
0xEB9C
PIC16C710
OFF
ON
0x3DFF
0x3E0E
0x09CD
0xEFC3
PIC16C71
OFF
ON
0x3BFF
0xFC6F
0x07CD
0xFC15
PIC16C711
OFF
ON
0x3BFF
0x3C0E
0x07CD
0xEDC3
PIC16C712
OFF
1/2
ALL
0x377F
0x5DEE
0x37CE
0x034D
0xF58A
0x039C
PIC16C716
OFF
1/2
3/4
ALL
0x377F
0x5DEE
0x4ADE
0x37CE
0x034D
0x0FA3
0xFC93
0x039C
PIC16C72
OFF
1/2
3/4
ALL
0x377F
0x5DEE
0x4ADE
0x37CE
0x034D
0x0FA3
0xFC93
0x039C
DS30228K-page 3-69
PIC16C6XX/7XX/9XX
TABLE 3-2:
Device
Checksum*
Blank
Value
0x25E6 at
0 and
Max
Address
PIC16C72A
OFF
1/2
3/4
ALL
0x377F
0x5DEE
0x4ADE
0x37CE
0x034D
0x0FA3
0xFC93
0x039C
PIC16C73
OFF
1/2
3/4
ALL
0x2FBF
0x2FAF
0x2F9F
0x2F8F
0xFB8D
0x1569
0x1559
0x2F35
PIC16C73A
OFF
1/2
3/4
ALL
0x2F7F
0x51EE
0x40DE
0x2FCE
0xFB4D
0x03A3
0xF293
0xFB9C
PIC16C73B
OFF
1/2
3/4
ALL
0x2F7F
0x51EE
0x40DE
0x2FCE
0xFB4D
0x03A3
0xF293
0xFB9C
PIC16C74
OFF
1/2
3/4
ALL
0x2FBF
0x2FAF
0x2F9F
0x2F8F
0xFB8D
0x1569
0x1559
0x2F35
PIC16C74A
OFF
1/2
3/4
ALL
0x2F7F
0x51EE
0x40DE
0x2FCE
0xFB4D
0x03A3
0xF293
0xFB9C
PIC16C74B
OFF
1/2
3/4
ALL
0x2F7F
0x51EE
0x40DE
0x2FCE
0xFB4D
0x03A3
0xF293
0xFB9C
PIC16C76
OFF
1/2
3/4
ALL
0x1F7F
0x39EE
0x2CDE
0x1FCE
0xEB4D
0xEBA3
0xDE93
0xEB9C
PIC16C77
OFF
1/2
3/4
ALL
0x1F7F
0x39EE
0x2CDE
0x1FCE
0xEB4D
0xEBA3
0xDE93
0xEB9C
PIC16C773
OFF
1/2
3/4
ALL
0x2F7F
0x55EE
0x48DE
0x3BCE
0xFB4D
0x07A3
0xFA93
0x079C
PIC16C774
OFF
1/2
3/4
ALL
0x2F7F
0X55EE
0X48DE
0x3BCE
0xFB4D
0x07A3
0xFA93
0X079C
DS30228K-page 3-70
PIC16C6XX/7XX/9XX
TABLE 3-2:
Device
Checksum*
Blank
Value
0x25E6 at
0 and
Max
Address
PIC16C923
PIC16C925
OFF
1/2
3/4
ALL
0x2F3F
0x516E
0x405E
0x2F4E
0xFB0D
0x0323
0xF213
0xFB1C
PIC16C924
PIC16C926
OFF
1/2
3/4
ALL
0x2F3F
0x516E
0x405E
0x2F4E
0xFB0D
0x0323
0xF213
0xFB1C
PIC16C745
OFF
1000:1FFF
800:1FFF
ALL
0x1F3F
0x396E
0x2C5E
0x1F4E
0xEB0D
0xEB23
0xDE13
0xEB1C
PIC16C765
OFF
1000:1FFF
800:1FFF
ALL
0x1F3F
0x396E
0x2C5E
0x1F4E
0xEB0D
0xEB23
0xDE13
0xEB1C
DS30228K-page 3-71
PIC16C6XX/7XX/9XX
4.0
PROGRAM/VERIFY MODE
TABLE 4-1:
AC/DC CHARACTERISTICS
TIMING REQUIREMENTS FOR PROGRAM/VERIFY TEST MODE
Sym.
Characteristic
Min.
Typ.
Max.
Units
4.75
5.0
5.25
20
mA
Conditions
General
PD1
PD2
IDDP
PD3
VDDMIN
VDDMAX
(Note 1)
PD4
12.75
13.25
(Note 2)
PD5
VDD + 4.5
13.25
PD6
IPP
50
mA
PD9
VIH
0.8 VDD
PD8
VIL
0.2 VDD
TR
8.0
P2
Tf
8.0
s
ns
P3
100
P4
100
ns
P5
1.0
P6
1.0
P7
200
ns
P8
Note 1: Program must be verified at the minimum and maximum VDD limits for the part.
2: VIHH must be greater than VDD + 4.5V to stay in Programming/Verify mode.
DS30228K-page 3-72
PIC16C6XX/7XX/9XX
FIGURE 4-1:
VIHH
MCLR/VPP
P8
RB6
(Clock)
RB7
(Data)
100 ns
1
100 ns
0
P6
6 1s min. 1
P5
15
P3
P4
}
}
1 s min.
100 ns
min.
FIGURE 4-2:
P3
P4
100 ns
min.
VIHH
MCLR/VPP
100 ns
P8
RB6
(Clock)
RB7
(Data)
0
P3
100 ns
1
15
P7
0
P5
P4
}
}
1 s min.
100 ns
min.
FIGURE 4-3:
P6
6 1 s min. 1
RB7
Input
RB7 = Output
MCLR/VPP
P6
1
1 s min.
Next Command
1
RB6
(Clock)
RB7
(Data)
P5
P3 P4
}
}
1 s min.
100 ns
min.
DS30228K-page 3-73
PIC16C6XX/7XX/9XX
NOTES:
DS30228K-page 3-74
PIC17C7XX
In-Circuit Serial Programming for PIC17C7XX OTP MCUs
This document includes the programming
specifications for the following devices:
PIC17C752
PIC17C756
PIC17C756A
PIC17C762
PIC17C766
1.0
PROGRAMMING THE
PIC17C7XX
=OMMP=j=q=fK
1.1
Hardware Requirements
apPMOTQ_J~=PJTR
PIC17C7XX
PIC17C752/756/756A/762/766 LCC
oeN
oeM
oaOL^aNM
oaPL^aNN
oaQL^aNO
oaRL^aNP
oaSL^aNQ
oaTL^aNR
o`ML^aM
saa
k`
spp
o`NL^aN
o`OL^aO
o`PL^aP
o`QL^aQ
o`RL^aR
o`SL^aS
o`TL^aT
ogT
ogS
FIGURE 1-1:
PIC17C762/766
Top View
ogR
ogQ
o^MLfkq
o_ML`^mN
o_NL`^mO
o_PLmtjO
o_QLq`ihNO
o_RLq`ihP
o_OLmtjN
spp
k`
lp`OL`ihlrq
lp`NL`ihfk
saa
o_TLpal
o_SLp`h
o^PLpafLpa^
o^OLppLp`i
o^NLqM`hf
ogP
ogO
oaOL^aNM
oaPL^aNN
oaQL^aNO
oaRL^aNP
oaSL^aNQ
oaTL^aNR
o`ML^aM
saa
k`
spp
o`NL^aN
o`OL^aO
o`PL^aP
o`QL^aQ
o`RL^aR
o`SL^aS
o`TL^aT
NN NM V U T S R Q P O N UQ UPUOUNUM TVTUTTTSTR
NO
TQ
NP
TP
NQ
TO
NR
TN
NS
TM
SV
NT
SU
NU
ST
NV
SS
OM
SR
ON
SQ
OO
SP
OP
SO
OQ
SN
OR
SM
OS
RV
OT
RU
OU
RT
OV
RS
PM
PN
RR
PO
RQ
PPPQPRPSPTPUPVQMQNQOQPQQQRQS QTQUQV RM RN RO RP
oeSL^kNQ
oeTL^kNR
ocNL^kR
ocML^kQ
^saa
^spp
odPL^kMLsobcH
odOL^kNLsobcJ
odNL^kO
odML^kP
k`
spp
saa
odQL`^mP
odRLmtjP
odTLquOL`hO
odSLouOLaqO
o^RLquNL`hN
o^QLouNLaqN
ogM
ogN
oeO
oeP
oaNL^aV
oaML^aU
obML^ib
obNLlb
obOLto
obPL`^mQ
j`ioLsmm
qbpq
k`
spp
saa
ocTL^kNN
ocSL^kNM
ocRL^kV
ocQL^kU
ocPL^kT
ocOL^kS
oeQL^kNO
oeRL^kNP
V U T S R Q P O N SU ST SS SR SQ SP SO SN
oaNL^aV
oaML^aU
obML^ib
obNLlb
obOLto
obPL`^mQ
j`ioLsmm
qbpq
k`
spp
saa
ocTL^kNN
ocSL^kNM
ocRL^kV
ocQL^kU
ocPL^kT
ocOL^kS
NM
NN
NO
NP
NQ
NR
NS
NT
NU
NV
OM
ON
OO
OP
OQ
OR
OS
PIC17C752/756/756A
Top View
SM
RV
RU
RT
RS
RR
RQ
RP
RO
RN
RM
QV
QU
QT
QS
QR
QQ
o^MLfkq
o_ML`^mN
o_NL`^mO
o_PLmtjO
o_QLq`ihNO
o_RLq`ihP
o_OLmtjN
spp
k`
lp`OL`ihlrq
lp`NL`ihfk
saa
o_TLpal
o_SLp`h
o^PLpafLpa^
o^OLppLp`i
o^NLqM`hf
ocNL^kR
ocML^kQ
^saa
^spp
odPL^kMLsobcH
odOL^kNLsobcJ
odNL^kO
odML^kP
k`
spp
saa
odQL`^mP
odRLmtjP
odTLquOL`hO
odSLouOLaqO
o^RLquNL`hN
o^QLouNLaqN
OT OU OV PM PN PO PP PQ PR PS PT PU PV QM QN QO QP
TABLE 1-1:
Pin Name
Pin Name
Pin Type
RA4:RA0
TEST
PORTB<7:0>
PORTC<7:0>
MCLR/VPP
VDD
VSS
RA4:RA0
TEST
DAD15:DAD8
DAD7:DAD0
VPP
VDD
VSS
I
I
I/O
I/O
P
P
P
Pin Description
Necessary in programming mode
Must be set to high to enter programming mode
Address & data: high byte
Address & data: low byte
Programming Power
Power Supply
Ground
apPMOTQ_J~=PJTS
=OMMP=j=q=fK
PIC17C7XX
2.0
2.1
Note:
Program/Verify Mode
e)
Load any arbitrary 16-bit address to start program and/or verify at that location.
Increment address to program/verify the next
location.
Allows arbitrary length programming pulse width.
Following a verify allows option to program the
same location or increment and verify the next
location.
Following a program allows options to program
the same location again, verify the same location or to increment and verify the next location.
FIGURE 2-1:
Reset
Jump to
Program
Routine
Pulse
RA1
Load
Address
Pulse
RA1
Pulse RA1
(Raise RA1
after RA0)
Reset
RA0
Raise RA1
before RA0
=OMMP=j=q=fK
Program
Pulse RA0
(RA0 pulse
width is
programming time)
apPMOTQ_J~=PJTT
PIC17C7XX
2.1.1
2.1.3
FIGURE 2-2:
PROGRAM CYCLE
Program cycle is entered from verify cycle or program cycle itself. After a verify, pulsing RA0 will begin
a program cycle. 16-bit data must be presented on
PORTB (high byte) and PORTC (low byte) before RA0
is raised.
The data is sampled 3 TCY cycles after the rising edge
of RA0. Programming continues for the duration of RA0
pulse.
At the end of programming, the user can choose one of
three different routes. If RA1 is kept low and RA0 is
pulsed again, the same location will be programmed
again. This is useful for applying over programming
pulses. If RA1 is raised before RA0 falling edge, then a
verify cycle is started without address increment. Raising RA1 after RA0 goes low will increment address and
begin verify cycle on the next address.
PIC17C756/756A
PIC17C762
PIC17C766
On-chip
Program
EPROM
On-chip
Program
EPROM
On-chip
Program
EPROM
On-chip
Program
EPROM
Configuration
Word
Configuration
Word
Configuration
Word
0000h
FE00h
FOSC0
FE01h
FOSC1
FE02h
WDTPS0
FE03h
WDTPS1
FE04h
PM0
FE05h
Reserved
FE06h
PM1
FE07h
Reserved
FE08h
Reserved
FE09h
Reserved
FE0Eh
BODEN
FE0Fh
PM2
1FFFh
3FFFh
FE00h Configuration
Word
FE0Fh
FFFFh
apPMOTQ_J~=PJTU
=OMMP=j=q=fK
PIC17C7XX
3.0
FIGURE 3-1:
NO
RA1 = 0
RA2 = 0
RA3 = 0
RA4 = 1
YES
NO
RA1 = 1
MCLR = 1
Bport = 0xE1
(hold for 10 TCY)
YES
NO
Present address
on ports RB, RC
hold TCY after
RA1 changes
to 1
NO
RA1 = 0
RA1 = 1
YES
B and C
ports not
driven by part
Program
16-bit
data
YES
NO
RA1 = 0
NO
If programming is desired
force portB = MSB of data
force portC = LSB of data
(hold 10 Tcy after RA0
is raised)
RA0 = 0
YES
YES
YES
Stop driving
address on ports
YES
YES
RA1 = 0
RA1 = 0
NO
RA0 = 1
NO
NO
RA0 = 1
NO
NO
NO
RA1 = 1
YES
RA1 = 1
YES
Increment
Address
NO
RA1 = 1
YES
Bport = xxx
- B port is forced by the part
B port =
MSB of Data
C port =
LSB of Data
Bport = xxx
=OMMP=j=q=fK
apPMOTQ_J~=PJTV
PIC17C7XX
FIGURE 3-2:
Verify blank
Pulse
Blank
Check?
NO
YES
Load new data
Set VDD = VDDMIN
YES
NO
Pass?
Verify location
for correct date
YES
Pass?
NO
NO
PulseCount
>25
YES
Location fails
programming issue error
message Unable to
programming location
apPMOTQ_J~=PJUM
=OMMP=j=q=fK
PIC17C7XX
FIGURE 3-3:
Start
Verify blank
Pass
Blank
check?
NO
YES
Load new data
Programming error:
Issue error message
Fail verify @ VDDmin/max
YES
Pass?
NO
Pulse
count
<100
NO
SetVVDD==VVDDmin
min
Set
aa
aa
Verify
location
YES
Pass?
NO
Location fails
programming, issue error
message Unable to
program location
=OMMP=j=q=fK
apPMOTQ_J~=PJUN
PIC17C7XX
4.0
4.1
4.2
Hardware Requirements
Function
Type
RA4/RX/DT
DT
I/O
Description
Serial Data
RA5/TX/CK
CK
Serial Clock
RA1/T0CKI
OSCI
TEST
TEST
MCLR/VPP
MCLR/VPP
Programming Power
VDD
VDD
Power Supply
VSS
VSS
Ground
apPMOTQ_J~=PJUO
=OMMP=j=q=fK
PIC17C7XX
4.3
Software Commands
4.3.1
This feature is similar to that of the PIC16CXXX midrange family, but the programming commands have
been implemented in the device Boot ROM. The Boot
ROM is located in the program memory from 0xFF60 to
0xFFFF. The ISP mode is entered when the TEST pin
has a VIHH voltage applied. Once in ISP mode, the
USART/SCI module is configured as a synchronous
slave receiver, and the device waits for a command to
be received. The ISP firmware recognizes eight commands. These are shown in Table 4-2.
TABLE 4-2:
4.3.2
INCREMENT ADDRESS
ISP COMMANDS
Command
Value
RESET PROGRAM
MEMORY POINTER
0000
0000
LOAD DATA
0000
0010
READ DATA
0000
0100
INCREMENT ADDRSS
0000
0110
BEGIN PROGRAMMING
0000
1000
LOAD ADDRESS
0000
1010
READ ADDRESS
0000
1100
END PROGRAMMING
0000
1110
FIGURE 4-1:
o^NLqM`hf
sfee
mpO
Test
j`io/smm
sfee
Ekbuq=`ljj^kaF
mpP
mpN
RA5 (Clock)
mpS
mpQmpR
M
RA4 (Data)
RA4 = Input
Reset
FIGURE 4-2:
o^NLqM`hf
sfee
Test
j`io/smm
mpO
sfee
mpP
mpN
Ekbuq=`ljj^kaF
R
RA5 (Clock)
mpS
mpQmpR
RA4 (Data)
RA4 = Input
Reset
=OMMP=j=q=fK
apPMOTQ_J~=PJUP
PIC17C7XX
4.3.3
LOAD ADDRESS
4.3.4
FIGURE 4-3:
READ ADDRESS
o^NLqM`hf
sfee
mpO
Test
sfee
j`io/smm
mpP
mpN
Ekbuq=`ljj^kaF
NR
NS
RA5 (Clock)
mpT
mpS
mpQmpR
M
RA4 (Data)
RA4 = Input
Reset
FIGURE 4-4:
o^NLqM`hf
sfee
mpO
Test
j`io/smm
sfee
mpP
mpN
Ekbuq=`ljj^kaF
NR
NS
RA5 (Clock)
mpU
mpS
mpQmpR
RA4 (Data)
mpV
RA4 = Input
Reset
apPMOTQ_J~=PJUQ
RA4 = Output
Program/Verify Test Mode
=OMMP=j=q=fK
PIC17C7XX
4.3.5
LOAD DATA
4.3.6
This is used to load the 16-bit data that is to be programmed into the Program Memory location. The Program Memory address may be modified after the data
is loaded. This data will not be programmed until a
BEGIN PROGRAMMING command is executed.
FIGURE 4-5:
READ DATA
o^NLqM`hf
sfee
Test
j`io/smm
mpO
sfee
Ekbuq=`ljj^kaF
mpP
mpN
NR
NS
RA5 (Clock)
mpT
pmS
mpQmpR
M
RA4 (Data)
RA4 = Input
Reset
FIGURE 4-6:
o^NLqM`hf
sfee
Test
j`io/smm
mpO
sfee
mpP
mpN
Ekbuq=`ljj^kaF
NR
NS
RA5 (Clock)
mpU
mpS
mpQmpR
RA4 (Data)
mpV
RA4 = Input
Reset
=OMMP=j=q=fK
RA4 = Output
Program/Verify Test Mode
apPMOTQ_J~=PJUR
PIC17C7XX
4.3.7
BEGIN PROGRAMMING
4.3.8
FIGURE 4-7:
3X OVERPROGRAMMING
Once a location has been both programmed and verified over a range of voltages, 3X overprogramming
should be applied. In other words, apply three times the
number of programming pulses that were required to
program a location in memory, to ensure a solid programming margin.
This means that every location will be programmed a
minimum of 4 times (1 + 3X overprogramming).
o^NLqM`hf
sfee
Test
j`io/smm
mpO
sfee
mpP
mpN
Ekbuq=`ljj^kaF
R
RA5 (Clock)
mpNM
mpQmpR
RA4 (Data)
RA4 = Input
Reset
apPMOTQ_J~=PJUS
=OMMP=j=q=fK
PIC17C7XX
FIGURE 4-8:
START
TEST = Vihh
MCLR = Vihh
ISP Command
RESET ADDRESS
ISP Command
INCREMENT ADDRESS
or
LOAD ADDRESS
N=1
ISP Command
LOAD DATA
Yes
No
ISP Command
BEGIN PROGRAMMING
N > 25?
Report
Programming
Failure
ISP Command
READ DATA
No
Data Correct?
N=N+1
Yes
N = 3N
ISP Command
BEGIN PROGRAMMING
Verify all Locations
@ Vddmin
Wait approx 100 ms
No
Data Correct?
N=N-1
Yes
No
N = 0?
Yes
No
Programmed all
required locations?
Report
Verify
Error
@ Vddmin
Yes
Yes
No
Data Correct?
Report
Verify
Error
@ Vddmax
DONE
=OMMP=j=q=fK
apPMOTQ_J~=PJUT
PIC17C7XX
5.0
CONFIGURATION WORD
5.1
TABLE 5-2:
TABLE 5-1:
CONFIGURATION BIT
PROGRAMMING LOCATIONS
Bit
Address
FOSC0
0xFE00
FOSC1
0xFE01
WDTPS0
0xFE02
WDTPS1
0xFE03
PM0
0xFE04
PM1
0xFE06
BODEN
0xFE0E
PM2
0xFE0F
15
14
13
12
11
10
PM1
15
1
14
1
13
1
12
1
11
1
10
1
9
1
8
1
7
PM2
6
BODEN
3
PM2
2
PM2
1
PM2
0
PM2
=Unused
PM<2:0>, Processor Mode Select bits
111 = Microprocessor mode
110 = Microcontroller mode
101 = Extended Microcontroller mode
000 = Code protected microcontroller mode
BODEN, Brown-out Detect Enable
1
= Brown-out Detect Circuitry enabled
0
= Brown-out Detect Circuitry disabled
WDTPS1:WDTPS0, WDT Prescaler Select bits.
11 = WDT enabled, postscaler = 1
10 = WDT enabled, postscaler = 256
01 = WDT enabled, postscaler = 64
00 = WDT disabled, 16-bit overflow timer
FOSC1:FOSC0, Oscillator Select bits
11 = EC oscillator
10 = XT oscillator
01 = RC oscillator
00 = LF oscillator
apPMOTQ_J~=PJUU
=OMMP=j=q=fK
PIC17C7XX
5.2
To allow portability of code, a PIC17C7XX programmer is required to read the configuration word locations from the
hex file when loading the hex file. If the configuration word information was not present in the hex file, then a simple
warning message may be issued. Similarly, while saving a hex file, all configuration word information must be included.
An option to not include the configuration word information may be provided. When embedding configuration word
information in the hex file, it should be to address FE00h.
Microchip Technology Inc. feels strongly that this feature is important for the benefit of the end customer.
5.3
=OMMP=j=q=fK
apPMOTQ_J~=PJUV
PIC17C7XX
5.4
CHECKSUM COMPUTATION
TABLE 5-3:
CHECKSUM COMPUTATION
Code
Protect
Checksum*
Blank
Value
0xC0DE at 0
and max
address
PIC17C752
MP mode
MC mode
EMC mode
PMC mode
0xA05F
0xA04F
0xA01F
0x200F
0x221D
0x220D
0x21DD
0xE3D3
PIC17C756
MP mode
MC mode
EMC mode
PMC mode
0x805F
0x804F
0x801F
0x000F
0x021D
0x020D
0x01DD
0xC3D3
PIC17C756A
MP mode
MC mode
EMC mode
PMC mode
0x805F
0x804F
0x801F
0x000F
0x021D
0x020D
0x01DD
0xC3D3
PIC17C762
MP mode
MC mode
EMC mode
PMC mode
0xA05F
0xA04F
0xA01F
0x200F
0x221D
0x220D
0x21DD
0xE3D3
PIC17C766
MP mode
MC mode
EMC mode
PMC mode
0x805F
0x804F
0x801F
0x000F
0x021D
0x020D
0x01DD
0xC3D3
Device
apPMOTQ_J~=PJVM
=OMMP=j=q=fK
PIC17C7XX
5.5
Device ID Register
TABLE 5-4:
REV
PIC17C766
X XXXX
PIC17C762
X XXXX
PIC17C756
X XXXX
PIC17C756A
X XXXX
PIC17C752
X XXXX
=OMMP=j=q=fK
apPMOTQ_J~=PJVN
PIC17C7XX
6.0
Parameter
No.
Sym.
Characteristic
Min.
Typ.
Max.
Units
PD1
VDDP
4.75
5.0
5.25
PD2
IDDP
50
mA
PD3
VDDV
Note 2
VPP
VDD
max.
13.25
PD4
VDD
min.
12.75
PD6
P1
P2
P3
P4
P5
P6
P7
P8
P9
P10
P11
P12
P13
P14
P15
P16
P17
P18
P19
Note 1:
2:
Conditions/Comments
V
Note 1
during programming
IPP
25
50
mA
Programming current on
VPP/MCLR pin
FOSCP
Osc/clockin frequency dur4
10
MHz
ing programming
TCY
Instruction cycle
1
0.4
ms
TCY = 4/FOSCP
TIRV2TSH
RA0, RA1, RA2, RA3, RA4
1
ms
setup before TEST
TEST to MCLR
1
ms
TTSH2MCH
TBCV2IRH
RC7:RC0, RB7:RB0 valid to
0
ms
RA1 or RA0:Address/Data
input setup time
RA1 or RA0 to RB7:RB0, 10 TCY
ms
TIRH2BCL
RC7:RC0 invalid; Address
data hold time;
8TCY
T0CKIL2RBCZ RT to RB7:RB0, RC7:RC0
hi-impedance
T0CKIH2BCV
RA1 to data out valid
10 TCY
TPROG
Programming pulse width
100
1000
ms
TIRH2IRL
RA0, RA1 high pulse width 10 TCY
ms
TIRL2IRH
RA0, RA1 low pulse width 10 TCY
ms
RA1 before INT (to go
0
ms
T0CKIV2INL
from prog cycle to verify w/o
increment)
TINL2RTL
RA1 valid after RA0 (to
ms
10 TCY
select increment or no
increment going from program to verify cycle
TVPPS
VPP setup time before RA0 100
ms
Note 1
TVPPH
VPP hold time after INT
0
ms
Note 1
TVDV2TSH
VDD stable to TEST
10
ms
0
ms
TRBV2MCH RB input (E1h) valid to VPP/
MCLR
TMCH2RBI
RB input (E1h) hold after 10TCY
ns
VPP/MCLR
TVPL2VDL
VDD power down after VPP
10
ms
power down
VPP/MCLR pin must only be equal to or greater than VDD at times other than programming.
Program must be verified at the minimum and maximum VDD limits for the part.
apPMOTQ_J~=PJVO
=OMMP=j=q=fK
=OMMP=j=q=fK
RC<7:0>
RB<7:0>
RA0
RA1
P5
E1H
P18
P4
Note:
Load Address X
ADDR_LO
ADDR_HI
RA2 = 0
RA3 = 0
RA4 = 1
Jump Address
Input
Programming
Mode Entry
5V
13V
P9
P7
DATA_LO OUT
DATA_HI OUT
P11
INC
ADDR
Verify location X
Increment Address to X + 1
by pulsing RA1
P10
Verify location X + 1
DATA_LO OUT
DATA_HI OUT
P9
P6
Program location X + !
Do not increment PC
by raising RA1 before
RA0
P5
DATA_LO OUT
DDATA_HI OUT
P14
P15
Verify location X + 1
DATA_LO OUT
DATA_HI OUT
FIGURE 6-1:
MCLR
Test
PIC17C7XX
apPMOTQ_J~=PJVP
apPMOTQ_J~=PJVQ
Note:
RC<7:0>
RB<7:0>
RA0
RA1
E1H
Jump Address
Input
RA2 = 0
RA3 = 0
RA4 = 1
Programming
mode entry
5V
13V
Load address X
ADDR_LO
ADDR_HI
Verify location X
DATA_LO OUT
DATA_HI OUT
P14
DATA_LO_IN
DATA_HI_IN
P9
Program location X
DATA_LO_IN
DATA_HI_IN
P9
Program location X
Move to verify cycle
Prevent increment of
PC by raising RA1
before RA0
DATA_LO_IN
DATA_HI_IN
P9
P15
Verify location X
DATA_LO OUT
DATA_HI OUT
FIGURE 6-2:
VPP/MCLR
Test
PIC17C7XX
PARALLEL MODE PROGRAMMING AND VERIFY TIMINGS II
=OMMP=j=q=fK
=OMMP=j=q=fK
DATA_LO OUT
RC<7:0>
Note:
Verify location X
DATA_HIOUT
RB<7:0>
INC PC
Program location X
Do not increment
PC Raise RA1 before
RA0 to do this
DATA_LO IN
DATA_HI IN
P12
Verify location X
DATA_LO OUT
DATA_HI OUT
Program location X
Raise RA1 after RA0
to increment location X + 1
DATA_LO IN
DATA_HI IN
INC PC
P13
Verify location X + 1
Pulse RA1 to increment
address to X + 2
DATA_LO OUT
DATA_HI OUT
INC PC
Verify location X + 2
DATA_LO IN
DATA_HI IN
FIGURE 6-3:
RA0
RA1
P13
PIC17C7XX
apPMOTQ_J~=PJVR
PIC17C7XX
FIGURE 6-4:
VDD
P19
P16
VPP/MCLR
Test
RA4
RA2
RA3
RA0
P3
RB<7:0>
P17
E1H
apPMOTQ_J~=PJVS
P18
=OMMP=j=q=fK
PIC17C7XX
7.0
PS1
0 to +70C
-40C to +85C
Sym
Characteristic
Min
Typ
Max
Units
VIHH
12.75
13.75
IPP
25
50
mA
FOSC
MHz
TCY
4/FOSC
TVH2VH
ms
PS2
TSER
20
TCY
PS3
TSCLK
TCY
PS4
TSET1
15
ns
PS5
THLD1
15
ns
PS6
TDLY1
20
TCY
PS7
TDLY2
20
TCY
PS8
TDLY3
30
TCY
PS9
TDLY4
TCY
PS10
TDLY5
100
ms
Conditions
=OMMP=j=q=fK
apPMOTQ_J~=PJVT
PIC17C7XX
FIGURE 7-1:
o^NLqM`hf
sfee
mpO
Test
j`io/smm
sfee
Ekbuq=`ljj^kaF
mpP
mpN
RA5 (Clock)
mpS
mpQmpR
M
RA4 (Data)
RA4 = Input
Reset
FIGURE 7-2:
o^NLqM`hf
sfee
Test
j`io/smm
mpO
sfee
mpP
mpN
Ekbuq=`ljj^kaF
R
RA5 (Clock)
mpS
mpQmpR
RA4 (Data)
RA4 = Input
Reset
apPMOTQ_J~=PJVU
=OMMP=j=q=fK
PIC17C7XX
FIGURE 7-3:
o^NLqM`hf
sfee
mpO
Test
sfee
j`io/smm
mpP
mpN
Ekbuq=`ljj^kaF
NR
NS
RA5 (Clock)
mpT
mpS
mpQmpR
M
RA4 (Data)
RA4 = Input
Reset
FIGURE 7-4:
o^NLqM`hf
sfee
Test
j`io/smm
mpO
sfee
mpP
mpN
Ekbuq=`ljj^kaF
NR
NS
RA5 (Clock)
mpU
mpS
mpQmpR
RA4 (Data)
mpV
RA4 = Input
Reset
=OMMP=j=q=fK
RA4 = Output
Program/Verify Test Mode
apPMOTQ_J~=PJVV
PIC17C7XX
FIGURE 7-5:
o^NLqM`hf
sfee
mpO
Test
j`io/smm
sfee
Ekbuq=`ljj^kaF
mpP
mpN
NR
NS
RA5 (Clock)
mpT
mpS
mpQmpR
M
RA4 (Data)
RA4 = Input
Reset
FIGURE 7-6:
o^NqM`hf
sfee
mpO
Test
j`io/smm
sfee
mpP
mpN
Ekbuq=`ljj^kaF
NR
NS
RA5 (Clock)
mpU
mpS
mpQmpR
M
RA4 (Data)
mpV
RA4 = Input
RA4 = Output
Reset
FIGURE 7-7:
o^NLqM`hf
sfee
Test
j`io/smm
mpO
sfee
mpP
mpN
Ekbuq=`ljj^kaF
R
RA5 (Clock)
mpNM
mpQmp
RA4 (Data)
RA4 = Input
Reset
apPMOTQ_J~=PJNMM
=OMMP=j=q=fK
PIC18CXXX
In-Circuit Serial ProgrammingTM for PIC18CXXX OTP MCUs
This document includes the
programming specifications for the
following devices:
PIC18C242
PIC18C601
PIC18C252
PIC18C801
PIC18C442
PIC18C658
PIC18C452
PIC18C858
1.0
Pin Diagrams
The pin diagrams for the PIC18CXX2 family are shown
below in Figure 1-1 through Figure 1-3. Pin diagrams for
the PIC18CXX8 family are provided in Figure 1-4
through Figure 1-7. Pin diagrams for the PIC18C601/801
family are provided in Figure 1-8 through Figure 1-11.
FIGURE 1-1:
PROGRAMMING THE
PIC18CXXX
Programming Mode
TABLE 1-1:
PIC18CXX2
Hardware Requirements
1.2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
MCLR/VPP
RA0/AN0
RA1/AN1
RA2/AN2/VREFRA3/AN3/VREF+
RA4/T0CKI
RA5/AN4/SS/LVDIN
RE0/RD/AN5
RE1/WR/AN6
RE2/CS/AN7
VDD
VSS
OSC1/CLKI
OSC2/CLKO/RA6
RC0/T1OSO/T1CKI
RC1/T1OSI/CCP2*
RC2/CCP1
RC3/SCK/SCL
RD0/PSP0
RD1/PSP1
1.1
PIC18CXX2 FAMILY
PIN DIAGRAM
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
RB7
RB6
RB5
RB4
RB3/CCP2*
RB2/INT2
RB1/INT1
RB0/INT0
VDD
VSS
RD7/PSP7
RD6/PSP6
RD5/PSP5
RD4/PSP4
RC7/RX/DT
RC6/TX/CK
RC5/SDO
RC4/SDI/SDA
RD3/PSP3
RD2/PSP2
Pin Name
Pin Name
Pin Type
Pin Description
MCLR/VPP
VPP
Programming Power
VDD
VDD
Power Supply
VSS
VSS
Ground
RB6
RB6
Serial Clock
RB7
RB7
I/O
Serial Data
DS39028E-page 3-101
PIC18CXXX
PIC18C4X2 44-PIN PLCC AND 44-PIN TQFP DIAGRAMS
RA3/AN3/VREF+
RA2/AN2/VREFRA1/AN1
RA0/AN0
MCLR/VPP
NC
RB7
RB6
RB5
RB4
NC
FIGURE 1-2:
6
5
4
3
2
1
44
43
42
41
40
PLCC
7
8
9
10
11
12
13
14
15
16
171
39
38
37
36
35
34
33
32
31
30
29
PIC18C4X2
28
27
26
25
24
23
22
21
20
19
8
RA4/T0CKI
RA5/AN4/SS/LVDIN
RE0/RD/AN5
RE1/WR/AN6
RE2/CS/AN7
VDD
VSS
OSC1/CLKI
OSC2/CLKO/RA6
RC0/T1OSO/T1CKI
NC
RB3/CCP2*
RB2/INT2
RB1/INT1
RB0/INT0
VDD
VSS
RD7/PSP7
RD6/PSP6
RD5/PSP5
RD4/PSP4
RC7/RX/DT
RC6/TX/CK
RC5/SDO
RC4/SDI/SDA
RD3/PSP3
RD2/PSP2
RD1/PSP1
RD0/PSP0
RC3/SCK/SCL
RC2/CCP1
RC1/T1OSI/CCP2*
NC
NC
RC6/TX/CK
RC5/SDO
RC4/SDI/SDA
RD3/PSP3
RD2/PSP2
RD1/PSP1
RD0/PSP0
RC3/SCK/SCL
RC2/CCP1
RC1/T1OSI/CCP2*
44
43
42
41
40
39
38
37
36
35
34
TQFP
1
2
3
4
5
6
7
8
9
10
11
PIC18C4X2
33
32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
RC7/RX/DT
RD4/PSP4
RD5/PSP5
RD6/PSP6
RD7/PSP7
VSS
VDD
RB0/INT0
RB1/INT1
RB2/INT2
RB3/CCP2*
NC
RC0/T1OSO/T1CKI
OSC2/CLKO/RA6
OSC1/CLKI
VSS
VDD
RE2/AN7/CS
RE1/AN6/WR
RE0/AN5/RD
RA5/AN4/SS/LVDIN
RA4/T0CKI
RA3/AN3/VREF+
RA2/AN2/VREFRA1/AN1
RA0/AN0
MCLR/VPP
RB7
RB6
RB5
RB4
NC
NC
* RB3 is the alternate pin for the CCP2 pin multiplexing.
Note: Pin compatible with 44-pin PIC16C7X devices.
DS39028E-page 3-102
PIC18CXXX
FIGURE 1-3:
MCLR/VPP
RA0/AN0
RA1/AN1
RA2/AN2/VREFRA3/AN3/VREF+
RA4/T0CKI
RA5/AN4/SS/LVDIN
VSS
OSC1/CLKI
OSC2/CLKO/RA6
RC0/T1OSO/T1CKI
RC1/T1OSI/CCP2*
RC2/CCP1
RC3/SCK/SCL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
PIC18C2X2
RB7
RB6
RB5
RB4
RB3/CCP2*
RB2/INT2
RB1/INT1
RB0/INT0
VDD
VSS
RC7/RX/DT
RC6/TX/CK
RC5/SDO
RC4/SDI/SDA
DS39028E-page 3-103
PIC18CXXX
RD4/PSP4
RD5/PSP5
RD6/PSP6
RD7/PSP7
RE5
RE6
RE7/CCP2
RD0/PSP0
VDD
VSS
RD1/PSP1
RD2/PSP2
RD3/PSP3
RE2/CS
RE3
RE4
FIGURE 1-4:
64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49
RE1/WR
48
RB0/INT0
RE0/RD
47
RB1/INT1
RG0/CANTX1
46
RB2/INT2
RG1/CANTX2
45
RB3/INT3
RG2/CANRX
44
RB4
RG3
43
RB5
MCLR/VPP
RG4
42
RB6
41
VSS
VSS
40
OSC2/CLKO/RA6
VDD
10
39
OSC1/CLKI
RF7
11
38
VDD
RF6/AN11
12
37
RB7
RF5/AN10/CVREF
13
36
RC5/SDO
RF4/AN9
14
35
RC4/SDI/SDA
RF3/AN8
15
34
RC3/SCK/SCL
RF2/AN7/C1OUT
16
33
RC2/CCP1
PIC18C658
RC0/T1OSO/T13CKI
RC6/TX/CK
RC7/RX/DT
RA4/T0CKI
RC1/T1OSI
RF0/AN5
AVDD
AVSS
RA3/AN3/VREF+
RA2/AN2/VREFRA1/AN1
RA0/AN0
VSS
VDD
RA5/SS/AN4/LVDIN
RF1/AN6/C2OUT
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Note: All PIC18C658 and PIC18C858 package outlines are compatible with PIC17C7XX.
DS39028E-page 3-104
PIC18CXXX
PIC18C658 68-PIN PLCC DIAGRAM
RE2/CS
RE3
RE4
RE5
RE6
RE7/CCP2
RD0/PSP0
VDD
NC
VSS
RD1/PSP1
RD2/PSP2
RD3/PSP3
RD4/PSP4
RD5/PSP5
RD6/PSP6
RD7/PSP7
FIGURE 1-5:
9 8 7 6 5 4 3 2 1 68 67 66 65 64 63 62 61
RE1/WR
RE0/RD
RG0/CANTX1
RG1/CANTX2
RG2/CANRX
RG3
MCLR/VPP
RG4
NC
VSS
VDD
RF7
RF6/AN11
RF5/AN10/CVREF
RF4/AN9
RF3/AN8
RF2/AN7/C1OUT
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
PIC18C658
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
RB0/INT0
RB1/INT1
RB2/INT2
RB3/INT3
RB4
RB5
RB6
VSS
NC
OSC2/CLKO/RA6
OSC1/CLKI
VDD
RB7
RC5/SDO
RC4/SDI/SDA
RC3/SCK/SCL
RC2/CCP1
RF1/AN6/C2OUT
RF0/AN5
AVDD
AVSS
RA3/AN3/VREF+
RA2/AN2/VREFRA1/AN1
RA0/AN0
NC
VSS
VDD
RA5/SS/AN4/LVDIN
RA4/T0CKI
RC1/T1OSI
RC0/T1OSO/T13CKI
RC6/TX/CK
RC7/RX/DT
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
Note: All PIC18C658 and PIC18C858 package outlines are compatible with PIC17C7XX.
DS39028E-page 3-105
PIC18CXXX
RD4/PSP4
RD5/PSP5
RD6/PSP6
RD7/PSP7
RJ0
RJ1
RE5
RE6
RE7/CCP2
RD0/PSP0
VDD
VSS
RD1/PSP1
RD2/PSP2
RD3/PSP3
RH1
RH0
RE2/CS
RE3
RE4
FIGURE 1-6:
80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61
RH2
60
RJ2
RH3
59
RE1/WR
58
RJ3
RB0/INT0
RE0/RD
57
RB1/INT1
RG0/CANTX1
56
RB2/INT2
RG1/CANTX2
55
RB3/INT3
RG2/CANRX
54
RB4
RG3
53
RB5
MCLR/VPP
RG4
52
RB6
10
51
VSS
50
OSC2/CLKO/RA6
49
OSC1/CLKI
VSS
11
VDD
12
RF7
13
48
VDD
PIC18C858
RF6/AN11
14
47
RB7
RF5/AN10/CVREF
15
46
RC5/SDO
RF4/AN9
16
45
RC4/SDI/SDA
RF3/AN8
17
44
RC3/SCK/SCL
RF2/AN7/C1OUT
18
43
RC2/CCP1
RH7/AN15
19
42
RK3
RH6/AN14
20
41
RK2
RK0
RK1
RC0/T1OSO/T13CKI
RC6/TX/CK
RC7/RX/DT
RA5/SS/AN4/LVDIN
RA4/T0CKI
RC1/T1OSI
RA1/AN1
RA0/AN0
VSS
VDD
RF1/AN6/C2OUT
RF0/AN5
AVDD
AVSS
RA3/AN3/VREF+
RA2/AN2/VREF-
RH5/AN13
RH4/AN12
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
Note: All PIC18C658 and PIC18C858 package outlines are compatible with PIC17C7XX.
DS39028E-page 3-106
PIC18CXXX
PIC18C858 84-PIN PLCC DIAGRAM
RH1
RH0
RE2/CS
RE3
RE4
RE5
RE6
RE7/CCP2
RD0/PSP0
VDD
NC
VSS
RD1/PSP1
RD2/PSP2
RD3/PSP3
RD4/PSP4
RD5/PSP5
RD6/PSP6
RD7/PSP7
RJ0
RJ1
FIGURE 1-7:
11 10 9 8 7 6 5 4 3 2 1 84 83 82 81 80 79 78 77 76 75
RH2
RH3
RE1/WR
RE0/RD
RG0/CANTX1
RG1/CANTX2
RG2/CANRX
RG3
MCLR/VPP
RG4
NC
VSS
VDD
RF7
RF6/AN11
RF5/AN10/CVREF
RF4/AN9
RF3/AN8
RF2/AN7/C1OUT
RH7/AN15
RH6/AN14
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
PIC18C858
74
73
72
71
70
69
68
67
66
65
64
63
62
61
60
59
58
57
56
55
54
RJ2
RJ3
RB0/INT0
RB1/INT1
RB2/INT2
RB3/INT3
RB4
RB5
RB6
VSS
NC
OSC2/CLKO/RA6
OSC1/CLKI
VDD
RB7
RC5/SDO
RC4/SDI/SDA
RC3/SCK/SCL
RC2/CCP1
RK3
RK2
RH5/AN13
RH4/AN12
RF1/AN6/C2OUT
RF0/AN5
AVDD
AVSS
RA3/AN3/VREF+
RA2/AN2/VREFRA1/AN1
RA0/AN0
NC
VSS
VDD
RA5/SS/AN4/LVDIN
RA4/T0CKI
RC1/T1OSI
RC0/T1OSO/T13CKI
RC6/TX/CK
RC7/RX/DT
RK0
RK1
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
Note: All PIC18C658 and PIC18C858 package outlines are compatible with PIC17C7XX.
DS39028E-page 3-107
PIC18CXXX
RD4/AD4
RD5/AD5
RD6/AD6
RD7/AD7
RE5/AD13
RE6/AD14
RE7/AD15
RD0/AD0
VDD
VSS
RD1/AD1
RD2/AD2
RD3/AD3
RE2/AD10
RE3/AD11
RE4/AD12
FIGURE 1-8:
64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49
RE1/AD9
48
RB0/INT0
RE0/AD8
47
RB1/INT1
RG0/ALE
46
RB2/INT2
RG1/OE
45
RB3/CCP2
RG2/WRL
44
RB4
RG3/WRH
43
RB5
MCLR/VPP
RG4/BA0
42
RB6
VSS
PIC18C601
41
VSS
40
OSC2/CLKO
VDD
10
39
OSC1/CLKI
RF7/UB
11
38
VDD
RF6/LB
12
37
RB7
RF5/CS1
13
36
RC5/SDO
RF4/A16
14
35
RC4/SDI/SDA
RF3/CSIO
15
34
RC3/SCK/SCL
RF2/AN7
NS
33
RC2/CCP1
DS39028E-page 3-108
o`MLqNlplLqNP`hf
o`SLquL`h
o`TLouLaq
o^QLqM`hf
o`NLqNlpf
ocML^kR
^saa
^spp
o^PL^kPLsobcH
o^OL^kOLsobcJ
o^NL^kN
o^ML^kM
spp
saa
o^RLppL^kQLisafk
ocNL^kS
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
PIC18CXXX
PIC18C601 68-PIN PLCC DIAGRAM
RE2/AD10
RE3/AD11
RE4/AD12
RE5/AD13
RE6/AD14
RE7/AD15
RD0/AD0
saa
NC
spp
RD1/AD1
RD2/AD2
RD3/AD3
RD4/AD4
RD5/AD5
RD6/AD6
RD7/AD7
FIGURE 1-9:
9 8 7 6 5 4 3 2 1 68 67 66 65 64 63 62 61
RE1/AD9
RE0/AD8
RG0/ALE
RG1/OE
RG2/WRL
RG3/WRH
j`ioLsmm
RG4/BA0
NC
VSS
VDD
RF7/UB
RF6/LB
RF5/CS1
RF4/A16
RF3/CSIO
ocOL^kT
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
PIC18C601
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
o_MLfkqM
o_NLfkqN
o_OLfkqO
RB3/CCP2
o_Q
o_R
o_S
spp
NC
lp`OL`ihl
lp`NL`ihf
saa
o_T
o`RLpal
o`QLpafLpa^
o`PLp`hLp`i
o`OL``mN
ocNL^kS
ocML^kR
^saa
^spp
o^PL^kPLsobcH
o^OL^kOLsobcJ
o^NL^kN
o^ML^kM
NC
spp
saa
o^RLppL^kQLisafk
o^QLqM`hf
o`NLqNlpf
o`MLqNlplLqNP`hf
o`SLquL`h
o`TLouLaq
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
DS39028E-page 3-109
PIC18CXXX
RD4/AD4
RD5/AD5
RD6/AD6
RD7/AD7
RJ0/D7
RJ1/D6
RE5/AD13
RE6/AD14
RE7/AD15
RD0/AD0
VDD
VSS
RD1/AD1
RD2/AD2
RD3/AD3
RH1/A17
RH0/A16
RE2/AD10
RE3/AD11
RE4/AD12
FIGURE 1-10:
80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61
RH2/A18
60
RJ5/D5
RH3/A19
59
RE1/AD9
58
RJ4/D4
RB0/INT0
RE0/AD8
57
RB1/INT1
RG0/ALE
56
RB2/INT2
RG1/OE
55
RB3/CCP2
RG2/WRL
54
RB4
RG3/WRH
53
RB5
MCLR/VPP
RG4/BA0
52
RB6
10
51
VSS
50
OSC2/CLKO
49
OSC1/CLKI
VSS
11
VDD
12
RF7/UB
13
48
VDD
PIC18C801
RF6/LB
14
47
RB7
RF5/CS1
15
46
RC5/SDO
RF4/CS2
16
45
RC4/SDI/SDA
RF3/CSIO
17
44
RC3/SCK/SCL
RF2/AN7
18
43
RC2/CCP1
RH4/AN8
19
42
RJ3/D3
RH5/AN9
20
41
RJ2/D2
DS39028E-page 3-110
RJ0/D0
RJ1/D1
RC0/T1OSO/T13CKI
RC6/TX/CK
RC7/RX/DT
RA5/SS/AN4/LVDIN
RA4/T0CKI
RC1/T1OSI
RA1/AN1
RA0/AN0
VSS
VDD
RF1/AN6
RF0/AN5
AVDD
AVSS
RA3/AN3/VREF+
RA2/AN2/VREF-
RH6/AN10
RH7/AN11
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
PIC18CXXX
PIC18C801 84-PIN PLCC DIAGRAM
RH1/A17
RH0/A16
RE2/AD10
RE3/AD11
RE4/AD12
RE5/AD13
RE6/AD14
RE7/AD15
RD0/AD0
VDD
NC
VSS
RD1/AD1
RD2/AD2
RD3/AD3
RD4/AD4
RD5/AD5
RD6/AD6
RD7/AD7
RJ7/D7
RJ6/D6
FIGURE 1-11:
11 10 9 8 7 6 5 4 3 2 1 84 83 82 81 80 79 78 77 76 75
RH2/A18
RH3/A19
RE1/AD9
RE0/AD8
RG0/ALE
RG1/OE
RG2/WRL
RG3/WRH
MCLR/VPP
RG4/BA0
NC
VSS
VDD
RF7/UB
RF6/LB
RF5/CS1
RF4/CS2
RF3/CSIO
RF2/AN7
RH4/AN8
RH5/AN9
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
PIC18C801
74
73
72
71
70
69
68
67
66
65
64
63
62
61
60
59
58
57
56
55
54
RJ5/D5
RJ4/D4
RB0/INT0
RB1/INT1
RB2/INT2
RB3/CCP2
RB4
RB5
RB6
VSS
NC
lp`OL`ihl
lp`NL`ihf
VDD
RB7
RC5/SDO
o`QLpafLpa^
o`PLp`hLp`i
RC2/CCP1
RJ3/D3
RJ2/D2
RH6/AN10
RH7/AN11
RF1/AN6
RF0/AN5
AVDD
AVSS
RA3/AN3/VREF+
RA2/AN2/VREFRA1/AN1
RA0/AN0
NC
VSS
VDD
RA5/SS/AN4/LVDIN
RA4/T0CKI
RC1/T1OSI
RC0/T1OSO/T13CKI
RC6/TX/CK
RC7/RX/DT
RJ0/D0
RJ1/D1
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
DS39028E-page 3-111
PIC18CXXX
2.0
2.1
IN-CIRCUIT SERIAL
PROGRAMMINGTM (ICSPTM)
MODE
Introduction
TABLE 2-1:
2.2
ICSP Operation
2.2.1
Mnemonic,
Operands
Description
Cycles
4-bit Opcode
Status
Affected
NOP
0000
None
TBLRD *
1000
None
TBLRD *+
1001
None
TBLRD *-
1010
None
TBLRD +*
1011
None
TBLWT *
1100
None
TBLWT *+
1101
None
TBLWT *-
1110
None
TBLWT +*
1111
None
Legend: Refer to the PIC18CXXX Data Sheet (DS39026 or DS30475) for opcode field descriptions.
Note: All special instructions not included in this table are decoded as NOPs.
DS39028E-page 3-112
PIC18CXXX
2.2.2
1.
2.
3.
FIGURE 2-1:
Q Cycles Q4 Q1 Q2 Q3 Q4
Q4 Q1 Q2 Q3 Q4
P1
VIHH
P2
MCLR/VPP
P2a
2
10
11
12
13
14
15
16
RB6 (Clock)
P5
P5
P4
P3
RB7 (Data)
Execute FNOP,
Fetch 4-bit Instruction
RESET
Execute Instruction,
Fetch Next 4-bit
Instruction
DS39028E-page 3-113
PIC18CXXX
2.2.3
2.2.4
FIGURE 2-2:
Q Cycles
Q4 Q1 Q2 Q3 Q4
MCLR/VPP = VIHH
1
10
11
12
13
14
15
16
RB6 (Clock)
P5
P5
RB7 (Data)
Execute PC-2,
Fetch NOP to enable
16-bit Instruction fetch
RB7 = Input
ICSP Mode
DS39028E-page 3-114
PIC18CXXX
FIGURE 2-3:
Start
Enable CPU,
execute 16-bit instruction,
and shift in next
4-bit instruction,
Num_Clk = 1,
Qstate = Q<Num_Clk>
MCLR = VSS,
RB6, RB7 = 0
VPP = VIHH
Enable CPU,
execute FNOP,
and shift in 1st
4-bit instruction,
Num_Clk = 1,
Qstate = Q<Num_Clk>
Clock
transition
RB6?
No
Yes
Shift(R) RB7
into ROMLAT<3>,
Num_Clk = Num_Clk + 1
Clock
transition
RB6?
No
Yes
Qstate = Q<4>?
Shift(R) RB7
into ROMLAT<3>,
Num_Clk = Num_Clk + 1
Qstate = Q<4>?
No
Yes
End
No
Yes
Clock
transition
RB6?
No
Yes
Shift(R) RB7
into ROMLAT<15>,
Num_Clk = Num_Clk + 1
Num_Clk = 16?
No
Yes
DS39028E-page 3-115
PIC18CXXX
FIGURE 2-4:
Start
Clock
transition
RB6?
No
Clock
transition
RB6?
Yes
No
Yes
Shift(R) RB7
Num_Clk = Num_Clk + 1
Shift(R) RB7
Num_Clk = Num_Clk + 1
4-bit instruction = NOP,
shift in 16-bit instruction,
Num_Clk = 1
End
Clock
transition
RB6?
No
Yes
Shift(R) RB7
Num_Clk = Num_Clk + 1
Num_Clk = 16?
No
Yes
DS39028E-page 3-116
PIC18CXXX
2.3
FIGURE 2-5:
Q Cycles
Q1 Q2 Q3 Q4
Q1 Q2 Q3 Q4
MCLR/VPP
1
15
16
15
16
RB6 (Clock)
P5
RB7 (Data)
Execute PC-2
Fetch 4-bit NOP
P5
P5
P5
RB7 = Input
ICSP Mode
DS39028E-page 3-117
PIC18CXXX
2.4
FIGURE 2-6:
Q Cycles
Q1 Q2 Q3 Q4
Q1 Q2 Q3 Q4
MCLR/VPP = VIHH
1
15
16
15
16
RB6 (Clock)
P5
RB7 (Data)
Execute PC-2,
Fetch 4-bit NOP
P5
P5
P5
RB7 = Input
ICSP Mode
DS39028E-page 3-118
PIC18CXXX
FIGURE 2-7:
Start
MCLR = VSS,
RB6, RB7 = 0
Clock
transition
RB6?
VPP = VIHH
Yes
Clock
transition
RB6?
No
Yes
Shift(R) RB7,
Num_Clk = Num_Clk + 1
Shift(R) RB7,
Num_Clk = Num_Clk + 1
Clock
transition
RB6?
No
Yes
Shift(R) RB7,
Num_Clk = Num_Clk + 1
Num_Clk = 16?
No
Yes
Enable CPU,
execute 1st cycle of 16-bit
instruction, and shift in next
4-bit instruction,
Num_Clk = 1
No
Yes
Shift(R) RB7,
Num_Clk = Num_Clk + 1
Num_Clk = 16?
Clock
transition
RB6?
No
No
Yes
Execute 2nd cycle of 16-bit
instruction, and shift in
next 4-bit instruction
Num_Clk = 1
Clock
transition
RB6?
No
Yes
Shift(R) RB7,
Num_Clk = Num_Clk + 1
End
DS39028E-page 3-119
PIC18CXXX
FIGURE 2-8:
Clock
transition
RB6?
Start
Yes
Clock
transition
RB6?
No
No
Yes
Shift(R) RB7,
Num_Clk = Num_Clk + 1
Shift(R) RB7,
Num_Clk = Num_Clk + 1
Clock
transition
RB6?
No
Yes
Shift(R) RB7,
Num_Clk = Num_Clk + 1
Num_Clk = 16?
Clock
transition
RB6?
No
Yes
Shift(R) RB7,
Num_Clk = Num_Clk + 1
Num_Clk = 16?
No
Yes
DS39028E-page 3-120
No
Yes
Execute 2nd cycle of 16-bit
instruction, and shift in
next 4-bit instruction
Num_Clk = 1
Clock
transition
RB6?
No
Yes
Shift(R) RB7,
Num_Clk = Num_Clk + 1
End
PIC18CXXX
2.5
TBLWT Instruction
The TBLWT instruction is used in ICSP mode to program the EPROM array. When writing a 16-bit value to
the EPROM, ID locations, or configuration locations,
the device, RB6 must be held high for the appropriate
programming time during the TBLWT instruction, as
specified by parameter P9.
When RB6 is asserted low, the device will cease programming the specified location.
After RB6 is asserted low, RB6 is held low for the time
specified by parameter P10, to allow high voltage discharge of the program memory array.
2.
3.
4.
FIGURE 2-9:
Q Cycles Q1 Q2 Q3 Q4
Q1 Q2 Q3 Q4
MCLR/VPP = VIHH
P10
1
15
16
RB6 (Clock)
P9
P5
P5
RB7 (Data)
Execute PC-2
Fetch TBLWT
Programming Time
Execute 1st
Cycle TBLWT
fetch next
4-bit command
RB7 = Input
ICSP Mode
DS39028E-page 3-121
PIC18CXXX
FIGURE 2-10:
Start
Clock
transition
RB6?
MCLR = VSS,
RB6, RB7 = 0
No
Yes
Shift(R) RB7
Num_Clk = Num_Clk + 1
VPP = VIHH
Execute FNOP,
and shift in 4-bit
TBLWT instruction,
Num_Clk = 1
Num_Clk = 12?
No
Yes
Clock
transition
RB6?
No
Yes
Shift(R) RB7
Num_Clk = Num_Clk + 1
Clock
transition
RB6?
No
Clock
transition
RB6?
No
Yes
Shift(R) RB7
Num_Clk = Num_Clk + 1
End
Yes
Shift(R) RB7
Num_Clk = Num_Clk + 1
Num_Clk = 4?
No
Yes
DS39028E-page 3-122
PIC18CXXX
FIGURE 2-11:
Start
Clock
transition
RB6?
Execute (PC-2),
and shift in 4-bit
TBLWT instruction,
Num_Clk = 1
No
Yes
Shift(R) RB7
Num_Clk = Num_Clk + 1
Clock
transition
RB6?
No
Num_Clk = 12?
No
Yes
Yes
Shift(R) RB7
Num_Clk = Num_Clk + 1
Clock
transition
RB6?
No
Clock
transition
RB6?
No
Yes
Yes
Shift(R) RB7
Num_Clk = Num_Clk + 1
Shift(R) RB7
Num_Clk = Num_Clk + 1
End
Num_Clk = 4?
No
Yes
DS39028E-page 3-123
PIC18CXXX
2.6
TBLRD Instruction
2.
3.
FIGURE 2-12:
Q Cycles
4.
Q1 Q2 Q3 Q4
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
MCLR/VPP = VIHH
2
10
11
12
13
14
15
16
RB6 (Clock)
P5
P6
P5
P14
RB7 (Data)
Execute PC-2
Fetch TBLRD
LSb
Execute Cycle 1
TBLRD
Execute Cycle 2
TBLRD
RB7 = Output
RB7 = Input
MSb
RB7 = Input
ICSP Mode
DS39028E-page 3-124
PIC18CXXX
FIGURE 2-13:
Start
Clock
transition
RB6?
MCLR = VSS,
RB6, RB7 = 0
No
Yes
VPP = VIHH
Shift(R) TABLAT<0>
out onto RB7
Num_Clk = Num_Clk + 1
Execute FNOP,
and shift in 4-bit
TBLRD instruction,
Num_Clk = 1
Num_Clk = 8?
No
Yes
Clock
transition
RB6?
No
Shift in next
4-bit instruction
Yes
Shift(R) RB7
Num_Clk = Num_Clk + 1
Enable CPU,
execute 1st and 2nd
cycle TBLRD instruction
Clock
transition
RB6?
No
Yes
Shift(R) RB7
Num_Clk = Num_Clk + 1
Clock
transition
RB6?
No
Num_Clk = 4?
No
Yes
Yes
TBLRD instruction execution
takes place here
Num_Clk = Num_Clk + 1
Num_Clk = 8?
End
No
Yes
Shift out 8 bits
of data to RB7
DS39028E-page 3-125
PIC18CXXX
FIGURE 2-14:
Start
Execute (PC-2),
and shift in 4-bit
TBLRD instruction,
Num_Clk = 1
Clock
transition
RB6?
No
Yes
Shift(R) TABLAT<0>
out onto RB7
Num_Clk = Num_Clk + 1
Clock
transition
RB6?
No
Num_Clk = 8?
No
Yes
Yes
Shift(R) RB7
Num_Clk = Num_Clk + 1
Shift in next
4-bit instruction
Clock
transition
RB6?
Clock
transition
RB6?
No
No
Yes
Shift(R) RB7
Num_Clk = Num_Clk + 1
Yes
TBLRD instruction execution
takes place here
Num_Clk = Num_Clk + 1
Num_Clk = 4?
Num_Clk = 8?
Yes
No
No
Yes
End
DS39028E-page 3-126
PIC18CXXX
2.6.1
SOFTWARE COMMANDS
TABLE 2-2:
ICSP
Command
Load
Configuration
Load Data
ICSP PSEUDO
COMMAND MAPPING
MOVLW
#Address1
MOVWF
TBLPTRL
MOVLW
#Address2
MOVWF
TBLPTRH
MOVLW
#Address3
MOVWF
TBLPTRU
TBLRD instruction
Increment
Address
Begin
Programming
End
Programming
;(4-BIT INSTRUCTION)
00h
;(4-BIT INSTRUCTION)
TBLPTRU
;(4-BIT INSTRUCTION)
TBLPTRH
;(4-BIT INSTRUCTION)
TBLPTRL
RESET Address
RESET ADDRESS
Read Data
Load Address
2.6.2
MOVLW
#Addr_low
MOVWF
TBLPTRL
MOVLW
#Addr_high
MOVWF
TBLPTRH
MOVLW
#Addr_upper
MOVWF
TBLPTRU
MOVLW
#Data
MOVWF
TBLPTRH
MOVWF
TBLPTRL
MOVWF
TBLPTRU
TBLWT
DS39028E-page 3-127
PIC18CXXX
FIGURE 2-15:
Start
(NOP)
MOVWF
TBLPTRU
(NOP)
No
Num_Clk = 4?
Num_Clk = 16?
No
Yes
Yes
4-bit instruction = NOP,
Shift in 16-bit MOVLW instruction,
Num_Clk = 1
(NOP)
Num_Clk = 16?
(NOP)
No
No
Num_Clk = 4?
Yes
Yes
(NOP)
No
Num_Clk = 16?
MOVWF
TBLPTRH
No
Yes
Yes
Execute MOVWF instruction,
shift in next 4-bit instruction,
Num_Clk = 1
DS39028E-page 3-128
PIC18CXXX
FIGURE 2-16:
A
On rising edge RB6,
Shift(R) RB7
into Shift Reg<3>,
Num_Clk = Num_Clk + 1
(NOP)
Num_Clk = 4?
No
Yes
4-bit instruction = NOP,
Shift in 16-bit MOVWF instruction,
Num_Clk = 1
No
Yes
End
2.6.3
LOAD ADDRESS
NOP
MOVLW
NOP
MOVWF
NOP
MOVLW
NOP
MOVWF
NOP
MOVLW
NOP
MOVWF
; 4-bit instruction
Low_Address
; 4-bit instruction
TBLPTRL
; 4-bit instruction
High_Address
; 4-bit instruction
TBLPTRH
; 4-bit instruction
Upper_Address
; 4-bit instruction
TBLPTRU
DS39028E-page 3-129
PIC18CXXX
FIGURE 2-17:
Start
No
Num_Clk = 4?
Num_Clk = 16?
No
Yes
Yes
4-bit instruction = NOP,
shift in 16-bit MOVLW instruction,
Num_Clk = 1
No
Num_Clk = 4?
Yes
No
Yes
Num_Clk = 4?
MOVWF
TBLPTRL
No
Num_Clk = 16?
MOVLW
High_Address
No
Yes
Yes
Execute MOVWF instruction,
shift in next 4-bit instruction,
Num_Clk = 1
DS39028E-page 3-130
PIC18CXXX
FIGURE 2-18:
A
On rising edge RB6,
Shift(R) RB7
into Shift Reg<3>,
Num_Clk = Num_Clk + 1
(NOP)
Num_Clk = 4?
No
Yes
4-bit instruction = NOP,
Shift in 16-bit MOVWF instruction,
Num_Clk = 1
No
Yes
End
DS39028E-page 3-131
PIC18CXXX
2.6.4
4.
5.
6.
7.
8.
FIGURE 2-19:
Program Memory
Bank 0
(Even Address)
TBLWT
Odd or Even
Address
Program Memory
Bank 1
(Odd Address)
TBLWT
Odd or Even
Address
Buffer Register
TABLAT Register
RB7
TBLRD
TBLRD
DS39028E-page 3-132
Odd
Even
PIC18CXXX
2.6.5
PROGRAMMING INSTRUCTION
SEQUENCE
MOVLW
NOP
MOVWF
NOP
MOVLW
NOP
MOVWF
NOP
MOVLW
NOP
MOVWF
;
;
;
Low_Byte_Address ;
;
TBLPTRL
;
;
;
;
High_Byte_Address ;
;
TBLPTRH
;
;
;
;
Upper_Byte_Address;
;
TBLPTRU
;
;
;
;
TBLWT+*
4-bit instruction
Set up low byte
of program address
= 00
4-bit instruction
4-bit instruction
Set up high byte
of program
address
= 00
4-bit instruction
4-bit instruction
Set up upper byte
of program
address
= 00
4-bit instruction
Program data byte
included in TBLWT
instruction
sequence
; TBLPTR = 000000h
2.6.6
VERIFY SEQUENCE
2.6.7
3X OVER-PROGRAMMING
Once a location has been both programmed and verified over the range of voltages, 3x over-programming
should be applied. In other words, apply three times the
number of programming pulses required to program a
location in memory to ensure solid programming
margin.
This means that every location will be programmed a
minimum of four times (1 + 3x over-programming).
DS39028E-page 3-133
PIC18CXXX
FIGURE 2-20:
Start
VPP = VIHH,
RB6, RB7 = 0
N=1
Execute FNOP
for four clock cycles,
shift in 4-bit NOP
Hold RB6
clock high (P9)
Execute MOVLW
for four clock cycles
and shift in 4-bit NOP
Clock low
for discharge (P10)
4-bit instruction = NOP,
shift in 16-bit MOVWF TBLPTRL
instruction for 16 clock cycles
Execute MOVWF
for four clock cycles
and shift in 4-bit NOP
Execute MOVWF
for four clock cycles
and shift in 4-bit NOP
Execute MOVLW
for four clock cycles
and shift in 4-bit NOP
Execute MOVLW
for four clock cycles
and shift in 4-bit NOP
Verify?
Execute current instruction
for four clock cycles, and
shift in 4-bit TBLWT+*
Yes
No
N=N+1
N > 25?
No
DS39028E-page 3-134
Yes
Report
Programming
Failure
PIC18CXXX
FIGURE 2-21:
A
N=3*N
N = 1?
No
Yes
Execute 2nd cycle
TBLWT* for four clock cycles
and shift in TBLWT*+
for four clock cycles
N=N-1
Execute current instruction
for four clock cycles, and
shift in 4-bit TBLWT+*
No
Data correct?
Yes
All locations
programmed?
Yes
No
Report
Verify
Error
@ VDDMIN
Data correct?
No
Report
Verify
Error
@ VDDMAX
End
DS39028E-page 3-135
PIC18CXXX
2.6.8
LOAD CONFIGURATION
; 4-bit instruction
; shift in 16-bit
; MOVLW instruction
MOVLW
NOP
03h
MOVWF
NOP
TBLPTRU
MOVLW
NOP
MOVWF
NOP
MOVLW
NOP
MOVWF
NOP
;
;
;
;
4-bit instruction
shift in 16-bit
MOVWF instruction
Enable Test memory
; 4-bit
; shift
; MOVLW
Low_Config_Address
; 4-bit
; shift
; MOVWF
TBLPTRL
; 4-bit
; shift
; MOVLW
High_Config_Address
; 4-bit
; shift
; MOVWF
TBLPTRH
; 4-bit
; shift
; MOVLW
2.6.9
END PROGRAMMING
When programming occurs, 16 bits of data are programmed into memory. The 16 bits of data are shifted
in during the TBLWT sequence. After the programming
command (TBLWT) has been executed, the user must
wait P9 until programming is complete, before another
command can be executed by the CPU. There is no
command to end programming.
RB6 must remain high for as long as programming is
desired. When RB6 is lowered, programming will
cease.
After the falling edge occurs on RB6, RB6 must be held
low for a period of time (Parameter 10), so a high voltage discharge can be performed. This ensures the program array isnt stressed at high voltage during
execution of the next instruction. The high voltage discharge will occur while RB6 is low, following the
programming time.
instruction
in 16-bit
instruction
instruction
in 16-bit
instruction
instruction
in 16-bit
instruction
instruction
in 16-bit
instruction
instruction
in 16-bit
instruction
TBLWT*+
;
;
;
;
;
;
;
;
DS39028E-page 3-136
PIC18CXXX
FIGURE 2-22:
START
Execute MOVLW
for four clock cycles
and shift in 4-bit NOP
MCLR = VSS
4.75 V < VDD < 5.25 V
VPP = VIHH
Execute FNOP
for four clock cycles,
shift in 4-bit NOP
N = 99
4-bit instruction = NOP,
shift in 16-bit MOVLW 30
instruction for 16 clock cycles
Execute MOVLW
for four clock cycles
and shift in 4-bit NOP
Execute MOVWF
for four clock cycles
and shift in 4-bit NOP
N = 1?
Yes
No
4-bit instruction = NOP,
shift in 16-bit MOVLW 00
instruction for 16 clock cycles
Execute MOVLW
for four clock cycles
and shift in 4-bit NOP
Execute MOVWF
for four clock cycles
and shift in 4-bit NOP
Clock low
for discharge (P10)
N=N-1
Execute 2nd cycle
TBLWT* for four clock cycles
and shift in TBLWT*for four clock cycles
Wait P9 + P10 to
ensure programming
DS39028E-page 3-137
PIC18CXXX
FIGURE 2-23:
A
Execute 1st cycle TBLWT*-,
and shift in first four bits of
configuration registers
for four clock cycles
Verify?
Shift in last 12 bits of data
for 12 clock cycles
Shift in TBLRD*+
for four clock cycles
No
Report
Verify
Error
No
Yes
All
locations
programmed?
Yes
Verify all ID_Locations
@ VDDMIN
Data correct?
No
Report
Verify
Error
@ VDDMIN
Yes
Verify all locations
@ VDDMAX
Report
Verify
Error
@ VDDMAX
Yes
DONE
DS39028E-page 3-138
PIC18CXXX
FIGURE 2-24:
Start
VPP = VIHH,
RB6, RB7 = 0
Execute 1st cycle
TBLWT+*, and shift in
first four bits of data
for four clock cycles
N=1
Execute FNOP
for four clock cycles,
shift in 4-bit NOP
Execute MOVLW
for four clock cycles
and shift in 4-bit NOP
Execute MOVWF
for four clock cycles
and shift in 4-bit NOP
Execute MOVLW
for four clock cycles
and shift in 4-bit NOP
Verify?
Execute MOVLW
for four clock cycles
and shift in 4-bit NOP
4-bit instruction = NOP,
shift in 16-bit MOVWF TBLPTRU
instruction for 16 clock cycles
4-bit instruction = NOP,
shift in 16-bit MOVWF TBLPTRH
instruction for 16 clock cycles
Shift in TBLRD*
for four clock cycles
No
N=N+1
N > 25?
No
Yes
Yes
Report
Programming
Failure
DS39028E-page 3-139
PIC18CXXX
FIGURE 2-25:
A
N=3*N
N = 1?
No
Yes
Execute 2nd cycle
TBLWT* for four clock cycles
and shift in TBLWT*+
for four clock cycles
N=N-1
Execute 2nd cycle TBLWT*+
for four clock cycles, and
shift in 4-bit TBLWT+*
Verify all locations
@ VDDMIN
No
Data correct?
Clock low
for discharge (P10)
Yes
Report
Verify
Error
@ VDDMIN
Yes
Yes
Data correct?
No
DS39028E-page 3-140
No
Report
Verify
Error
@ VDDMAX
End
PIC18CXXX
3.0
CONFIGURATION WORD
3.1
ID Locations
TABLE 3-1:
File Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Default/
Unprogrammed
Value
300000h
300001h
CONFIG1L
CONFIG1H
CP
r
CP
r
CP
OSCSEN
CP
CP
CP
CP
CP
1111 1111
FOSC2
FOSC1
FOSC0
111- -111
300002h
CONFIG2L
BORV1
BORV0
BOREN
PWRTEN
---- 1111
300003h
300005h
CONFIG2H
CONFIG3H
WDTPS2
WDTPS1
WDTPS0
WDTEN
CCP2MX
---- 1111
---- ---1
300006h
CONFIG4L
3FFFFEh
DEVID1
DEV2
DEV1
DEV0
REV4
REV3
REV2
r
REV1
STVREN
REV0
---- --11
0000 0000
3FFFFFh
DEVID2
DEV10
DEV9
DEV8
DEV7
DEV6
DEV5
DEV4
DEV3
0000 0010
TABLE 3-2:
File Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Default/
Unprogrammed
Value
300000h
CONFIG1L
CP
CP
CP
CP
CP
CP
CP
CP
1111 1111
300001h
CONFIG1H
OSCSEN
FOSC2
FOSC1
FOSC0
111- -111
300002h
300003h
CONFIG2L
CONFIG2H
DEV2
DEV1
DEV0
REV4
300006h CONFIG4L
3FFFFEh
DEVID1
BORV1
BORV0
BOREN PWRTEN
WDTPS2 WDTPS1 WDTPS0 WDTEN
REV3
REV2
r
REV1
STVREN
REV0
3FFFFFh
DEVID2
DEV10
DEV9
DEV8
DEV7
DEV6
DEV5
DEV4
DEV3
Legend: x = unknown, u = unchanged, - = unimplemented, q = value depends on condition, r = reserved.
Grayed cells are unimplemented, read as 0.
TABLE 3-3:
---- 1111
---- 1111
---- --11
0000 0000
0000 0010
Filename
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Default/
Unprogrammed
Value
300001h
CONFIG1H
FOSC1
FOSC0
---- --10
300002h
CONFIG2L
BW
PWRTEN
-1-- ---1
300003h
CONFIG2H
WDTPS2
WDTPS1
WDTPS0
WDTEN
---- 1111
300006h
CONFIG4L
STVREN
1--- ---1
3FFFFEh
DEVID1
DEV2
DEV1
DEV0
REV4
REV3
REV2
REV1
REV0
0000 0000
3FFFFFh
DEVID2
DEV10
DEV9
DEV8
DEV7
DEV6
DEV5
DEV4
DEV3
0000 0010
DS39028E-page 3-141
PIC18CXXX
TABLE 3-4:
Bit Name
File Name/Devices
Description
CP
R/P 1
CONFIG1L/
18CXX2 and 18CXX8
OSCSEN
R/P 1
CONFIG1H/
18CXX2 and 18CXX8
FOSC2:
FOSC0
R/P 1
CONFIG1H/
18CXXX
BORV1:
BORV0
R/P 1
CONFIG2L/
18CXX2 and 18CXX8
BOREN
R/P 1
CONFIG2L/
18CXX2 and 18CXX8
PWRTEN
R/P 1
CONFIG2L/
18CXXX
WDTPS2:
WDTPS0
R/P 1
CONFIG2H/
18CXXX
DS39028E-page 3-142
PIC18CXXX
TABLE 3-4:
Bit Name
File Name/Devices
Description
WDTEN
R/P 1
CONFIG2H/
18CXXX
CCP2MX
R/P 1
CONFIG3H/
18CXX2
STVREN
R/P 1
CONFIG4L/
18CXXX
BW
R/P 1
CONFIG2L/
18C601/801
DEV10:DEV3
DEVID2/
18CXXX
Device ID bits
These bits are used with the DEV2:DEV0 bits in the
DEVID1 register to identify part number.
DEV2:DEV0
DEVID1/
18CXXX
Device ID bits
These bits are used with the DEV10:DEV3 bits in the
DEVID2 register to identify part number.
REV4:REV0
DEVID1/
18CXXX
DS39028E-page 3-143
PIC18CXXX
3.2
To allow portability of code, a PIC18CXXX programmer is required to read the configuration word locations from the
HEX file when loading the HEX file. If configuration word information was not present in the HEX file, then a simple
warning message may be issued. Similarly, while saving a HEX file, all configuration word information must be
included. An option to not include the configuration word information may be provided. When embedding configuration
word information in the HEX file, it should be to address FE00h.
Microchip Technology Inc. feels strongly that this feature is important for the benefit of the end customer.
3.3
Checksum Computation
DS39028E-page 3-144
PIC18CXXX
TABLE 3-5:
Device
CHECKSUM COMPUTATION
Code
Protect
Checksum
Blank
Value
0xAA at 0
and Max
Address
0xC146
0xC09C
0x005E
0x0068
0x8146
0x809C
0x005A
0x0064
0xC146
0xC09C
0x005E
0x0068
0x8146
0x809C
0x005A
0x0064
0x8145
0x809B
0x0058
0x0062
0x8145
0x809B
0x0058
0x0062
DS39028E-page 3-145
PIC18CXXX
4.0
AC/DC CHARACTERISTICS
TIMING REQUIREMENTS FOR PROGRAM/VERIFY TEST MODE
Operating Voltage:
Param
No.
Sym
VIHH
IPP
P1
TSER
Characteristic
Min
18CXX2/XX8
18C601/801
Typ
Max
Units
Conditions
12.75
25
13.25
50
mA
.5
mA
20
ns
P2
TSCLK
100
ns
P3
TSET1
15
ns
P4
THLD1
15
ns
P5
TDLY1
20
ns
P6
TDLY2
20
ns
P8
TDLY4
P9
TDLY5
P10
TDLY6
P14
TVALID
18CXX2/XX8
18C601/801
ns
100
ms
100
ns
10
ns
DS39028E-page 3-146
PIC16F8X
EEPROM Memory Programming Specification
This document includes the
programming specifications for the
following devices:
1.0
1.2
PIC16F83
PIC16CR83
PIC16F84
PIC16CR84
PIC16F84A
Pin Diagram
PDIP, SOIC
RA2
RA3
RA4/T0CKI
MCLR
VSS
RB0/INT
RB1
RB2
RB3
Hardware Requirements
1
2
3
4
5
6
7
8
9
PIC16F8X
1.1
Programming Mode
18
17
16
15
14
13
12
11
10
RA1
RA0
OSC1/CLKIN
OSC2/CLKOUT
VDD
RB7
RB6
RB5
RB4
TABLE 1-1:
Pin Name
Function
Pin Type
Pin Description
RB6
CLOCK
RB7
DATA
I/O
Clock Input
Data Input/Output
MCLR
VTEST MODE
P(1)
VDD
VDD
Power Supply
VSS
VSS
Ground
DS30262E-page 3-147
PIC16F8X
2.0
2.1
second half (2000h-3FFFh) being configuration memory. The PC will increment from 0000h to 1FFFh and
wrap to 0000h, or 2000h to 3FFFh and wrap around to
2000h (not to 0000h). Once in configuration memory,
the highest bit of the PC stays a 1, thus always pointing to the configuration memory. The only way to point
to user program memory is to reset the part and
re-enter Program/Verify mode, as described in
Section 2.3.
FIGURE 2-1:
1K Word
Implemented
Implemented
Not Implemented
Not Implemented
Implemented
Implemented
Reserved
Reserved
Not Implemented
Not Implemented
1FFFh
2000h
2000
2001
2008h
ID Location
200Fh
ID Location
2002
ID Location
2003
Reserved
2004
Reserved
2005
Reserved
2006
2007
ID Location
Configuration Word
DS30262E-page 3-148
3FFFh
PIC16F8X
2.2
ID Locations
2.3
Program/Verify Mode
Do not allow excess time when transitioning MCLR between VIL and VIHH; this can
cause spurious program executions to
occur. The maximum transition time is
1TCY + TPWRT (if enabled) +
1024 TOSC (for LP, HS and XT modes only)
where TCY is the Instruction Cycle Time,
TPWRT is the Power-up Timer Period, and
TOSC is the Oscillator Period (all values in
s or ns).
For specific values, refer to the Electrical
Characteristics section of the Device Data
Sheet for the particular device.
The sequence that enters the device into the Programming/Verify mode places all other logic into the RESET
state (the MCLR pin was initially at VIL). This means
that all I/O are in the RESET state (high impedance
inputs).
2.3.1
SERIAL PROGRAM/VERIFY
OPERATION
The RB6 pin is used as a clock input pin, and the RB7
pin is used for entering command bits and data
input/output during serial operation. To input a command, the clock pin (RB6) is cycled six times. Each
command bit is latched on the falling edge of the clock
with the Least Significant bit (LSb) of the command
being input first. The data on pin RB7 is required to
have a minimum setup and hold time (see AC/DC
specifications in Table 5-1), with respect to the falling
edge of the clock. Commands that have data associated with them (read and load) are specified to have a
minimum delay of 1 s between the command and the
data. After this delay, the clock pin is cycled 16 times
with the first cycle being a START bit and the last cycle
being a STOP bit. Data is also input and output LSb
first.
Therefore, during a read operation, the LSb will be
transmitted onto pin RB7 on the rising edge of the second cycle, and during a load operation, the LSb will be
latched on the falling edge of the second cycle. A minimum 1 s delay is also specified between consecutive
commands.
All commands are transmitted LSb first. Data words are
also transmitted LSb first. The data is transmitted on
the rising edge and latched on the falling edge of the
clock. To allow for decoding of commands and reversal
of data pin configuration, a time separation of at least
1 s is required between a command and a data word
(or another command).
The available commands (Load Configuration and
Load Data for Program Memory) are discussed in the
following sections.
DS30262E-page 3-149
PIC16F8X
2.3.1.1
Load Configuration
2.3.1.2
TABLE 2-1:
Data
Load Configuration
0, data (14), 0
0, data (14), 0
0, data (14), 0
Increment Address
0, data (14), 0
0, data (14), 0
TABLE 2-2:
Data
Load Configuration
0, data (14), 0
0, data (14), 0
0, data (14), 0
Increment Address
0, data (14), 0
0, data (14), 0
DS30262E-page 3-150
PIC16F8X
FIGURE 2-2:
Start
Program Cycle
PROGRAM CYCLE
Read Data
Command
Data Correct?
Increment
Address
Command
No
All Locations
Done?
Load Data
Command
No
Report
Programming
Failure
Begin
Programming
Command
Wait 8 ms - PIC16F84A
Wait 20 ms - All Others
Verify all
Locations @
VDDMIN
Report Verify
Error @
VDDMIN
No
Data Correct?
Verify all
Locations @
VDDMAX
Report Verify
Error @
VDDMAX
No
Data Correct?
Done
DS30262E-page 3-151
PIC16F8X
FIGURE 2-3:
Load
Configuration
Data
No
Program ID
Location?
Yes
Read Data
Command
Program Cycle
Report
Programming
Failure
Increment
Address
Command
No
Data Correct?
Yes
No
Address =
0x2004?
Yes
Increment
Address
Command
Increment
Address
Command
Increment
Address
Command
Report Program
Configuration
Word Error
No
Program
Cycle
(Config. Word)
Set VDD =
VDDMAX
Data Correct?
Read Data
Command
Yes
Set VDD =
VDDMAX
No
Yes
Done
DS30262E-page 3-152
Data Correct?
Read Data
Command
PIC16F8X
2.3.1.3
2.3.1.4
2.3.1.5
2.3.1.6
Increment Address
2.3.1.7
2.3.1.8
Begin Programming
DS30262E-page 3-153
PIC16F8X
2.3.1.9
2.3.1.10
2.4
To perform a bulk erase of the data memory, the following sequence must be performed.
For PIC16F84A, perform the following commands:
1.
2.
3.
4.
Note:
DS30262E-page 3-154
PIC16F8X
3.0
CONFIGURATION WORD
3.1
Device ID Word
TABLE 3-1:
DEVICE ID WORD
Device ID Value
Device
PIC16F84A
REGISTER 3-1:
Dev
Rev
00 0101 011
X XXXX
For PIC16F83/84/84A:
CP
CP
CP
CP
CP
CP
CP
CP
CP
CP
PWTREN
WDTEN
FOSC1
FOSC0
CP
CP
CP
DP
CP
CP
CP
PWTREN
WDTEN
FOSC1
FOSC0
FOR PIC16CR83/84:
CP
CP
CP
bit13
bit0
bit 13-8,
bit 6-4
bit 7
For PIC16F83/84/84A:
CP: Code Protection bits(1)
1 = Code protection off
0 = Code protection on
For PIC16CR83/84:
DP: Data Memory Code Protection bit
1 = Code protection off
0 = Data memory is code protected
bit 3
bit 2
bit 1-0
Note 1: All of the CP bits have to be given the same value to enable the code protection scheme listed.
DS30262E-page 3-155
PIC16F8X
4.0
CODE PROTECTION
4.1
4.2
Note:
It is recommended that the following procedure be performed before any other programming is attempted. It
is also possible to turn code protection off (code protect
bit = 1) using this procedure; however, all data within
the program memory and the data memory will be
erased when this procedure is executed, and thus,
the security of the data or code is not compromised.
Procedure to disable code protect:
1.
2.
3.
4.
5.
6.
7.
8.
DS30262E-page 3-156
PIC16F8X
Device: PIC16F83
To code protect: 0000000000XXXX
Program Memory Segment
All memory
Device: PIC16CR83
To code protect:
0000000000XXXX
Device: PIC16CR84
To code protect:
0000000000XXXX
Device: PIC16F84
To code protect: 0000000000XXXX
Program Memory Segment
Configuration Word (2007h)
All memory
ID Locations [2000h : 2003h]
Device: PIC16F84A
To code protect: 0000000000XXXX
Program Memory Segment
Configuration Word (2007h)
All memory
ID Locations [2000h : 2003h]
DS30262E-page 3-157
PIC16F8X
4.3
Checksum Computation
4.3.1
CHECKSUM
TABLE 4-1:
Device
CHECKSUM COMPUTATION
Code
Protect
Checksum*
Blank
Value
25E6h at 0
and Max
Address
PIC16F83
OFF
ON
3DFFh
3E0Eh
09CDh
09DCh
PIC16CR83
OFF
ON
3DFFh
3E0Eh
09CDh
09DCh
PIC16F84
OFF
ON
3BFFh
3C0Eh
07CDh
07DCh
PIC16CR84
OFF
ON
3BFFh
3C0Eh
07CDh
07DCh
PIC16F84A
OFF
ON
3BFFh
3C0Eh
07CDh
07DCh
Legend: CFGW
= Configuration Word
SUM[a:b] = [Sum of locations a to b inclusive]
SUM_ID = ID locations masked by 0xF then made into a 16-bit value with ID0 as the most significant nibble.
For example, ID0 =01h, ID1 = 02h, ID3 = 03h, ID4 = 04h, then SUM_ID = 1234h.
*Checksum = [Sum of all the individual expressions] MODULO [FFFFh]
+
= Addition
&
= Bitwise AND
DS30262E-page 3-158
PIC16F8X
5.0
5.1
TABLE 5-1:
AC/DC CHARACTERISTICS
TIMING REQUIREMENTS FOR PROGRAM/VERIFY TEST MODE
Sym.
Characteristic
VDDP
VDDV
VIHH
IDDP
Min.
Typ.
4.5
5.0
Max.
Units
Conditions/Comme
nts
5.5
VDDMIN
VDDMAX
(Note 1)
12
14.0
(Note 2)
50
mA
IHH
200
VIH1
0.8 VDD
VIL1
0.2 VDD
P1
TvHHR
P2
Tset0
100
ns
P3
Tset1
100
ns
P4
Thld1
100
ns
P5
Tdly1
1.0
P6
Tdly2
1.0
P7
Tdly3
80
ns
P8
Thld0
100
ms
PIC16F84A only
8
20
ms
ms
PIC16F84A only
All other devices
8.0
ns
ms
PIC16F84A only
Note 1: Program must be verified at the minimum and maximum VDD limits for the part.
2: VIHH must be greater than VDD + 4.5V to stay in Programming/Verify mode.
DS30262E-page 3-159
PIC16F8X
FIGURE 5-1:
VIHH
MCLR
100 ns
P2
RB6
(CLOCK)
P8
RB7
(DATA)
100 ns
0
P6
6 1 s min. 1
MCLR
P3
1 s min.
FIGURE 5-2:
15
P5
P4
100 ns
min.
RESET
}
}
100 ns
min.
P3
P4
P1
VIHH
P2
RB6
(CLOCK)
100 ns
2
P8
P6
6 1 s min. 1
100
ns
RB7
(DATA)
0
P3
15
P7
P5
P4
}
}
1 s
min.
100 ns
min.
RB7
Input
RB7 = Output
Program/Verify Test Mode
RESET
FIGURE 5-3:
MCLR
1
P6
1 s min.
Next Command
1
RB6
(CLOCK)
RB7
(DATA)
P5
P3 P4
1 s min.
}
}
100 ns
min
RESET
DS30262E-page 3-160
PIC16F62X
PIC16F62X EEPROM Memory Programming Specification
This document includes the
programming specifications for the
following devices:
1.2
PIC16F627
PIC16F628
PIC16LF627
PIC16LF628
Note:
1.0
PROGRAMMING THE
PIC16F62X
1.1
Programmers must verify the PIC16F62X is at its specified VDDMAX and VDDMIN levels. Since Microchip may
introduce future versions of the PIC16F62X with a
broader VDD range, it is best that these levels are user
selectable (defaults are ok).
Note:
Hardware Requirements
1.3
Programming Mode
The Programming mode for the PIC16F62X allows programming of user program memory, data memory,
special locations used for ID, and the configuration
word.
Preliminary
DS30034D-page 3-161
PIC16F62X
Pin Diagram
PDIP, SOIC
RA2/AN2/VREF
18
RA1/AN1
17
RA0/AN0
RA4/T0CKI/CMP2
16
RA7/OSC1/CLKIN
RA5/MCLR/THV
15
RA6/OSC2/CLKOUT
VSS
14
VDD
PIC16F62X
RA3/AN3/CMP1
RB0/INT
13
RB7/DATA/T1OSI
RB1/RX/DT
12
RB6/CLOCK/T1OSO/T1CKI
RB2/TX/CK
11
RB5
RB3/CCP1
10
RB4/PGM
SSOP
1
20
RA1/AN1
19
RA0/AN0
RA4/T0CKI/CMP2
18
RA7/OSC1/CLKIN
RA5/MCLR/THV
17
RA6/OSC2/CLKOUT
16
VDD
15
VDD
PIC16F62X
RA2/AN2/VREF
RA3/AN3/CMP1
VSS
VSS
RB0/INT
14
RB7/DATA/T1OSI
RB1/RX/DT
13
RB6/CLOCK/T1OSO/T1CKI
RB2/TX/CK
12
RB5
RB3/CCP1
10
11
RB4/PGM
TABLE 1-1:
Pin Name
Function
Pin Type
Pin Description
RB4
PGM
RB6
CLOCK
Clock input
RB7
DATA
I/O
Data input/output
Programming Mode
P*
VDD
VDD
Power Supply
VSS
VSS
Ground
MCLR
DS30034D-page 3-162
Preliminary
PIC16F62X
2.0
PROGRAM DETAILS
2.2
2.1
User ID Locations
FIGURE 2-1:
2 KW
Implemented
Implemented
0x3FF
0x07FF
2000 ID Location
2001
2002
2003
2004
2005
2006
ID Location
1FFF
2000
Implemented
Implemented
2008
ID Location
ID Location
Reserved
Not Implemented
Reserved
Device ID
2007
Configuration Word
3FFF
Preliminary
DS30034D-page 3-163
PIC16F62X
2.3
Program/Verify Mode
The programming module operates on simple command sequences entered in serial fashion with the data
being latched on the failing edge of the clock pulse. The
sequences are entered serially, via the clock and data
lines, which are Schmitt Trigger in this mode. The general form for all command sequences consists of a 6-bit
command and conditionally a 16-bit data word. Both
command and data word are clocked LSb first.
The signal on the data pin is required to have a
minimum setup and hold time (see AC/DC specifications), with respect to the falling edge of the clock.
Commands that have data associated with them (read
and load), require a minimum delay of Tdly1 between
the command and the data.
The 6-bit command sequences are shown in Table 2-1.
TABLE 2-1:
Command
Data
Load Configuration
0, data (14), 0
0, data (14), 0
Increment Address
0, data (14), 0
DS30034D-page 3-164
Preliminary
PIC16F62X
The optional 16-bit data word will either be an input to,
or an output from the PICmicro MCU, depending on
the command. Load Data commands will be input, and
Read Data commands will be output. The 16-bit data
word only contains 14 bits of data to conform to the 14bit program memory word. The 14 bits are centered
within the 16-bit word, padded with a leading and trailing zero.
Program/Verify mode may be entered via one of two
methods. High voltage Program/Verify is entered by
holding clock and data pins low while raising VPP first,
then VDD, as shown in Figure 2-2. Low voltage Program/Verify mode is entered by raising VDD, then
MCLR and PGM, as shown in Figure 2-3. The PC will
be set to 0 upon entering into Program/Verify mode.
The PC can be changed by the execution of either an
increment PC command, or a Load Configuration command, which sets the PC to 0x2000.
All other logic is held in the RESET state while in Program/Verify mode. This means that all I/O are in the
RESET state (high impedance inputs).
FIGURE 2-2:
FIGURE 2-3:
ENTERING LOW
VOLTAGE PROGRAM/
VERIFY MODE
Tppdp
Thld0
VDD
MCLR
PGM
DATA
CLOCK
Note:
ENTERING HIGH
VOLTAGE PROGRAM/
VERIFY MODE
Tppdp
Thld0
VPP
VDD
PGM
DATA
CLOCK
Note:
PGM should be held low to prevent inadvertent entry into LVP mode.
Preliminary
DS30034D-page 3-165
PIC16F62X
2.3.1
FIGURE 2-4:
15
16
RB6
(CLOCK)
0
RB7
(DATA)
X
stp_bit
Tset1
Thld1
2.3.2
FIGURE 2-5:
15
16
RB6
(CLOCK)
RB7
(DATA)
Tset1
X
stp_bit
Thld1
DS30034D-page 3-166
Preliminary
PIC16F62X
2.3.3
FIGURE 2-6:
LOAD CONFIGURATION
Tdly2
1
15
16
RB6
(CLOCK)
0
RB7
(DATA)
2.3.4
X
stp_bit
Begin Programming Only Cycle programs the previously loaded word into the appropriate memory (User
Program, Data or Configuration memory). A Load
command must be given before every Programming command. Programming begins after this command is received and decoded. An internal timing
mechanism executes the write. The user must allow for
program cycle time before issuing the next command.
No End Programming command is required.
This command is similar to the Erase/Program command, except that a word erase is not done. It is
recommended that a bulk erase be performed before
starting a series of programming only cycles.
FIGURE 2-7:
Tprog
1
15
next
command
16
RB6
(CLOCK)
RB7
(DATA)
X
stp_bit
Tset1
Thld1
Preliminary
DS30034D-page 3-167
PIC16F62X
2.3.5
BEGIN ERASE/PROGRAMMING
CYCLE
FIGURE 2-8:
Tera + Tprog
1
15
next
command
16
RB6
(CLOCK)
RB7
(DATA)
2.3.6
X
stp_bit
INCREMENT ADDRESS
FIGURE 2-9:
RB6
(CLOCK)
RB7
(DATA)
Next Command
1
Tdly1
Tset1
Thld1
}
}
DS30034D-page 3-168
Preliminary
PIC16F62X
2.3.7
FIGURE 2-10:
Thld0
1
RB6
(CLOCK)
15
16
Tdly3
0
RB7
(DATA)
strt_bit
stp_bit
Tdly1
Tset1
Thld1
RB7 = input
2.3.8
RB7
input
RB7 = output
FIGURE 2-11:
RB6
(CLOCK)
RB7
(DATA)
15
16
Tdly3
X
strt_bit
stp_bit
Tdly1
Tset1
Thld1
}
RB7 = input
RB7 = output
Preliminary
RB7
input
DS30034D-page 3-169
PIC16F62X
2.3.9
FIGURE 2-12:
Thld0
1
15
16
RB6
(CLOCK)
1
RB7
(DATA)
stp_bit
FIGURE 2-13:
Thld0
1
15
16
RB6
(CLOCK)
RB7
(DATA)
DS30034D-page 3-170
X
stp_bit
Preliminary
PIC16F62X
3.0
COMMON PROGRAMMING
TASKS
Note:
3.1
If the device is not code protected, the program memory can be erased with the Bulk Erase Program Memory command. See Section 3.4 for removing code
protection if it is set.
Note:
To perform a bulk erase of the program memory, the following sequence must be performed:
1.
2.
3.
4.
FIGURE 3-1:
Thld0
1
RB6
(CLOCK)
RB7
(DATA)
15
16
Tdly3
1
X
stp_bit
Preliminary
DS30034D-page 3-171
PIC16F62X
3.2
To perform a bulk erase of the data memory, the following sequence must be performed:
Note:
1.
2.
3.
4.
Note:
FIGURE 3-2:
Thld0
1
RB6
(CLOCK)
RB7
(DATA)
15
16
Tdly3
1
X
stp_bit
Tset1
Thld1
3.3
DS30034D-page 3-172
Preliminary
PIC16F62X
3.4
FIGURE 3-3:
Start
High Voltage
Programming
Program Cycle
PROGRAM CYCLE
Read Data
from Program
Memory
Load Data
Command
No
Data Correct?
Increment
Address
Command
No
Report
Programming
Failure
All Locations
Done?
Begin
Programming
Command
Wait tprog
Verify all
Locations @
VDDMIN
Report Verify
Error @
VDDMIN
No
Data Correct?
Verify all
Locations @
VDDMAX
Report Verify
Error @
VDDMAX
No
Data Correct?
Done
Preliminary
DS30034D-page 3-173
PIC16F62X
FIGURE 3-4:
Load
Configuration
Data
No
Program ID
Location?
Yes
Read Data
Command
Program Cycle
Report
Programming
Failure
Increment
Address
Command
No
Data Correct?
Yes
No
Address =
0x2004?
Yes
Increment
Address
Command
Increment
Address
Command
Increment
Address
Command
Report Program
Configuration
Word Error
No
Program
Cycle
(Config. Word)
Set VDD =
VDDMIN
Data Correct?
Read Data
Command
Yes
Set VDD =
VDDMAX
No
Yes
Done
DS30034D-page 3-174
Data Correct?
Preliminary
Read Data
Command
PIC16F62X
3.5
FIGURE 3-5:
Start
PROGRAM CYCLE
Program Cycle
LOAD DATA
for
Data Memory
READ DATA
from
Data Memory
Data Correct?
INCREMENT
ADDRESS
Command
No
BEGIN
PROGRAMMING
Command
No
Report
Programming
Failure
Wait Tprog
All Locations
Done?
Data Correct?
No
Report Verify
Error
Done
Preliminary
DS30034D-page 3-175
PIC16F62X
3.6
FIGURE 3-6:
Start
Low Voltage
Programming
Increment
Address
Command
No
Address
= Start
Address?
PROGRAM CYCLE
Load Data
Command
Program Cycle
Begin
Programming
Command
Read Data
from Program
Memory
No
Data Correct?
Increment
Address
Command
No
Report
Programming
Failure
Wait Tprog
All Locations
Done?
Verify all
Locations @
VDDMIN &
VDDMAX
Done
DS30034D-page 3-176
Preliminary
PIC16F62X
3.7
Configuration Word
TABLE 3-1:
3.8
Device ID Word
Device
PIC16F627
PIC16F628
DEVICE ID VALUES
Device ID Value
Dev
Rev
00 0111 101
00 0111 110
x xxxx
x xxxx
Preliminary
DS30034D-page 3-177
PIC16F62X
REGISTER 3-1:
CP1
CP0
CP1
CP0
CPD
LVP
BOREN
MCLRE
bit 13
bit 0
Unimplemented: Read as 1
bit 8
bit 7
bit 6
bit 5
bit 3
bit 2
Legend:
R = Readable bit
-n = Value at POR
DS30034D-page 3-178
W = Writable bit
1 = Bit is set
Preliminary
x = Bit is unknown
PIC16F62X
3.9
To allow portability of code, the programmer is required to read the configuration word and ID locations from the HEX
file when loading the HEX file. If configuration word information was not present in the HEX file, then a simple warning
message may be issued. Similarly, while saving a HEX file, configuration word and ID information must be included.
An option to not include this information may be provided.
Specifically for the PIC16F62X, the EEPROM data memory should also be embedded in the HEX file (see
Section 4.1).
Microchip Technology Inc. feels strongly that this feature is important for the benefit of the end customer.
3.10
Checksum Computation
3.10.1
CHECKSUM
TABLE 3-2:
Device
PIC16F627
CHECKSUM COMPUTATION
Code
Protect
OFF
Blank
Value
0x25E6 at 0
and Max
Address
0x39FF
0x05CD
0x4DFE
0xFFB3
ALL
0x3BFE
0x07CC
OFF
0x35FF
0x01CD
0x400 : 0x7FF
0x5BFE
0x0DB3
0x200 : 0x7FF
0x49FE
0xFBB3
0x37FE
0x03CC
0x200 : 0x3FF
PIC16F628
Checksum*
ALL
Preliminary
DS30034D-page 3-179
PIC16F62X
4.0
4.1
The programmer should be able to read data EEPROM information from a HEX file, and conversely (as an option) write
data EEPROM contents to a HEX file, along with program memory information and fuse information.
The 128 data memory locations are logically mapped starting at address 0x2100. The format for data memory storage
is one data byte per address location, LSB aligned.
TABLE 4-1:
AC/DC Characteristics
Characteristics
Min
VDD
Typ
Max
Units
2.0
5.5
VDD
2.0
5.5
VDD
4.5
5.5
VIHH
VDD + 3.5
13.5
1.0
Conditions/Comments
General
TVHHR
Tppdp
VIH1
0.8 VDD
VIL1
Tset0
100
ns
Thld0
s
0.2 VDD
Serial Program/Verify
Data in setup time before clock
Tset1
100
ns
Thld1
100
ns
Tdly1
1.0
Tdly2
1.0
Tdly3
Tera
DS30034D-page 3-180
Tprog
Tdis
80
ns
ms
ms
0.5
Preliminary
PIC16F87X
EEPROM Memory Programming Specification
PIC16F874
PIC16F871
PIC16F876
PIC16F872
PIC16F877
PIC16F873
1.0
PROGRAMMING THE
PIC16F87X
1.1
Programming Algorithm
Requirements
1.2
PDIP, SOIC
MCLR/VPP
RA0/AN0
RA1/AN1
RA2/AN2/VREF
RA3/AN3/VREF
RA4/T0CKI
RA5/AN4/SS
VSS
OSC1/CLKIN
OSC2/CLKOUT
RC0/T1OSO/T1CKI
RC1/T1OSI/CCP2
RC2/CCP1
RC3/SCK/SCL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
PIC16F876/873/872/870
PIC16F870
Pin Diagram
28
27
26
25
24
23
22
21
20
19
18
17
16
15
RB7
RB6
RB5
RB4
RB3
RB2
RB1
RB0/INT
VDD
VSS
RC7/RX/DT
RC6/TX/CK
RC5/SDO
RC4/SDI/SDA
MCLR/VPP
RA0/AN0
40
39
RB7
RB6
RA1/AN1
RA2/AN2/VREF
38
RB5
37
RA3/AN3/VREF
36
RB4
RB3
35
RB2
34
RB1
33
RB0/INT
32
31
VDD
30
RD7/PSP7
29
28
RD6/PSP6
RD5/PSP5
RA4/T0CKI
RA5/AN4/SS
RE0/RD/AN5
RE1/WR/AN6
9
10
RE2/CS/AN7
VDD
11
VSS
12
OSC1/CLKIN
13
PIC16F877/874/871
VSS
OSC2/CLKOUT
14
27
RD4/PSP4
RC0/T1OSO/T1CKI
15
26
RC7/RX/DT
RC1/T1OSI/CCP2
16
25
RC6/TX/CK
RC2/CCP1
17
24
RC5/SDO
RC3/SCK/SCL
RD0/PSP0
18
23
19
20
22
21
RC4/SDI/SDA
RD3/PSP3
RD1/PSP1
RD2/PSP2
Programming Mode
The Programming mode for the PIC16F87X allows programming of user program memory, data memory, special locations used for ID, and the configuration word.
DS39025F-page 3-181
PIC16F87X
=
Pin Type
Pin Description
RB3
PGM
RB6
CLOCK
Clock input
RB7
DATA
I/O
Data input/output
MCLR
VTEST MODE
P*
VDD
VDD
Power Supply
VSS
VSS
Ground
DS39025F-page 3-182
PIC16F87X
2.0
The contents of data EEPROM memory have the capability to be embedded into the HEX file.
2.1
2.2
# of Bytes
PIC16F870
64
PIC16F871
64
PIC16F872
64
PIC16F873
128
PIC16F874
128
PIC16F876
256
PIC16F877
256
2.3
ID Locations
DS39025F-page 3-183
PIC16F87X
TABLE 2-1:
4K words
8K words
0h
1FFh
Implemented
Implemented
Implemented
Implemented
Implemented
Implemented
2000h
ID Location
2001h
ID Location
3FFh
400h
2002h
ID Location
7FFh
800h
Implemented
Implemented
2003h
ID Location
BFFh
C00h
Implemented
Implemented
2004h
Reserved
FFFh
1000h
2005h
Reserved
2006h
Device ID
Implemented
2007h
Configuration Word
Implemented
Reserved
Implemented
Reserved
Implemented
1FFFh
2008h
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
2100h
3FFFh
DS39025F-page 3-184
PIC16F87X
2.4
Program/Verify Mode
The sequence that enters the device into the Programming/Verify mode places all other logic into the RESET
state (the MCLR pin was initially at VIL). This means
that all I/O are in the RESET state (high impedance
inputs).
The normal sequence for programming is to use the
load data command to set a value to be written at the
selected address. Issue the begin programming command followed by read data command to verify, and
then increment the address.
A device RESET will clear the PC and set the address
to 0. The increment address command will increment
the PC. The load configuration command will set the
PC to 0x2000. The available commands are shown in
Table 2-2.
2.4.1
2.4.2
SERIAL PROGRAM/VERIFY
OPERATION
The RB6 pin is used as a clock input pin, and the RB7
pin is used for entering command bits and data
input/output during serial operation. To input a command, the clock pin (RB6) is cycled six times. Each
command bit is latched on the falling edge of the clock,
with the Least Significant bit (LSb) of the command
being input first. The data on pin RB7 is required to
have a minimum setup and hold time (see AC/DC
specifications), with respect to the falling edge of the
clock. Commands that have data associated with them
(read and load) are specified to have a minimum delay
of 1 s between the command and the data. After this
delay, the clock pin is cycled 16 times with the first cycle
being a START bit and the last cycle being a STOP bit.
Data is also input and output LSb first.
Therefore, during a read operation, the LSb will be
transmitted onto pin RB7 on the rising edge of the second cycle, and during a load operation, the LSb will be
latched on the falling edge of the second cycle. A minimum 1 s delay is also specified between consecutive
commands.
All commands are transmitted LSb first. Data words are
also transmitted LSb first. The data is transmitted on
the rising edge and latched on the falling edge of the
clock. To allow for decoding of commands and reversal
of data pin configuration, a time separation of at least
1 s is required between a command and a data word
(or another command).
The commands that are available are:
2.4.2.1
Load Configuration
2.4.2.2
DS39025F-page 3-185
PIC16F87X
2.4.2.3
2.4.2.6
2.4.2.4
2.4.2.7
2.4.2.8
Begin Programming
Note:
TABLE 2-2:
2.4.2.5
Increment Address
Command
Data
Voltage
Range
Load Configuration
0, data (14), 0
2.2V - 5.5V
0, data (14), 0
2.2V - 5.5V
0, data (14), 0
2.2V - 5.5V
Increment Address
2.2V - 5.5V
2.2V - 5.5V
4.5V - 5.5V
0, data (14), 0
2.2V - 5.5V
0, data (14), 0
2.2V - 5.5V
4.5V - 5.5V
4.5V - 5.5V
DS39025F-page 3-186
PIC16F87X
2.5
Depending on the state of the code protection bits, program and data memory will be erased using different
procedures. The first set of procedures is used when
both program and data memories are not code protected. The second set of procedures must be used
when either memory is code protected. A device programmer should determine the state of the code protection bits and then apply the proper procedure to
erase the desired memory.
2.5.1
2.5.2
1.
4.
1.
2.
3.
4.
5.
6.
7.
Execute a Load Data for Program Memory command (000010) with a '1' in all locations
(0x3FFF)
Execute a Bulk Erase Setup1 command
(000001)
Execute a Bulk Erase Setup2 command
(000111)
Execute a Begin Erase/Programming command
(001000)
Wait 8 ms
Execute a Bulk Erase Setup1 command
(000001)
Execute a Bulk Erase Setup2 command
(000111)
2.
3.
5.
6.
7.
8.
2.
3.
4.
5.
6.
7.
Execute a Load Data for Data Memory command (000011) with a '1' in all locations
(0x3FFF)
Execute a Bulk Erase Setup1 command
(000001)
Execute a Bulk Erase Setup2 command
(000111)
Execute a Begin Erase/Programming command
(001000)
Wait 8 ms
Execute a Bulk Erase Setup1 command
(000001)
Execute a Bulk Erase Setup2 command
(000111)
DS39025F-page 3-187
PIC16F87X
FIGURE 2-1:
START
Load Data
Command
Begin
Erase/Programming
Command
Wait
tera + tprog
Increment
Address
Command
No
All Locations
Done?
Verify all
Locations
Report Verify
Error
No
Data Correct?
DONE
DS39025F-page 3-188
PIC16F87X
FIGURE 2-2:
START
Bulk Erase
Sequence
Load Data
Command
Begin
Programming Only
Command
Wait tprog
Increment
Address
Command
No
All Locations
Done?
Verify all
Locations
Report Verify
Error
No
Data Correct?
DONE
DS39025F-page 3-189
PIC16F87X
FIGURE 2-3:
START
Load
Configuration
Data
No
Yes
Program ID
Location?
Read Data
Command
Program Cycle
Report
Programming
Failure
Increment
Address
Command
No
Data Correct?
Yes
No
Address =
0x2004?
Yes
PROGRAM CYCLE
Load Data
Command
Begin
Erase/Program
Command
Wait
tera + tprog
Increment
Address
Command
Increment
Address
Command
Increment
Address
Command
Program
Cycle
(Config. Word)
Report Program
Configuration
Word Error
No
Data Correct?
Read Data
Command
Yes
DONE
DS39025F-page 3-190
PIC16F87X
FIGURE 2-4:
START
Load
Configuration
Data
No
Yes
Program ID
Location?
Read Data
Command
Program Cycle
Report
Programming
Failure
Increment
Address
Command
No
Data Correct?
Yes
No
Address =
0x2004?
Yes
PROGRAM CYCLE
Load Data
Command
Begin
Program Only
Command*
Increment
Address
Command
Increment
Address
Command
Increment
Address
Command
Program
Cycle
(Config. Word)
Wait tprog
Report Program
Configuration
Word Error
No
Data Correct?
Read Data
Command
Yes
DONE
* Assumes that a bulk erase was issued before programming configuration word. If not, use the program flow from Figure 2-4.
DS39025F-page 3-191
PIC16F87X
3.0
CONFIGURATION WORD
3.1
Device ID Word
DS39025F-page 3-192
TABLE 3-1:
DEVICE ID VALUE
Device ID Value
Device
Dev
Rev
PIC16F870
00 1101 000
x xxxx
PIC16F871
00 1101 001
x xxxx
PIC16F872
00 1000 111
x xxxx
PIC16F873
00 1001 011
x xxxx
PIC16F874
00 1001 001
x xxxx
PIC16F876
00 1001 111
x xxxx
PIC16F877
00 1001 101
x xxxx
PIC16F87X
REGISTER 3-1:
U-0
U-0
U-0
U-0
U-0
U-0
U-0
R/P-1
U-0
R/P-1
R/P-1
R/P-1
R/P-1
R/P-1
CP1
CP0
RESV
WRT
CPD
LVP
BODEN
CP1
CP0
PWRTE
WDTE
F0SC1
F0SC0
bit 13
bit 0
bit 13-12
bit 5-4
bit 11
bit 10
Unimplemented: Read as 1
bit 9
bit 8
bit 7
bit 6
bit 3
bit 2
bit 1-0
Legend:
R = Readable bit
P = Programmable bit
DS39025F-page 3-193
PIC16F87X
REGISTER 3-2:
U-0
U-0
U-0
U-0
U-0
U-0
U-0
R/P-1
U-0
R/P-1
R/P-1
R/P-1
R/P-1
R/P-1
CP1
CP0
RESV
WRT
CPD
LVP
BODEN
CP1
CP0
PWRTE
WDTE
F0SC1
F0SC0
bit 13
bit 0
bit 13-12
bit 5-4
bit 11
bit 10
Unimplemented: Read as 1
bit 9
bit 8
bit 7
bit 6
bit 3
bit 2
bit 1-0
Legend:
R = Readable bit
P = Programmable bit
DS39025F-page 3-194
PIC16F87X
4.0
To allow portability of code, the programmer is required to read the configuration word and ID locations from the HEX
file when loading the HEX file. If configuration word information was not present in the HEX file, then a simple warning
message may be issued. Similarly, while saving a HEX file, configuration word and ID information must be included.
An option to not include this information may be provided.
Specifically for the PIC16F87X, the EEPROM data memory should also be embedded in the HEX file (see
Section 2.2).
Microchip Technology Inc. feels strongly that this feature is important for the benefit of the end customer.
DS39025F-page 3-195
PIC16F87X
5.0
CHECKSUM COMPUTATION
DS39025F-page 3-196
PIC16F87X
TABLE 5-1:
CHECKSUM COMPUTATION
Code
Protect
PIC16F870
OFF
0x33FF
0xFFCD
ALL
0x3FCE
0x0B9C
OFF
0x33FF
0xFFCD
ALL
0x3FCE
0x0B9C
OFF
0x33FF
0xFFCD
ALL
0x3FCE
0x0B9C
OFF
PIC16F871
PIC16F872
PIC16F873
Checksum*
Blank
Value
0x25E6 at 0
and max
address
Device
0x2BFF
0xF7CD
0x0F00 : 0xFFF
0x48EE
0xFAA3
0x0800 : 0xFFF
PIC16F874
0x3FDE
0xF193
ALL
0x37CE
0x039C
OFF
0x2BFF
0xF7CD
0x0F00 : 0xFFF
0x48EE
0xFAA3
0x0800 : 0xFFF
PIC16F876
0x3FDE
0xF193
ALL
0x37CE
0x039C
OFF
0x1BFF
0xE7CD
0x1F00 : 0x1FFF
0x28EE
0xDAA3
0x1000 : 0x1FFF
PIC16F877
0x27DE
0xD993
ALL
0x27CE
0xF39C
OFF
0x1BFF
0xE7CD
0x1F00 : 0x1FFF
0x28EE
0xDAA3
0x1000 : 0x1FFF
0x27DE
0xD993
0x27CE
0xF39C
ALL
Legend: CFGW
SUM[a:b]
SUM_ID
= Configuration Word
= [Sum of locations a to b inclusive]
= ID locations masked by 0xF then made into a 16-bit value with ID0 as the most significant nibble.
For example, ID0 = 0x1, ID1 = 0x2, ID3 = 0x3, ID4 = 0x4, then SUM_ID = 0x1234
*Checksum = [Sum of all the individual expressions] MODULO [0xFFFF]
+
= Addition
&
= Bitwise AND
DS39025F-page 3-197
PIC16F87X
6.0
TABLE 6-1:
AC/DC CHARACTERISTICS
Characteristics
Min
VDD
Typ
Max
Units
Conditions/Comments
2.2
5.5
VDD
4.5
5.5
General
VIHH
VDD + 3.5
13.5
VIH
2.2
5.5
tVHHR
1.0
VIH1
0.8 VDD
VIL1
0.2 VDD
tset0
100
ns
thld0
tset2
100
ns
tset1
100
ns
thld1
100
ns
tdly1
1.0
tdly2
1.0
tdly3
80
tera
ms
tprog
ms
Serial Program/Verify
DS39025F-page 3-198
ns
PIC16F87X
FIGURE 6-1:
VIHH
1 s min.
MCLR
tset0
RB6
(Clock)
tdly2
15
16
thld0
1
RB7
(Data)
strt_bit
tset1
stp_bit
tset1
}
}
thld1
}
}
tdly1
1 s min.
thld1
100 ns min.
100 ns min.
RESET
FIGURE 6-2:
VIHH
MCLR
tdly2
tset0
thld0
1
1 s min.
RB6
(Clock)
15
16
tdly3
RB7
(Data)
stp_bit
strt_bit
tdly1
tset1
thld1
}
}
1 s min.
100 ns min.
RB7
input
RB7 = output
RB7 = input
RESET
FIGURE 6-3:
MCLR
tdly2
1
1 s min.
Next Command
1
RB6
(Clock)
RB7
(Data)
tdly1
tset1
thld1
}
}
1 s min.
100 ns min.
RESET
DS39025F-page 3-199
PIC16F87X
FIGURE 6-4:
VIH
1 s min.
MCLR
tset0
RB6
(Clock)
tdly2
15
16
thld0
1
RB7
(Data)
tset2
strt_bit
tset1
stp_bit
tset1
}
}
thld1
}
}
tdly1
1 s min.
thld1
100 ns min.
100 ns min.
RB3
RESET
FIGURE 6-5:
VIH
MCLR
tdly2
tset0
thld0
1
1 s min.
RB6
(Clock)
15
16
tdly3
RB7
(Data)
thld1
1 s min.
}
}
tset2
stp_bit
strt_bit
tdly1
tset1
100 ns min.
RB7
input
RB7 = output
RB7 = input
RB3
Program/Verify Test Mode
RESET
FIGURE 6-6:
MCLR
tdly2
1
1 s min.
Next Command
1
RB6
(Clock)
RB7
(Data)
tset1
tdly1
tset2
thld1
}
}
1 s min.
100 ns min.
RB3
RESET
DS39025F-page 3-200
IN-CIRCUIT SERIAL
PROGRAMMING GUIDE
Section 4 Application Notes
IN-CIRCUIT SERIAL PROGRAMMING (ICSP) OF CALIBRATION PARAMETERS
USING A PICmicro MICROCONTROLLER ......................................................................................... 4-1
DS30277D-page 4-i
DS30277D-page 4-ii
AN656
In-Circuit Serial Programming (ICSP) of Calibration Parameters
Using a PICmicro Microcontroller
PROGRAMMING FIXTURE
INTRODUCTION
Many embedded control applications, where sensor
offsets, slopes and configuration information are measured and stored, require a calibration step. Traditionally, potentiometers or Serial EEPROM devices are
used to set up and store this calibration information.
This application note will show how to construct a programming jig that will receive calibration parameters
from the application mid-range PICmicro microcontrollers (MCU) and program this information into the
application baseline PICmicro MCU using the In-Circuit
Serial Programming (ICSP) protocol. This method uses
the PIC16CXXX In-Circuit Serial Programming algorithm of the 14-bit core microcontrollers.
FIGURE 1:
+5V
Sensor(s)
PIC16CXXX
RAX
MCLR/VPP
VDD
VSS
Application I/O
RBX
RB7
RB6
+5V
+13V VPP
Generator
10k
VPP
VDD
GND_ON
VPP_ON
MCLR
VSS
VDD
1k
VSS
RB7
RB6
PIC16C58
To Application Input(s)
=OMMP=j=q=fK
RB7
RB6
RB5
o_Q
o` osc
RB3
o_N
Wait
RB2
Done
Optional PC Connection
apMMSRS_J~=QJN
AN656
Electrical Interface
Programming Issues
MCLR/VPP - High voltage pin used to place application PIC16CXXX into programming mode
VDD - +5 volt power supply connection to the
application PIC16CXXX
VSS - Ground power supply connection to the
application PIC16CXXX
RB6 - PORTB, bit6 connection to application
PIC16CXXX used to clock programming data
RB7 - PORTB, bit7 connection to application
PIC16CXXX used to send programming data
This programming jig is intended to grab power from
the application power supply through the VDD connection. The programming jig will require 100 mA of peak
current during programming. The application will need
to set RB6 and RB7 as inputs, which means external
devices cannot drive these lines. The calibration data
will be sent to the programming jig by the application
PIC16CXXX through RB6 and RB7. The programming
jig will later use these lines to clock the calibration data
into the application PIC16CXXX.
apMMSRS_J~=QJO
=OMMP=j=q=fK
AN656
Communication Format (Application
Microcontroller to Programming Jig)
RB7
CALbit7
CALbit6
CALbit5
CALbit4
CALbit3
CALbit2
CALbit1
CALbit0
FIGURE 1:
AddrH
AddrL
=OMMP=j=q=fK
Data 0
Data 1
Data N
CKSUM
apMMSRS_J~=QJP
AN656
LED Operation
When the programming jig is waiting for communication from the application PICmicro MCU, both LEDs are
OFF. Once a valid data stream is received (with at least
one calibration byte and a correct checksum) the
WORK LED is lit while the calibration parameters are
printed through the optional RB3 port. Next, the DONE
LED is lit to indicate that these parameters are being
programmed and verified by the programming jig. Once
the programming is finished, the WORK LED is extinguished and the DONE LED remains lit. If any parameters fail programming, the DONE LED is extinguished;
therefore both LEDs would remain off.
FIGURE 2:
VCC
VCC
VCC
VCC
VCC
T0CKI
VSS
VDD
VCC
VPP
VCC
VIN
VCC
VREF
VPP
apMMSRS_J~=QJQ
=OMMP=j=q=fK
AN656
Code Protection
the application PIC16CXXX, places it into programming mode and programs/verifies each calibration
word.
2.
CONCLUSION
Typically, calibration information about a system is
stored in EEPROM. For calibration data that does not
change over time, the In-circuit Serial Programming
capability of the PIC16CXXX devices provide a simple,
cost effective solution to an external EEPROM. This
method not only decreases the cost of a design, but
also reduces the complexity and possible failure points
of the application.
Do not code protect the device when programming it with the programmer. Add additional
code (See the PIC16C6X/7X programming
Spec) to the ISPPRGM.ASM to program the
code protection bit after complete verification of
the calibration parameters
Only code protect 1/2 or 3/4 of the program
memory with the programmer. Place the calibration constants into the unprotected part of program memory.
Software Routines
There are two source code files needed for this application note:
1. ISPTEST.ASM (Appendix A) Contains the source
code for the application PIC16CXXX, sets up the calibration look-up table and implements the communication protocol to the programming jig.
2. ISPPRGM.ASM (Appendix B) Source code for a
PIC16C58A to implement the programming jig. This
waits for and receives the calibration parameters from
TABLE 1:
Bill of Material
Item
Quantity
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
1
1
2
2
1
1
1
1
2
2
5
4
2
1
1
1
1
1
=OMMP=j=q=fK
Reference
C1,C2
C3
C4
C5,C6
D1,D2
E1
E2
J1
L1
Q1,Q2
Q3,Q4
R1,R2,R3,R4,R15
R5,R6,R12,R14
R7,R8
R9
R10
R11
R13
Y1
Part
15 pF
620 pF
0.1 mF
220 mF
LED
PIC16C58
LM78S40
CON5
270 mH
2N2222
2N2907
1k
10k
270
180
23.7k
2.49k
2.2k
4.0 MHz
apMMSRS_J~=QJR
AN656
APPENDIX A:
MPASM 01.40.01 Intermediate
0FFF 0FF9
00000006
00000007
00000005
00000004
00000003
00000002
00000001
ISPPRGM.ASM
3-31-1997
10:57:03
PAGE
apMMSRS_J~=QJS
=OMMP=j=q=fK
AN656
00000007
00000008
00000007
00000008
00000009
0000000A
0000000B
0000000C
0000000D
00000007
00000008
00000009
0000000A
0000000B
0000000C
0000000E
0000000F
00000001
00000081
00000006
00000010
00000007
00000006
00000008
0000000E
00000002
00000004
00000034
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
; *************************************************
; * RAM register definition:
*
; * 07h - 0Fh - used for internal counters, vars *
; * 10h - 7Fh - 64 bytes for cal param storage
*
; *************************************************
; ***
; *** The following VARS are used during ISP programming:
; ***
HIADDR
EQU 07h ; High address of CAL params to be stored
LOADDR
EQU 08h ; Low address of CAL params to be stored
HIDATA
EQU 07h ; High byte of data to be sent via ISP
LODATA
EQU 08h ; Low byte of data to be sent via ISP
HIBYTE
EQU 09h ; High byte of data received via ISP
LOBYTE
EQU 0Ah ; Low byte of data received via ISP
PULSECNT
EQU 0Bh ; Number of times PIC has been pulse programmed
TEMPCOUNT
EQU 0Ch ; TEMP var used in counters
TEMP
EQU 0Dh ; TEMP var used throughout program
; ***
; *** The following VARS are used to receive and store CAL params:
; ***
COUNT
EQU 07h ; Counter var used to receive cal params
TEMP1
EQU 08h ; TEMP var used for RS-232 comm
DATAREG
EQU 09h ; Data register used for RS-232 comm
CSUMTOTAL
EQU 0Ah ; Running total of checksum (addr + data)
TIMEHIGH
EQU 0Bh ; Count how long CLOCK line is high
TIMELOW
EQU 0Ch ; Count how long CLOCK line is low
ADDRPTR
EQU 0Eh ; Pointer to next byte of CAL storage
BYTECOUNT
EQU 0Fh ; Number of CAL bytes received
; *************************************
; * Various constants used in program *
; *************************************
DATISPOUT
EQU b00000001 ; tris settings for ISP data out
DATISPIN
EQU b10000001 ; tris settings for ISP data in
CMDISPCNT
EQU 6
; Number of bits for ISP command
STARTCALBYTE
EQU 10h
; Address in RAM where CAL byte data stored
VFYYES
EQU PA2
; Flag bit enables verification (STATUS)
CMDISPINCRADDR EQU b00000110 ; ISP Pattern to increment address
CMDISPPGMSTART EQU b00001000 ; ISP Pattern to start programming
CMDISPPGMEND
EQU b00001110 ; ISP Pattern to end programming
CMDISPLOAD
EQU b00000010 ; ISP Pattern to load data for program
CMDISPREAD
EQU b00000100 ; ISP Pattern to read data for verify
UPPER6BITS
EQU 034h
; Upper 6 bits for retlw instruction
; *************************************
; * delaybit macro
*
; * Delays for 104 uS (at 4 Mhz clock)*
; * for 9600 baud communications
*
; *
RAM used:
COUNT
*
; *************************************
delaybit macro
local dlylabels
; 9600 baud, 8 bit, no parity, 104 us per bit, 52 uS per half bit
; (8) shift/usage + (2) setup + (1) nop + (3 * 31) literal = (104) 4Mhz
movlw
.31
; place 31 decimal literal into count
movwf
COUNT
; Initialize COUNT with loop count
nop
; Add one cycle delay
dlylabels
decfsz COUNT,F
; Decrement count until done
goto
dlylabels
; Not done delaying - go back!
ENDM
; Done with Macro
;
;
;
;
************************************************
* addrtofsr macro
*
* Converts logical, continuous address 10h-4Fh *
* to FSR address as follows for access to (4) *
=OMMP=j=q=fK
apMMSRS_J~=QJT
AN656
00120 ; * banks of file registers in PIC16C58:
*
00121 ; *
Logical Address
FSR Value
*
00122 ; *
10h-1Fh
10h-1Fh
*
00123 ; *
20h-2Fh
30h-3Fh
*
00124 ; *
30h-3Fh
50h-5Fh
*
00125 ; *
40h-4Fh
70h-7Fh
*
00126 ; *
Variable Passed: Logical Address
*
00127 ; *
RAM used:
FSR
*
00128 ; *
W
*
00129 ; ************************************************
00130 addrtofsr macro TESTADDR
00131
movlw
STARTCALBYTE
; Place base address into W
00132
subwf
TESTADDR,w
; Offset by STARTCALBYTE
00133
movwf
FSR
; Place into FSR
00134
btfsc
FSR,5
; Shift bits 4,5 to 5,6
00135
bsf
FSR,6
00136
bcf
FSR,5
00137
btfsc
FSR,4
00138
bsf
FSR,5
00139
bsf
FSR,4
00140
endm
00141
00142
00143 ; **************************************
00144 ; * The PC starts at the END of memory *
00145 ; **************************************
07FF
00146
ORG
7FFh
Message[306]: Crossing page boundary -- ensure page bits are set.
07FF 0A00
00147
goto
start
00148
00149 ; **************************************
00150 ; * Start of CAL param read routine
*
00151 ; **************************************
0000
00152
ORG
0h
0000
00153 start
0000 0C0A
00154
movlw
b00001010
; Serial OFF, LEDS OFF, VPP OFF
0001 0026
00155
movwf
PORTB
; Place 0 into port b latch register
0002 0CC1
00156
movlw
b11000001
; RB7;:RB6, RB0 set to inputs
0003 0006
00157
tris
PORTB
; Move to tris registers
0004 0040
00158
clrw
; Place 0 into W
0005 0065
00159
clrf
PORTA
; Place all ZERO into latch
0006 0005
00160
tris
PORTA
; Make all pins outputs to be safe..
0007 0586
00161
bsf
PORTB,GNDON
; TEST ONLY-RESET PIC-NOT NEEDED IN REAL DESIGN!
0008
00162 clearram
0008 0C10
00163
movlw
010h
; Place start of buffer into W
0009 0027
00164
movwf
COUNT
; Use count for RAM pointer
000A
00165 loopclrram
00166
addrtofsr COUNT
; Set up FSR
000A 0C10
M
movlw
STARTCALBYTE ; Place base address into W
000B 0087
M
subwf
COUNT,w
; Offset by STARTCALBYTE
000C 0024
M
movwf
FSR
; Place into FSR
000D 06A4
M
btfsc
FSR,5
; Shift bits 4,5 to 5,6
000E 05C4
M
bsf
FSR,6
000F 04A4
M
bcf
FSR,5
0010 0684
M
btfsc
FSR,4
0011 05A4
M
bsf
FSR,5
0012 0584
M
bsf
FSR,4
0013 0060
00167
clrf
INDF
; Clear buffer value
0014 02A7
00168
incf
COUNT,F
; Move to next reg
0015 0C50
00169
movlw
050h
; Move end of buffer addr to W
0016 0087
00170
subwf
COUNT,W
; Check if at last MEM
0017 0743
00171
btfss
STATUS,Z
; Skip when at end of counter
0018 0A0A
00172
goto
loopclrram
; go back to next location
0019 0486
00173
bcf
PORTB,GNDON
; TEST ONLY-LET IT GO-NOT NEEDED IN REAL DESIGN!
001A
00174 calget
001A 006A
00175
clrf
CSUMTOTAL
; Clear checksum total byte
apMMSRS_J~=QJU
=OMMP=j=q=fK
AN656
001B
001C
001D
001E
001E
001F
0020
0020
0021
0022
0022
0023
0024
0024
0025
0026
0027
0028
0029
0029
002A
002B
002C
002D
002E
002E
002F
0030
0031
0032
0033
0034
0034
0035
0036
0037
0038
0039
0069
0C10
002E
003A
003B
003C
003D
003E
003F
0040
0041
0042
0043
0044
0045
0046
0047
0047
0048
0049
004A
004B
004C
004D
004E
004F
004F
0050
0051
0052
0C10
008E
0024
06A4
05C4
04A4
0684
05A4
0584
0209
0020
02AE
0A20
07C6
0A1E
0C08
0027
006B
006C
06C6
0A29
02EB
0A24
0A47
07C6
0A2E
02EC
0A29
0A47
0C08
0087
0743
0A34
0209
01EA
0503
07E6
0403
0369
02E7
0A22
0C14
008E
0703
0A93
0200
00AA
0743
0A9F
0426
0C10
008E
002F
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
M
M
M
M
M
M
M
M
M
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
clrf
DATAREG
; Clear out data receive register
movlw
STARTCALBYTE
; Place RAM start address of first cal byte
movwf
ADDRPTR
; Place this into ADDRPTR
waitclockpulse
btfss
PORTB,ISPCLOCK
; Wait for CLOCK high pulse - skip when high
goto
waitclockpulse
; CLOCK is low - go back and wait!
loopcal
movlw
.8
; Place 8 into W (8 bits/byte)
movwf
COUNT
; set up counter register to count bits
loopsendcal
clrf
TIMEHIGH
; Clear timeout counter for high pulse
clrf
TIMELOW
; Clear timeout counter for low pulse
waitclkhi
btfsc
PORTB,ISPCLOCK
; Wait for CLOCK high - skip if it is low
goto
waitclklo
; Jump to wait for CLOCK low state
decfsz TIMEHIGH,F
; Decrement counter - skip if timeout
goto
waitclkhi
; Jump back and wait for CLOCK high again
goto
timeout
; Timed out waiting for high - check data!
waitclklo
btfss
PORTB,ISPCLOCK
; Wait for CLOCK low - skip if it is high
goto
clockok
; Got a high to low pulse - jump to clockok
decfsz TIMELOW,F
; Decrement counter - skip if timeout
goto
waitclklo
; Jump back and wait for CLOCK low again
goto
timeout
; Timed out waiting for low - check data!
clockok
movlw
.8
; Place initial count value into W
subwf
COUNT,W
; Subtract from count, place into W
btfss
STATUS,Z
; Skip if we are at count 8 (first value)
goto
skipcsumadd
; Skip checksum add if any other count value
movf
DATAREG,W
; Place last byte received into W
addwf
CSUMTOTAL,F
; Add to checksum
skipcsumadd
bsf
STATUS,C
; Assume data bit is high
btfss
PORTB,ISPDATA
; Skip if the data bit was high
bcf
STATUS,C
; Set data bit to low
rlf
DATAREG,F
; Rotate next bit into DATAREG
decfsz COUNT,F
; Skip after 8 bits
goto
loopsendcal
; Jump back and send next bit
addrtofsr ADDRPTR
; Convert pointer address to FSR
movlw
STARTCALBYTE
; Place base address into W
subwf
ADDRPTR,w
; Offset by STARTCALBYTE
movwf
FSR
; Place into FSR
btfsc
FSR,5
; Shift bits 4,5 to 5,6
bsf
FSR,6
bcf
FSR,5
btfsc
FSR,4
bsf
FSR,5
bsf
FSR,4
movf
DATAREG,W
; Place received byte into W
movwf
INDF
; Move recvd byte into CAL buffer location
incf
ADDRPTR,F
; Move to the next cal byte
goto
loopcal
; Go back for next byte
timeout
movlw
STARTCALBYTE+4
; check if we received (4) params
subwf
ADDRPTR,W
; Move current address pointer to W
btfss
STATUS,C
; Skip if we have at least (4)
goto
sendnoise
; not enough params - print and RESET!
movf
INDF,W
; Move received checksum into W
subwf
CSUMTOTAL,F
; Subtract received Checksum from calcd checksum
btfss
STATUS,Z
; Skip if CSUM OK
goto
sendcsumbad
; Checksum bad - print and RESET!
csumok
bcf
PORTB,WORKLED
; Turn on WORK LED
movlw
STARTCALBYTE
; Place start pointer into W
subwf
ADDRPTR,W
; Subtract from current address
movwf
BYTECOUNT
; Place into number of bytes into BYTECOUNT
=OMMP=j=q=fK
apMMSRS_J~=QJV
AN656
0053 002B
0054 0C10
0055 002E
0056
0C7C
09AE
028E
0E0F
00233
00234
00235
00236
00237
M
M
M
M
M
M
M
M
M
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
008B 0643
00288
0056
0057
0058
0059
005A
005B
005C
005D
005E
005F
0060
0061
0062
0063
0064
0065
0066
0066
0067
0068
0069
006A
006B
006C
006D
006D
006E
006F
0070
0071
0072
0073
0073
0074
0075
0076
0077
0078
0079
007A
007A
007B
007C
007D
007E
007F
0080
0081
0081
0082
0083
0084
0085
0086
0087
0087
0088
0089
008A
0C10
008E
0024
06A4
05C4
04A4
0684
05A4
0584
0380
0E0F
002D
0C0A
00AD
0603
0A6D
0380
0E0F
002D
0C30
01CD
09AE
0A73
0380
0E0F
002D
0C37
01CD
09AE
0200
0E0F
002D
0C0A
00AD
0603
0A81
0200
0E0F
002D
0C30
01CD
09AE
0A87
0200
0E0F
002D
0C37
01CD
09AE
apMMSRS_J~=QJNM
movwf
TIMEHIGH
movlw
STARTCALBYTE
movwf
ADDRPTR
loopprintnums
addrtofsr ADDRPTR
movlw
STARTCALBYTE
subwf
ADDRPTR,w
movwf
FSR
btfsc
FSR,5
bsf
FSR,6
bcf
FSR,5
btfsc
FSR,4
bsf
FSR,5
bsf
FSR,4
swapf
INDF,W
andlw
0Fh
movwf
TEMP
movlw
.10
subwf
TEMP,F
btfsc
STATUS,C
goto
printhiletter
printhinumber
swapf
INDF,W
andlw 0Fh
movwf
TEMP
movlw
0
addwf
TEMP,w
call
putchar
goto
printlo
printhiletter
swapf
INDF,W
andlw 0Fh
movwf
TEMP
movlw
A-.10
addwf
TEMP,w
call
putchar
printlo
movf
INDF,W
andlw
0Fh
movwf
TEMP
movlw
.10
subwf
TEMP,F
btfsc
STATUS,C
goto
printloletter
printlonumber
movf
INDF,W
andlw
0Fh
movwf
TEMP
movlw
0
addwf
TEMP,w
call
putchar
goto
printnext
printloletter
movf
INDF,W
andlw
0Fh
movwf
TEMP
movlw
A-.10
addwf
TEMP,w
call
putchar
printnext
movlw
|
call
putchar
incf
ADDRPTR,W
andlw
0Fh
btfsc
STATUS,Z
Set up FSR
Place base address into W
Offset by STARTCALBYTE
Place into FSR
Shift bits 4,5 to 5,6
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
=OMMP=j=q=fK
AN656
008C 09A9
00289
call
printcrlf
; Print CR and LF every 16 chars
008D 02AE
00290
incf
ADDRPTR,F
; go to next address
008E 02EF
00291
decfsz BYTECOUNT,F
; Skip after last byte
008F 0A56
00292
goto
loopprintnums
; Go back and print next char
0090 09A9
00293
call
printcrlf
; Print CR and LF
0091 05A3
00294
bsf
STATUS,PA0
; Set page bit to page 1
Message[306]: Crossing page boundary -- ensure page bits are set.
0092 0A6B
00295
goto
programpartisp
; Go to program part through ISP
0093
00296 sendnoise
0093 0C4E
00297
movlw N
; Place N into W
0094 09AE
00298
call
putchar
; Send char in W to terminal
0095 0C4F
00299
movlw O
; Place O into W
0096 09AE
00300
call
putchar
; Send char in W to terminal
0097 0C49
00301
movlw I
; Place I into W
0098 09AE
00302
call
putchar
; Send char in W to terminal
0099 0C53
00303
movlw S
; Place S into W
009A 09AE
00304
call
putchar
; Send char in W to terminal
009B 0C45
00305
movlw E
; Place E into W
009C 09AE
00306
call
putchar
; Send char in W to terminal
009D 09A9
00307
call
printcrlf
; Print CR and LF
009E 0A1A
00308
goto
calget
; RESET!
009F
00309 sendcsumbad
009F 0C43
00310
movlw
C
; Place C into W
00A0 09AE
00311
call
putchar
; Send char in W to terminal
00A1 0C53
00312
movlw
S
; Place S into W
00A2 09AE
00313
call
putchar
; Send char in W to terminal
00A3 0C55
00314
movlw
U
; Place U into W
00A4 09AE
00315
call
putchar
; Send char in W to terminal
00A5 0C4D
00316
movlw
M
; Place M into W
00A6 09AE
00317
call
putchar
; Send char in W to terminal
00A7 09A9
00318
call
printcrlf
; Print CR and LF
00A8 0A1A
00319
goto
calget
; RESET!
00320
00321 ; ******************************************
00322 ; * printcrlf
*
00323 ; * Sends char .13 (Carrage Return) and
*
00324 ; * char .10 (Line Feed) to RS-232 port
*
00325 ; * by calling putchar.
*
00326 ; *
RAM used: W
*
00327 ; ******************************************
00A9
00328 printcrlf
00A9 0C0D
00329
movlw
.13
; Value for CR placed into W
00AA 09AE
00330
call
putchar
; Send char in W to terminal
00AB 0C0A
00331
movlw
.10
; Value for LF placed into W
00AC 09AE
00332
call
putchar
; Send char in W to terminal
00AD 0800
00333
retlw
0
; Done - return!
00334
00335 ; ******************************************
00336 ; * putchar
*
00337 ; * Print out the character stored in W
*
00338 ; * by toggling the data to the RS-232
*
00339 ; * output pin in software.
*
00340 ; *
RAM used: W,DATAREG,TEMP1
*
00341 ; ******************************************
00AE
00342 putchar
00AE 0029
00343
movwf
DATAREG
; Place character into DATAREG
00AF 0C09
00344
movlw
09h
; Place total number of bits into W
00B0 0028
00345
movwf
TEMP1
; Init TEMP1 for bit counter
00B1 0403
00346
bcf
STATUS,C
; Set carry to send start bit
00B2 0AB4
00347
goto
putloop1
; Send out start bit
00B3
00348 putloop
00B3 0329
00349
rrf
DATAREG,F
; Place next bit into carry
00B4
00350 putloop1
00B4 0703
00351
btfss
STATUS,C
; Skip if carry was set
00B5 0466
00352
bcf
PORTB,SEROUT
; Clear RS-232 serial output bit
00B6 0603
00353
btfsc
STATUS,C
; Skip if carry was clear
=OMMP=j=q=fK
apMMSRS_J~=QJNN
AN656
00B7 0566
0000
00B8
00B9
00BA
00BB
00BB
00BC
00BD
00BE
00BF
0C1F
0027
0000
02E7
0ABB
02E8
0AB3
0566
0000
00C0
00C1
00C2
00C3
00C3
00C4
00C5
0C1F
0027
0000
02E7
0AC3
0800
0200
0200
0200
0201
0202
0203
0204
0205
0206
0207
0207
0208
0209
020A
020B
020C
020D
020E
020F
0210
0211
0212
04A6
0586
0CC1
0006
0486
0526
0800
0C08
0026
04A6
0586
0C01
0006
0206
002D
048D
05AD
020D
0026
00354
00355
M
M
M
M
M
M
M
M
M
00356
00357
00358
00359
M
M
M
M
M
M
M
M
M
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
apMMSRS_J~=QJNO
bsf
PORTB,SEROUT
; Set RS-232 serial output bit
delaybit
; Delay for one bit time
local dlylabels
; 9600 baud, 8 bit, no parity, 104 us per bit, 52 uS per half bit
; (8) shift/usage + (2) setup + (1) nop + (3 * 31) literal = (104) 4Mhz
movlw
.31
; place 31 decimal literal into count
movwf
COUNT
; Initialize COUNT with loop count
nop
; Add one cycle delay
dlylabels
decfsz COUNT,F
; Decrement count until done
goto
dlylabels
; Not done delaying - go back!
decfsz TEMP1,F
; Decrement bit counter, skip when done!
goto
putloop
; Jump back and send next bit
bsf
PORTB,SEROUT
; Send out stop bit
delaybit
; delay for stop bit
local dlylabels
; 9600 baud, 8 bit, no parity, 104 us per bit, 52 uS per half bit
; (8) shift/usage + (2) setup + (1) nop + (3 * 31) literal = (104) 4Mhz
movlw
.31
; place 31 decimal literal into count
movwf
COUNT
; Initialize COUNT with loop count
nop
; Add one cycle delay
dlylabels
decfsz COUNT,F
; Decrement count until done
goto
dlylabels
; Not done delaying - go back!
retlw
0
; Done - RETURN
;
;
;
;
;
*******************************************************************
* ISP routines from PICSTART-16C
*
* Converted from PIC17C42 to PIC16C5X code by John Day
*
* Originially written by Jim Pepping
*
*******************************************************************
ORG 200
; ISP routines stored on page 1
; *******************************************************************
; * poweroffisp
*
; * Power off application PIC - turn off VPP and reset device after *
; * programming pass is complete
*
; *******************************************************************
poweroffisp
bcf
PORTB,VPPON
; Turn off VPP 13 volts
bsf
PORTB,GNDON
; Apply 0 V to MCLR to reset PIC
movlw
b11000001
; RB6,7 set to inputs
tris
PORTB
; Move to tris registers
bcf
PORTB,GNDON
; Allow MCLR to go back to 5 volts, deassert reset
bsf
PORTB,WORKLED
; Turn off WORK LED
retlw 0
; Done so return!
; *******************************************************************
; * testmodeisp
*
; * Apply VPP voltage to place application PIC into test mode.
*
; * this enables ISP programming to proceed
*
; *
RAM used:
TEMP
*
; *******************************************************************
testmodeisp
movlw
b00001000
; Serial OFF, LEDS OFF, VPP OFF
movwf
PORTB
; Place 0 into port b latch register
bcf
PORTB,VPPON
; Turn off VPP just in case!
bsf
PORTB,GNDON
; Apply 0 volts to MCLR
movlw
b00000001
; RB6,7 set to outputs
tris
PORTB
; Move to tris registers
movf
PORTB,W
; Place PORT B state into W
movwf
TEMP
; Move state to TEMP
bcf
TEMP,4
; Turn off MCLR GND
bsf
TEMP,5
; Turn on VPP voltage
movf
TEMP,W
; Place TEMP into W
movwf
PORTB
; Turn OFF GND and ON VPP
=OMMP=j=q=fK
AN656
0213 0546
0214 0800
0215
0215
0216
0217
0218
0219
021A
021B
021C
021D
021E
021E
021F
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
022A
022B
022C
022C
022D
022E
022F
0230
0231
0232
0233
0234
0235
0236
0237
0237
0238
0239
023A
023B
023C
023D
023E
023F
0240
0C0E
002D
04C6
04E6
0C01
0006
04E6
05C6
04C6
0403
04E6
0329
032A
0603
05E6
05C6
04C6
02ED
0A1E
04E6
05C6
04C6
0800
0C0E
002D
0069
006A
0403
04C6
04E6
0C81
0006
05C6
04C6
05C6
0000
0403
06E6
0503
0329
032A
04C6
0000
0000
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
bsf
PORTB,DONELED
retlw 0
; *******************************************************************
; * p16cispout
*
; * Send 14-bit data word to application PIC for writing this data *
; * to its program memory.
The data to be sent is stored in both *
; * HIBYTE (6 MSBs only) and LOBYTE.
*
; *
RAM used:
TEMP, W, HIBYTE (inputs), LOBYTE (inputs)
*
; *******************************************************************
P16cispout
movlw
.14
; Place 14 into W for bit counter
movwf
TEMP
; Use TEMP as bit counter
bcf
PORTB,ISPCLOCK
; Clear CLOCK line
bcf
PORTB,ISPDATA
; Clear DATA line
movlw
DATISPOUT
; Place tris value for data output
tris
PORTB
; Set tris latch as data output
bcf
PORTB,ISPDATA
; Send a start bit (0)
bsf
PORTB,ISPCLOCK
; Set CLOCK output
bcf
PORTB,ISPCLOCK
; Clear CLOCK output (clock start bit)
P16cispoutloop
bcf
STATUS,C
; Clear carry bit to start clean
bcf
PORTB,ISPDATA
; Clear DATA bit to start (assume 0)
rrf
HIBYTE,F
; Rotate HIBYTE output
rrf
LOBYTE,F
; Rotate LOBYTE output
btfsc
STATUS,C
; Skip if data bit is zero
bsf
PORTB,ISPDATA
; Set DATA line to send a one
bsf
PORTB,ISPCLOCK
; Set CLOCK output
bcf
PORTB,ISPCLOCK
; Clear CLOCK output (clock bit)
decfsz TEMP,F
; Decrement bit counter, skip when done
goto
P16cispoutloop
; Jump back and send next bit
bcf
PORTB,ISPDATA
; Send a stop bit (0)
bsf
PORTB,ISPCLOCK
; Set CLOCK output
bcf
PORTB,ISPCLOCK
; Clear CLOCK output (clock stop bit)
retlw 0
; Done so return!
; *******************************************************************
; * p16cispin
*
; * Receive 14-bit data word from application PIC for reading this *
; * data from its program memory.
The data received is stored in *
; * both HIBYTE (6 MSBs only) and LOBYTE.
*
; *
RAM used:
TEMP, W, HIBYTE (output), LOBYTE (output)
*
; *******************************************************************
P16cispin
movlw
.14
; Place 14 data bit count value into W
movwf
TEMP
; Init TEMP and use for bit counter
clrf
HIBYTE
; Clear recieved HIBYTE register
clrf
LOBYTE
; Clear recieved LOBYTE register
bcf
STATUS,C
; Clear carry bit to start clean
bcf
PORTB,ISPCLOCK
; Clear CLOCK output
bcf
PORTB,ISPDATA
; Clear DATA output
movlw
DATISPIN
; Place tris value for data input into W
tris
PORTB
; Set up tris latch for data input
bsf
PORTB,ISPCLOCK
; Send a single clock to start things going
bcf
PORTB,ISPCLOCK
; Clear CLOCK to start receive
P16cispinloop
bsf
PORTB,ISPCLOCK
; Set CLOCK bit
nop
; Wait one cycle
bcf
STATUS,C
; Clear carry bit, assume 0 read
btfsc
PORTB,ISPDATA
; Check the data, skip if it was zero
bsf
STATUS,C
; Set carry bit if data was one
rrf
HIBYTE,F
; Move recevied bit into HIBYTE
rrf
LOBYTE,F
; Update LOBYTE
bcf
PORTB,ISPCLOCK
; Clear CLOCK line
nop
; Wait one cycle
nop
; Wait one cycle
=OMMP=j=q=fK
apMMSRS_J~=QJNP
AN656
0241
0242
0243
0244
0245
0246
0247
0248
0249
024A
024B
024C
024D
024E
024F
0250
0251
0252
0252
0253
0254
0255
0256
0257
0258
0259
0259
025A
025B
025C
025D
025E
025F
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269
026A
026B
026B
026C
026D
026E
026F
0270
02ED
0A37
05C6
0000
04C6
0000
0403
0329
032A
0403
0329
032A
04C6
04E6
0C01
0006
0800
002A
0C06
002D
04E6
04C6
0C01
0006
0403
04E6
032A
0603
05E6
05C6
0000
04C6
02ED
0A59
0000
04E6
04C6
0C81
0006
0000
0000
0800
0907
0064
0210
0027
0211
0028
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
apMMSRS_J~=QJNQ
decfsz
goto
bsf
nop
bcf
nop
bcf
rrf
rrf
bcf
rrf
rrf
bcf
bcf
movlw
tris
retlw 0
TEMP,F
P16cispinloop
PORTB,ISPCLOCK
PORTB,ISPCLOCK
STATUS,C
HIBYTE,F
LOBYTE,F
STATUS,C
HIBYTE,F
LOBYTE,F
PORTB,ISPCLOCK
PORTB,ISPDATA
DATISPOUT
PORTB
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
; *******************************************************************
; * commandisp
*
; * Send 6-bit ISP command to application PIC. The command is sent *
; * in the W register and later stored in LOBYTE for shifting.
*
; *
RAM used: LOBYTE, W, TEMP
*
; *******************************************************************
commandisp
movwf
LOBYTE
; Place command into LOBYTE
movlw
CMDISPCNT
; Place number of command bits into W
movwf
TEMP
; Use TEMP as command bit counter
bcf
PORTB,ISPDATA
; Clear DATA line
bcf
PORTB,ISPCLOCK
; Clear CLOCK line
movlw
DATISPOUT
; Place tris value for data output into W
tris
PORTB
; Set tris to data output
P16cispcmmdoutloop
bcf
STATUS,C
; Clear carry bit to start clean
bcf
PORTB,ISPDATA
; Clear the DATA line to start
rrf
LOBYTE,F
; Update carry with next CMD bit to send
btfsc
STATUS,C
; Skip if bit is supposed to be 0
bsf
PORTB,ISPDATA
; Command bit was a one - set DATA to one
bsf
PORTB,ISPCLOCK
; Set CLOCK line to clock the data
nop
; Wait one cycle
bcf
PORTB,ISPCLOCK
; Clear CLOCK line to clock data
decfsz TEMP,F
; Decement bit counter TEMP, skip when done
goto
P16cispcmmdoutloop ; Jump back and send next cmd bit
nop
; Wait one cycle
bcf
PORTB,ISPDATA
; Clear DATA line
bcf
PORTB,ISPCLOCK
; Clear CLOCK line
movlw
DATISPIN
; Place tris value for data input into W
tris
PORTB
; set as input to avoid any contention
nop
; Wait one cycle
nop
; Wait one cycle
retlw 0
; Done - return!
; ********************************************************************
; * programpartisp
*
; * Main ISP programming loop. Reads data starting at STARTCALBYTE *
; * and calls programming subroutines to program and verify this
*
; * data into the application PIC.
*
; *
RAM used: LOADDR, HIADDR, LODATA, HIDATA, FSR, LOBYTE, HIBYTE*
; ********************************************************************
programpartisp
call
testmodeisp
; Place PIC into test/program mode
clrf
FSR
; Point to bank 0
movf
STARTCALBYTE,W ; Upper order address of data to be stored into W
movwf
HIADDR
; place into counter
movf
STARTCALBYTE+1,W ; Lower order address byte of data to be stored
movwf
LOADDR
; place into counter
=OMMP=j=q=fK
AN656
0271
0272
0273
0273
0274
0275
0276
0277
0278
0279
027A
027B
027C
027D
027E
027E
027F
00E8
02A7
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
028A
028B
028C
028D
028E
028F
0290
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
029A
029B
029C
029D
029E
029F
02A0
02A1
02A2
02A3
02A4
02A4
02A5
02A6
02A7
02A8
02A9
02A9
02AA
02AA
02AB
0C10
008E
0024
06A4
05C4
04A4
0684
05A4
0584
0200
0028
0208
002A
0207
0029
006B
0C06
0952
02E8
0A73
02E7
0A73
0C03
008B
002F
0C12
002E
0C34
0027
05E3
09B1
02AB
0C19
008B
0643
0AA9
0209
0087
0743
0A90
020A
0088
0743
0A90
0040
01CB
01CB
01CB
002B
04E3
09B1
02EB
0AA4
0AAA
0446
0C06
0952
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
M
M
M
M
M
M
M
M
M
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
decf
LOADDR,F
incf
HIADDR,F
programsetptr
movlw
CMDISPINCRADDR
call
commandisp
decfsz LOADDR,F
goto
programsetptr
decfsz HIADDR,F
goto
programsetptr
movlw
.3
subwf
TIMEHIGH,W
movwf
BYTECOUNT
movlw
STARTCALBYTE+2
movwf
ADDRPTR
programisploop
movlw
UPPER6BITS
movwf
HIDATA
addrtofsr ADDRPTR
movlw
STARTCALBYTE
subwf
ADDRPTR,w
movwf
FSR
btfsc
FSR,5
bsf
FSR,6
bcf
FSR,5
btfsc
FSR,4
bsf
FSR,5
bsf
FSR,4
movf
INDF,W
movwf
LODATA
movf
LODATA,W
movwf
LOBYTE
movf
HIDATA,W
movwf
HIBYTE
clrf
PULSECNT
pgmispcntloop
bsf
STATUS,VFYYES
call
pgmvfyisp
incf
PULSECNT,F
movlw
.25
subwf
PULSECNT,w
btfsc
STATUS,Z
goto
pgmispfail
movf
HIBYTE,w
subwf
HIDATA,w
btfss
STATUS,Z
goto
pgmispcntloop
movf
LOBYTE,w
subwf
LODATA,w
btfss
STATUS,Z
goto
pgmispcntloop
clrw
addwf
PULSECNT,W
addwf
PULSECNT,W
addwf
PULSECNT,W
movwf
PULSECNT
pgmisp3X
bcf
STATUS,VFYYES
call
pgmvfyisp
decfsz PULSECNT,F
goto
pgmisp3X
goto
prgnextbyte
pgmispfail
bcf
PORTB,DONELED
prgnextbyte
movlw
CMDISPINCRADDR
call
commandisp
=OMMP=j=q=fK
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
; Skip if programmed is OK
; Miscompare - program it again!
; Subtract programmed and read data
;
;
;
;
Skip if programmed is OK
Miscompare - program it again!
Clear W reg
now do 3 times overprogramming pulses
apMMSRS_J~=QJNR
AN656
02AC
02AD
02AE
02AF
02B0
02B0
02B1
02B1
02B1
02B2
02B3
02B4
02B5
02B6
02B7
02B8
02B9
02BA
02BB
02BC
02BD
02BD
02BE
02BF
02C0
02C0
02C1
02C2
02C3
02C4
02C5
02C6
02C7
02C7
02C8
02C9
02CA
02AE
02EF
0A7E
0900
0AB0
0C02
0952
0000
0000
0000
0208
002A
0207
0029
0915
0C08
0952
0C20
0000
002D
02ED
0AC0
0C0E
0952
07E3
0800
0000
0C04
0952
092C
0800
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
apMMSRS_J~=QJNS
incf
decfsz
goto
call
ADDRPTR,F
BYTECOUNT,F
programisploop
poweroffisp
;
;
;
;
goto
self
self
; *******************************************************************
; * pgmvfyisp
*
; * Program and/or Veryify a word in program memory on the
*
; * application PIC. The data to be programmed is in HIDATA and
*
; * LODATA.
*
; *
RAM used: HIBYTE, LOBYTE, HIDATA, LODATA, TEMP
*
; *******************************************************************
pgmvfyisp
loadcisp
movlw
CMDISPLOAD
; Place load data command into W
call
commandisp
; Send load data command to PIC
nop
; Wait one cycle
nop
; Wait one cycle
nop
; Wait one cycle
movf
LODATA,w
; Place LODATA byte into W
movwf
LOBYTE
; Move it to LOBYTE reg
movf
HIDATA,w
; Place HIDATA byte into W
movwf
HIBYTE
; Move it to HIBYTE reg
call
P16cispout
; Send data to PIC
movlw
CMDISPPGMSTART
; Place start programming command into W
call
commandisp
; Send start programming command to PIC
delay100us
movlw
.32
; Place 32 into W
nop
; Wait one cycle
movwf
TEMP
; Move it to TEMP for delay counter
loopprgm
decfsz TEMP,F
; Decrement TEMP, skip when delay done
goto
loopprgm
; Jump back and loop delay
movlw
CMDISPPGMEND
; Place stop programming command into W
call
commandisp
; Send end programming command to PIC
btfss
STATUS,VFYYES
; Skip if we are supposed to verify this time
retlw 0
; Done - return!
nop
; Wait one cycle
readcisp
movlw
CMDISPREAD
; Place read data command into W
call
commandisp
; Send read data command to PIC
call
P16cispin
; Read programmed data
retlw 0
; Done - return!
END
=OMMP=j=q=fK
AN656
MEMORY USAGE MAP (X = Used,
0000
0040
0080
00C0
0200
0240
0280
02C0
07C0
0FC0
:
:
:
:
:
:
:
:
:
:
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXX---------XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXX-----------------------------------
- = Unused)
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
---------------XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
----------------------------------------------
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
---------------XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
----------------------------------------------
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
---------------XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
------------------------------X
---------------X
Errors
:
Warnings :
Messages :
0
0 reported,
2 reported,
=OMMP=j=q=fK
402
1646
0 suppressed
0 suppressed
apMMSRS_J~=QJNT
AN656
APPENDIX B:
MPASM 01.40.01 Intermediate
3-31-1997
10:55:57
PAGE
00001 ;
00002 ;
00003 ;
00004 ;
00005 ;
00006 ;
00007 ;
00008 ;
00009 ;
00010 ;
00011 ;
00012 ;
00013 ;
00014 ;
00015 ;
00016 ;
00017 ;
00018 ;
00019 ;
00020 ;
00021 ;
00022 ;
00023 ;
00024 ;
00025 ;
00026 ;
00027 ;
00028 ;
00029 ;
00030 ;
00031 ;
00032 ;
00033 ;
00034 ;
00035 ;
00036 ;
00037 ;
00038 ;
00039 ;
00040 ;
00041 ;
00042 ;
00043 ;
00044
Warning[217]: Hex file
00045
00046
00001
00002 ;
00142
2007 3FF1
00047
00048
00049 ;
00050 ;
00051 ;
00052 ;
00053
00054 ;
00055 ;
apMMSRS_J~=QJNU
ISPTEST.ASM
Filename: ISPTEST.ASM
**********************************************
* Author:
John Day
*
*
Sr. Field Applications Engineer *
*
Microchip Technology
*
* Revision: 1.0
*
* Date
August 25, 1995
*
* Part:
PIC16CXX
*
* Compiled using MPASM V1.40
*
**********************************************
* Include files:
*
*
P16CXX.ASM
*
**********************************************
* Fuses:
OSC: XT (4.0 Mhz xtal)
*
*
WDT: OFF
*
*
CP: OFF
*
*
PWRTE: OFF
*
**************************************************************************
* This program is intended to be used as a code example to
*
* show how to comunicate with a manufacturing test jig that
*
* allows this PIC16CXX device to self program.
The RB6 and RB7
*
* lines of this PIC16CXX device are used to clock the data from
*
* this device to the test jig (running ISPPRGM.ASM). Once the
*
* PIC16C58 running ISPPRGM in the test jig receives the data,
*
* it places this device in test mode and programs these parameters.
*
* The code with comments TEST - is used to create some fakecalibration *
* parameters that are first written to addresses STARTCALBYTE through
*
* ENDCALBYTE and later used to call the self-programming algorithm.
*
* Replace this code with your parameter calculation procedure,
*
* placing each parameter into the STARTCALBYTE to ENDCALBYTE
*
* file register addresses (16 are used in this example). The address
*
* lookuptable is used by the main code later on for the final lookup
*
* table of calibration constants. 16 words are reserved for this lookup *
* table.
*
**************************************************************************
* Program Memory:
*
*
49 Words - communication with test jig
*
*
17 Words - calibration look-up table (16 bytes of data)
*
*
13 Words - Test Code to generate Calibration Constants
*
* RAM Memory:
*
*
16 Bytes -Temporary- Store 16 bytes of calibration constant*
*
4 Bytes -Temporary- Store 4 bytes of temp variables
*
**************************************************************************
format specified on command line.
list p=16C71,f=inhx8m
include <p16C71.inc>
LIST
P16C71.INC Standard Header File, Version 1.00 Microchip Technology, Inc.
LIST
__CONFIG _CP_OFF&_WDT_OFF&_XT_OSC&_PWRTE_OFF
************************************
* Port A (RA0-RA4) bit definitions *
************************************
Port A is not used in this test program
************************************
* Port B (RB0-RB7) bit definitions *
=OMMP=j=q=fK
AN656
0000000C
0000000D
0000000E
0000000F
00000010
0000002F
00000020
0000
0000
0000
0001
0002
0002
0003
0004
0005
0006
0007
0008
0009
000A
000B
000C
000D
000E
000E
000F
3010
0084
0804
0080
0A84
0804
3C30
1D03
2802
0103
200F
3CFF
1903
2830
280E
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
; ************************************
#define
CLOCK
6 ; clock line for ISP
#define
DATA
7 ; data line for ISP
; Port pins RB0-5 are not used in this test program
; ************************************
; * RAM register usage definition
*
; ************************************
CSUMTOTAL
EQU 0Ch ; Address for checksum var
COUNT
EQU 0Dh ; Address for COUNT var
DATAREG
EQU 0Eh ; Address for Data output register var
COUNTDLY
EQU 0Fh ; Address for clock delay counter
;
;
;
;
;
These two symbols are used for the start and end address
in RAM where the calibration bytes are stored. There are 16 bytes
to be stored in this example; however, you can increase or
decrease the number of bytes by changing the STARTCALBYTE or ENDCALBYTE
address values.
STARTCALBYTE
ENDCALBYTE
EQU 10h
EQU 2Fh
ENDCALBYTE - STARTCALBYTE + 1
ORG 0
; ******************************************************************
; * testcode routine
*
; * TEST code - sets up RAM register with register address as data *
; * Uses file register STARTCALBYTE through ENDCALBYTE to store the*
; * calibration values that are to be programmed into the lookup
*
; * table by the test jig running ISPPRGM.
*
; * Customer would place calibration code here and make sure that *
; * calibration constants start at address STARTCALBYTE
*
; ******************************************************************
testcode
movlw
STARTCALBYTE
; TEST movwf
FSR
; TEST - Init FSR with start of RAM addres
looptestram
movf
FSR,W
; TEST - Place address into W
movwf
INDF
; TEST - Place address into RAM data byte
incf
FSR,F
; TEST - Move to next address
movf
FSR,W
; TEST - Place current address into W
sublw
ENDCALBYTE+1
; TEST - Subtract from end of RAM
btfss
STATUS,Z
; TEST - Skip if at END of ram
goto
looptestram
; TEST - Jump back and init next RAM byte
clrw
; TEST - Clear W
call
lookuptable
; TEST - Get first CAL value from lookup table
sublw
0FFh
; TEST - Check if lookup CAL table is blank
btfsc
STATUS,Z
; TEST - Skip if table is NOT blank
goto
calsend
; TEST - Table blank - send out cal parameters
mainloop
goto
mainloop
; TEST - Jump back to self since CAL is done
; ******************************************************************
; * lookuptable
*
; * Calibration constants look-up table. This is where the CAL
*
; * Constants will be stored via ISP protocol later. Note it is
*
; * blank, since these values will be pogrammed by the test jig
*
; * running ISPPRGM later.
*
; *
Input Variable: W stores index for table lookup
*
; *
Output Variable: W returns with the calibration constant
*
; * NOTE: Blank table when programmed reads FF for all locations *
; ******************************************************************
lookuptable
=OMMP=j=q=fK
apMMSRS_J~=QJNV
AN656
000F 0782
00122
addwf
PCL,F
; Place the calibration constant table here!
00123
002F
00124
ORG
lookuptable + CALTABLELENGTH
002F 34FF
00125
retlw
0FFh
; Return FF at last location for a blank table
00126
00127 ; ******************************************************************
00128 ; * calsend subroutine
*
00129 ; * Send the calibration data stored in locations STARTCALBYTE
*
00130 ; * through ENDCALBYTE in RAM to the programming jig using a serial*
00131 ; * clock and data protocol
*
00132 ; *
Input Variables:
STARTCALBYTE through ENDCALBYTE
*
00133 ; ******************************************************************
0030
00134 calsend
0030 018C
00135
clrf
CSUMTOTAL
; Clear CSUMTOTAL reg for delay counter
0031 018D
00136
clrf
COUNT
; Clear COUNT reg to delay counter
0032
00137 delayloop
; Delay for 100 mS to wait for prog jig wakeup
0032 0B8D
00138
decfsz COUNT,F
; Decrement COUNT and skip when zero
0033 2832
00139
goto
delayloop
; Go back and delay again
0034 0B8C
00140
decfsz CSUMTOTAL,F
; Decrement CSUMTOTAL and skip when zero
0035 2832
00141
goto
delayloop
; Go back and delay again
0036 0186
00142
clrf
PORTB
; Place 0 into port b latch register
0037 1683
00143
bsf
STATUS,RP0
; Switch to bank 1
0038 303F
00144
movlw
b00111111
; RB6,7 set to outputs
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
0039 0086
00145
movwf
TRISB
; Move to TRIS registers
003A 1283
00146
bcf
STATUS,RP0
; Switch to bank 0
003B 018C
00147
clrf
CSUMTOTAL
; Clear checksum total byte
003C 3001
00148
movlw
high lookuptable+1 ; place MSB of first addr of cal table into W
003D 204D
00149
call
sendcalbyte
; Send the high address out
003E 3010
00150
movlw
low lookuptable+1 ; place LSB of first addr of cal table into W
003F 204D
00151
call
sendcalbyte
; Send low address out
0040 3010
00152
movlw
STARTCALBYTE
; Place RAM start address of first cal byte
0041 0084
00153
movwf
FSR
; Place this into FSR
0042
00154 loopcal
0042 0800
00155
movf
INDF,W
; Place data into W
0043 204D
00156
call
sendcalbyte
; Send the byte out
0044 0A84
00157
incf
FSR,F
; Move to the next cal byte
0045 0804
00158
movf
FSR,W
; Place byte address into W
0046 3C30
00159
sublw
ENDCALBYTE+1
; Set Z bit if we are at the end of CAL data
0047 1D03
00160
btfss
STATUS,Z
; Skip if we are done
0048 2842
00161
goto
loopcal
; Go back for next byte
0049 080C
00162
movf
CSUMTOTAL,W
; place checksum total into W
004A 204D
00163
call
sendcalbyte
; Send the checksum out
004B 0186
00164
clrf
PORTB
; clear out port pins
004C
00165 calsenddone
004C 284C
00166
goto
calsenddone
; We are done - go home!
00167
00168 ; ******************************************************************
00169 ; * sendcalbyte subroutine
*
00170 ; * Send one byte of calibration data to the programming jig
*
00171 ; *
Input Variable: W contains the byte to be sent
*
00172 ; ******************************************************************
004D
00173 sendcalbyte
004D 008E
00174
movwf
DATAREG
; Place send byte into data register
004E 078C
00175
addwf
CSUMTOTAL,F
; Update checksum total
004F 3008
00176
movlw
.8
; Place 8 into W
0050 008D
00177
movwf
COUNT
; set up counter register
0051
00178 loopsendcal
0051 1706
00179
bsf
PORTB,CLOCK
; Set clock line high
0052 205C
00180
call
delaysend
; Wait for test jig to synch up
0053 0D8E
00181
rlf
DATAREG,F
; Rotate to next bit
0054 1786
00182
bsf
PORTB,DATA
; Assume data bit is high
0055 1C03
00183
btfss
STATUS,C
; Skip if the data bit was high
0056 1386
00184
bcf
PORTB,DATA
; Set data bit to low
0057 1306
00185
bcf
PORTB,CLOCK
; Clear clock bit to clock data out
0058 205C
00186
call
delaysend
; Wait for test jig to synch up
apMMSRS_J~=QJOM
=OMMP=j=q=fK
AN656
0059 0B8D
005A 2851
005B 0008
005C
005C
005D
005E
005E
005F
0060
3010
008F
0B8F
285E
0008
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
decfsz
goto
return
COUNT,F
loopsendcal
; ******************************************************************
; * delaysend subroutine
*
; * Delay for 50 ms to wait for the programming jig to synch up
*
; ******************************************************************
delaysend
movlw
10h
; Delay for 16 loops
movwf
COUNTDLY
; Use COUNTDLY as delay count variable
loopdelaysend
decfsz COUNTDLY,F
; Decrement COUNTDLY and skip when done
goto
loopdelaysend
; Jump back for more delay
return
END
- = Unused)
Errors
:
Warnings :
Messages :
0
1 reported,
1 reported,
=OMMP=j=q=fK
66
958
0 suppressed
0 suppressed
apMMSRS_J~=QJON
AN656
NOTES:
apMMSRS_J~=QJOO
=OMMP=j=q=fK
AN656
NOTES:
=OMMP=j=q=fK
apMMSRS_J~=QJOP
ASIA/PACIFIC
Japan
Corporate Office
Australia
Atlanta
3780 Mansell Road, Suite 130
Alpharetta, GA 30022
Tel: 770-640-0034 Fax: 770-640-0307
China - Beijing
Chicago
China - Chengdu
Boston
Dallas
4570 Westgrove Drive, Suite 160
Addison, TX 75001
Tel: 972-818-7423 Fax: 972-818-2924
Detroit
Tri-Atria Office Building
32255 Northwestern Highway, Suite 190
Farmington Hills, MI 48334
Tel: 248-538-2250 Fax: 248-538-2260
Kokomo
2767 S. Albright Road
Kokomo, IN 46902
Tel: 765-864-8360 Fax: 765-864-8387
Los Angeles
18201 Von Karman, Suite 1090
Irvine, CA 92612
Tel: 949-263-1888 Fax: 949-263-1338
Phoenix
2355 West Chandler Blvd.
Chandler, AZ 85224-6199
Tel: 480-792-7966 Fax: 480-792-4338
San Jose
Microchip Technology Inc.
2107 North First Street, Suite 590
San Jose, CA 95131
Tel: 408-436-7950 Fax: 408-436-7955
Toronto
6285 Northam Drive, Suite 108
Mississauga, Ontario L4V 1X5, Canada
Tel: 905-673-0699 Fax: 905-673-6509
China - Fuzhou
Microchip Technology Consulting (Shanghai)
Co., Ltd., Fuzhou Liaison Office
Unit 28F, World Trade Plaza
No. 71 Wusi Road
Fuzhou 350001, China
Tel: 86-591-7503506 Fax: 86-591-7503521
China - Shanghai
Microchip Technology Consulting (Shanghai)
Co., Ltd.
Room 701, Bldg. B
Far East International Plaza
No. 317 Xian Xia Road
Shanghai, 200051
Tel: 86-21-6275-5700 Fax: 86-21-6275-5060
China - Shenzhen
Microchip Technology Consulting (Shanghai)
Co., Ltd., Shenzhen Liaison Office
Rm. 1812, 18/F, Building A, United Plaza
No. 5022 Binhe Road, Futian District
Shenzhen 518033, China
Tel: 86-755-82901380 Fax: 86-755-82966626
China - Qingdao
Rm. B505A, Fullhope Plaza,
No. 12 Hong Kong Central Rd.
Qingdao 266071, China
Tel: 86-532-5027355 Fax: 86-532-5027205
India
Microchip Technology Inc.
India Liaison Office
Marketing Support Division
Divyasree Chambers
1 Floor, Wing A (A3/A4)
No. 11, OShaugnessey Road
Bangalore, 560 025, India
Tel: 91-80-2290061 Fax: 91-80-2290062
Korea
Microchip Technology Korea
168-1, Youngbo Bldg. 3 Floor
Samsung-Dong, Kangnam-Ku
Seoul, Korea 135-882
Tel: 82-2-554-7200 Fax: 82-2-558-5934
Singapore
Microchip Technology Singapore Pte Ltd.
200 Middle Road
#07-02 Prime Centre
Singapore, 188980
Tel: 65-6334-8870 Fax: 65-6334-8850
Taiwan
Microchip Technology (Barbados) Inc.,
Taiwan Branch
11F-3, No. 207
Tung Hua North Road
Taipei, 105, Taiwan
Tel: 886-2-2717-7175 Fax: 886-2-2545-0139
EUROPE
Austria
Microchip Technology Austria GmbH
Durisolstrasse 2
A-4600 Wels
Austria
Tel: 43-7242-2244-399
Fax: 43-7242-2244-393
Denmark
Microchip Technology Nordic ApS
Regus Business Centre
Lautrup hoj 1-3
Ballerup DK-2750 Denmark
Tel: 45 4420 9895 Fax: 45 4420 9910
France
Microchip Technology SARL
Parc dActivite du Moulin de Massy
43 Rue du Saule Trapu
Batiment A - ler Etage
91300 Massy, France
Tel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79
Germany
Microchip Technology GmbH
Steinheilstrasse 10
D-85737 Ismaning, Germany
Tel: 49-89-627-144-0
Fax: 49-89-627-144-44
Italy
Microchip Technology SRL
Via Quasimodo, 12
20025 Legnano (MI)
Milan, Italy
Tel: 39-0331-742611 Fax: 39-0331-466781
United Kingdom
Microchip Ltd.
505 Eskdale Road
Winnersh Triangle
Wokingham
Berkshire, England RG41 5TU
Tel: 44 118 921 5869 Fax: 44-118 921-5820
03/25/03
DS30277D-page 24