Micro & Eprom Programmer pgrm3 : programmer side


Pgrm3 project is the programmer side of my programming system. It use a atmega644 microprocessor to handle the programming circuits and the connection with the host, see [4]. So it is not a standalone hardware, it just do a part of the job.

Pgrm3 is not a new project, it is the continuation of prm2 project with the change of the processor and with some other new features.

This programmer is initialy aimed to program eproms that can be plugged directely on the socket. But with help of adaptors, it is able to program any moderm devices as long as the firmware has been created. Programming can be done in Parallel mode on a byte/word basis or in Serial mode depending on the capabilities of the device.

Communication is done through host PC parallel port or RS232 serial line. The communication protocol is as much as possible compliant with the stk500 protocol.



List of devices, I have used, others should be possible, but I have not tried :

Parallel programming
  1. Eproms : 2716, 2732, 2764,27128, 27256, 27512
  2. EEproms : 2864
  3. msc51 : at89c2051, at89c51, at89s52
  4. msc48 : Program memory read only: 8048, 8049, 8748, 8749
  5. Avrs : attiny15, attiny2313, attiny26, at90s4433, atmega8, atmega48, atmega88, atmega168, atmega8515, atmega644, ...
  6. Flash : SST49LF002, SST49LF004, ...
Serial programming
  1. msc51 : at89s52
  2. Avrs : attiny15, attiny2313, attiny26,at90s4433, atmega8, atmega48, atmega88, atmega168, atmega8515, atmega644, ...
  3. Pics : pic18fxxxx, ...


Hardware, essentialy, consists of port extension around the micro and two programming voltage generators, just in order to symplify the wiring for some old devices. The first one is programmable from 9.5 Volts to 25.5 Volts in step of 0.25 Volt and has to supply 0, 5 Volts as well (The luxe !). The second is limited to 0, 5, 12.5 and 25 Volts. A control of the power supply voltage for the device is also implemented for 0, 5, 6, 6.25 volts. Note some manual switching are necessary before accessing these old devices like 2716 (Not the luxe !).

Here is the main schematics. The other parts and adaptors are in the tarball that you can find at the download section. Click the image to view full size.

Definition of signals on the socket pins.

SCK BUSY 1                     40  S_XTAL1
    A23  2                     39  A15
    A22  3                     38  A20
    A21  4                     37  A19
    VPP  5  1               32 36  VCC
    A16  6  2               31 35  A18
A15 VPP  7  3  1         28 30 34  A17 VCC
    A12  8  4  2         27 29 33  A14 PGM
    A7   9  5  3  1   24 26 28 32  A13 VCC 
    A6  10  6  4  2   23 25 27 31  A8
    A5  11  7  5  3   22 24 26 30  A9
    A4  12  8  6  4   21 23 25 29  A11 VPP2
    A3  13  9  7  5   20 22 24 28  OE  VPP2 MOSI
    A2  14 10  8  6   19 21 23 27  A10
    A1  15 11  9  7   18 20 22 26  CE       MISO
    A0  16 12 10  8   17 19 21 25  D7
    D0  17 13 11  9   16 18 20 24  D6
    D1  18 14 12 10   15 17 19 23  D5
    D2  19 15 13 11   14 16 18 22  D4
    GND 20 16 14 12   13 15 17 21  D3

Connection definition for some Avr adaptors in parallel programming.

                                                    attiny26    |
                                          at89c2051    |        |
                                attiny2313   |         |        |
                       atmega8515    |       |         |        |
              atmega8      |         |       |         |        |
                 |         |         |       |         |        |
BUSY     1/40  PD1(3)    PD1(11)   PD1(3)   P3.1(3)  PB6(9)   PD1(15)    
OE      22/28  PD2(4)    PD2(12)   PD2(6)   P3.4(8)  PB5(8)   PD2(16)    
PGM WR  27/28  PD3(5)    PD3(13)   PD3(7)   P3.2(6)  PB0(1)   PD3(17)    
CE BS1  20/28  PD4(6)    PD4(14)   PD4(8)   P3.3(7)  PB3(4)   PD4(18)     
XA0      2/40  PD5(11)   PD5(15)   PD5(9)   P3.7(11) PB1(2)   PD5(19)    
XA1      3/40  PD6(12)   PD6(16)   PD6(11)  P3.5(9)  PB2(3)   PD6(20)    
PAGEL   38/40  PD7(13)   PD7(17)   *        *        *        PD7(21)
BS2     37/40  PC2(25)   PA0(39)   *        *        *        PA0(40)     
XT1     40/40 XTAL1(9)  XTAL1(19) XTAL1(5) XTAL1(5) XTAL1(7)  XTAL1(13)

VPP      1/28 Reset(1)  Reset(9)  Reset(1) Reset(1) Reset(10) Reset(9)

Connection definition for serial programming.

VPP      1/28
VCC     28/28
GND     14/28
S_MOSI  22/28
S_SCK    1/40
S_MISO  20/28
S_XTAL1 40/40
S_RES    1/28

External programming

External programming is a feature that let users, that are afraid at the view of the pgrm3 schematics and do not need of parallel programming, to program devices in serial programming mode and serial communication.

The fuse may be different depending on using a crystal or an oscillator. I use an oscillator and cksel0-3 are set to 0000.

The firmware used is the same as for pgrm3. The connection of the pin PD2 (INT0) to 0v at startup will make the difference.

To do this, program the processor with the pgrm3 firmware, connect the processor to the PC with the serial link, connect the processor to the device to be programmed and run pgrm on the pc. The next image shows the connections needed for this.

Note: the atmega8515, on the Schematics, is not part of the programmer. It is there only to show the connections. When using another device, you should connect the same pins functions, but this do not imply the same pins number.

As the picture shows, there is connector for ICSP Pic programming. You need to add a 12 Volts supply remote controlled by the processor.

Just keep in mind, that each time you add something, you have started building a programmer !!!.

Self programming

Pgrm3 is intended to program external devices, but sometimes and even more it is necessary to reload the program in the flash of the pgrm3 processor. To do this, we need to switch from the main loop to an alternate main loop, the bootloader main loop, by sending a switch command on the serial line. The switch command is the 2 characters "X ", that is character 'X' followed by character SPACE. They can be sent from the pgrm terminal by keying the 2 characters or from a linux terminal with the command :

echo -n "X " > /dev/ttyS0

You can now run pgrm and load your program. See page [5].

Another note: before being able to use this feature, le processor needs to be programmed at leat one time . This page on the serpp driver provides one solution to this problem as it does not need a programmer.

BIOS Flash device programming

See this page: PC Bios flash memory programming

Note about serial communication

Until now, the processor was driven by its internal clock at 8 MHz. This worked fine at 9600 bauds but not at 115 200 bauds. This can be solved by adding a crystal or an oscillator at 18432 kHz. The previous solution is still usable.

The new solution is selected by default. To use the previous solution, just define the variable EXTRAOPT = -DINTERNAL_OSC in the Makefile.

And do not forget to set the appropriate values for the fuses bits... CKSEL3-0 = 1110 instead of CKSEL3-0 = 0010.

This paragraph apply, not only to pgrm3 but to your board as well. If a crystal frequency is implied by your apllication, you will have to choose the closest baud rate.


The software is writen in C and consists of a parallel driver, a serial driver, a command interpreter in the main loop followed with a command dispatcher which is table driven. There is one table for each function and one entry in the tables for each device class. When necessary, another table will dispatch for the different devices in the class.

To be simple, each function is limited to read a word in flash, write a word in flash, read a byte in eeprom, write a byte in eeprom, read a signature byte, read a fuse byte, ....


The software is developed on a Linux system with avr-gcc Compiler, see [1]. and the avr libc library see [2].

Schematics are created with gschem from the GEDA suite see [3]. You could need it to edit, print, view or, why not, create other schematics.

Compiling the firmware

You need to have the tools installed, and next run the following commands.

tar zxvf pgrm3-yyyymmdd.tar.gz
cd pgrm3-yyyymmdd


  1. 1 - GCC, the GNU Compiler Collection .
  2. 2 - AVR Libc Home Page.
  3. 3 - gEDA Project Homepage.
  4. 4 - host part of the programming system.
  5. 5 - A bootloader program.
  6. 6 - PC Bios flash memory programming.
  7. 7 - Rs232 serial adaptor.


The Pgrm3 software is licensed under the terms of the GNU General Public License as published by the Free Software Foundation. See the file "COPYING" in the "Pgrm3" directory.