GETTING STARTED WITH PICs
■ FIGURE 4. The MPLAB IDE Window.
The output window will gain a
PICkit 2 tab and show the status of
the PICkit 2 Programmer. You should
see the following text displayed in the
Found PICkit 2 - Operating System
Target power not detected - Powering
from PICkit 2
PIC16F690 found (Rev 0x4)
PICkit 2 Ready
The message will indicate the
operating system in the PICkit 2
Programmer, where the development
board is receiving power from, and
which MCU it detected. After this, a
message stating the PICkit 2 is ready
to program will be displayed. At the
top right of the MPLAB window, the
control buttons for the PICkit 2 Programmer should also
appear, as shown in Figure 7. These buttons allow you to:
MCU, and then program and verify it. After this, the
programmer is ready to run. Click on the rising-edge button
to bring MCLR to VDD. The LED should start to flash.
1) Program the complete part.
2) Read program memory.
3) Read EEPROM.
4) Verify that the program inside matches what you
5) Erase the complete device.
6) Verify that the complete device is erased.
You also have control over the MCLR reset line on
the MCU, which are the rising- and falling-edge icons. By
clicking on the rising-edge icon, you allow the PIC16F690
MCU to run the program. The last icon is a miniature
PICkit 2, which just allows you to re-check the status of
To load the BLINK.hex file into the PIC16F690 MCU,
simply click on the first icon button and the PICkit 2
Programmer will handle the rest. You will see the status
in the PICkit 2 output window. It will first erase the
To get through all of this without errors is a very good
start. However, chances are you might see a few errors, or
get all the way to the end and find that the LED does not
flash. I’ll try to cover a few of the more common errors
that the beginner might run into. The first involves the
PICBASIC PRO compiler and the MPLAB IDE/Windows
structure. For some reason, no matter how I changed the
path structure in Windows or reset things in the MPLAB
setup screens, I would encounter the error shown in
Figure 8 when I first tried to run the PICBASIC PRO
compiler in the MPLAB IDE.
In fact, I received a whole list of errors that started
with the line “Cannot open file … P16F690.INC.” This is
LISTING 1: BLINK.BAS Sample Program
■ FIGURE 5. PICkit 2
‘ Example program from manual to blink and LED connected
‘ to PORTC.0 about once a second.
ANSEL = 0
CM1CON0 = 0
CM2CON0 = 0
loop: High PORTC.0
‘ Initialize A/D ports off
‘ Initialize Comparator1 off
‘ Initialize Comparator2 off
‘ Turn on LED connected to PORTC.0
‘ Delay for 5 seconds
‘ Turn off LED connected to PORTC.0
‘ Delay for 5 seconds
‘ Loop back and blink LED forever
May 2008 99