Tuesday, March 22, 2011

A simple and short introduction to Microcontrollers...

Assalaamu Alaikum (May peace and blessings of the Almighty be upon us all)

This article you are about to read was taken from "Tutorial on Microcontrollers" written by our beloved vice principal Mr.S.Oulaganathan. We love him so much for his dedication in improving students' technical strengths. This particular tutorial is very short extending upto only 12 pages and written in simple language.

All the basic things that a beginner want to know (from pin details to IDE to sample circuits) were explained in such a simple way. I can't post all the twelve pages here. Hence, those who are interested in reading further, feel free to send me a email at I will send you the soft copy of the tutorial (insha'allah, God willing). 

If you are benefitted from this tutorial, please share it with your friends...thanks


Microcontrollers are microprocessors with peripheral devices and memory embedded in a single chip. They are used in almost all modern day appliances as embedded controllers and so are produced in millions. They are available readily in our local markets at a very affordable cost.

The subject of microprocessor is introduced in colleges with 8085 architecture and programming in Assembly language. It is a good start to understand the basics of microprocessor, but this knowledge of microprocessor limited only to 8085 is grossly inadequate when they go to the industry. And also 8085 is decades old and is definitely not suitable for the current day applications.

This tutorial is to help the students to come out of their academic 8085 cocoon and learn the tricks of designing microcontroller based electronic systems during their final year project work, gain practical knowledge on hardware design and go out to the industry with confidence.

The most popular microcontroller architecture is Intel’s 8051. There are number of IC manufacturers offering microcontrollers based on 8051 architecture. ATMEL ( is one of them. Two microcontrollers 89C2051 and 89C51 from ATMEL are chosen for our use, for the following reasons,
· They have all the necessary features for use in a small to medium application,
· Software development tools are available free,
· Flash Programmer for ATMEL series microcontroller has been available in most of the colleges. (emphasis mine, edited to suit the broader audience),
· These ICs are readily available in cities (emphasis mine, edited to suit the broader audience) and costs between Rs. 50 to 70.

Microcontrollers basics:

The first step towards taking up microcontroller design is to understand the basic architecture and its features. It is highly recommended to follow the excellent text book, 
The 8051 Microcontroller and Embedded systems – Muhammad Ali Mazidi, Janice Gillispie Mazidi
Microcontroller consists of the following functional blocks, (microprocessor will have only CPU and may be some peripherals integrated into and not memories)
· Central Processing Unit (CPU)
· Flash memory (Read Only Memory)
· Random Access Memory (RAM)
· Serial communication port
· Parallel Input/Output ports
· Timer
· Interrupt controller
· Analogue to Digital Converter (ADC)
Flash memory is mostly Read Only Memory (ROM) used to store programs. The Flash capacity in microcontroller ranges from 2 Kbytes to say 16 Kbytes. It is a non-volatile memory meaning that even when power is not available to the microcontroller the contents of Flash memory are retained. The contents can be changed by erasing electrically and reprogrammed using a Flash Programmer (we will see in detail about Programmer later) This cycle of erasure and programming can be performed for a few thousand times.

RAM as every student bursts out when asked, is Random Access Memory, functionally it is a Read and Write Memory meaning that data can be written, read and re-written any number of times. Data access is at random (compared to serial memories). RAM is a volatile memory. When power goes out, data stored in it also evaporates and is not retained. RAM capacity in microcontrollers is normally kept very low to few hundreds of bytes, say128 or 256 bytes. RAM is used to store real time data, which is temporary in nature (tables, lists etc) while the processor is executing a task.

Most of the microcontrollers have the following peripheral devices built into. 

1. Parallel Input/Output port - They can be programmed as input to read data into the microcontroller from external devices or as output to output data from microcontroller for controlling them. 
2. Timer – this device is used to measure time in real time applications. A programmable counter is maintained by the microprocessor internally. By software a specific value can be loaded into the counter. Internal or external clock can be selected to clock the counter. When the counter counts down to zero an interrupt is raised to indicate the elapsed time. 
3. Serial communication controller – or simply just called UART (Universal Asynchronous Receive Transmit) is used to transfer serial data between the microcontroller and an external system, say a PC. The data is formed in a standard format with start, stop and parity bits and transferred at a fixed baudrate.
4. Interrupt controller – a set of external interrupt lines are provided to interrupt the processor and bring to attention the external event occurrence. Built in interrupt controller coordinates the interrupt process.
5. Some advanced microcontrollers have built in A to D converters also.

With the Flash Memory, RAM and other peripherals built-in the microcontroller is a single chip microcomputer and is equipped to handle any real time control application.

Overview of AT89C51-24PC Microcontroller:

It is a Dual in line (DIP) 40 pin, (P- plastic package, C- commercial operating temperature of 0 to 70 C) IC with the maximum operating frequency of 24 MHz, manufactured by ATMEL.

The operating supply voltage is +5 Volts. 

Crystal Oscillator:

For all its internal operation, microcontroller needs an external stable clock source. It has an on chip oscillator, but we need to connect a crystal across the pins XTAL1 and XTAL2. A two lead metal can crystal has to be bought (Rs.5 to 10) along with the microcontroller. Crystal has to be specified with the operating frequency. Higher the crystal frequency chosen, the microcontroller runs at a higher speed and so throughput of the processor will be higher. But we cannot exceed the maximum operating frequency of the IC. If it is a AT89C51-12PC processor, then the crystal to be chosen should be 12MHz or less. Some of the standard frequencies of crystal available are 6.141 MHz, 11.0592 MHz, 12 MHz, 24 MHz etc. 

We need to connect two small value 30 pf ceramic capacitors from each leg of crystal to ground to complete the oscillator circuit as shown in fig.1.

Fig. 1

Power ON reset:

Microcontroller has a reset pin RST. It is an input pin, when it is pulled to logical high, the processor gets reset and terminates all its activities and restarts its operation from beginning. The processor has to be reset immediately after power ON or whenever an irrecoverable error has occurred during its operation and the processor is hanging. Normally, a 10uf capacitor and 4.7Kohm resistor are connected as shown to reset the processor automatically on Power ON. When power is applied, initially the voltage across capacitor is zero and so the RST pin gets +5V. Then the voltage across capacitor rises and reaches 5 volts and so the RST pin comes to logical ground. With this arrangement the processor gets automatically reset on power ON. Additionally a reset push to operate switch across the 10uf capacitor can be added to reset the processor manually whenever required.

To read the entire tutorial, send a request to Soft copy of the tutorial will be sent (insha'allah, God willing)

Thanks and take care...

My Sincere Thanks to:
1. Prof.S.Oulaganathan

Your brother,
Aashiq Ahamed A


nidurali said...

Maasah - ALLah

Please visit


Aashiq Ahamed said...

Dear grandpa nidur ali,

Thanks a lot...ur article is simply amazing...i bookmarked...jazakkallah for sharing..

aashiq ahamed a

Fasil Eriyadan said...

thanks... May Allah bless you....

Post a Comment