You are on page 1of 6

Getting Started

Objective Programming the PIC16F690, using PICKit 2


programmer
Equipment PICKit 2 programmer, PIC16F690, 10x330
ohm resistors, 10X LED bar graph, breadboard,
wires.
Alternatively, PICKit2 programmer and Low
Pin Count Demo board (LPC demo board)
Software PICKit 2, MikroC. Microsoft Vista Users
please see the instructions for installing
MikoC.

ATTENTION!!!! In the schematic shown later, the ground connection on PIN 20 of the PIC16F690 is
missing. You need to connect the pin to ground or eles you will get unpredictable results.


NOTE: MICROCHIP Home page has changed. Here are the direct links to PicKit2 software
If you already have .NET (almost all of the computers have it) use this link: Setup if you have .NET
If you do not have .NET then use this link Setup + .NET
To see the page where I got the links click here: Microchip search results
Or do a google search on: Microchip Pickit 2 software

Images



Preparation
1. Download and install the latest PICKIT2 software from Microchip website: (this
link may not work. See earlier note) http://www.microchip.com. From the main
click on Development Tools and then PICkit2 Debug Express and scroll down
to Downloads
2. Download and install the latest version of MikroC from http://www.mikroe.com/en/
compilers/mikroc/pic (I currently use version 8. The most recent version is 9. I will
upgrade my computer soon). If you use Microsoft Vista, locate the folder where MikroC is
installed (default: C:\program files\Mikroelektronika) and make sure the folder is owned
by you. You need to do this since Vista will not let you update configurations. I have
found that with Vista the easiest solution is not to fight Microsoft but to install MikroC in a
subfolder of public documents
Procedure
1. Wire the circuit as shown in figure 1. Note that pin 1 on PICKit 2 is identified by a white
triangle. You can power the circuit either from your computer's USB port or you can
externally power it by connecting a regulated 5 V supply to Vdd. For this experiment,
we will be powering the circuit from the USB port. Do not connect the PICKit2 to the
USB port of the computer till you have completed the wiring. If you happen to have
the low pin count demo board, then the above circuit is already part of the
board. Just connect the board so the two white triangles line up.
2. Connect PICKit2 to the USB port and run the PICKit2 program. The program should
automatically recognize the programmer and the chip. If not, double check your wiring.
See figure 2.
3. If you are using the programmer for the first time, you may have to upgrade the operating
system that is in the programmer. If the update fails the first time, quit the program and
restart and try again. The operating system is typically called PK2VXXXXXX.hex.
4. Start MikroC
5. From the project menu select New Project and enter the following
Project name: LAB1.
Project path: A new folder
Device: PIC16F690
Clock: 004.00000
Device Flags: MCLRE_OFF, WDT_OFF, INTRC_OSC_NOCLKOUT
6. Enter your first C program shown in the code section.
7. Build your project from the project menu. Make sure you fix any syntax errors you may
encounter. This will create a hex file called LAB1.HEX in the project folder you specified.
8. Go back to the PICKit2 program and from the File menu select Import Hex.
Find the LAB1.HEX file you created in the previous step and click Open From
the Programmer Menu, select Write Device (or you can click on the button
labeled Write). This will program your processor. You can automate this step by
pressing on the button labeled Auto Import Hex + Write Device.
9. Power your processor from PICKit2 by checking On under VDD PICKit2. See figure
2 for details. You should see the LEDs blink in a pattern.

Code: LAB1.c
// Okay! This is not the best way to do this.
// But it gets the job done...
void main() {
ANSELH=0; ANSEL=0; // Turn of A2D
TRISC=0x00; // Set data direction
PORTC=0x00; // Start with zero
while(1) {
PORTC +=1; Delay_ms(250);
PORTC +=2; Delay_ms(250);
PORTC +=4; Delay_ms(250);
PORTC +=8; Delay_ms(250);

// Skip the next 4 lines if you are using LPC demo board
PORTC +=16; Delay_ms(250);
PORTC +=32; Delay_ms(250);
PORTC +=64; Delay_ms(250);
PORTC +=128; Delay_ms(250);


PORTC -=1; Delay_ms(250);
PORTC -=2; Delay_ms(250);
PORTC -=4; Delay_ms(250);
PORTC -=8; Delay_ms(250);


// Skip the next 4 lines if you are using LPC demo board
PORTC -=16; Delay_ms(250);

PORTC -=32; Delay_ms(250);
PORTC -=64; Delay_ms(250);
PORTC -=128; Delay_ms(250);
}
}







Figure 1: Circuit schematic. LPC demo board has this circuit but with only 4 LEDs





Figure 2: Opening screen for PICKit 2 when connected to an unused processor.









Figure 3: PICKit 2 screen after writing a HEX file

You might also like