PICProgramming Getting Started
PICProgramming Getting Started
PICProgramming Getting Started
If you bought a UAV DevBoard, you will need to program it in order to do anything useful or
interesting with it. It is not hard to do, after a few times it will be easy. But the first time can be
confusing. This document will help you get started.
In addition to the UAV DevBoard itself, you will need the following items to program it:
• An ICD2. This is a programmer/debugger hardware item for connecting the
DevBoard up to your computer. I suggest that you buy the one recommended by
SparkFun, http://www.sparkfun.com/commerce/product_info.php?products_id=5. I
do not recommend the “PIC-ICD2-Pocket”. I have one of these, and I have been able
to get it to work with the dsPIC30F4011 CPU on the DevBoard, but there have been
several reports of problems with it.
• An IDE (interactive development environment). This software suite is available as a
free download from MicroChip. It provides an excellent support environment for
firmware development for the DevBoard.
• A C compiler for the dsPIC30 family of CPUs. This is also available as a free
download from MicroChip.
PIC Programming 2
5/11/2009
PIC Programming 3
5/11/2009
The IDE is capable of both simple programming as well as debugging. You will start
with programming. After you open the project, select RELEASE in the IDE toolbar.
There are only two options, RELEASE and DEBUG. Chances are the project will come
up in the DEBUG mode, change it to RELEASE.
7. Select your ICD2 as the programmer and check its settings.
Select MPLAB ICD2 from the programmer menu. Check a couple of settings under
programmer settings or debugger settings. Under the STATUS tab, select automatic
downloading of firmware, but do not select connect at startup. Under the POWER tab,
make sure that the programmer/debugger is not going to try to power the DevBoard from
the ICD2.
8. Do a project “make”.
This is an important step. Do not skip it. Otherwise you will simply erase the PIC
without reprogramming it. Select “make” from the project menu. The IDE will compile
and build the firmware. There will be several warnings issued, but there should not be
any errors. At the end, there will be a message that the build was successful. This step
usually goes smoothly, but there are a couple of things that could go wrong.
If something went wrong during the installation of the C compiler, the IDE might not
be able to find it. In that case, go to “Select Language Toolsuite” under the project menu.
You want the Microchip C30 Toolsuite. If it is not selected, use the Toolsuite browser to
find and select it. It should be located where ever you saved the IDE, probably under
ProgramFiles\Microchip\MPLABC30.
9. Execute a “Connect” operation.
Select connect from the programmer menu. You should receive the following
messages if everything goes right. If something goes wrong, skip to the last section for a
list of common mistakes, misunderstandings, and problems.
Connecting to MPLAB ICD 2
...Connected
Setting Vdd source to target
Target Device dsPIC30F4011 found, revision = Rev 0x1003
...Reading ICD Product ID
Running ICD Self Test
...Passed
MPLAB ICD 2 ready for next operation
Also, the first time that you connect, the IDE will install a new operating system into
the ICD2. It will ask you if you want to do that, you should accept. It will take a few
minutes. After the first time, the IDE will skip this step, unless you are using the ICD2 to
program another type of PIC.
10. Execute a “Program” operation.
The IDE will program the board through the ICD2. You should see something similar
to the following messages:
Programming Target...
...Validating configuration fields
...Erasing Part
PIC Programming 4
5/11/2009
PIC Programming 5
5/11/2009
PIC Programming 6
5/11/2009
PIC Programming 7