02. Getting Started
The PIC24 is divided into two families. The PIC24F series emphasizes cost, but can only go up to around 40 MHz, while the PIC24H series is targeted towards applications where performance is generally more important. The cost/performance factor only comes into consideration if you need to mass produce your product. For in house development, both are very good microcontrollers performing similar functions. The best part of it all is that they cost dirt cheap. Online retailers such as Digikey, Mouser and Microchip Direct tags the cheapest PIC24F chip at around $2.50, while the PIC24H is somewhere around maybe $4-5 depending on the model.
Because the chips are very similar, the rest of the guide will all be written for the PIC24FJ64GA002 or the PIC24H32GP202. I am particularly fond of these two models because they have most of the features of the high-end chips in the PIC24 group, but at reduced pin out counts. Both have 28 pins, and their footprints are interchangeable.
However, the PIC24FJ64GA002 has a few extra features when compared to its performance oriented cousin. For example, the PIC24FJ64GA002 has two UART modules and two I2C modules as opposed to only one on the PIC24H series brethren. The former also has an extra double 16 bit/single 32 bit timer module. There are a few more minor differences, but they will be discussed a bit further in the guide.
The MPLAB IDE and the ICD 2
Microchip provides a very good programming platform to program, compile and even debug the PICs. It is not an industrial programmer such as the JTAG interface, even though many of Microchip’s controllers have pins reserved for the protocol. Since the program is very user friendly, and is my preferred way of working with PIC, this is a little introduction for people who are not familiar with the program.
The MPLAB IDE is an integrated development environment in which the user can write code, program PICs and even debug them in-circuit. Together with the in circuit debugger, the user can pretty much do everything the microcontrollers can offer. The program also allows you to pick compiler suites, and integrates the use of both C programming and assembly. It is a power tool, and greatly increases the effectiveness of a programmer from the heydays of DOS based assembly mayhem. Since the guide focuses on the PIC24s, the rest of the guide is written with the assumption that you are using MPLAB 8, with an ICD 2, and a student version of the C30 compiler. Both the MPLAB 8 and the student version of the C30 compiler is free, but the ICD 2 will set you back 180 dollars. Though it’s quite a bit of money to put down for hobbyists, buying the tool allows you to program the whole range of Microchip’s products. If you are a company, the entry cost of the tool is a drop in the bucket.
C30
C30 refers to the C compiler used for the dsPIC and PIC24 line of products. There is a student version, which costs nothing, but does not allow code optimization beyond “1”, and there is a commercial version that Microchip sells for about $2000. This version of the compiler has higher optimization levels. At optimization “S”, the code is more compact and executes faster. However, considering the myriad of oscillator options and the size of the program memory, it’s a waste of 2000 dollars if you ask me. The two versions are similar in every other way.
Making your first program
The first program that I always write when I am working with a new processor is to find the oscillator-out pin (OSCO), and make sure the oscillator works. What I am looking for is a relatively clean clock signal whose frequency corresponds to the configuration that set by the configuration bit. However, before such a program can be loaded into the PICs, a circuit must be made so that the ICD 2 can interface with the microcontroller. It is always the first thing that I do because finding the OSCO means that the circuit is working correctly.
Typical circuit
Every chip in Microchip’s huge line of controllers is compatible with the ICD 2. On these chips, you will always find 5 pins named Vdd (power), Vss (GND), PGC (Program clock), PGD (Program data) and /MCL (Master clear bar, active low). In order the program a device, these five pins must be connected to the corresponding pins on the ICD 2. The following is a typical circuit that I use. I have a RJ11 jack to a 5 pin 1.25 mm header connector converter, which is then connected to my circuit though a set of discreet wires. Please note that the Vdd pin from the ICD 2 does NOT provide power. The Vdd supply, which is 3.3 volts for the PIC24 line of chips must be provided externally. Note the bypass capacitor on the VddCore pin and the pull up resistor on the /MCL. These are needed for a stable power supply and program restarts, respectively.
After building the circuit, you are ready to test your circuit. Power your circuit and hope that nothing burns. If you feel that the chip is getting extremely hot, or that your external voltage regulator is burning up, then you probably shorted something. If not, you’re ready to go to the next step.
Table of Contents
Previous – Getting Started
Next – First Program

Entries (RSS)
Thank you!
Thank you!
Thank you!
Thanks.. Im just getting started..and have never programmed a chip before (still havent).. I have flashed a chip (PIC24f) with pre-existing HEX files..but what to learn to do my own.
Finding your site gives me hope..LOL
My question is.. what is the difference between an ICD2/3 vs the PICKIT2 programmer I already own?
Thanks
The PICKIT2 use to support less PIC models. And from what I heard it can be a bit flakey in Debug mode. However, it can power your pick circuits with any voltage up to 5V. The ICD2 however can only power a 5V (not sure about the ICD3). I usually turn this option off anyway because I don’t want to accidentally blow any of my 3.3V circuits. If you already have a PICKIT2, then I would just keep on using it until you absolutely find a reason to switching. Also the PICKIT is about $40 dollars, whereas the ICD2/3 is over $180.
-J
Thanks..
so I can still follow along with the tutorials..no matter if Im using the PICKIT2 or an ICD2/3? correct?
this is my first step into this world.. I just only installed MPLAB and C30 compiler..
Thanks