PIC12F508/509: Memory Programming Specification
PIC12F508/509: Memory Programming Specification
1.2
PIC12F508
PIC12F509
Pin Diagrams
PROGRAMMING THE
PIC12F508/509
1.1
VDD
GP5/OSC1/CLKIN
GP4/OSC2
GP3/MCLR/VPP
PIC12F508/509
1.0
Program/Verify Mode
VSS
GP0/ICSPDAT
GP1/ICSPCLK
GP2/T0CKI
Hardware Requirements
TABLE 1-1:
Pin Name
Pin Type
Pin Description
GP1
ICSPCLK
GP0
ICSPDAT
I/O
Program/Verify mode
P(1)
VDD
VDD
Power Supply
VSS
VSS
Ground
MCLR/VPP
Preliminary
DS41227E-page 1
PIC12F508/509
MEMORY MAPPING
2.1
FIGURE 2-1:
2.3
Configuration Word
DS41227E-page 2
0FFh
100h
Reset Vector
1FEh
1FFh
User ID Locations
Backup OSCCAL value
200h
203h
204h
205h
Reserved
Unimplemented
Configuration Word
FIGURE 2-2:
User Memory
Space
User ID Locations
On-chip User
Program Memory
23Fh
240h
On-chip User
Program
On-chip User
Program
Memory (Page 1)
User ID Locations
Backup OSCCAL value
000h
1FFh
200h
3FEh
3FFh
400h
403h
404h
405h
Reserved
43Fh
440h
Unimplemented
Configuration Word
2.4
3FEh
3FFh
PIC12F509 PROGRAM
MEMORY MAP
Reset Vector
Config Memory
Space
2.2
Config Memory
Space
PIC12F508 PROGRAM
MEMORY MAP
000h
User Memory
Space
2.0
7FEh
7FFh
2.5
Preliminary
PIC12F508/509
3.0
COMMANDS AND
ALGORITHMS
3.1
Program/Verify Mode
3.1.2
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).
3.1.1
PROGRAMMING
FIGURE 3-1:
Note:
The first and last clock pulses during the data segment
correspond to the Start and Stop bits, respectively.
Input data is a don't care during the Start and Stop
cycles. The 14 clock pulses between the Start and Stop
cycles clock the 14 bits of input/output data. Data is
transferred LSb first.
ENTERING HIGH
VOLTAGE PROGRAM/
VERIFY MODE
TPPDP
SERIAL PROGRAM/VERIFY
OPERATION
THLD0
VPP
VDD
ICSPDAT
ICSPCLK
TABLE 3-1:
Data
0
0, data (14), 0
0, data (14), 0
Increment Address
Begin Programming
End Programming
Preliminary
Externally Timed
Internally Timed
DS41227E-page 3
PIC12F508/509
3.1.2.1
FIGURE 3-2:
0
0
TSET1
THLD1
TDLY2
ICSPCLK
3.1.2.2
ICSPDAT
16
15
MSb stp_bit
LSb
strt_bit
TSET1
-+THLD1
TDLY1
FIGURE 3-3:
ICSPCLK
ICSPDAT
15
16
TDLY3
1 0
strt_bit
TDLY1
TSET1
MSb stp_bit
LSb
THLD1
input
DS41227E-page 4
output
Preliminary
input
PIC12F508/509
3.1.2.3
Increment Address
FIGURE 3-4:
Next Command
1
ICSPCLK
ICSPDAT
TSET1
THLD1
3.1.2.4
FIGURE 3-5:
ICSPCLK
ICSPDAT
TSET1
THLD1
Preliminary
DS41227E-page 5
PIC12F508/509
3.1.2.5
End Programming
FIGURE 3-6:
Next Command
1
ICSPCLK
ICSPDAT
TSET1
3.1.2.6
2.
3.
4.
5.
THLD1
2.
3.
4.
5.
6.
7.
Read and save 0x1FF/0x3FF oscillator Calibration bits and 0x204/0x404 backup OSCCAL bits
into computer/programmer temporary memory.
Enter Program/Verify mode.
Increment PC to 0x200/0x400 (first user ID
location).
Perform a Bulk Erase command.
Wait TERA to complete Bulk Erase.
Restore OSCCAL bits.
Restore backup OSCCAL bits.
DS41227E-page 6
Preliminary
PIC12F508/509
TABLE 3-2:
PC =
Program Memory
Reset Vector
Configuration
Word
User ID
Backup
OSCCAL
Configuration Word or
Program Memory Space
FIGURE 3-7:
TERA
1
Next Command
1
ICSPCLK
ICSPDAT
TSET1
THLD1
Preliminary
DS41227E-page 7
PIC12F508/509
FIGURE 3-8:
Enter Programming
Mode
Increment
Address
No
PC =
0x1FF/0x3FF?
Yes
Read Calibration
Bits and Save in
Computer/Programmer
Temp. Memory
Increment
Address
No
PC =
0x204/0x404?
Yes
Done
DS41227E-page 8
Preliminary
PIC12F508/509
FIGURE 3-9:
Enter Programming
Mode
Increment
Address
No
PC =
0x1FF/0x3FF?
Yes
Read Calibration
Bits from
Computer/Programmer
Temp. Memory
Increment
Address
No
PC =
0x204/0x404?
Yes
Read Backup OSCCAL
Calibration Bits from
Computer/Programmer
Temp. Memory
Done
Preliminary
DS41227E-page 9
PIC12F508/509
FIGURE 3-10:
Enter Programming
Mode
PC = 0x3FF/0x7FF
(Config Word)
Increment
Address
Bulk Erase
Device
PROGRAM CYCLE
Load Data
for
Program Memory
One Word
Program Cycle
Begin
Programming
Command
(Externally timed)
Read Data
from
Program Memory
Data Correct?
No
Report
Programming
Failure
End
Programming
Yes
Increment
Address
Command
No
Wait TPROG
All Programming
Locations
Done?
Wait TDIS
Yes
Exit Programming
Mode
Program
Configuration
Memory
(Figure 3-11)
Done
DS41227E-page 10
Preliminary
PIC12F508/509
FIGURE 3-11:
One-Word
Programming
Cycle
(see Figure 3-10)
Data
Correct?
No
Report
Programming
Failure
Yes
Increment Address
Command
No
Address =
0x200/0x400?
Yes
Load Data
Command
One-Word
Programming
Cycle
(see Figure 3-10)
Data
Correct?
No
Report
Programming
Failure
Yes
Increment Address
Command
No
Address =
0x204/0x404?
Yes
Exit Programming Mode
Done
Preliminary
DS41227E-page 11
PIC12F508/509
FIGURE 3-12:
Wait TERA
Enter
Program/Verify mode
PC = 0x3FF/0x7FF
(Config Word)
Exit Programming
Mode
Done
DS41227E-page 12
Preliminary
PIC12F508/509
FIGURE 3-13:
Start
Enter
Program/Verify mode
PC = 0x3FF/0x7FF
(Config Word)
Increment
PC
No
PC = 0x200/0x400?
(First User ID)
Yes
Bulk Erase Device
Wait TERA
Done
Preliminary
DS41227E-page 13
PIC12F508/509
4.0
CONFIGURATION WORD
REGISTER 4-1:
MCLRE
CP
WDTE
FOSC1 FOSC0
bit 11
bit 0
bit 11-5
Unimplemented: Read as 1
bit 4
bit 3
bit 2
bit 1-0
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
DS41227E-page 14
Preliminary
x = Bit is unknown
PIC12F508/509
5.0
CODE PROTECTION
5.3
5.3.1
Checksum Computation
CHECKSUM
5.1
c)
5.2
Note:
To disable code-protect:
a)
b)
Program
Memory
Preliminary
DS41227E-page 15
PIC12F508/509
TABLE 5-1:
Device
PIC12F508
Checksum*
Blank
Value
0x723 at 0
and Max
Address
OFF
0xEE20
0x0C68
ON
0xEDF7
0xD363
TABLE 5-2:
Device
PIC12F509
Checksum*
Blank
Value
0x723 at 0
and Max
Address
OFF
0xEC20
0xDA68
ON
0xEBF7
0xD163
DS41227E-page 16
Preliminary
PIC12F508/509
6.0
TABLE 6-1:
AC/DC CHARACTERISTICS
Sym.
Characteristics
Min.
Typ.
Max.
Units
4.5
5.5
VDDERA
4.5
5.5
IDDPROG
0.5
mA
IDDERA
0.5
mA
VPP
12.5
13.5
IPP
0.45
mA
TVHHR
1.0
0.8 VDD
Conditions/
Comments
General
TPPDP
VIH1
VIL1
TSET0
THLD0
0.2 VDD
100
ns
Serial Program/Verify
TSET1
100
ns
THLD1
100
ns
TDLY1
1.0
TDLY2
1.0
TDLY3
80
ns
(1)
TERA
10
TPROG
2(1)
ms
TDIS
100
TRESET
10
ms
Legend:
Note 1:
TBD = To Be Determined.
Minimum time to ensure that function completes successfully over voltage, temperature and device variations.
Preliminary
ms
DS41227E-page 17
PIC12F508/509
NOTES:
DS41227E-page 18
Preliminary
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 Microchips 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, Accuron,
dsPIC, KEELOQ, KEELOQ logo, microID, MPLAB, PIC,
PICmicro, PICSTART, PRO MATE, rfPIC and SmartShunt are
registered trademarks of Microchip Technology Incorporated
in the U.S.A. and other countries.
AmpLab, FilterLab, Linear Active Thermistor, Migratable
Memory, MXDEV, MXLAB, SEEVAL, SmartSensor and The
Embedded Control Solutions Company are registered
trademarks of Microchip Technology Incorporated in the
U.S.A.
Analog-for-the-Digital Age, Application Maestro, CodeGuard,
dsPICDEM, dsPICDEM.net, dsPICworks, dsSPEAK, ECAN,
ECONOMONITOR, FanSense, FlexROM, fuzzyLAB,
In-Circuit Serial Programming, ICSP, ICEPIC, Mindi, MiWi,
MPASM, MPLAB Certified logo, MPLIB, MPLINK, PICkit,
PICDEM, PICDEM.net, PICLAB, PICtail, PowerCal,
PowerInfo, PowerMate, PowerTool, REAL ICE, rfLAB, Select
Mode, Smart Serial, SmartTel, Total Endurance, UNI/O,
WiperLock and ZENA are trademarks of Microchip
Technology Incorporated in the U.S.A. and other countries.
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.
2007, Microchip Technology Incorporated, Printed in the
U.S.A., All Rights Reserved.
Printed on recycled paper.
Preliminary
DS41227E-page 19
ASIA/PACIFIC
ASIA/PACIFIC
EUROPE
Corporate Office
2355 West Chandler Blvd.
Chandler, AZ 85224-6199
Tel: 480-792-7200
Fax: 480-792-7277
Technical Support:
http://support.microchip.com
Web Address:
www.microchip.com
India - Bangalore
Tel: 91-80-4182-8400
Fax: 91-80-4182-8422
India - New Delhi
Tel: 91-11-4160-8631
Fax: 91-11-4160-8632
Austria - Wels
Tel: 43-7242-2244-39
Fax: 43-7242-2244-393
Denmark - Copenhagen
Tel: 45-4450-2828
Fax: 45-4485-2829
India - Pune
Tel: 91-20-2566-1512
Fax: 91-20-2566-1513
France - Paris
Tel: 33-1-69-53-63-20
Fax: 33-1-69-30-90-79
Japan - Yokohama
Tel: 81-45-471- 6166
Fax: 81-45-471-6122
Germany - Munich
Tel: 49-89-627-144-0
Fax: 49-89-627-144-44
Atlanta
Duluth, GA
Tel: 678-957-9614
Fax: 678-957-1455
Boston
Westborough, MA
Tel: 774-760-0087
Fax: 774-760-0088
Chicago
Itasca, IL
Tel: 630-285-0071
Fax: 630-285-0075
Dallas
Addison, TX
Tel: 972-818-7423
Fax: 972-818-2924
Detroit
Farmington Hills, MI
Tel: 248-538-2250
Fax: 248-538-2260
Kokomo
Kokomo, IN
Tel: 765-864-8360
Fax: 765-864-8387
Los Angeles
Mission Viejo, CA
Tel: 949-462-9523
Fax: 949-462-9608
Santa Clara
Santa Clara, CA
Tel: 408-961-6444
Fax: 408-961-6445
Toronto
Mississauga, Ontario,
Canada
Tel: 905-673-0699
Fax: 905-673-6509
Australia - Sydney
Tel: 61-2-9868-6733
Fax: 61-2-9868-6755
China - Beijing
Tel: 86-10-8528-2100
Fax: 86-10-8528-2104
Korea - Daegu
Tel: 82-53-744-4301
Fax: 82-53-744-4302
China - Chengdu
Tel: 86-28-8665-5511
Fax: 86-28-8665-7889
China - Fuzhou
Tel: 86-591-8750-3506
Fax: 86-591-8750-3521
Korea - Seoul
Tel: 82-2-554-7200
Fax: 82-2-558-5932 or
82-2-558-5934
China - Nanjing
Tel: 86-25-8473-2460
Fax: 86-25-8473-2470
Malaysia - Penang
Tel: 60-4-227-8870
Fax: 60-4-227-4068
China - Qingdao
Tel: 86-532-8502-7355
Fax: 86-532-8502-7205
Philippines - Manila
Tel: 63-2-634-9065
Fax: 63-2-634-9069
China - Shanghai
Tel: 86-21-5407-5533
Fax: 86-21-5407-5066
Singapore
Tel: 65-6334-8870
Fax: 65-6334-8850
China - Shenyang
Tel: 86-24-2334-2829
Fax: 86-24-2334-2393
China - Shenzhen
Tel: 86-755-8203-2660
Fax: 86-755-8203-1760
Taiwan - Kaohsiung
Tel: 886-7-536-4818
Fax: 886-7-536-4803
China - Shunde
Tel: 86-757-2839-5507
Fax: 86-757-2839-5571
Taiwan - Taipei
Tel: 886-2-2500-6610
Fax: 886-2-2508-0102
China - Wuhan
Tel: 86-27-5980-5300
Fax: 86-27-5980-5118
Thailand - Bangkok
Tel: 66-2-694-1351
Fax: 66-2-694-1350
Italy - Milan
Tel: 39-0331-742611
Fax: 39-0331-466781
Netherlands - Drunen
Tel: 31-416-690399
Fax: 31-416-690340
Spain - Madrid
Tel: 34-91-708-08-90
Fax: 34-91-708-08-91
UK - Wokingham
Tel: 44-118-921-5869
Fax: 44-118-921-5820
China - Xian
Tel: 86-29-8833-7252
Fax: 86-29-8833-7256
10/05/07
DS41227E-page 20
Preliminary