PIC:Introduction to PIC with simulation in Proteus.

Post image of PIC:Introduction to PIC with simulation in Proteus.
Filed in Featured , MCU , PIC 2 comments

There are many microcntrollers running in market, but only those survive which have competitive price, features and architecture. PIC is one of them which is one of the best micronctrollers in the world, along with AVR.



A long, long time ago General Instruments produced a chip called the PIC1650, described as a Programmable Intelligent Computer. This chip is the mother of all PIC chips, functionally close to the current 16C54. It was intended as a peripheral for their CP1600 microprocessor. Maybe that is why most people think PIC stands for Peripheral Interface Controller. As far as I know Microchip has never used PIC as an abbreviation, just as PIC. And recently Microchip has started calling its PICs microcontrollers PICmicro MCU’s.

Tools Required:
Following are the tools and software required for this thutorial;

- PIC16F84 – Microcontroller
- Proteus – Simulator
- CCS C – Compiler

A lil’ about PIC16F84

In this tutorial we will be using a small PIC controller named 16F84. It is good for beginners as it includes all the basic features of PIC architecture.

Following are its features;

Operating Speed: Max 20 Mhz.
Input/Output Pins: 13
Current Source/Sink via I/O Pins: 25mA
Interrupts: 4
Timers: 1 Timer of 8-Bit
Watchdog Timer: Yes, with On-Chip RC Oscillator for reliable operation.
In-Ciruit Serial Programming via 2 Pins.
$6.45 (from SparkFun)



To learn more about PIC16F8a read the post Article: PIC16F84 – Features and Circuit.

Programming and Compiler

CCS C is a very widely used compiler for PIC. It offers programming of almost all the PIC Microcntrollers, along with its appealing and friendly interface. There is also a EBook I have posted here, which will help you alot with this compiler.

We will write a program which will toggle a LED with 1 second delay.

Step 1
- Run the CCS C Compiler and Create a new file.
- Save the file in your desired location.
- Copy the following code in compiler

#include <16F84.h>
#use delay(clock=20000000)

void main ()





CCS C Compiler

CCS C Compiler

Assuming you are familiar with C syntax, the code is a very easy one.
#include <16F84.h> attaches the header file for our controller 16F84.
#fuses HS,NOPROTECT declares fueses such as HS which means High Speed Oscialltor. If yuo are running on clock speed more than 8MHz, then you HS fuse is to be added.

while(1) is used to keep the program running in an infinite loop, to keep it alive.
output_toggle(PIN_B0) is used to toggle the output state of the pin B0. For example, if before executing the statement pin B0 was low, it will go high after execution.

delay_ms(1000) provides delay of 1000 ms i.e 1 sec.

These two lines do all the magic, change the state and provide delay.

- Press ‘F9′ to compile the code. It will save the HEX file with the same name as code. We will use the HEX will to download it into our controller.

Step 2

Second step is related to downloading the HEX file into the controller. There are many programmers available in the which serves the purpose. Or you can build your own. For beginners I advice to have a cheap parallel port programmers available in your local store. And if your enthusiast to build your own, please check the following links;





Whatever programmer you will be using, it will have a software. Select the HEX file we just created and download it into the controller.

And if you are curious, and want to test your programming asap. Than start Proteus and have fun in it.

Step 3

In this step we will simulate our circuit and code in Protues. Protues is a simualtor software which is capable to simulate any circuit and scenario. Mainly, it is best for microcontrollers.

- Run Proteus and get familiarized with the tools around.
- Press ‘P’ and it show a window to select device use.
- First we will add controller i.e 16F84. Type ‘PIC16F84′ in keywords text box. It will automatically show the controller results. Select it and press OK.

Deivce Select Window

Deivce Select Window

- Now in the design area, double click where you want to put the controller.
- Also select a ‘led-red” LED,  ’10watt22r’ resistor and ‘crystal’  using previous step from Device Select Window.
- For ground connection needed for LED, right click in the design area . Goto Place -> Terminal and select Ground. This will place a ground symbol.
- For Vcc connection, do the same and select Power from Terminal menu.
- Connect all the devices as shown below;

Circuit in Proteus

Circuit in Proteus

- By default the crystal is set at 1MHz. Double click it, and enter 20MHz in frequency text box.

- As in actual controller we need to download the HEX file generated in Step 1. Same way we will give that HEX file to proteus to simulate the program. Double-click controller and click browse icon infront of ‘Program File’ text box.
- Select the compiler generated HEX file and press OK.
- Now everything is set to go. Press ‘F12′ to start the simulation. The LED will start blinking if everything goes fine :)

Step 4

Now, you are familiarized with PIC and Proteus environment.   Read the following books which are master in their field.

- For PIC Programming: Programming PIC in CCS C
- For PIC Simualtion in Proteus: Interfacing PIC Microcontrollers – Embedded Design by Interactive Simulation

Step 5

Enjoy PIC-InterfacING =)


We now have a video which demnostrates the toggling example with PIC16f877.

Posted by hamzaazeem   @   15 September 2009 2 comments
Tags : , , , , ,

Share This Post

RSS Digg Twitter StumbleUpon Delicious Technorati


  • Kumail Ahmed

    Good Article............

blog comments powered by Disqus
Previous Post
Next Post