Micro controllers are hidden inside a surprising number of products these days. If your microwave oven has an LED or LCD screen and a keypad, it contains a micro controller.
To get you understand quickly I define a micro controller as a single chip computer.Yes it is a full blown computer in its own. It has a C.P.U., RAM,some amount of EEPROM(for secondary storage i.e. permanent storage without power), many on-chip peripherals(Timer,Serial communication, Analogue to Digital converters etc.).If you don't understand, no problem I will be dealing them in detail in next tutorials. But compared to a P.C. their resources(RAM,speed etc)are less.But that is what is required !!! Because P.C. is a general purpose computer, which means it can run thousands of different soft wares that are available for specific needs.Like it can run a game.The same P.C. can run this browser in which you are reading this!It can run a custom solution for banks,railways and airways.It can run a 3D modeling,video editing & image editing software for a production company. Many of these are huge software,requiring lots of memory and CPU power.And a P.C. can run simultaneously many of this !!! So to run them the host computer should have enough RAM and CPU power so that it can run heaviest of them. But in case of a micro controller which is used for a specific purpose like switching a Microwave oven heating off after a preset time,and also when temperature exceed preset value, high power CPU s, and large RAM size is not required. so micro controller is a dedicated micro computer for specific application.
In this article, we will look at micro controllers so that you can understand what they are and how they work. Then we will go one step further and discuss how you can start working with micro controllers yourself.
then we will go to programming aspects and how to use in your projects....
for pin diagram and pin description refer to atmega8 data sheet here
A Simple program
void main()
{
SetPortDirection();
while(1)
{
PORTA=0b00000001;
Delay(0.5);
PORTA=0b00000000;
Delay(0.5);
}
}
What the program does
STEP 1 SetPortDirection(); This Function Makes the PORTA as OUTPUT.Its implementation detail is not shown.
STEP 2 PORTB=0b00000001; makes the 0th bit high, switching off the L.E.D. because other end of LED is connected to VCC(i.e. Supply voltage 5V)
STEP 3 Delay(0.5); Halts the MCU for 0.5 Sec
STEP 4 PORTB=0b00000000; Switches on the LED
STEP 5 Delay(0.5); STEP 2 to 5 are within an infinite while loop so it runs till MCU is powered. The program is compiled, and burned into the chip and power is turned on and that LED is blinking once every second.You have just understood the "HELLO WORLD" program for MCU empire .Although the given program doesn't do something very important and can be done without a MCU and in a cheap manner, but it introduce you to micro controller programming.Doing this with MCU has some advantages also.You can change the way LED blinks by simply writing a new program without touching the hardware part.You can also connect 8 LEDs to all 8 PINs of the PORTB, write a nice program them to light them in various pattern !!! Which you can't make easily without MCUs.So you have seen that major functioning of a MCU project are made in software and hardware part is simple and small. So you have learned the basics of MCUs and their use.Hope you have nice time reading.
In next tutorial we will learn tools and soft wares required to work with AVR family of micro controllers. we will meet in next tutorial.