Programming At89s5x



What you need to program the chip:

If you just want to upload a precompiled hex-file to your controller, you need a programmer.

If you want to make your own c-programs you also ned a compiler,


I have used a pololu programmer and a cheap USBasp programmer from ebay. Both work OK. You connect the corresponding pins:
Programmer / AT89sxx
MOSI / 6
MISO / 7
sck / 8

The reset of at89S52 are inverted, which means that you reset the chip by connecting the rest-pin
to VCC (and not the other way around) Therefore you nead to invert the reset signal from the programmer.
You can use a simple inverter like this:


Uploading HEX file:
avrdude -c usbasp -p AT89S52 -B10 -D -e -Uflash:w:blink.hex:i

For more information regarding avrdude see Ladyada
You will need to ad the AT89S52 to AVRdude.conf see: how to do this



C-compiler for AT89sXX The SDCC compiler is open software and very easy to use. An example: Copy and paste the below C-program into notepad or any other texteditor and save it as in a folder called hfiles (or whatever) Make a commandline and navigate to the hfiles folder. Type
sdcc blink.c
Now the compiler wil produce some files in your hfiles folder, among these one called blink.ihx, which is the hexfile you can upload to your controller. If you don't like this commandline stuff you can install an IDE (integrated development environment) called mcu8051ide. Whit this installed you can edit your c-files and compile them whitout leaving the editor. IDE for AT89sXX



Blink for AT89s52

#include <at89x52.h>
#include <compiler_defs.h>
//Compiled using SDCC

void msdelay(unsigned int );
void main(){
  P1_2=0x00;  //all pin of PORT2 declared as output
  //infinite loop
    P1_2=1;   //pin P1_2 high
    msdelay(250);    //delay
    P1_2=0;   //pin P1_2 low
    msdelay(250); //delay
//delay function
void msdelay(unsigned int value){
  unsigned int x,y;


Download the hexfile, compiled using SDCC




ArduinoISP for at89s5x