Introduction to 8051

As writing a C program starts with displaying a string hello world, most of the times learning about microcontrollers/embedded systems starts with 8051. It was introduced long time back but it in terms of understanding basics of embedded systems it still stands to the test. We will keep these tutorials less of theory and more of interfacing. And this one thing we have been glued to embedded systems so long, it is exciting when you make these small chips run and make interesting things out of them.
We would be doing all the hardware sessions on ULTRA_X51, although the examples presented should work for any of the microcontroller platform or development boards.

What makes them Powerful?

Looking at the microcontroller features, one might be question; as to what makes these controllers so powerful, that these are part of such a wide ranging device. Right from smart phones to dumb phones from robots to rovers, here’s what makes these devices click.

Programmable!

Making Integrated Circuits which could be programmed depending on the application was breakthrough. The array of varied applications that these microcontrollers are used, only justifies the purpose. Making custom Integrated circuits with specific to a particular application is time consuming! Microcontrollers inspired a new generation of designs which were highly scalable yet generic, simply have an idea, put on the chip and run it

Speed:

Today, we have controllers from the ARM family that run at a few Giga Hertz! The basic operations that most of the controllers perform are arithmetic (binary addition, subtraction etc) and logical (simple NAND, NOR applications). Well, what makes these simple instructions powerful is the speed at which these can be executed.

What do you need to know to get started? Perquisites!


  • Basic C programming.
  • Basic understanding of electronics, we would try and clarify the basic concepts, as and when required during the tutorial.
  • Justdo it! The most important thing is do the practical stuff as go through the tutorials. This will give you the much needed fuel and excitement when things really work. If they don’t you’ll learn more than what these tutorials teach and more the fun!

Features of 8051


8 bit controller:

It basically means the microcontroller handles data in sizes of 8 bits or simply a byte. In other words, the architecture of 8051 is 8-bit, meaning to say ALU, Input output Ports, most of the registers, internal bus is 8 bit, we will see more of this while discussing the architecture of the controller.

4KB of internal ROM and 128 bytes of RAM memory.

The programs that are written in C or assembly get converted to hex code when compiled. This file is flashed/written to the controller and resides in the ROM. Hence 4KB of ROM determines the size of hex file or eventually the code that the controller is able to store, fetch and execute. Well it may seem very little, indeed it is. But this would more than enough for simple interfaces and even some of the commercial applications. The RAM is the faster accessible volatile storage memory that gets erased when you turn off the controller. This is needed to store real time data, the data from peripherals or calculations that you do while the program is executing. Well 128 Bytes! Yes that’all we have!

Four 8 pin I/O ports (P0,P1,P2,P3).

    • Each of the IO Pins can be configured as Input or Output. IO pins are basically used to read/write data to external peripherals and sensors

Two 16 timers/counters.

The unit can be configured as timer when it measures time internally and configured as counter when external events are to be counted.

One serial port (UART).

One of the oldest most widely used communication protocols. This is used to communicate with a computer or any peripheral which has a UART interface. The protocol is very simple to learn and implement.

  • 8bit data bus and 16bit address bus hence can access 64k of external memory.

Interrupts

Interrupts basically are requests to stop current execution and serve a request, either from a internal unit of a Microcontroller or a external device. Interrupts are used with numerous external peripherals as well as internal features of a microcontroller. They come in very hand to break normal sequential flow of execution and switch to a different task or request.