AT89S51 compiling and programming advice for a novice

Discussion in 'Embedded Systems and Microcontrollers' started by cork_ie, Apr 8, 2016.

  1. cork_ie

    Thread Starter Member

    Oct 8, 2011
    348
    58
    Hi all,
    I am a member of these forums for quite a while and generally don't have too many hardware issues.
    However micro-controllers are all very new to me. I have just about managed to master the Arduino Uno and now need to go a step further.

    I found a very nice project online that I would like to build.
    The original controller was an AT89C51 but I understand that the AT89S51 is compatible and programming is even easier.
    The project designer posted his source code and his description is
    " The program is written in embedded C language and compiled through KEIL (IDE) cross compiler."
    I downloaded the evaluation version of Keil uVision5 hoping it would be of use to me, but unfortunately it has a 2Kb limit , the full version is $2,600 and I don't see myself paying as much as that for a hobby project.

    What I would like to know is :
    1) Are there any alternatives to compiling the source code in an alternative compiler, what modifications would I have to make to the source code.
    2) What is the easiest way of programming the AT89S51 once I have compiled my file.
    I have attached the source code in a text file in case anyone cares to take a look.
    Thank You.
     
  2. dannyf

    Well-Known Member

    Sep 13, 2015
    1,786
    360
    Why does that matter if your code doesn't compile to anything close to that?
     
  3. cork_ie

    Thread Starter Member

    Oct 8, 2011
    348
    58
    Keil kept warning me that there was a 2Kb limit and didn't compile, so I assumed it was because the file size was greater or am I doing something else incorrectly.
     
  4. cmartinez

    AAC Fanatic!

    Jan 17, 2007
    3,572
    2,535
    I've been programming 8051s for more than 20 years now, and I only write my programs in assembly code. If you're interested, I'd be more than happy to share my compiler with you, and point you to several examples on how to use it.
     
    cork_ie likes this.
  5. cork_ie

    Thread Starter Member

    Oct 8, 2011
    348
    58
    After several hours reading, - always a good place to start, I eventually managed to compile the source code. and now have a very nice hex file. The next step is to find a way of getting it on to my chip.

    The biggest thing I have learnt , is you don't learn C (or assembly either ) in an afternoon !
    I am not far short of 60 and between , automotive electronics CAN LIN etc., new emissions regulations , and Spanish, I am now studying harder than the average full-time student, and running a very busy workshop as well for 50 + hours a week.

    I see that some people have managed to flash the 89S51 with an Arduino and I am willing to give it a go. Any suggestions or comments on this route are welcome. I really appreciate that people here are prepared to help and share their experiences .

    For this project and only because I have the source code in C I will stick with it for now. But I really appreciate your offer and I am going to take you up on it . I need to do a bit of reading on assembly code first, so that I get a grasp of it and then write some basic "Blink Light" programs to start with.
    I would appreciate it if you are prepared to give me some help and guidance doing so.
     
    cmartinez likes this.
  6. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,388
    497
    For FREE compiler, I think, most people end up using GCC. I have not setup it myself, but I probably will later.

    Using Arduino board is probably by far the easiest. You can get copy/clone of Arduino Uno for 8 USD.

    An interesting option with these 8051 chips is using one that has bootloader on the chip. That way you don't need a big/dedicated programmer circuit. That is what I am planning, I got Microchip's SST89E516RD chip, the circuit that I am going to use have RS232 chip between the pc serial port and the SST89E516RD. Also, recently, while discussing a Maxim 8051 chip I learned that they have one that comes with bootloader too.
     
    Last edited: Apr 9, 2016
    cork_ie likes this.
  7. dannyf

    Well-Known Member

    Sep 13, 2015
    1,786
    360
    I compiled your code to less than 1.5KB so the free version will work.

    There are numerous programmers for 8051, typically vendor specific.

    The ones I have used a lot is usbasp, and they go for less $5 on ebay and also work on AVRs too. You can use a customized avrdude to program it but I used a chinese programmer, progisp, to program it - it supports numerous Atmel 8051s out of the box and is much faster than avrdude / avrdudess. But you have to get a hang of it as it is in Chinese - after a few tries, I go by the icons, :), like reading a picture book.
     
Loading...