The AT89S52 microcontroller

Discussion about project that uses other controller, or non controller based project such as using logic gates, FPGA, ARM, Mechanical ....etc. Welcome to post it here

The AT89S52 microcontroller

Postby Brian Griffin » Sat Nov 16, 2013 2:03 pm

Someone happened to give this microcontroller to me because it's not been used, so I have an idea - let's try to program something inside it!

Programming the Atmel AT89S52 is not terribly difficult if you have the USBASP stick, but if you don't have, and you have an extra parallel port at your PC with a cable, you can build your own programmer. Refer to the website. I'll post up the improved schematics here later.

However, those good C compilers for 8051 are not really available for free, and luckily we have the SDCC. You can get the SDCC here. Create a new file name "hello.c" or something, and then copy the code provided. Don't worry about the inline assembler - I fine-tuned the delays a bit more.

CODE: SELECT_ALL_CODE
#include <mcs51\at89x52.h>

void delayMs(unsigned int inputDelay) {
   for(;inputDelay; inputDelay--)
   {
      __asm
      push 0
      push 1
      mov  r0, #49
      mov  r1, #10
      00002$:
      00001$:
      djnz r0, 00001$
      mov  r0, #49
      djnz r1, 00002$
      pop  1
      pop  0
      __endasm;
   }
   
}

void main()
{
   while(1)
    {
        P2_0 = 0;
        delayMs(500);
      P2_0 = 1;
      delayMs(500);
    }
}


In the command prompt, switch to the directory you are working on, and then compile it by typing
CODE: SELECT_ALL_CODE
sdcc hello.c


This code switches on the LED for 500ms, and then off for 500ms and again.

The P2_0 is at the 21st pin of the microcontroller. Sink the pin with the LED and the 330ohms resistor. 12mhz crystal too is needed for the project.

The AT89S52 is based on the old 8052 microcontroller. Nothing fancy, no A/D and all that other peripherals, and it's really slow. Back then many were working on the 8051 and the 68HC11, but now we have the PIC and the ARMs together.

Reference: Delay routine courtesy of http://8051.scottmay.org/.
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

Re: The AT89S52 microcontroller

Postby ober » Mon Nov 18, 2013 8:52 am

Brian, thanks for sharing.

I was learning 68000 mikroP from Motorola and move to 68HC11 for microC. I have experience in using AT89C51, and I am using Assembly too. Back then, there is no free compiler or maybe we did not search it.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1455
Joined: Wed Apr 15, 2009 1:03 pm

Re: The AT89S52 microcontroller

Postby Brian Griffin » Mon Nov 18, 2013 4:08 pm

ober WROTE:Brian, thanks for sharing.

I was learning 68000 mikroP from Motorola and move to 68HC11 for microC. I have experience in using AT89C51, and I am using Assembly too. Back then, there is no free compiler or maybe we did not search it.


SDCC was started at year 2000, according to the webpage, but back then we do not have good access to the internet.

Fast forward to today it seems very easy to program a microcontroller, just use the ISP and we are good to go. :)
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am


Return to Misc Project

Who is online

Users browsing this forum: No registered users and 3 guests

cron