To prepare and test your system for use with the programs in this library collection, perform the following steps:
- Software installation - Install the necessary software on a Windows-based PC. All the necessary software is free.
- Hardware bring-up - Build or purchase a PIC24-based board.
- Test the PIC - Using the bootloader, program the PIC with the echo program and test. This verifies proper installation of your hardware/software setup.
After this, view a wide range of
videos to use your working system in a number of practical ways.
Software installation
- Download and install the latest version of the MPLAB IDE (the Full Release Zipped Installation under the
Downloads section near the bottom).
- Download and install the latest student version of the MPLAB C Compiler for PIC24 MCUs. Notes:
- MPLAB must be installed before the compiler
- Accept all the defaults when installing; in particular,
click "Yes" to the "Modify Environment?" question.
No new program will show up on your start menu; instead, the compiler
will now be available in MPLAB. That enables the compiler to properly
register itself with MPLAB.
- See the BugMeNot for a userid/password if you don't want to create one.
- If you do not have the Microsoft .NET framework installed, download and install the .NET runtime by visiting
the Microsoft Download Center and searching for '.NET runtime'. Install version 2.0 or later. If you're not sure if the .NET framework is installed, try running the bootloader in the following step; if it fails, download the .NET framework.
- Download and unzip the latest version of the PIC24 library collection. Notes:
- We recommend installing to a directory without spaces; on pre-Vista windows, installing on the desktop violates this rule, since the desktop directory is "C:\Documents and settings\...".
- Test the bootloader, a .NET application, by executing
bin\winbootldr.exe. A GUI should pop up. If that fails, consult the bootloader documentation for troubleshooting steps.

Hardware bring-up
There are several options for acquiring the hardware necessary to run a PIC24:
Wiring up a PIC24
- Begin by following the prototyping walk-through, also available as a video.
- Using an ICSP programmer, program the bootloader onto your PIC.
- Install the FTDI drivers (use the setup executable link) to communicate with your PIC via an FTDI cable.
SparkFun PIC24 breakout board
Purchase a
SparkFun PIC24 breakout board. This comes with bootloader firmware already installed as well as the 'reset.c' application (code/chap8/reset.mcp) with the bootloader's baudrate set to 57600. Then, watch the
video or read
instructions on using it. The brief version:
- At a minimum, install 0.1" pitch headers in the 6-pin connection for use with an FTDI cable. Installing headers in the remaining positions allows access to much of the functionality of the chip.
- Install the FTDI drivers (use the setup executable link) to communicate with your PIC via an FTDI cable.
- For advanced users, purchase a SparkFun ICSP connector for use with an ICSP programmer.
Explorer 16 board
The
Explorer 16 is a development board available from Microchip - it
comes in 100 pin and 44 pin versions. This
video discusses its use with the library. The CPU is set by a plug-in
module, of which each board has a few available. The directory
code/explorer16_100p contains a few examples for the Explorer16/100
pin board. These projects can use the source files from the other
directories, but the macro
HARDWARE_PLATFORM=EXPLORER16_100P either must defined in the
include/pic24_all.h
file or it must be added to the MPLAB project (Use Project->Build
Options-> Project, click on the MPLAB C30 tab, and in Macro
Definitions click 'Add', and add EXPLORER16_100P). The
HARDWARE_PLATFORM=EXPLORER16_100P macro causes the default UART to be UART2 since that is what is used on
the Explorer16/100 pin board. It also causes the clock option to use
the external 8 MHz oscillator, with the PLL used to produce a 16 MHz
F
CY for PIC24F devices and 40 MHz F
CY for the PIC24H.
Microchip Microstick
The
Microchip Microstick is a new low-cost platform for PIC24 and dsPIC33 experimentation. This
video discusses its use with the library. It is a breakout board for 28-pin devices that offers on-board debugging and in-circuit programming (like a PICkit). The board plugs into a breadboard, with access to all pins for maximum versatility. This
page shows how to use the Microchip Microstick with the book examples.
The Dangerous Prototypes web server
The library provides support for the
Dangerous Prototypes web server, by defining
HARDWARE_PLATFORM=DANGEROUS_WEB. See the instructions above for the Explorer 16 board on how to incorporate this in to the library.
The Microchip 16-bit 28-pin Starter Board
The library provides support for the
Microchip 16-bit 28-pin Starter Board, by defining
HARDWARE_PLATFORM=STARTER_BOARD_28P. See the instructions above for the Explorer 16 board on how to incorporate this in to the library. Thanks to
István (icserny at gmail dot com) for contributing this code!
FTDI cable
A simple solution for connecting your PIC24 to a PIC is an
FTDI TTL-232R-3V3 USB to TTL level serial converter cable. One end plugs into a PC's USB port while the other provides TTL-compatible serial I/O lines which can be directly connected to your PIC's serial I/O pins. In addition, the cable provide +5V, which can be used to power your board through a regulator. For more information, see the
FTDI datasheet. Sources:
- Digi-key, Mouser, etc.
- SparkFun sells their own FTDI board, which provides the same functionality as the cable.
ICSP programmers
If you purchase an unprogrammed PIC24 chip, you'll need to program it with the bootloader, after which the bootloader can be used to program the PIC24 with your code. If the bootloader gets corrupted, it must be reprogrammed. Finally, advanced users may which to remove the bootloader and program the PIC24 via ICSP. Several options exist:
- Microchip sells the PICkit2, and PICkit3, low-cost programmers; only the PICkit2/3, not the various starter kits, are required. This is the solution used by the authors of this site. The direct link to buy just a PICkit2 by itself (part number PG164120) from Microchip is here. This video discusses using the PICkit2 with PIC24 CPUs.
- A second, more expensive option is the Microchip ICD2.
- Third-party programmers can (possibly) be used.
To program your PIC with the bootloader using a PICkit2:
- Install the PICkit 2 software from Microchip's website.
- Connect the PICkit 2 programmer up to your board. The arrow on the PICkit corresponds to pin 1.
- The PICkit may need to have an OS downloaded. If the PICkit
software complains, click Tools -> Download PICkit 2 Operating
System.
- In the PICkit software, select Device Family -> PIC24.
- If the PIC is not automatically found, press and hold the MCLR
button on the board. When you release the MCLR button, click the "Read"
button in the PICkit software.
- Check to make sure your device is properly recognized and that the
- Load on the bootloader via File -> Import Hex. Be sure to
select the appropriate PIC architecture. Additionally, take note of the
information contained in the bootloader's name (i.e. baudrate).
Testing with echo
With the necessary software installed and hardware acquired, test your system by programming it with a simple echo program. The echo program waits for a UART1 RX character, increments it, then echos it back. To test:
- Before programming the PIC with the echo program, be sure to have all the required software installed and the bootloader loaded (see the steps above).
- Open MPLAB, then open the echo project using Project -> Open.
- The project should compile as is; build the project with Project -> Make (or press F10). To troubleshoot:
- Click Configure -> Select Device and make sure the appropriate device is selected.
- Click Project -> Build Options -> Project. Under the Directories tab, "Show directories for:" the Include Search Path and make sure the relative paths are meaningful for your setup.
- Start the PIC24 bootloader application by opening
bin/winbootloader.exe. - Hook the USB cable up to your computer and to your PIC.
- In Bully bootloader, select the appropriate COM port and baud rate and check "OpenCOM."
- The baud rate is determined by the bootloader firmware loaded on the target PIC24 micro (the baudrate is typically 57600).
- If you do not know which COM port to use, in Windows select Start -> Control Panel -> System (or Windows Key + Pause|Break). Select the Hardware tab and click Device Manager. In the new window, expand the "Ports (COM & LPT)" entry and look for "USB Serial Port (COMx)".
- Click the HexFile button and navigate within the Open dialog box to your MPLAB's project directory.
- Select the appropriate .hex file, and click Open.
- Press and hold the MCLR button on your miniBully24. Immediately after you release the MCLR button, click the Program button in the Bully bootloader. You should see the lower output box scrolling with information.
- At the top of Bully bootloader is a white text input field. Type the letter 'a' into the box, and click Send.
- Check to see that the letter 'b' appeared in the top output box, just below the input text field. More bootloader documentation is found at Bully Bootloader GUI documentation.
Hardware Debugging Tools
An extremely useful hardware debugging tool is a USB logic analyzer. The
Intronix Logicport is an inexpensive one that can prove invaluable in tracking down hardware problems. Here is a
screenshot for the reverse string application of Chapter 10 that demonstrates two PIC24 CPUs communicating over the SPI port.