| Home |
| Contact |
| About Us |
| Privacy Policy |
8051 Projects - Learn 8051 ProgrammingMost computers in use today are embedded in some electronic device, from appliances to mobile devices. Such computers are called embedded systems. A key component in embedded system is a microcontroller. This is a microprocessor with emphasis on I/O operations. The role of microcontroller is to control electronic devices providing all necessary switching, measurements and communication with the world. Microcontroller is the brain of the device.
The first microcontrollers emerged in 1970s. They were 8-bit devices capable of running a program from internal ROM or external EEPROM memory. One of the popular microcontrollers was Intel 8051. Intel developed a family of microcontrollers named MCS-51, where 8051 was probably the most popular member. It is amazing that this architecture is still popular today. There are many manufacturers like Atmel, Silicon Labs and NXP that still use the 8051 core for their microcontrollers. This means that all the tools that were developed thirty years ago can, at least in theory, be still used today to develop programs for 8051-compatible microcontrollers.
The 8051 family of microcontrollers is special because it has many types of memory that need special instructions to access it. The basic memory is located in the DATA segment and most instructions can access it. The size of this memory segment is 256 bytes. The upper 128 bytes are reserved for Special Function Registers, memory mapped registers that control functions of the microcontroller. The lower half is divided into three parts. Addresses from 0 to 31 are memory addresses for registers R0 to R7 in 4 register banks (0 to 3). Addresses from 32 to 127 are general purpose memory locations with additional function of addresses from 32 to 47 which are also bit-addressable. Most 8051 microcontrollers (except the original 8051 microcontroller) have also additional 128 bytes of IDATA memory which is similar to DATA memory but can only be accessed indirectly. It is located at addresses from 128 to 255. Special instructions are needed for this type of memory. 8051 microcontrollers support also external memory located at XDATA segment. Its size is 64kB and can be accessed only indirectly with few special instructions. There is also a special bit-addressable memory where you can access individual bits (256 bits in total). The first half of this bit-addressable memory is general purpose memory while the upper half maps to bit-addressable special function registers.
This complicated memory model makes compiler construction a complicated task. But because the 8051 microcontrollers were well accepted in industry and they are also present in many hobby projects, quite a lot of companies decided to develop their own 8051 compiler. There are many commercial C compilers for 8051 microcontrollers available. Most of them are part of some commercial package together with integrated development environment (IDE), debugger and simulator. Among those the Keil IDE/compiler is probably the most popular. There is also one popular and free C compiler SDCC (Small Device C Compiler). SDCC is a retargettable, optimizing ANSI - C compiler that targets the Intel 8051, Maxim 80DS390, Zilog Z80 and the Motorola 68HC08 based microcontrollers. SDCC is Free Open Source Software, distributed under GNU General Public License (GPL).
Another world in 8051 programming is Pascal. Pascal programming language was designed by Niklaus Wirth in late 1960s. Its main purpose was to teach programming. The language itself is focused on structured programming and has many constructs for data structures. Borland Turbo Pascal was probably one of the most successful Pascal compilers around. It was very popular in 1980s and early 1990s. Its successor was Borland Delphi which is a visual rapid application development tool still in use today. Pascal is rarely used in embedded programming although there are compilers available also for AVR, ARM and PIC microcontrollers. There is one free Pascal compiler for 8051 microcontrollers, Turbo51. It is a fast single pass optimizing compiler with Borland Turbo Pascal 7 syntax and advanced multi-pass optimizer.
Similar situation is also with other popular microcontroller families like AVR, ARM and PIC. A plethora of C compilers are available and only a few Pascal or Basic compilers. Of course, we should not count assembly language compilers. These are the basic compilers for every processor or microcontroller. The most important thing with compilers is the code they generate. This should be highly optimized for size and speed. Comparing the code size of a program written for the same task in SDCC and in Turbo51 we can conclude that the result is not dependent on programming language. Either C or Pascal can be used to create a compact and optimized code. It is just the personal preference of the programmer what language he will use.
It is very interesting to compare generated code for some particular C or Pascal instruction, e.g. for 8051 microcontroller. We get practically the same microcontroller instructions. This is another confirmation that high level language is only a tool to describe the algorithm. It is the task of an optimizing compiler to generate individual microcontroller instructions that do what is needed.
Microcontroller market will continue to grow. One of the most important markets for microcontrollers is the automotive industry. It is the a driving force in the microcontroller market, especially at it's high end. Many microcontrollers were developed specifically for automotive applications. On the other hand almost every electrical device from toys to appliances uses some form of embedded system. The conclusion is that with microcontroller market growing also the need for high-quality embedded compilers will grow. This will lead to better compilers that will generate faster and more optimized code.
Microcontroller ProjectsAre you a young engineer looking for simple projects to learn about embedded systems and microcontrollers? Or maybe a high school / college student looking for information on microcontroller based projects? Or you are maybe planning to convert an old digital technology based project to a compact microcontroller based design? The best way to learn about microcontrollers is to work with them. Start building electronic projects, from simple microcontroller projects to complex embedded designs. Here are the steps and information for you to get started.
Your knowledge and abilityEvery human is unique in the knowledge he has acquired and the abilities he has. Knowledge indicates the "experience" and ability indicate "time required to solve a design problem", e.g. I know C language very well but I probably can't solve an "Array Sorting" problem easily. This indicates having knowledge of C programming is not enough but one should have good ability to "Analyze and solve the problem statement". And this is the key and most important feature required while working with any microcontroller based embedded design system. In other word this ability to solve problems is called as "Logic of creating solutions".
Hardware & SoftwareMicrocontroller based embedded system designing is combination of hardware and software. Microcontroller is a small Integrated Chip (IC) and is the hardware part of the system. This small chip called microcontroller has facility to store a "Program" inside it. This is called software - in embedded systems it is usually called firmware. You as a product designer, must have both expertise. Let's understand this by one example: "You have been assigned a simple task to design and develop a microcontroller project to display room temperature" This project will need following components:
Once you have this set ready, then its time to create a circuit / schematics for this. Here is the point where you start learning about internals of 8051 microcontroller. Learn the hardware aspect of this microcontroller and then the study software. You can use Assembly, Pascal or C Language.
Tools and EquipmentYou will need a PC / Laptop, installed with IDE (development environment), ISP Programmer hardware, Starter kit / target development board and some books or reference manuals In the above example we have selected C8051F020 microcontroller. This is made by Silabs and is from 8051 family of microcontrollers. This is an 8-bit controller. Keil is used as IDE for writing program. There are many ISP programmers (hardware) available in the market - in this particular example we can use a JTAG programmer. Starter kit helps you to experiment and test your program by downloading (flashing) the developed source code into the 8051 microcontroller. Books, reference manuals and e-book tutorials will help you to get started with the new and exciting world of microcontrollers. There are several other microcontrollers available like PIC, AVR, ARM, etc. Every family has some unique features to offer and you have to decide which feature you need the most. The cost of microcontroller is also an important factor, especially when the project will be produced in high volume. Other also important factors are availability of tools like compilers, IDEs, starter kits, programmers, books and reference material.
8051 Projects8051 is an old 8-bit architecture but still popular and widely used by many respected manufacturers like Atmel, NXP, Silabs, etc. Because of this many embedded projects are based on 8051 microcontrollers. There are many free 8051 projects available on the web. It is important to start with a project that is matched to your skills. Do not start a project unless you don't understand how it works. You don't have to understand all software features of the microcontroller, the beauty of such projects is experimenting while writing software. Just be sure you can build the hardware and compile the software. |