Intro: Program 8051 (AT89 Series) With Arduino
This guide provides a complete solution to program the AT89S51 or AT89S52 (these are what I have tested) with an Arduino. Multiple setups are included in this guide; the easiest setup requires no additional software other than the Arduino IDE.
Step 1: Wire the AT89S52 As You Would Normally Do
Feel free to skip this step if it is already wired.
What you usually need to set up a minimum system for AT89S52:
1x Crystal Oscillator, less than 33Mhz
2x Capacitors, about 33pF depending on which crystal you use
For the reset circuit:
1x 10kOhm Resistor
1x 10μF Capacitor
The microcontroller can definitely run without the reset circuit, you just have to manually reset it after powering it up.
You can also use one of those minimum system boards. If this is the case, go ahead and skip to the next step.
Step 2: Wire the AT89S52 to the Arduino
The AT89S52 (AT89S51 too) uses SPI as the ISP protocol. It enters ISP mode when RST pin is pulled high.
Wiring in addition to that of Step 1:
RST pin on the 8051 to pin 10 on the Arduino;
Pin 8 (P1.7) on the 8051 to pin 13 on the Arduino (SCK);
Pin 7 (P1.6) on the 8051 to pin 12 on the Arduino (MISO);
Pin 6 (P1.5) on the 8051 to pin 11 on the Arduino (MOSI).
Step 3: Programming Using My Software (Skip to Step 4 If You Want to Use Avrdude)
Upload the sketch contained in the repository and you can start programming your AT89S51(52)!
Step 4: Programming Using Avrdude
The Arduino IDE comes with avrdude preinstalled. Even better, ArduinoISP, which also comes with the IDE, supports AT89S51(AT89S52).
First, upload the sketch named "ArduinoISP" onto your arduino. The sketch can be found under "File" -> "Examples" -> "11.ArduinoISP" in the Arduino IDE.
Then, you have to customize the configuration file of avrdude in order to enable support for our AT89S51(52). You can download an already modified configuration on this page.
Double check your wiring, if everything seems OK, run the following:
"C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avrdude.exe" -C E:/avrdude8051.conf -c stk500v1 -P COM3 -p 89s51 -b 19200
(You might want to replace the path to "avrdude.exe" with your installation path of the Arduino IDE. Replace "COM3" with the serial port name of the arduino you use as the programmer. Replace 89s51 with 89s52 if you have an AT89S52. Replace "E:/avrdude8051.conf" with path to the configuration you just downloaded.)
Step 5: Programming Using Avrdude (Cont'd)
Your setup is correct if avrdude outputs the device signature correctly.
To upload a program, run the command in the previous step with one extra option:
To verify, run avrdude with:
For further information regarding the usage of avrdude, consult its manual at: