Sie sind auf Seite 1von 3

Main page

Castellano

Deutsch

English

How to program a PIC 12Fxxx/16Fxxx


These PICs are programmed using a proprietary serial protocol. So you can't connect them directly to any "usual" interface. Fortunately, the timing requirements are rather lax. This gives the possibility to use some pins of a parallel or serial port of the PC to generate the programming sequence by software. Besides the operating voltage, three further signals are necessary: the programming voltage Vpp (about 13V) and the programming Clock (clk = PGC = ICSPCLK) and Data (data = PGD = ICSPDAT). Since most PICs tolerate a programming voltage Vpp somewhat below the specification, one can take advantage of the 12V signal levels of the serial port of a Desktop PC and "burn" a PIC without the need for an extra power supply. The level conversion can be done with a few components. However, this simple circuit has its limitations and allows only reading and programming the PIC. There is no guarantee that it works with all controllers, since it does not meet all programming specifications. (Board layout (inverted), Placing) See below how to connect the programming signals to the PIC.

In-circuit programming of a PIC


ICSP offers the possibility to program the microcontroller within the application circuit. This is especially beneficial in class room or developing environments, where repetitive change between programming the PIC and testing the circuit occurs. It not only avoids risks when moving the PIC between different sockets like bending the pins or "tormenting" the PIC with electrostatic discharges , but also saves time. To be able to use ICSP neither the circuit must disturb the programming signals nor the programming signals should affect the circuit. The main programming conditions are: 1. The programming voltage Vpp applied at /MCLR should switch between zero and 13 volts within a few microseconds. 2. The clock and data signals must reach near rail-to-rail levels within one microsecond. 3. Some PICs use a pin (RB3 or RB4) as PGM signal to offer Low Voltage Programming (LVP). This pin must stay Low while programming. 4. Some PICs require that the programming voltage Vpp is applied before the operating voltage Vdd. In this case Vdd must be operated by the programmer module. The simplest way to fulfil the first two conditions is, not to use the corresponding pins within the application circuit. If you also want to use the debugger, this is a must.

Recommendations: Don't connect active circuits to /MCLR. If /MCLR is used to reset the PIC, there should be a resistor greater than 56k between /MCLR and Vdd. It may be combined with a small capacitor of less than 100 pF to GND (Vss ). There must not be any inductive or capacitive load on the programming signal pins. You may connect a highimpedance circuit (>10k), e.g., a key. When the operating voltage Vdd is operated by the programmer module, eventually you must isolate the Vdd pin of the PIC from the rest of the application circuit during programming. This may be the case, if the application circuit contains its own voltage regulator for Vdd, has a big decoupling capacitor, which the programmer module can't charge fast enough, is designed for a supply voltage of 3.3V, and the PIC needs at least 4.5V for programming. Instead of a complete isolation, possibly a Schottky diode may work. To hold the PGM pin Low while programming connect it with a resistor of about 2.2k to 10k to GND. Always enable the Power-Up Timer in the configuration word. Its delay of more than 40ms gives enough time to have a stable Vdd before starting any operation and avoids unintended program execution before entering programming mode. During programming the other port pins stay in input mode, e.g., they have a very high impedance. The application circuit should handle this state in the most inactive way possible. To avoid undesired 'side effects' you may consider pull-down or pull-up resistors. To be able to re-program a PIC with Vdd below 4.5V, the memory must not be protected, since the "Chip Erase" which is the only way to remove code or data protection requires a Vdd above 4.5V on almost all PIC.

Assignment of the ICSP signals to the pins of a PIC 12Fxxx/16Fxxx


The number below the signal name corresponds to the pin of the ICSP connector of the programmer module. Pay attention: the ICSP connector of this programmer module has a different order of signals than other PIC-programmers. For using it with third-party test boards an adaptor is necessary. Controller
8-pin 14-pin 12F629/675 other 12Fxxx 12F630/676 other 16F6xx 16F62x(A), 16F648A 16F716

Vpp
(1)

GND
(2)

Vdd
(3)

Data
(4)

Clk
(5)

PGM
@ "Low"

Programming Vdd range


4.5V - 5.5V 2.0V - 5.5V 4.5V - 5.5V 2.0V - 5.5V 4,5V - 5,5V 4,5V - 5,5V

4 4 4 4 4 4

8 8 14 14 5 5

1 1 1 1 14 14

7 7 13 13 13 13

8 8 12 12 12 12

10 -

18-pin

16F818/819 16F84(A) 16F87/88

4 4 4 4 1 1 1 1 1 1 1 1 1 1 1 1

5 5 5 20 8, 19 8, 19 8, 19 8, 19 8, 19 8, 19 12, 31 12, 31 12, 31 12, 31 12, 31 12, 31

14 14 14 1 20 20 20 20 20 20 11, 32 11, 32 11, 32 11, 32 11, 32 11, 32

13 13 13 19 28 28 28 28 28 28 40 40 40 40 40 40

12 12 12 18 27 27 27 27 27 27 38 38 38 38 38 38

9 9 24 24 24 24 24 36 36 36 36 36

2,0V - 5,5V 4,5V - 5,5V 2,0V - 5,5V 2.0V - 5.5V 4.75V - 5.25V 4.75V - 5.25V 2.5V - 5.5V 2.0V - 5.5V 2.0V - 5.5V 2.0V - 5.5V 4.75V - 5.25V 4.75V - 5.25V 2.5V - 5.5V 2.0V - 5.5V 2.0V - 5.5V 2.0V - 5.5V

20-pin

16F6xx, 16F785 16F7x 16F7x7 16F87x 16F87xA 16F88x 16F91x 16F7x 16F7x7 16F87x 16F87xA 16F88x 16F91x

28-pin

40-pin

Connection schemes with lateral placing of the ICSP connector


The following schemes show how to connect the programming signals to the PIC 12Fxxx/16Fxxx.

back to the main page

Das könnte Ihnen auch gefallen