01 - Programacion Cobol- Programacion Estructurada Con Cobol
programacion icsp
-
Upload
gerardo-madrigal -
Category
Documents
-
view
8 -
download
1
Transcript of programacion icsp
TB013How to Implement ICSP™ Using PIC16CXXX OTP MCUs
INTRODUCTION
In-Circuit Serial Programming (ICSP™) is a great wayto reduce your inventory overhead and time-to-marketfor your product. By assembling your product with ablank Microchip microcontroller (MCU), you can stockone design. When an order has been placed, theseunits can be programmed with the latest revision offirmware, tested, and shipped in a very short time. Thismethod also reduces scrapped inventory due to oldfirmware revisions. This type of manufacturing systemcan also facilitate quick turnarounds on custom ordersfor your product.
Most people would think to use ICSP with PICmicro™OTP MCUs only on an assembly line where the deviceis programmed once. However, there is a method bywhich an OTP device can be programmed severaltimes depending on the size of the firmware. Thismethod, explained later, provides a way to fieldupgrade your firmware in a way similar to EEPROM- orFlash-based devices.
HOW DOES ICSP WORK?
Now that ICSP appeals to you, what steps do you taketo implement it in your application? There are threemain components of an ICSP system: ApplicationCircuit, Programmer and Programming Environment.
Author: Rodger RicheyMicrochip Technology Inc.
1997 Microchip Technology Inc. Prelimin
Application Circuit
The application circuit must be designed to allow all theprogramming signals to be directly connected to thePICmicro. Figure 1 shows a typical circuit that is astarting point for when designing with ICSP. Theapplication must compensate for the following issues:
1. Isolation of the MCLR/VPP pin from the rest ofthe circuit.
2. Isolation of pins RB6 and RB7 from the rest ofthe circuit.
3. Capacitance on each of the VDD, MCLR/VPP,RB6, and RB7 pins.
4. Minimum and maximum operating voltage forVDD.
5. PICmicro Oscillator.6. Interface to the programmer.
The MCLR/VPP pin is normally connected to an RC cir-cuit. The pull-up resistor is tied to VDD and a capacitoris tied to ground. This circuit can affect the operation ofICSP depending on the size of the capacitor. It is,therefore, recommended that the circuit in Figure 1 beused when an RC is connected to MCLR/VPP. Thediode should be a Schottky-type device. Another issuewith MCLR/VPP is that when the PICmicro device isprogrammed, this pin is driven to approximately 13Vand also to ground. Therefore, the application circuitmust be isolated from this voltage provided by theprogrammer.
FIGURE 1: TYPICAL APPLICATION CIRCUIT
Application PCBPIC16CXXX
MCLR/VPP
VDD
VSS
RB7RB6
VDD VDD
To application circuit
Isolation circuits
ICSP Connector
PRO MATE and PICSTART are registered trademarks and PICmicro and ICSP are trademarks of Microchip Technology Inc.
ary DS91013B-page 1
TB013
Pins RB6 and RB7 are used by the PICmicro for serialprogramming. RB6 is the clock line and RB7 is the dataline. RB6 is driven by the programmer. RB7 is abi-directional pin that is driven by the programmer whenprogramming, and driven by the PICmicro when verify-ing. These pins must be isolated from the rest of theapplication circuit so as not to affect the signals duringprogramming. You must take into consideration theoutput impedance of the programmer when isolatingRB6 and RB7 from the rest of the circuit. This isolationcircuit must account for RB6 being an input on thePICmicro, and for RB7 being bi-directional (can bedriven by both the PICmicro and the programmer). Forinstance, PRO MATE® II has an output impedance of1k¾. If the design permits, these pins should not beused by the application. This is not the case with mostapplications so it is recommended that the designerevaluate whether these signals need to be buffered. Asa designer, you must consider what type of circuitry isconnected to RB6 and RB7 and then make a decisionon how to isolate these pins. Figure 1 does not showany circuitry to isolate RB6 and RB7 on the applicationcircuit because this is very application dependent.
The total capacitance on the programming pins affectsthe rise rates of these signals as they are driven out ofthe programmer. Typical circuits use several hundredmicrofarads of capacitance on VDD which helps todampen noise and ripple. However, this capacitancerequires a fairly strong driver in the programmer tomeet the rise rate timings for VDD. Most programmersare designed to simply program the PICmicro itself anddon’t have strong enough drivers to power the applica-tion circuit. One solution is to use a driver boardbetween the programmer and the application circuit.The driver board requires a separate power supply thatis capable of driving the VPP and VDD pins with thecorrect rise rates and should also provide enough cur-rent to power the application circuit. RB6 and RB7 arenot buffered on this schematic but may require buffer-ing depending upon the application. A sample driverboard schematic is shown in Appendix A.
The Microchip programming specification states thatthe device should be programmed at 5V. Special con-siderations must be made if your application circuitoperates at 3V only. These considerations may includetotally isolating the PICmicro during programming. Theother issue is that the device must be verified at theminimum and maximum voltages at which the applica-tion circuit will be operating. For instance, a battery
Note: The driver board design MUST be tested inthe user’s application to determine the effectsof the application circuit on the program-ming signals timing. Changes may berequired if the application places a signifi-cant load on VDD, VPP, RB6 OR RB7.
DS91013B-page 2 Prelimin
operated system may operate from three 1.5V cells giv-ing an operating voltage range of 2.7V to 4.5V. Theprogrammer must program the device at 5V and mustverify the program memory contents at both 2.7V and4.5V to ensure that proper programming margins havebeen achieved. This ensures the PICmicro option overthe voltage range of the system.
This final issue deals with the oscillator circuit on theapplication board. The voltage on MCLR/VPP must riseto the specified program mode entry voltage before thedevice executes any code. The crystal modes availableon the PICmicro are not affected by this issue becausethe Oscillator Start-up Timer waits for 1024 oscillationsbefore any code is executed. However, RC oscillatorsdo not require any startup time and, therefore, theOscillator Startup Timer is not used. The programmermust drive MCLR/VPP to the program mode entry volt-age before the RC oscillator toggles four times. If theRC oscillator toggles four or more times, the programcounter will be incremented to some value X. Nowwhen the device enters programming mode, the pro-gram counter will not be zero and the programmer willstart programming your code at an offset of X. Thereare several alternatives that can compensate for a slowrise rate on MCLR/VPP. The first method would be tonot populate the R, program the device, and then insertthe R. The other method would be to have the pro-gramming interface drive the OSC1 pin of the PICmicroto ground while programming. This will prevent anyoscillations from occurring during programming.
Now all that is left is how to connect the application cir-cuit to the programmer. This depends a lot on theprogramming environment and will be discussed in thatsection.
Programmer
The second consideration is the programmer.PIC16CXXX MCUs only use serial programming andtherefore all programmers supporting these deviceswill support ICSP. One issue with the programmer isthe drive capability. As discussed before, it must beable to provide the specified rise rates on the ICSP sig-nals and also provide enough current to power theapplication circuit. Appendix A shows an exampledriver board. This driver schematic does not show anybuffer circuitry for RB6 and RB7. It is recommendedthat an evaluation be performed to determine if buffer-ing is required. Another issue with the programmer iswhat VDD levels are used to verify the memory contentsof the PICmicro. For instance, the PRO MATE II verifiesprogram memory at the minimum and maximum VDD
levels for the specified device and is therefore consid-ered a production quality programmer. On the otherhand, the PICSTART® Plus only verifies at 5V and is forprototyping use only. The Microchip programmingspecifications state that the program memory contentsshould be verified at both the minimum and maximumVDD levels that the application circuit will be operating.This implies that the application circuit must be able tohandle the varying VDD voltages.
ary 1997 Microchip Technology Inc.
How to Implement ICSP™ Using PIC16CXXX OTP MCUs
There are also several third party programmers that areavailable. You should select a programmer based onthe features it has and how it fits into your programmingenvironment. The Microchip Development SystemsOrdering Guide (DS30177) provides detailed informa-tion on all our development tools. The Microchip ThirdParty Guide (DS00104) provides information on all ofour third party tool developers. Please consult thesetwo references when selecting a programmer. Manyoptions exist including serial or parallel PC host con-nection, stand-alone operation, and single or gang pro-grammers. Some of the third party developers includeAdvanced Transdata Corporation, BP Microsystems,Data I/O, Emulation Technology and Logical Devices.
Programming Environment
The programming environment will affect the type ofprogrammer used, the programmer cable length, andthe application circuit interface. Some programmersare well suited for a manual assembly line while othersare desirable for an automated assembly line. You maywant to choose a gang programmer to program multiplesystems at a time.
The physical distance between the programmer andthe application circuit affects the load capacitance oneach of the programming signals. This will directlyaffect the drive strength needed to provide the correctsignal rise rates and current. This programming cablemust also be as short as possible and properlyterminated and shielded, or the programming signalsmay be corrupted by ringing or noise.
Finally, the application circuit interface to the program-mer depends on the size constraints of the applicationcircuit itself and the assembly line. A simple headercan be used to interface the application circuit to theprogrammer. This might be more desirable for a man-ual assembly line where a technician plugs theprogrammer cable into the board. A different method isthe use of spring loaded test pins (commonly referredto as pogo pins). The application circuit has pads onthe board for each of the programming signals. Thenthere is a fixture that has pogo pins in the same config-uration as the pads on the board. The applicationcircuit or fixture is moved into position such that thepogo pins come into contact with the board. Thismethod might be more suitable for an automatedassembly line.
After taking into consideration the issues with the appli-cation circuit, the programmer, and the programmingenvironment, anyone can build a high quality, reliablemanufacturing line based on ICSP.
1997 Microchip Technology Inc. Prelimin
Other Benefits
ICSP provides other benefits, such as calibration andserialization. If program memory permits, it would becheaper and more reliable to store calibration con-stants in program memory instead of using an externalserial EEPROM. For example, your system has a ther-mistor which can vary from one system to another.Storing some calibration information in a table formatallows the micrcontroller to compensate in software forexternal component tolerances. System cost can bereduced without affecting the required performance ofthe system by using software calibration techniques.But how does this relate to ICSP? The PICmicro hasalready been programmed with firmware that performsa calibration cycle. The calibration data is transferredto a calibration fixture. When all calibration data hasbeen transferred, the fixture places the PICmicro inprogramming mode and programs the PICmicro withthe calibration data. Application note AN656, In-CircuitSerial Programming of Calibration Parameters Using aPICmicro Microcontroller, shows exactly how to imple-ment this type of calibration data programming.
The other benefit of ICSP is serialization. Each individ-ual system can be programmed with a unique or ran-dom serial number. One such application of a uniqueserial number would be for security systems. A typicalsystem might use DIP switches to set the serial num-ber. Instead, this number can be burned into programmemory, thus reducing the overall system cost and low-ering the risk of tampering.
Field Programming of PICmicro OTP MCUs
An OTP device is not normally capable of beingreprogrammed, but the PICmicro architecture givesyou this flexibility provided the size of your firmware isat least half that of the desired device and the device isnot code protected. If your target device does not haveenough program memory, Microchip provides a widespectrum of devices from 0.5K to 8K program memorywith the same set of peripheral features that will helpmeet the criteria.
The PIC16CXXX microcontrollers have two vectors,reset and interrupt, at locations 0x0000 and 0x0004.When the PICmicro encounters a reset or interrupt con-dition, the code located at one of these two locations inprogram memory is executed. The first listing ofExample 1 shows the code that is first programmed intothe PICmicro. The second listing of Example 1 showsthe code that is programmed into the PICmicro for thesecond time.
ary DS91013B-page 3
TB013
EXAMPLE 1: PROGRAMMING CYCLE LISTING FILESFirst Program Cycle Second Program Cycle
_________________________________________________________________________________________Prog Opcode Assembly | Prog Opcode AssemblyMem Instruction | Mem Instruction-----------------------------------------------------------------------------------------0000 2808 goto Main ;Main loop | 0000 0000 nop0001 3FFF <blank> ;at 0x0008 | 0001 2860 goto Main ;Main now0002 3FFF <blank> | 0002 3FFF <blank> ;at 0x00600003 3FFF <blank> | 0003 3FFF <blank>0004 2848 goto ISR ;ISR at | 0004 0000 nop0005 3FFF <blank> ;0x0048 | 0005 28A8 goto ISR ;ISR now at0006 3FFF <blank> | 0006 3FFF <blank> ;0x00A80007 3FFF <blank> | 0007 3FFF <blank>0008 1683 bsf STATUS,RP0 | 0008 1683 bsf STATUS,RP00009 3007 movlw 0x07 | 0009 3007 movlw 0x07000A 009F movwf ADCON1 | 000A 009F movwf ADCON1 . | . . | . . | .0048 1C0C btfss PIR1,RBIF | 0048 1C0C btfss PIR1,RBIF0049 284E goto EndISR | 0049 284E goto EndISR004A 1806 btfsc PORTB,0 | 004A 1806 btfsc PORTB,0 . | . . | . . | .0060 3FFF <blank> | 0060 1683 bsf STATUS,RP00061 3FFF <blank> | 0061 3005 movlw 0x050062 3FFF <blank> | 0062 009F movwf ADCON1 . | . . | . . | .00A8 3FFF <blank> | 00A8 1C0C btfss PIR1,RBIF00A9 3FFF <blank> | 00A9 28AE goto EndISR00AA 3FFF <blank> | 00AA 1806 btfsc PORTB,0 . | . . | . . | .-----------------------------------------------------------------------------------------
DS91013B-page 4 Preliminary 1997 Microchip Technology Inc.
How to Implement ICSP™ Using PIC16CXXX OTP MCUs
The example shows that to program the PICmicro asecond time the memory location 0x0000, originallygoto Main (0x2808), is reprogrammed to all 0’s whichhappens to be a nop instruction. This location cannotbe reprogrammed to the new opcode (0x2860)because the bits that are 0’s cannot be reprogrammedto 1’s, only bits that are 1’s can be reprogrammed to0’s. The next memory location 0x0001 was originallyblank (all 1’s) and now becomes a goto Main(0x2860). When a reset condition occurs, the PICmicroexecutes the instruction at location 0x0000 which is thenop, a completely benign instruction, and then exe-cutes the goto Main to start the execution of code.The example also shows that all program memory loca-tions after 0x005A are blank in the original program sothat the second time the PICmicro is programmed, therevised code can be programmed at these locations.The same descriptions can be given for the interruptvector at location 0x0004.
This method changes slightly for PICmicros with >2Kwords of program memory. Each of the goto Mainand goto ISR instructions are replaced by the follow-ing code segments due to paging on devices with >2Kwords of program memory.
movlw <page> movlw <page>movwf PCLATH movwf PCLATHgoto Main goto ISR
Now your one time programmable PICmicro is exhibit-ing more EEPROM- or Flash-like qualities.
1997 Microchip Technology Inc. Prelimin
CONCLUSION
Microchip Technology Inc. is committed to supportingyour ICSP needs by providing you with our many yearsof experience and expertise in developing ICSPsolutions. Anyone can create a reliable ICSP program-ming station by coupling our background with someforethought to the circuit design and programmerselection issues previously mentioned. Your localMicrochip representative is available to answer anyquestions you have about the requirements for ICSP.
ary DS91013B-page 5
TB013
APPENDIX A: SAMPLE DRIVER BOARD SCHEMATIC
R6
1V
PP_O
UT
TO
CIR
CU
IT
3 2 1
41U
1A
TL
E21
44A
R9
100
R9
100
VC
CQ1
2N39
06
R10
100
R2
33k
5 6 7
U1B
TL
E21
44A
VC
C
VC
C
15V
EX
TE
RN
AL
PO
WE
R S
UP
PL
Y R12
100k
VP
P_I
N
FR
OM
PR
OG
RA
MM
ER
C1
1NF
D1
12.7
V
Q2
2N22
22
R13
5k
Q3
2N39
06
C3
0.1µ
F
VD
D_O
UT
R15
1T
O C
IRC
UIT
C6
0.1µ
F
10
9 8
U1C
TL
E21
44A
VC
CR
18
100
R17
100
Q4
2N22
22
R22
5k
R19
100
C4
1NF
D2
6.2V
VD
D_I
N
12
13
14U
1D
TL
E21
44A
R4
10k
R21
100k
FR
OM
PR
OG
RA
MM
ER
RB
6_IN
GN
D_I
NG
ND
_OU
T
FR
OM
PR
OG
RA
MM
ER
FR
OM
PR
OG
RA
MM
ER
TO
CIR
CU
IT
RB
6_O
UT
RB
7_IN
FR
OM
PR
OG
RA
MM
ER
TO
CIR
CU
IT
RB
7_O
UT
TO
CIR
CU
IT
No
te:
The
driv
er b
oard
des
ign
MU
ST
be
test
ed in
the
use
r’sap
plic
atio
n to
det
erm
ine
the
effe
cts
of t
he a
pplic
atio
nci
rcui
t on
the
pro
gram
min
g si
gnal
s tim
ing.
Cha
nges
may
be
requ
ired
if th
e ap
plic
atio
n pl
aces
a s
igni
fican
tlo
ad o
n V
dd, V
pp, R
B6
or R
B7.
*see
text
in te
chni
cal b
rief.
*see
text
in te
chni
cal b
rief.
DS91013B-page 6 Preliminary 1997 Microchip Technology Inc.
How to Implement ICSP™ Using PIC16CXXX OTP MCUs
NOTES:
1997 Microchip Technology Inc. Prelimin
ary DS91013B-page 7Information contained in this publication regarding device applications and the like is intended through suggestion only and may be superseded by updates.It is your responsibility to ensure that your application meets with your specifications. No representation or warranty is given and no liability is assumed byMicrochip Technology Incorporated with respect to the accuracy or use of such information, or infringement of patents or other intellectual property rightsarising from such use or otherwise. Use of Microchip’s products as critical components in life support systems is not authorized except with express writtenapproval by Microchip. No licenses are conveyed, implicitly or otherwise, except as maybe explicitly expressed herein, under any intellectual propertyrights. The Microchip logo and name are registered trademarks of Microchip Technology Inc. in the U.S.A. and other countries. All rights reserved. All othertrademarks mentioned herein are the property of their respective companies.
-page 12 2000 Microchip Technology Inc.
All rights reserved. © 2000 Microchip Technology Incorporated. Printed in the USA. 2/00 Printed on recycled paper.
AMERICASCorporate OfficeMicrochip Technology Inc.2355 West Chandler Blvd.Chandler, AZ 85224-6199Tel: 480-786-7200 Fax: 480-786-7277Technical Support: 480-786-7627Web Address: http://www.microchip.com
AtlantaMicrochip Technology Inc.500 Sugar Mill Road, Suite 200BAtlanta, GA 30350Tel: 770-640-0034 Fax: 770-640-0307BostonMicrochip Technology Inc.5 Mount Royal AvenueMarlborough, MA 01752Tel: 508-480-9990 Fax: 508-480-8575ChicagoMicrochip Technology Inc.333 Pierce Road, Suite 180Itasca, IL 60143Tel: 630-285-0071 Fax: 630-285-0075DallasMicrochip Technology Inc.4570 Westgrove Drive, Suite 160Addison, TX 75248Tel: 972-818-7423 Fax: 972-818-2924DaytonMicrochip Technology Inc.Two Prestige Place, Suite 150Miamisburg, OH 45342Tel: 937-291-1654 Fax: 937-291-9175DetroitMicrochip Technology Inc.Tri-Atria Office Building 32255 Northwestern Highway, Suite 190Farmington Hills, MI 48334Tel: 248-538-2250 Fax: 248-538-2260Los AngelesMicrochip Technology Inc.18201 Von Karman, Suite 1090Irvine, CA 92612Tel: 949-263-1888 Fax: 949-263-1338New YorkMicrochip Technology Inc.150 Motor Parkway, Suite 202Hauppauge, NY 11788Tel: 631-273-5305 Fax: 631-273-5335San JoseMicrochip Technology Inc.2107 North First Street, Suite 590San Jose, CA 95131Tel: 408-436-7950 Fax: 408-436-7955
AMERICAS (continued)TorontoMicrochip Technology Inc.5925 Airport Road, Suite 200Mississauga, Ontario L4V 1W1, Canada Tel: 905-405-6279 Fax: 905-405-6253
ASIA/PACIFICBeijingMicrochip Technology, Beijing Unit 915, 6 Chaoyangmen Bei Dajie Dong Erhuan Road, Dongcheng District New China Hong Kong Manhattan BuildingBeijing 100027 PRC Tel: 86-10-85282100 Fax: 86-10-85282104Hong KongMicrochip Asia PacificUnit 2101, Tower 2Metroplaza223 Hing Fong RoadKwai Fong, N.T., Hong KongTel: 852-2-401-1200 Fax: 852-2-401-3431IndiaMicrochip Technology Inc.India Liaison OfficeNo. 6, Legacy, Convent RoadBangalore 560 025, IndiaTel: 91-80-229-0061 Fax: 91-80-229-0062JapanMicrochip Technology Intl. Inc.Benex S-1 6F3-18-20, ShinyokohamaKohoku-Ku, Yokohama-shiKanagawa 222-0033 JapanTel: 81-45-471- 6166 Fax: 81-45-471-6122KoreaMicrochip Technology Korea168-1, Youngbo Bldg. 3 FloorSamsung-Dong, Kangnam-KuSeoul, KoreaTel: 82-2-554-7200 Fax: 82-2-558-5934ShanghaiMicrochip Technology Unit B701, Far East International Plaza,No. 317, Xianxia RoadShanghai, 200051 P.R.CTel: 86-21-6275-5700 Fax: 86-21-6275-5060
ASIA/PACIFIC (continued)SingaporeMicrochip Technology Singapore Pte Ltd.200 Middle Road#07-02 Prime CentreSingapore 188980Tel: 65-334-8870 Fax: 65-334-8850Taiwan, R.O.CMicrochip Technology Taiwan10F-1C 207Tung Hua North RoadTaipei, Taiwan, ROCTel: 886-2-2717-7175 Fax: 886-2-2545-0139
EUROPEDenmarkMicrochip Technology Denmark ApSRegus Business CentreLautrup hoj 1-3Ballerup DK-2750 DenmarkTel: 45 4420 9895 Fax: 45 4420 9910FranceArizona Microchip Technology SARLParc d’Activite du Moulin de Massy43 Rue du Saule TrapuBatiment A - ler Etage91300 Massy, FranceTel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79GermanyArizona Microchip Technology GmbHGustav-Heinemann-Ring 125D-81739 München, GermanyTel: 49-89-627-144 0 Fax: 49-89-627-144-44ItalyArizona Microchip Technology SRLCentro Direzionale Colleoni Palazzo Taurus 1 V. Le Colleoni 120041 Agrate BrianzaMilan, Italy Tel: 39-039-65791-1 Fax: 39-039-6899883United KingdomArizona Microchip Technology Ltd.505 Eskdale RoadWinnersh TriangleWokingham Berkshire, England RG41 5TUTel: 44 118 921 5858 Fax: 44-118 921-5835
01/21/00
WORLDWIDE SALES AND SERVICE
Microchip received QS-9000 quality system certification for its worldwide headquarters, design and wafer fabrication facilities in Chandler and Tempe, Arizona in July 1999. The Company’s quality system processes and procedures are QS-9000 compliant for its PICmicro® 8-bit MCUs, KEELOQ® code hopping devices, Serial EEPROMs and microperipheral products. In addition, Microchip’s quality system for the design and manufacture of development systems is ISO 9001 certified.