■ FIGURE 6. PICkit 2 Programmer
MCU you are using. In this case, the
file is named 16F690.inc. You will find
it in the PBP or PBPDEMO directory,
where you installed the PICBASIC
PRO compiler. The file will contain a
_config line, like the example below:
__config _INTRC_OSC_NOCLKOUT & _WDT_ON
& _MCLRE_ON & _CP_OFF
■ FIGURE 7. PICkit 2 Control Buttons.
why I suggest you use the project wizard the first time you
create a project, and include the P file for the part you are
using to prevent this error from occurring. If you forget,
you can add a copy of the P file later, but it has to be put
into the same directory as the .bas file you created.
Another beginner error that crops up often involves
the configuration settings. Outside the structure of your
program, the PIC16F690 MCU has certain bits that are
set at program time to control the watchdog timer, the
power-up timer, the oscillator selection, and more. All
of the options for the part can be seen by clicking on the
Configure>Configuration bits menu selection in the MPLAB
IDE (see Figure 9). You can manually select the options, or
click on the little box in the upper-left corner to allow the
compiler to set these in code.
I recommend that you set the options in code, because
they will then be embedded in the .hex file used to program
the MCU. The PICBASIC PRO compiler puts that configuration setup in a separate file that it calls at compile time.
The setup will be in an .inc file that has the name of the
This line in the 16F690.inc file is
where the PICBASIC PRO compiler
gets the information on how to set the
configuration bits inside the .hex file.
In this example, the internal RC
oscillator is used as the system clock.
This is what I recommend for the
PIC16F690 MCU, but you can change
it to an external oscillator if you need
more accuracy. For the beginner, I
would not worry about all of this — just
know that it exists. However, if you find
that your LED does not flash, then you
might want to make sure the settings
are adequate for what you need. For
example, if you are developing on a
board that has an external 20 MHz crystal and you keep
finding that the program is running slow, you might have
the internal oscillator set up in the configuration.
One of the biggest errors I’ve seen with beginners is the
exact opposite-they think they are using the internal oscillator,
but the configuration is set to run from an external oscillator
(i.e., _XT_OSC). The MCU won’t run without a clock.
I covered a lot of ground in this article. However, if you
use this setup and get that first LED to blink, you are ready
to start creating more software programs without having
to worry about all of the hardware setup connections. What
I suggest you do is modify the PAUSE command value to
get the LED to flash faster or slower. Then, perhaps try to
duplicate the code and get it to flash a second LED. If you
alternate the high and low commands, you can make the
LEDs flash back and forth, like lights at a railroad crossing.
Some readers have shared that they think my column
is good, but they sometimes get lost trying to follow along.
They feel I’m writing to a bunch
of engineers, rather than to
hobbyists. I understand this
completely, however this is a
normal reaction as my subject
matter can seem complicated to
■ FIGURE 8. Compiler Error.