[?] Subscribe To This Site

XML RSS
Add to Google
Add to My Yahoo!
Add to My MSN
Add to Newsgator
Subscribe with Bloglines


Custom Search

Sign up for MicroZine:
''The'' Microcontroller Newsletter


:
:
Don't worry -- your e-mail address is totally secure. I promise to use it only to send you MicroZine
Enter your first Name and primary email address in the form above:

And receive absolutely FREE a full project for:


"Measuring Analogue Voltages
Without An ADC"

(Using only one pin).

Instant Download:
You Can
Get It Right Now

Warning: This project could be Removed
at any time.  

It will NOT be
available indefinitely SO

To avoid
disappointment get it:

Now



Remember this is a project with full description and fully debugged C Source code - and it's not available from the main website.

You can only get it through this newsletter.


To get exclusive access Enter your first name Name and primary email address Now in the form above.:

But wait !

There's more...

You'll receive more
free and exclusive reports as well as site information and site product updates.

Scroll up to the form above and sign up NOW.  Don't forget it's FREE and if you don't like it you can unsubscribe at any time.

Click Here Now to use the form above to get your Valuable information absolutely free.



Social Bookmarking
Click & Add:
add to BlinkBlink
add to Del.icio.usDel.icio.us
add to DiggDigg
add to FurlFurl
add to GoogleGoogle
add to SimpySimpy
add to SpurlSpurl
Bookmark at TechnoratiTechnorati
add to YahooY! MyWeb
Readers comments

"I wanted to thank
you so so so much
for all the information
you have provided in
your site it's

SUPERB and FANTASTIC."


- Ranish Pottath


"This site really is
the best and my favorite.
I find here many useful
projects and tips."

- Milan

bursach<at>gmail.com

Learn PIC C Now
Wondering how to program your next project using C and need a great start?


"Awesome site,
very, very easy and nice
to navigate!"


- Matt
matt_tr<at>
wolf359.cjb.net


"I am a newbie to PIC
and I wanted to say
 how great your
site has been for me."


- Dave

de_scott<at>bellsouth.net

Learn Microcontrollers
"Interested in
Microcontrollers?"


Sign up for The
Free 7 day guide:

FREE GUIDE : CLICK HERE

"Your site is a great
and perfect work.
congratulations."


- Suresh

integratredinfosys<at>
yahoo.com

"I couldn't find the correct
words to define
yourweb site.

Very useful, uncovered,
honest and clear.

Thanks so much for
your time and works.
Regards."


- Anon





PIC16F84 Introduction.

The 16F84 is deserves looking at
because it is the GranDaddy of
PIC Microcontrollers but you should
not use it for new designs (see Below)...

Sponsored Links...
Even though the PIC16F84 is getting on a bit it is one of the most popular of the PIC microcontrollers and there are hundreds of circuits for it on the web but it does have limited memory, RAM and peripherals.

It is an 8 bit mid-range microcontroller having 1024 words of program memory, 68 bytes of RAM and 64 bytes of long term EEPROM storage.

The most useful feature of this microcontroller is that it's flash based so  it can be re-programmed many times.  In addition if you design the circuit correctly you can re-program it in-circuit without removing the chip using (ICSP) In Circuit Serial Programming.


Since it is an older device you can not program it using a Low Voltage Programmer (which is easier since an LVP needs very few components) you must use a High Volt Programmer - you can find an HVP circuit here.

Warning the 16F84 is obsolete.

You can still buy it but it's getting more expensive.

The 16F88 has the same pinout and is cheaper.

Even so if you already have a PIC16F84 then this introduction will show you how to program it with a ICSP programmer.


For a comparison between the 16F84 and some other PIC micros (including the 16F88) you can compare bubble diagrams showing PIC features visually here.

In fact the 16F88 is a good PIC micro to progress onto after starting out on the 16F84 as the 16F88 is backwards compatible with the 16F84 -it has the same number of pins and same pin functions.  Some pins are more flexible but still backwards compatible with the 16F84.

Note you can't easily go from a 16F88 as the 16F88 lets you use pins in a more flexible manner e.g. the 16F88 has an internal oscillator and you can use the crystal oscillator pins either for an external crystal oscillator (as in the 16F84) or as normal I/O pins.  This lets the 16F88 have 16 I/O pins as compared to the 16F84 with 13 I/O pins.

For this introduction you need a PIC programmer with an ICSP output connector.

You'll also need to download the C compiler for source code re-compilation (if you want the re-compile code). The compiler is free for the small amounts of code used here.

Jump to Circuit diagram.


PIC 16F84 Index
Features
Programming
ICSP Connection
Power Supply
Oscillator modes
Starter circuit and software

Before you start have a look at the following for background info:
 

PIC16F84 Features

The 16F84 is packaged in an 18 pin chip and although it has limited peripherals it is usable in many circuits. Here are its features and a short comparison.

Comparison 16F84 16F88
Program Memory 1024 Words 4096 Words
RAM 68 Bytes 368 Bytes
EEPROM 64 Bytes 256 Bytes
I/O PINS 13 16
PERIPHERALS 1 6
List of peripherals Timer:1 Timers:3, ADC 7 i/ps, 2 Analogue comparators, CCP,SSP, USART

Sponsored Links...

The following bubble diagram shows the major peripherals and features of the 16F84 in a visual format:

12F675 bubble diagram

Note: you can compare this chip (using bubble diagrams) to some others used on this site by clicking here.

PIC16F84 Programming

You can program the chip using the same ICSP programmer used for the other PIC chips with the circuit shown below and use ICPROG (PC software) to control the programmer hardware from the PC.

You can find a programmer circuit here and information on using ICPROG here.

PIC16F84 : ICSP connections:

16F84 ICSP connections

PIC16F84 Power Supply

If you don't have a bench power supply then you can use this circuit.

five volt power supplyx

All you will need is a power supply block with dc output (greater than 8V and no more than 35V) or a 9V battery to plug into CN1.  

Note: It is best to use the 5V power supply circuit as it not only correctly regulates the dc voltage but it protects your PIC chip.  The input voltage can go up to 35V without damaging the 7805 (although the power dissipated by the 7805 will increase for higher input voltages i.e.it wail get hot!) .

7805 pinout

PIC16F84 Oscillator modes

There are four oscillator modes either using an resistor and capacitor pair or a crystal.

PIC16F84 Flashing an LED

16F84 flashing led schematic

Note: The LED current limiter resistor (1k) is not ideal it just lets you see the led (you don't need maximum current to see it) - Replace the 1k with a 220 if you want brighter output.

PIC16F84 Flashing LED

The following code flashes the LED.

Download the source file and hex files here.

You can use the hex file directly to program the 16F84 then it will flash the led on and off or you can re-compile the files using the Mikroelectronika compiler MikroC. 

Some of the PIC16F84 C source code is :


//////////////////////////////////////////////////////////////////////
// Start here for PIC16F84 led flash
//
void main() {
unsigned short pa=0;
unsigned int i;


  PORTA = 0;
  TRISA = 0; // o/p   - sets analogue pins to digital output

  TRISB = 0;
  PORTB = 0;

  while(1) {

     pa=~pa;
     if (pa) {
        setBit(PORTB,3);
     } else {
        resBit(PORTB,3);
     }
     Delay_ms(100);
  } ; // infinite while loop
}

First of all the ports are initialized using TRISA, TRISB which set up the direction of pins for each port - in common with all the other PIC Micros you can change the port direction at any time using  a TRIS keyword (which is just another register location).  

Setting a bit in the TRIS register to zero sets the pin direction to an output.  Here all bits are zero for TRISA and TRISB so all PORTA and PORTB bits are set as outputs.  Then PORTA and PORTB are initialized to logic level zero.

As you can see main() is a very simple it alternately sets and resets bit 3 of PORTB

Try changing the delay time in the delay_ms statements to a smaller or larger value, re-compile and re-program the chip to see the effect.

This gives you the basis for using the PIC16F84 so that you can move on to more complex projects.

Sponsored Links...


Jump from PIC16F84 Introduction to
Best-Microcontroller-Projects Home Page



Don't forget to Sign Up for your

Microcontroller Newsletter

With "Essential tips and techniques",

..."New Site Info" and more...

Including a free project :

How to drive an LCD and 12key keypad using "Only One 8 Bit Port" with no interface logic!...

(Works for any microcontroller)

This costs you : Nothing...
Just fill out the form below and you'll get full C source code and project schematic and description.



:
:
Don't worry -- your e-mail address is totally secure. I promise to use it only to send you MicroZine
Google

  Best Microcontroller projects.










<-- --> <-- -->