PIC16F877A Introduction and Features
PIC16F877A Introduction and Features
PIC16F877A Introduction and Features
features
The PIC microcontroller PIC16f877a is one
of the most renowned microcontrollers in
the industry. This controller is very
convenient to use, the coding or
programming of this controller is also
easier. One of the main advantages is that
it can be write-erase as many times as
possible because it use FLASH memory
technology. It has a total number of 40
pins and there are 33 pins for input and
output. PIC16F877A is used in many pic
microcontroller projects. PIC16F877A also have many application in
digital electronics circuits.
PIC16f877a finds its applications in a huge number of devices. It is
used in remote sensors, security and safety devices, home automation and
in many industrial instruments. An EEPROM is also featured in it which
makes it possible to store some of the information permanently like
transmitter codes and receiver frequencies and some other related data. The
cost of this controller is low and its handling is also easy. Its flexible and can
be used in areas where microcontrollers have never been used before as in
coprocessor applications and timer functions etc.
PIN CONFIGURATION AND
DESCRIPTION of PIC16F877A
As it has been mentioned before, there are 40 pins of this microcontroller IC.
It consists of two 8 bit and one 16 bit timer. Capture and compare modules,
serial ports, parallel ports and five input/output ports are also present in it.
PIN 1: MCLR
The first pin is the master clear pin
of this IC. It resets the
microcontroller and is active low,
meaning that it should constantly
be given a voltage of 5V and if 0 V
are given then the controller is
reset. Resetting the controller will
bring it back to the first line of the
program that has been burned into
the IC.
A push button and a resistor is connected to the pin. The pin is already being
supplied by constant 5V. When we want to reset the IC we just have to push
the button which will bring the MCLR pin to 0 potential thereby resetting the
controller.
PIN 2: RA0/AN0
PORTA consists of 6 pins, from pin 2 to pin 7, all of these are bidirectional
input/output pins. Pin 2 is the first pin of this port. This pin can also be used
as an analog pin AN0. It is built in analog to digital converter.
PIN 3: RA1/AN1
This can be the analog input 1.
PIN 4: RA2/AN2/Vref-
It can also act as the analog input2. Or negative analog reference voltage
can be given to it.
PIN 5: RA3/AN3/Vref+
It can act as the analog input 3. Or can act as the analog positive reference
voltage.
PIN 6: RA0/T0CKI
To timer0 this pin can act as the clock input pin, the type of output is open
drain.
PIN 7: RA5/SS/AN4
This can be the analog input 4. There is synchronous serial port in the
controller also and this pin can be used as the slave select for that port.
PIN 8: RE0/RD/AN5
PORTE starts from pin 8 to pin 10 and this is also a bidirectional input output
port. It can be the analog input 5 or for parallel slave port it can act as a
read control pin which will be active low.
PIN 9: RE1/WR/AN6
It can be the analog input 6. And for the parallel slave port it can act as the
write control which will be active low.
PIN 19,20,21,22,27,28,29,30:
All of these pins belong to PORTD which is again a bidirectional input and
output port. When the microprocessor bus is to be interfaced, it can act as
the parallel slave port.
There is a register named as TRIS which controls the direction of ports. For
different ports there are different registers such as TRISA, TRISB etc.
If we set a bit of the TRIS register to 0, the corresponding port bit will
act as the digital output.
If we set a bit of the TRIS register to 1, the corresponding port bit will
act as the digital input.
For example to set the whole port-b to output we can write the program
statement as:
TRISB=0;
Now the port will act as the output port and we can send any value on the
output such as
PORTB=0XFF;
FF represents all 1s in binary i.e. FF=11111111, now all the pins of port b
are high. If we connect LEDs at all the pins then they will all start glowing in
this condition.
If we want to negate the values of the port b we can use the statement:
PORTB=~PORTB;
void main()
}while(1);
}
Circuit diagram for flashing LED WITH
PIC16F877A
Design this circuit in proteus. Connect the pins with the source, ground and
oscillator as explained in the pin description section. An LED is connected on
pin 33 RB0, a resistor is used to limit the current and to prevent the LED from
burning up. Write and compile the program in mikro C pro. Burn the
controller with the hex file by double clicking on the controller in proteus and
run the circuit successfully. Best way to learn any microcontroller is to
check its data sheet.