Home > Embedded Systems > Microcontroller

Microcontroller

This is my first experience with Microcontrollers (µC).

Before I know about µC, I’ve already had a lot of experience about computer architecture and the story of running a software on a PC. I’ve then attended a summer training introducing Microcontrollers with a hands-on practice. Let’s get started…

microcontroller_ATMega32

What is a Microcontroller?

Microcontroller is actually a computer but a small one. It’s simply a computer on a chip. It has all the 3 main elements of any stored-program computer system. It has a processor, a storage memory and some I/O facilities.

Comparison between Microcontroller and PC

  1. In a PC: Processor, memory and I/O each is provided as a separate chip and are linked together via bus connections on a Mother Board while on the other hand – in a Microcontroller – these elements are all fabricated together on a single chip. This is why we call Microcontroller a simple and small computer on a chip.
  2. Microcontroller’s processing unit is not as powerful as a PC’s one that has a wide and complex instruction set. A PC is a general purpose machine and that’s why there should be a powerful processor compared to a Microcontroller’s one for the reason in the next point.
  3. Microcontoller is a special purpose computer i.e. It tends to have a single dedicated function when used inside some circuit. One should write a control program, burn it to the µC, connect the µC in the circuit and it’s all done. If you’d like to use it to do a different task, you’ll have to replace the control program with a new one.

A µC is sometimes called an embedded computer. µC actually has seven main components which are CPU, RAM, I/O, ROM, Timer, Interrupt Circuitry and Buses. This is shown below:

Overview

Typical Microncontroller components

Where can we see µC in the real life?

Microcontrollers are used everywhere. Have you ever heard about Embedded Systems (Like  your mobile phone, MP4, Router, …)?. µC is one of the most significant components used in any Embedded System.

Typical µC Example

This is an example of a µC from the popular PIC family: PIC16F877A

P16F877A Pin Diagram

P16F877A Pin Diagram

In the P16F877A µC above, there are 4 I/O ports:

  1. PORTA: pins RA0-RA5
  2. PORTB: pins RB0-RB7
  3. PORTC: pins RC0-RC7
  4. PORTD: pins RD0-RD7

Note that some of the pins of each PORT are multiplexed to do different functions when needed. For example PORTA pin RA4 is multiplexed with the Timer0 module clock input to become the RA4/T0CKI pin while other pins of PORTA are multiplexed with analog inputs AN0-AN4.

There’s also – attached with each PORT – a data direction register (TRIS_) that controls the direction of data (input or output) of each pin of that port. For example having TRISA cleared (=0 which is the default) will configure all pins of PORTA as output while setting TRISA=15 will configure RA0, RA1, RA2 as input while other pins of that port are by default output.

There are a lot to say about the µC above and it’s all in its data sheet. However the information given above is enough to write our first program.

My first µC control program

Language: C

Compiler: MicroC 8.2.0.0

Design Software (Simulator): Proteus 7.5 SP3

firstProgram.c

mcfirstprogramcode

The program is relatively simple. Its purpose is to have a seven segment blinking.

Design on Proteus

mcfirstprogram

Finally, I’d like to say that there are some helpful Development Boards like EasyPIC5 provided by MikroElektronika™ which is the same company that provides MikroC the compiler I used above.

Resources:

Video Demonstration

MicroC v8.2.0.0 Compiler

Design and program files


Hope this is of benefit to you.

– Ahmed Abdullah

  1. August 30, 2009 at 6:15 AM

    That’s really an interesting and beneficial post 🙂

  2. mostafa mohamed zaky
    August 31, 2009 at 10:28 PM

    well done moro
    u have to study hard

  3. Ahmed Ragab
    September 1, 2009 at 5:21 AM

    great work Moro

    could you complete the tutorial series ?

  4. pepsii
    October 6, 2009 at 3:30 AM

    really, it seem hard and intelligant work but u know i have alittle knowledge in that field with more success my bro pepsii

  5. samawat
    December 9, 2009 at 8:43 PM

    please compelet in explain the component of the microcontroll in detial

  1. No trackbacks yet.

Leave a comment