Datasheet
PICkit™ 3 Debug Express Lessons
© 2009 Microchip Technology Inc. DS41370C-page 21
3.2 LESSON 2: BLINK LED
This lesson discusses the Configuration bits of the PIC18FXXXX microcontrollers and
how to set them in an MPLAB C source file. It also presents using a library function and
shows how delays can be used to blink an LED on the demo board.
3.2.1 Opening the Lesson 2 Project and Workspace in the MPLAB
IDE
This and the remaining lessons already have a project and workspace defined. To open
the workspace for Lesson 2, select menu File > Open Workspace…
in the MPLAB IDE.
Browse to the directory C:\Lessons\PICkit 3 Debug Express Lessons\02
Blink LED and open the 02 Blink LED.mcw file.
Before opening the new workspace, the MPLAB IDE will prompt you to save the current
workspace. It is generally a good idea to click Yes. Afterwards, the new workspace and
project for Lesson 2 will open.
3.2.2 Defining Configuration Bit Settings in the Source Code
Configuration bits are fuses in the PIC18FXXXX microcontrollers that are programmed
along with the application code to set up or “configure” different microcontroller
operating modes and enable or disable certain microcontroller features. For example,
in the PIC18F45K20 the Configuration bits select such features as which oscillator
option to use, whether the processor runs in Traditional or Extended mode; whether to
use the Brown-out Reset circuit and which voltage to trip at; whether the Watchdog
Timer is enabled or disabled and which options to use, and if the Flash memory
code-protect feature is enabled, among many other options.
Note that some features, such as the Watchdog Timer, can be configured so that it may
be enabled or disabled by software in the Special Function Registers while the
application code is executing. For detailed descriptions and information on the
PIC18F45K20 Configuration bits, see Section 23.1 “Configuration Bits” in the data
sheet, under the section heading 23.0 “Special Features of the CPU”.
In the Lesson 2 source code, all Configuration bits are defined at the top of the 02
Blink LED.c file, as shown in Figure 3-12.
Key Concepts
- Open existing project work spaces by selecting File > Open Workspace…
in the MPLAB IDE.
- Configuration bits are special purpose fuse bits that set PIC microcontroller
modes of operation and enable or disable microcontroller features.
- A number of libraries are included with the MPLAB C compiler with
predefined and compiled functions. The “MPLAB C18 C Compiler Libraries”
document (DS51297) provides detailed information on all included libraries.
- Delays can be created to time events by using software loops.