Experimenting with 8051 Microcontrollers


 
A decent micro family to learn on.

        If you would like to experiment (play) with a microcontroller I would like to recommend that you look into the 8051 family of parts. This family has been around for a very long time (in electronics anything over 10 years is ancient and this family qualifies). The original maker of the parts (Intel) has to the best of my knowledge dropped out of the picture as a supplier but there are a large number of chip maker which continue to not only supply "original" 8051 parts but also are extending the family with newer / faster / more highly integrated parts.

        One chip maker who's parts I have used recently is Atmel and these chips have worked well for me. The parts are available with Flash memory as opposed to Eprom memory which is a real boon to a developer. Eprom memory is reprogrammable as is Flash, but Eprom memory requires an Ultra-Violet erase lamp and some exposure time (up to 30 minutes) to erase it's contents where Flash is Electrically Eraseable and the time required is almost negligible (less than ten seconds). To work with the Atmel parts I purchased a device programmer from Iguanna Labs and it has proven to be a great tool. The included software runs under Windows but there is supposed to be a Linux driver available as well. The Atmel parts are available in the standard "full-sized" packages as well as in a 20 pin configuration. I've used some of these devices, P89C2051 and P89C4051, for small dedicated controller applications they work nicely.( One other important factor in this vendors favor is the fact that there are a number of places on the web which sell the Atmel micros, not all vendors seem interested in selling parts to the general public.)

        I have also recently started working with some Philips P89C664 and P89C668 microcontrollers and these are indeed nice micros with which to work. I chose these particular chips as they each have a full 64K bytes of flash memory onboard and either 2K of ram (P89C664) or 8K of ram (P89C668). This is a great deal of memory when compared with the original 8051 which sported 128 bytes of ram. Another advantage that these chips have over some of the others in the family is the ability to "self-program". [No, I don't mean that you can tell them what you want done and they will wag thier tails and write thier own code !] These chips have an internal rom which may be utilized to load your program into thier flash memory with a minimum of external hardware. I have built and tested the programmer circuit shown in the Application Note and I now use this programmer for all my P89C664 and P89C668 development. (I wire-wrapped my programmer board in an afternoon. I left plenty of room for expansion as this programmer board is a good basis for experimenting in that it already has a working serial link.) I have made a copy of the schematic and have included it below. Please note that I have made only those changes to the drawing that I found useful. I have also eliminated the VPP supply section from the drawing as the P89C66x parts are 5 Volt only parts (which makes the programmer board all the more easily built). The software that runs on the PC which interfaces with the Philips Microcontrollers is named Flash Magic and it has run well on all of the PCs I have used. [The serial communication speed when running on a 500Mhz P3 under Windows NT was rather low, but I don't expect much running NT anyway. I tend to run Windows 98 on my machines and the communication speed on those machines has been very high (57,600 baud) !].(These Philips parts are quite nice to work with however I have not been able to find anywhere on the web that sells them. I managed to get some through a project I was working on, so be warned.)

Why 8051 vs PIC, AVR, SX, ... ?

        Suggesting that someone look into an older part such as the 8051 will usually bring out the zealots who believe that thier personal favorite microcontroller is the "Best that has ever been Made" (tm) and as far as I am concerned they may be right. I don't have a dog in that fight as I make my living working with whatever micro has been chosen by the company to whom I am currently contracted. I have had the opportunity to program the PIC, SX, AVR, 8051, 6805, 80386EX, 68hc11, 68hc16, 68331, 68349, and a host of other controllers over the years. I don't really have a preference when it comes down to getting a job done as you can usually make any micro do a specific job. Yes, some are better suited to some tasks than others and when allowed to make the decision I chose the family that will make my life as a programmer easier (I admit it, I'm as lazy as the next guy). Generally I prefer to use a processor for which there is a good C Cross-Compiler as well as a good Assembler. I prefer to write in C as much as possible as this can save me the time of becoming an assembly language expert in any specific processor. This also helps when the chip maker decides to "End-Of-Life" your processor while you are still in the initial software development phase (I've had it happen !). Code written well in C is generally not too bad to port to another micro. (It helps if you can design the code so as to keep processor specific code in a few specific source files. When this is impractical, use of macros to implement machine specific interfaces can make life easier when told to "Make it Run on the new micro ASAP !".

        Anyway, back to the question of why the 8051 family. My reasons for suggesting this family are:

1) Availability:

 

Multiple vendors (Atmel,Phillips, Siemens, Dallas)
    [ Hey, I'm an engineer and I have been down the "Second Source" path too often to get myself boxed in to a single-sourced part if I can help it. I can get 8051 (DIP) parts from at least four vendors via the web and that's not a bad thing !]

2) Tools:

 

Multiple vendors as well as very good freeware tools
    The SDCC compiler has been great. I have also used the Keil package but the security/copy protection scheme is annoying. (personal opinion)

3) Uart:

Most if not all 8051 Micros have a built-in UART which is a wonderful bit of circuitry to have when debugging either hardware or software.

4) Source Code:

 

An incredible amount of source code is available on the web which can be viewed to give examples on how to do, and sometimes how NOT to do things.

 

 

Updated P89C66x Programmer Schematic

Click on the image for a larger version.

-- Arkwolf --