Homemade programmer for PIC controllers.

Tell in:
For some unknown reason now, I constantly tried to postpone my acquaintance with microcontrollers for later. Perhaps the thought of using digital technology modules created unfounded fears in the head of a novice who had never tried to look beyond the boundaries of analog electronics. However, at the same time, I very clearly understood what opportunities even the cheapest microcontrollers would provide me. And then, one day, I nevertheless decided to understand this, at first glance, complex, but also very interesting topic.

It was logical to start by studying the theory and assembling some someone else's project using a microcontroller (hereinafter MK). I think it's not worth talking about the first one - the Internet is full of articles on this topic. As for the second, my choice fell on this device. Its scheme is simple enough for repetition and focusing on the assembly will also be superfluous, so let's go straight to the MK firmware.

ExtraCheap programmer After a short search on the Internet, quite a lot of programmer schemes were found, but most of them were rather complex devices designed for flashing several types of MK. I wanted to build a circuit specifically for the PIC12F629. After spending a little more time, I finally found what I was looking for - the ExtraCheap programmer from the WiiFree project.

A COM port is used for data transfer. The circuit is powered by 5 volts which can be taken from USB or PS / 2 ports.
Several photos of the assembled device:

It is recommended to use the IC-Prog program to work with the programmer.

Setting up IC-Prog Download the archives with the latest versions of IC-Prog Software, NT / 2000 driver, Helpfile in Russian language from the official website of the program and unpack them into one and the same directory.
Now you need to install the programmer driver, for which we run icprog.exe (if any error messages appear, simply ignore them) and select the "Options" item in the "Settings" menu. Open the "Programming" tab and check the box opposite the "Verify during programming" item. Next, in the "Misc" section, you need to activate the "Enable NT / 2000 / XP Driver" option, save the settings by clicking on the "OK" button and restart the program.

You can change the interface language in the "Language" section. In order to indicate to the program the type of our programmer, press F3, in the window that opens, select "JDM Programmer" and indicate the COM port to which the device is connected.

This completes the presetting of the program.

The MKIC-Prog firmware allows you to work with a large number of MKs, but we only need PIC12F629 - select it in the drop-down list located in the upper right corner of the program.
To read the firmware from the MK, we execute the "Read microcircuit" command (the icon with a green arrow or F8).

At the end of the reading process, the MC firmware will be displayed in hexadecimal form in the program code window. You should pay attention to the last memory cell at 03F8 - it stores the value of the constant OSCCAL, which is set by the manufacturer when calibrating the chip. Each MK has its own, so it would be nice to rewrite it somewhere (I, for example, scratch it with a needle on the back of the PIC) to facilitate the recovery process (although this is not necessary) if this constant was accidentally overwritten during the firmware.


In order to "fill" the firmware from the * .hex file into the MK, it must be opened in the program ("File" -\u003e "Open File ..." or Ctrl + O) and execute the command "Program microcircuit" (the icon with yellow lightning or F5). We answer "Yes" to the first question.


But the next question must be answered “No”, otherwise the OSCCAL constant mentioned earlier will be overwritten.


After that, the firmware process will begin. Upon completion, the program will display an informational message about its results.

On this I would like to bring the topic to an end. Hopefully this information will help beginners understand the basics of programming PIC microcontrollers.
Thank you for your attention. PCB File (LAY) Section:

The development of electronics is progressing at a rapid pace, and more and more often the main element of a device is a microcontroller. It does the bulk of the work and frees the designer from the need for elaborate circuitry, thereby reducing the size of the PCB to a minimum. As everyone knows, the microcontroller is controlled by a program written to its internal memory. And if an experienced electronic programmer does not experience problems using microcontrollers in their devices, then for a beginner radio amateur, an attempt to write a program to a controller (especially a PIC) can turn into a big disappointment, and sometimes a small pyrotechnic show in the form of a smoking microcircuit.

Oddly enough, for all the greatness of the Internet, there is very little information about the firmware in it. PIC controllers, and the material that can be found is of a very dubious quality. Of course, you can buy a factory programmer for an inadequate price and sew as much as you like, but what to do if a person is not engaged in mass production. For these purposes, you can assemble a simple and inexpensive home-made product called JDM programmer according to the diagram below (Figure 1):



Figure 1 - programmer diagram


I immediately give a list of elements for those who are too lazy to peer at the diagram:

  • R1 - 10 kOhm
  • R2 - 10 kOhm (subscript). By adjusting the resistance of this resistor, you need to achieve about 13V at pin # 4 (VPP) during programming. In my case, the resistance is 1.2 kOhm
  • R3 - 200 Ohm
  • R4, R5 - 1.5 kOhm
  • VD1, VD2, VD3, VD4, VD6 - 1N4148
  • VD5 - 1N4733A (Voltage stabilization 5.1V)
  • VD7 - 1N4743A (Voltage stabilization 13V)
  • C1 - 100 nF (0.1 μF)
  • C2 - 470 μF x 16 V (electrolytic)
  • SUB-D9F - COM port connector (MAMA or SOCKET)
  • DIP8 socket - depends on the controller you are using

The diagram uses an example of connecting such common controllers as PIC12F675 and PIC12F629, but this does not mean at all that the firmware of other series PIC will be impossible. To write a program to a controller of a different type, it is enough to throw the wires of the programmer in accordance with figure 2, which is given below.



Figure # 2 - options for PIC controller packages with the required pins


As you might guess, the case is used in the circuit of my programmer DIP8... With a strong desire, you can make a universal adapter for each type of microcircuit, thereby obtaining a universal programmer. But since with PIC controllers I rarely work, that's enough for me.

Although the circuit itself is quite simple and will not cause difficulties in assembly, it also requires respect. Therefore, it would be nice to make a printed circuit board for it. After some manipulation of the program SprintLayout, with textolite, a drill and an iron, such a blank was born (photo # 3).



Photo # 3 - programmer printed circuit board


Download the source of the printed circuit board for the program SprintLayout you can follow this link:
(downloads: 680)
If desired, you can change it for your type of PIC controller. For those who decided to leave the board unchanged, here is a view from the side of the parts to facilitate installation (Figure 4).



Figure №4 - board from the mounting side


A little more witchcraft with a soldering iron and we have a ready-made device that can flash PIC controller across COM port your computer. The result of my efforts, still warm and not washed from the flux, is shown in photo # 5.



Photo # 5 - complete programmer


From now on, the first stage on the way to firmware PIC controller, has come to an end. The second stage will include connecting the programmer to a computer and working with the program IC-Prog.
Unfortunately, not all modern computers and laptops are able to work with this programmer due to the banal absence of COM ports, and those that are installed on laptops do not issue the necessary for programming 12V... So I decided to turn to my first PC, which a long time ago was gathering dust and was waiting for its finest hour (and still waited).
So we turn on the computer and first of all install the program IC-Prog... You can download it from the author's website or follow this link:
(downloads: 778)
We connect the programmer to COM port and launch the newly installed application. For correct operation, you need to perform a number of manipulations. Initially, you need to select the type of controller that you are going to sew. I have it PIC12F675... In the screenshot # 6, the field for choosing a controller is highlighted in red.



Screenshot 6 - choosing the type of microcontroller




Screenshot # 7 - Setting up the controller recording method


In the same window, go to the " Programming"and select the item" Programming check". Checking after programming may cause an error, since in some cases the firmware itself installs the read blocking fuses Wed... In order not to fool yourself, it is better to disable this check. In short, follow the screenshot # 8.



Screenshot # 8 - verification setting


We continue working with this window and go to the " Are common". Here you must set the priority of the program and be sure to use NT / 2000 / XP driver (screenshot # 9). In some cases, the program may offer to install this driver and a restart is required IC-Prog.



Screenshot # 9 - general settings


So, with this window, the work is over. Now let's move on to the settings of the programmer itself. Choose from the menu " Settings "-\u003e" Programmer settings"or just press the key F3... The following window appears as shown in screenshot # 10.



Screenshot # 10 - Programmer settings window


First of all, we select the type of programmer - JDM Programmer... Next, set the radio button to use the driver Windows... The next step involves choosing COM portto which your programmer is connected. If it is alone, there are no questions at all, and if there is more than one, look in the device manager which one is currently being used. The I / O latency slider is for adjusting the write and read speed. This may be needed on fast computers and in case of problems with the firmware - this parameter must be increased. In my case, it remained by default equal 10 and everything worked fine.

This completes the program setting IC-Prog is over and you can proceed to the process of the firmware itself, but first we read the data from the microcontroller and see what is written into it. To do this, on the toolbar, click on the microcircuit icon with a green arrow, as shown in screenshot 11.



Screenshot 11 - the process of reading information from the microcontroller


If the microcontroller is new and has not been flashed before, then all its memory cells will be filled with values 3FFFexcept for the very last one. It will contain the value of the calibration constant. This value is very important and unique to each controller. The timing accuracy depends on it, which is set by the manufacturer by selecting and setting this very constant. Screenshot 12 shows the memory cell that will store the constant when reading the controller.



Screenshot # 12 - the value of the calibration constant


Again, the value is unique for each microcircuit and does not have to be the same as in the figure. Many, out of inexperience, overwrite this constant and subsequently PIC controller starts to work incorrectly if the project uses clocking from an internal generator. I advise you to write down this constant and stick an inscription with its value directly on the controller. This way you will avoid a lot of trouble in the future. So, the value is written down - let's move on. Open the firmware file, which usually has the extension .hex... Now instead of labels 3FFF, the programming buffer contains the code of our program (screenshot # 13).



Screenshot # 13 - firmware loaded into the programming buffer


Above, I wrote that many overwrite the calibration constant by negligence. When does this happen? This happens when the firmware file is opened. The constant value is automatically changed to 3FFF and if you start the programming process, then there is no turning back. Screenshot 14 shows the memory cell where the constant was previously 3450 (before opening hex file).

Many beginner radio amateurs at the beginning of their business are afraid to start working with a microcontroller. This is due to many, and the main often fear is how to program correctly and how to program. simple programmer circuit for PIC microcontroller.We look, collect, ask on the official forum and leave feedback if you succeed

I would advise you to start your work first with general information about microcontrollers.

ExtraCheap programmer

In the Internet many different programming schemesBut most of them are very complex, and it is rare to see photographs that would confirm its performance.

But the required programmer was found for many requests.

A COM port is used for data transfer. The circuit is powered by 5 volts which can be taken from USB or PS / 2 ports.

Another photo of this device:

It is recommended to use the IC-Prog program to work with the programmer

Setting up IC-Prog

Downloading the latest version of the program from the off site IC-Prog Software, NT / 2000 driver, Helpfile in Russian language and unpack them into one and the same directory.

Now you need to install the programmer driver, for which we run icprog.exe (if any error messages appear, simply ignore them) and select the "Options" item in the "Settings" menu. Open the "Programming" tab and check the box opposite the "Verify during programming" item. Next, in the "Misc" section, you need to activate the "Enable NT / 2000 / XP Driver" option, save the settings by clicking on the "OK" button and restart the program.

You can change the interface language in the "Language" section. In order to indicate to the program the type of our programmer, press F3, in the window that opens, select "JDM Programmer" and indicate the COM port to which the device is connected.

This completes the presetting of the program.

MK firmware

IC-Prog allows you to work with a large number of MKs, but we only need PIC12F629 - select it in the drop-down list located in the upper right corner of the program.
To read the firmware from the MK, we execute the "Read microcircuit" command (the icon with a green arrow or F8).

At the end of the reading process, the MC firmware will be displayed in hexadecimal form in the program code window. You should pay attention to the last memory cell at 03F8 - the value of the constant OSCCAL is stored there. , which is set by the manufacturer when calibrating the chip. Each MK has its own, so it would be nice to rewrite it somewhere (for example, I scratch it with a needle on the back of the PIC "a) to facilitate the recovery process (although this is not necessary ) if this constant was accidentally overwritten during flashing.


In order to "fill" the firmware from the * .hex file into the MK, it must be opened in the program ("File" -\u003e "Open File ..." or Ctrl + O) and execute the command "Program microcircuit" (the icon with yellow lightning or F5). We answer "Yes" to the first question.


But the next question must be answered “No”, otherwise the OSCCAL constant mentioned earlier will be overwritten.


After that, the firmware process will begin. Upon completion, the program will display an informational message about its results.

On this I would like to bring the topic to an end. I hope this information will help beginners understand the basics of PIC programming. microcontrollers.

When I started to deal with PIC-controllers, then, naturally, the first thing was the question of choosing a programmer. Since branded programmers are not cheap, and in general it seemed to me not sporting to buy a programmer, it was decided to assemble it myself. After surfing the Internet, I downloaded the circuit and assembled a JDM programmer. It worked very badly: either it filled in some kind of garbage, then it did not fill in the first few bytes, then it did not fill anything at all.

A significant drawback of the JDM programmer is that it cannot control the Vdd line and, as a result, cannot implement the correct voltage supply algorithm during programming. If the controller is configured in the following way: "Internal Oscillator", "MCLR Off", then if the voltage supply sequence is incorrect, it first starts up and starts executing the program previously embedded in it, and then enters the programming mode (in this case, the pointer can point anywhere, but not at the beginning of the program memory). In this regard, where your program will be uploaded, and whether it will be uploaded at all, is a big question!

Having worn out with a JDM programmer, on one of the bourgeois sites I found a programmer circuit in which these shortcomings were corrected. I use this programmer to this day and bring it to your attention:

The simplest RS232-\u003e TTL level converter is made on diodes D1 ... D4 and a Zener diode D6. When the voltage on the DATA, CLOCK lines is less than 0V, then they are pulled to the ground through the diodes D1, D2, and when the voltage on these lines is more than 5V, then they are pulled up through the diodes D3, D4 to the + 5V supply, which is set by the Zener diode D6.

This device is powered directly from the COM port. Zener diodes and diodes in this circuit can be replaced with domestic ones: D814D, KS147A, etc.

How is the correct voltage supply algorithm implemented and where does the 13 Volt programming voltage come from? Everything is very simple as always.

When the port is initialized, the TxD output hangs at -10V. In this case, the capacitor C1 is charged through the Zener diode D7 (which in this case turns out to be switched on in the direct
direction and works as a diode). Those. the voltage on the positive leg C1 relative to GND is zero, but relative to TxD \u003d + 10V (or how much voltage you have at the COM port output).

Now let's imagine what happens when the voltage at the TxD output changes from -10V to + 10V. Simultaneously with the increase in the voltage at the TxD pin, the voltage at the positive leg of the capacitor C1 will also begin to rise. The charge cannot drain to the ground through D7, because now D7 is turned back on, the only way is to leak through the PIC, but the current is scanty. So, the voltage on the C1 plus leg (and, therefore, on the MCLR pin) begins to rise. At the moment when TxD is zero relative to ground, on the capacitor C1 (on its plus leg, and therefore on MCLR), it is just + 10V relative to ground. When TxD + 3V, - on C1 already 3 + 10 \u003d 13V. That's all, the Vpp voltage has already been applied, and the VDD line is still only + 3V.

With a further increase in the voltage on TxD, the voltage on C1 does not increase, since the Zener diode D7 starts to work. When the voltage on TxD rises above + 5V, the Zener diode D6 begins to work.

To limit the discharge current of the capacitor C1 through the Zener diode D7, the resistor R6 is included in the circuit, respectively, the voltage on C1 is not exactly equal to the stabilization voltage, but somewhat higher: U C1 \u003d Ust + I DISP * R6. Resistance R3 is used to adjust the programming voltage. You can put a variable 10KΩ or choose a constant one, so that the programming voltage is approximately 13 V (in the device shown in the figure below, R3 \u003d 1.2 kΩ).

I successfully program controllers with this programmer PIC12F629 and PIC16F628A, however, the author argued that this programmer (in the version I presented) can be programmed PIC12F508 , PIC12F509 , PIC12F629 , PIC12F635, PIC12F675, PIC12F683 , PIC16F627A , PIC16F628A , PIC16F648A... In addition to these, the author's website feng3.cool.ne.jp has programmer modifications for other PIC controllers.

Ready-made devices:

Programmer option from Mixer.