Program 8051 (AT89 Series) With Arduino

Introduction: 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:

For clock:
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)

From here:
https://github.com/cyj0912/AT89ISP

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:

-U flash:w:YOURPROGRAM.HEX

To verify, run avrdude with:

-U flash:v:YOURPROGRAM.HEX

For further information regarding the usage of avrdude, consult its manual at:

http://www.nongnu.org/avrdude/user-manual/avrdude_...

Be the First to Share

    Recommendations

    • STEM Contest

      STEM Contest
    • Role Playing Game Challenge

      Role Playing Game Challenge
    • CNC Contest

      CNC Contest

    12 Comments

    0
    ppoonpp
    ppoonpp

    Question 6 months ago on Step 5

    Can the programmer be able to flash a ATmel AT89C52 instead of AT89S52?

    0
    B SamyS
    B SamyS

    1 year ago

    Used it on my new subject (this year) to all my pupils: "Industrial Programming I" (IP1)
    And this is used ONLY for my (Electrical) Engineering classes !
    Keep the good work...

    0
    WeTeachThemSTEM
    WeTeachThemSTEM

    Reply 1 year ago

    Thanks for sharing a Teacher Note and letting us know the grade level and subject of the class you used this project with. How did you integrate the project into your lessons? Did you create any student resources to go with the lesson?

    0
    guillermos46
    guillermos46

    Question 1 year ago

    Hi. He has given me some micro P80C31BH and is looking to use this post, but I have mounted it and it does not work for me.
    What is the difference of At89s51 and P80c31?
    Is it the same in the case of 80c31?

    0
    Ravi ravnang
    Ravi ravnang

    1 year ago

    I am using AT89S52 and following the circuit as shown above. The Arduino program is being loaded on the Arduino Uno board without any error. But, the chip is not getting detected in the SPI programmer! As a result, i cannot burn the Hex file! Please help to as to what can be wrong?
    Please help

    1
    eengr
    eengr

    Question 2 years ago on Step 4

    avrdude.exe: can't open config file "stk500v1" no such file or directory
    Help please

    0
    pirathi
    pirathi

    2 years ago on Step 5

    Hi

    Why this error caused? explain plz.
    stk500_recv(): programmer is not responding
    avrdude.exe: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03

    1
    Arkojitdas09
    Arkojitdas09

    Question 2 years ago on Introduction

    How can 89C52 be programmed with arduino? It is low cost than 89S52 but with the above tutorial, it is not working. 89S52 is working fine

    0
    TheGardenBoy
    TheGardenBoy

    Question 3 years ago on Introduction

    Hello...what should I do after connecting as per given on the sketch?please make an YouTube tutorial about it...or send me step by step guide to my mail account decoder143@yahoo.com....I am doing project...burner kit is costly...help

    0
    SudarshanH3
    SudarshanH3

    3 years ago

    I'm getting "Device signature = 0x7f7f7f, Expected signature for AT89S51 is 1E 51 06, Double check chip or use -F to override this check".

    What could be the problem? Please help. Thanks!

    0
    JackDiamond
    JackDiamond

    3 years ago

    I lost my code (one of many) with failure of hdd. I need to modify something and i can't. Its 8051 (AT89S52), is there any chance to read it back ? Thanks