PG302 Device Programmer Protocol, Last Updated February 13, 2003
This document contains the complete communication protocol for the PG302 Device Programmer. Commands are sent as ASCII characters. Characters sent and received are shown in the document as follows. Ascii characters are shown in quotes. For example "1" which is ascii character 49, which is Hex value 31, and binary byte 0011 0001. To try and avoid confusion, values in the document are often shown in their binary format as (B 0011 0001) and/or the hex format as (H 31). For some, only the last 4 bits of the character are important. For these, the Binary value is given as B xxxx 0000 to show that the first 4 bits are not important.
The timing for sending commands is not important. Once you start a command sequence, the PG302 will wait indefinitely for the sequence to continue (there is no timeout period). This means you may need to unplug the PG302 to reset it if you lose track of where you are in the command sequence.
You can easily experiment using a terminal program such as HyperTerminal with settings of 9600 baud, No Parity, 8 Data Bits, 1 Stop Bit and no flow control. If the PG302 stops responding or you want to start over, unplug the PG302 and plug it back in to reset it.
***************************************************************************
Commands from host:
"1" = Erase, (B 0011 0001, H 31)
"2" = Program Lock Bits, (B 0011 0010, H 32)
"3" = Get Chip Checksum, (B 0011 0011, H 33)
"6" = Check if chip is blank (Blank Check), (B
0011 0110, H 36)
"P" = Program, (B 0101 0000, H 50)
"R" = Read, (B 0101 0010, H 52)
"V" = Verify, (B 0101 0110, H56)
Common responses from PG302
"Y" = Confirm something was received, (B 0101
1001, H 59)
"N" = Confirm data was received correctly and
ready for more data, (B 0100 1110, H 4E)
*************************************************************************
AVR Type. This is the first byte
sent by host after above command. Only last 4 bits are important.
AVR = 0 => not AVR
AVR = 2 => serially programmable x51, FLASH
AVR = 3 => serially programmble x51, EEPROM
AVR = 4 => normal AVR, FLASH
AVR = 5 => normal AVR, EEPROM
************************************************************************
The following sections give details of the sequence of events for each command. The events are shown by telling whether the host (usually a PC) or the PG302 is acting, followed by the character they are sending. For example, Host: "1" means the host is sending the ascii character 65 (Binary 0100 0001 or Hex 41)
The timing for sending commands is not important. Once you start a command sequence, the PG302 will wait indefinitely for the sequence to continue (there is no timeout period). This means you may need to unplug the PG302 to reset it if you lose track of where you are in the command sequence.
*************************************************************************************
Erase Sequence:
Host: "1"
(Erase Command)
PG302: "Y" (Command Received)
Host: AVR Type
"0" for x51 (B xxxx
0000)
"2" for serial x51 (B xxxx
0010)
"4" for AVR (B xxxx 0100)
***********************************************************************************
Program Sequence:
Host: "P"
(Program Command)
PG302: "Y" (Command Received)
Host: Sends one of the following characters specifying
AVR Type
"0" for x51 (B xxxx
0000)
"2" for serial x51, program
FLASH (B xxxx 0010)
"3" for serial x51, program
EEPROM (B xxxx 0011)
"4" for AVR, program FLASH
(B xxxx 0100)
"5" for AVR, program EEPROM
(B xxxx 0101)
Host: NumPulses (see chart at end of document)
Host: NumPulses (see chart at end of document)
(yes, same thing twice)
PG302: "N" (Ready for first line of
hex file)
Host: Sends complete line of hex file such as
":00000001FF" including ":"
PG302: "N" (Ready for next line of
hex file)
Host: Next line
Continues until last line which should be ":00000001FF" (can be anything that starts with :00 and ends with FF and has an odd number of characters (including ":", meaning any number of pairs of characters inbetween :00 and FF)
PG302: "D" means no programming errors.
"C" means programming complete but Hex file has invalid checksum.
Sequence Complete
An "I" received anytime during program means checksum error for that specific line.
*************************************************************************************
Read Sequence
Host: "R" (Read
Command)
PG302: "Y" (Yes)
Host: Sends one of the following characters specifying
AVR Type
"0" for x51 (B xxxx
0000)
"2" for serial x51, read FLASH
(B xxxx 0010)
"3" for serial x51, read EEPROM
(B xxxx 0011)
"4" for AVR, read FLASH (B
xxxx 0100)
"5" for AVR, read EEPROM (B
xxxx 0101)
Host: EE size or FLASH Size, sent as 4 ascii characters
which represents a 4 Digit Hex number. For example, "0", "8", "0",
"0" means the hex number 0800.
PG302: Returns Hex file, line by line, including
":" at beginning of line, but no end of line markers. (":" marks beginning
of each line)
Sequence Complete
************************************************************************
Verify Sequence
Host: "V" (Verify
Command)
PG302: "Y" (Yes)
Host: Sends one of the following characters specifying
AVR Type
"0" for x51 (B xxxx
0000)
"2" for serial x51, verify
FLASH (B xxxx 0010)
"3" for serial x51, verify
EEPROM (B xxxx 0011)
"4" for AVR, verify FLASH
(B xxxx 0100)
"5" for AVR, verify EEPROM
(B xxxx 0101)
PG302: "N"
Host: Send line of Hex file, including ":"
PG302: "N" means line verified and ready for
next line
"B" means line did not verify. Device does not equal file
Host: Send line of Hex file, including ":"
PG302: "N" means line verified and ready for
next line
"B" means line did not verify. Device does not equal file
Continue until last line is sent (something like :0000001FF)
PG302: "C" means device equals file but there
was an invalid checksum
"D" means device equals file with no errors
Sequence complete
****************************************************************************
Checksum Sequence
Host: "3" (Verify
Command)
PG302: "Y" (Yes)
Host: Sends one of the following characters specifying
AVR Type
"0" for x51 (B xxxx
0000)
"2" for serial x51, FLASH
(B xxxx 0010)
"3" for serial x51, EEPROM
(B xxxx 0011)
"4" for AVR, FLASH (B xxxx
0100)
"5" for AVR, EEPROM (B xxxx
0101)
Host: EE size or FLASH Size, sent as 4 ascii
characters which represents a 4 Digit Hex number. For example, "0",
"8", "0", "0" means the hex number 0800.
PG302: Returns 2 bytes (a 16 bit sum) representing
checksum. The most significant byte is first and the least significant
byte is second.
Sequence complete
******************************************************************************
Blanck Check Sequence (Can check EEPROM and FLASH space independently)
Host: "6"
PG302: "Y"
Host: Sends one of the following characters specifying
AVR Type
"0" for x51 (B xxxx
0000)
"2" for serial x51, check
FLASH (B xxxx 0010)
"3" for serial x51, check
EEPROM (B xxxx 0011)
"4" for AVR, check FLASH (B
xxxx 0100)
"5" for AVR, check EEPROM
(B xxxx 0101)
Host: EE size or FLASH Size, sent as 4 ascii
characters which represents a 4 Digit Hex number. For example, "0",
"8", "0", "0" means the hex number 0800.
PG302: "Y" for blank
"N" for not blank
Sequence complete
****************************************************************************
Program Lock Bits Sequence
Host: "2"
PG302: "Y"
Host: Sends one of the following characters specifying
AVR Type
"0" for x51 (B xxxx
0000)
"2" for serial x51, (B xxxx
0010)
"4" for AVR, (B xxxx 0100)
Host: NumPulses (See chart at end of document)
Host: Lock Bit Code
"1" for Lock Bit 1 only
"2" for Lock Bit 1 and 2.
"3" for Lock Bit 1, 2 and
3
Sequence complete
*************************************************************************************
Number of Pulses (NumPulses) for various chips, by company
AMD = 25 (B 0001 1001)
Atmel = 1 (B 0000 0001)
Dallas = 5 (B 0000 0101)
Intel (BH chips) = 25 (B 0001 1001)
Intel (Other) = 5 (B 0000 0101)
Philips = 25 (B 0001 1001)