Microcontroller is a combination of μP, Data memory, and some devices like Input Output pins(I/O), A/D converter, etc in a single package. So our work becomes easy and only thing we need to do is programming the microcontroller.
Mircocontroller: This is general structure of a microcontroller. This is Harvard architecture. this also varies with different microcontrollers.
The output ports are the only way to express the result of the program to the outside world. In the output ports, the result will appear as +5V and OV as I said early. In order to see that voltage at the output pins we connect some components like Bulb or LED to these pins so that it will glow when +5V is at the output pin.
I said that devices are connected to microcontroller(μC) but how do we communicate with it? Simple! Each device have some special registers assigned to it. So if you can configure and access that device using those registers. Each device inside μC is associated with one or more registers.
Let us consider the device I/O ports which communicates with external world. In a microcontroller, a pin can be programmed to either Input or Output which is determined by a special register called “TRIS” register. The I/O ports are named as Port A, B, C etc. Each port is associated with a “data register” to which a data is written when it acts as output and read when it acts as input.
PIC microcontrollers
Now we move on to PIC Microcontroller which I had chosen. In PIC, there are three types namely,
- low end
- midrange
- high end.
We are going to see the mid range PIC microcontroller.
(this type of PIC is widely used in all fields, industry, student projects, hobby projects, etc. especially pic 16F877A)
There are two types of program memory.
ROM - once a program is written you cannot erase it.
EPROM – you can rewrite programs more than 1000 times.
Even in EPROM there are many kinds depending on technology of the memory. Here we use a FLASH EPROM.
You cannot write the program directly into the device. First you have to write the program in computer and test it. Then it can be written into the μC.
In order to write the program into μC, we need special hardware called Programmer.
We need to write the program for specific purposes of real time applications and problems. This real time problem should be mathematically modeled or logically modeled, then it is very easy to write a program for it.