Neues Projekt Hilfe?

Atmel 8051 Series Programmer

Status: Einsendung
22. Januar 2019
Project by Noel A. Rios. Complete schematics and full source code are available.

Here is an 8051-series flash microcontroller programmer which can program the AT89C2051, AT89C4051, AT89C51, AT89C52, and AT89S52. 

These microcontrollers are very cheap and can still do the job. Most of them have multiple IO ports, two Timers/counters  with interrupt, Serial port with a baud rate generator and interrupt and  external pin interrupt.  You can also set the priority of the interrupt of the peripherals.  Please see the respective datasheet of each microcontroller for more info. 

The programmer has two ZIF sockets for 20-pin and 40-pin microcontrollers but only one can programmed at a time. It can auto detect the type of 8051 variant inserted in the socket.  You can also disable this feature since most processes won’t continue if there is no valid device in the socket provided  you can check if the microcontroller will still run without a valid device signature.

The programmer has an 8 bit ADC for Voltage and Current Sensor.  It monitors the input voltage from the USB port and the voltage and current at the ZIF sockets.  It disables the voltages if there is an over current.

It uses an USB port for reading the Intel Hex file and controlling the programmer by using a program called CoolTerm.

The firmware resides inside the controlling microcontroller.  The machine code or binary code is 10K plus bytes. It has a 32 kilobyte SRAM for holding the HEX file.  Maximum size of Intel Hex file is 24 Kilobytes.

Only Five volts from the USB port is needed,  it uses a boost regulator to supply the Super voltage for programming the target microcontroller.

It has several LEDs to indicate the status of the device programmer. You can program your code in Intel Hex file format by sending the Hex file to the device programmer. Intel Hex file is used since the file has a checksum to make sure the file is correct and is verified by the device programmer. It can erase, blank check, program and verify the target microcontroller. It can also read the contents of the microcontroller and create the Intel Hex File which can be uploaded and saved as a file if the microcontroller is not copy protected. It can also copy protect the contents of the microcontroller by enabling  the lock bits.

The Hardware

The microcontroller that manages the device programmer is an AT89C55WD See Figure.  It was chosen since it has a 20Kbyte flash memory which can hold the binary code of the firmware of the device programmer.  The microcontroller has a 24 Mhz clock since the pulse that programs the target microcontroller is 500 nanoseconds wide.  This is computed by the clock divide by 12.  This is so since the AT89C55WD uses 12 oscillator cycles per instruction.  The device programmer use three latches, one for the address, one for setting the control signals for programming, erasing, reading etc. and one for controlling the analog multiplexer CD4051B to steer the voltage and current signals to the 8 bit ADC ADC0831. In addition, it alos lights the appropriate LED to show the status of the device programmer.  To connect the device programmer to an USB port, U7 CH340 is used.  An USB to serial bridge was chosen since the RS232C serial port is becoming scarce today.  The device programmer also gets it power from the USB port.  The device programmer also has PTC fuse to protect the USB of the Laptop or computer in case there is a component failure in the device programmer.  It  also uses a Schmitt trigger IC to connect the clock of the AT89C55WD to the target microcontroller thus saving one crystal and also to steer the clock pulse from the AT89C55WD to the clock input of the target microntroller, AT89C2051 and AT89C4051.  The device programmer also uses two high side current sensors.  It uses U12 TL082, an N-channel MOSFET 2N7000 and two resistors R23 50 ohms and R22 10 ohms.  When no current flows through R22 10ohms the voltage at the two inputs of the OPAMP are equal and the output of the OPAMP is zero.  When there is a current flowing through R22 10 ohms, the voltage at the non inverting input is greater than the inverting input causing the output of the OPAMP at pin 1 to go high at some voltage.  This turns on the N-Channel enhancement MOSFET pulling down the voltage at R23 50 ohm.  The output of the OPAMP TL082 stop at a certain voltage once the voltage at the two inputs of the OPAMP are equal.  The current flowing at R24 1K generates a voltage which give the current per voltage. The formula is ((Icurrent*R22)/R23)*1K.  This gives 0.2 volt / milli ampere.
  The device programmer also uses an MC34063 Switch mode converter used in a boost  topology.  The boost regulator uses a current resistor so it is short circuit proof.  The Inductor L1 220uH is in series to the power supply which is five volts.  The MC34063 conducts and shorts one side of the inductor to ground and energy is stored in the inductor.  The Collector of the MC34063 opens and the polarity of inductor is reversed.  Now, the side of the inductor connected to the positive supply becomes negative and the voltage of the power supply and the voltage of the inductor adds up to form the super voltage for programming the flash microcontroller which is 12 volts.

The device programmer also uses U15 74HC245 to Isolate the target microcontroller from the bus of the of the AT89C55WD.  This is because there will be a bus contention when you set the AT89C2051 to read its contents.  Without the 74HC245, the AT89C2051 will output its data before you can set the bus of the AT89C55WD to HIGH to read the contents.

The project uses a software read and write access for all operations since the Normal read and write access using the control lines  /RD and WR/ are too fast for programming the target microcontrollers.

If you look at the interfacing of the 32KB SRAM U3,  you may say the control lines are interchanged. However, since I used the /RD and /WR as I/O pins and not control line so I did not care which is which. I also used a positive line switch comprising of Q1 2N3906,R9 10K,R11 4.7K,Q3 2N3904,Q4 2N3904,R15 10K, And R20 4.7K.  This circuit is like an inverter since the I/O pins of the AT89C55WD is high at power up.  Using this switch will ensure no voltage is switched at power up at the ZIF sockets.  Also this circuit isolates the voltage at the PNP transistor 2N3906 from the I/O pin of the AT89C55WD.

I also added a 78L12 linear regulator to the output of the boost converter to fix the super voltage after the drops at the current sensor and positive line switch. 

The Firmware

I used C language to program the firmware of the device programmer.  I used the I/O pins of the microcontroller to make the hardware simpler.  The device is connected to an USB port of a computer or a laptop.  The firmware of the target microcontroller which is an Intel Hex file  is sent through the COM ports assigned to the device programmer.  Since the connection is serial through a serial terminal like Cool Term,  the data arrives at the device programer in ASCII format and not binary.  Because of this you must convert the ASCII data to binary.  Also note that the characters arrive one at a time so you must convert the characters to binary and combine them to form the binary number.  After conversion, you can now determine how many bytes are in one line, the load address, store the data and the checksum.

The sum of all the bytes plus the checksum should be zero.  This scheme is nice so you will determine if there is an error In the transmission of data from the COM port to the device programmer. The reverse is true for creating the Intel Hex file.  You must determine  the number of bytes per line, the load address and the checksum.  After that you must convert it to an ASCII characters so the laptop or computer will receive it as a text or Intel Hex File.  To program  the device, you set the control lines of the target microcontroller which is latched to U11 74HC574, set the super voltage to 12 Volts and strobe the /PROG I/O pin of the AT89C55WD.  The program to flash is timed so you will need to wait at a time indicated in the datasheet.  Every operation the device programmer measures the voltages and current at the ZIF sockets.  This is done through the high side current sensor and voltage dividers.  Measurement of the voltages and current is measured  by an 8 bit ADC ADC0831.  The AT89C55WD bit bangs the I/O pins as software SPI to read the data inside the ADC ADC0831.

How to use the Device Programmer

First, install the CH340 device driver for Windows.  After a successful installation connect the device programmer.  Take note of the COM port of the device programmer.  Now open Cool Term.  In Options button, Enter the COM port of the Device programmer and select the 14400 as the baud rate.  After that, click connect.  You can Press the Reset switch or press m.  The Menu shows all the things that can be done on the device programmer, See Figure 2.  The one that needs instrauction is how to download the firmware and up load the firmware.  To download the firmware to the buffer of the device programmer, press l to load t Intel Hex File.  After that, the device programmer will respond, “waiting for Intel Hex file”. On the Cool Term, click connection and then Click Send text File. After that the Intel Hex File will load and stops automatically.  To upload the Intel Hex File, use the read  device  (r)  to read the contents the microcontroller.  Make sure the Microcontroller is not copy protected or you will not read its contents.  On the Cool Term Menu, click on Connection, then click on Capture Hex File.  Then Click on Start. Enter the Name of the Intel Hex file.  Make sure the filename extension is .hex.  Then click on Save.  After the Hex File is finished, click on Stop.   That saves , the Intel Hex File.  If too much data is scrolling to the screen, you can click on Clear Data on Cool Term.  Right now, the firmware of the device programmer is dependent on Cool Term because of the behavior or serial terminal programs which inserts Line feed and Carriage return to the Uploaded data or the Intel Hex File.
Mehr anzeigen
Weniger anzeigen
8051 programmer for Atmel devices
Terminal user interface

Kommentare werden geladen...