NB: This guide assumes that you're using a PICkit2-compatible hardware programmer with OSX. I use the CanaKit 1301.
It's important to keep the PIC10F200 series datasheet handy. I also like having the pinouts for the PIC10F200 as well the programmer pinout around:
Here's a diagram of how the breadboard should be set up to program the PIC10F200 chip. The breadboard can be powered by any power source, but the voltage should be between 3 and 7 volts.
Some notes:
In the pictures below, the breadboard does not exactly match the diagram above. This is just to illustrate how the programmer slots into the breadboard.
Once you have a programming breadboard set up, you need to set up the software toolchain.
If you don't already have a package manager that you use and like, I recommend homebrew. To install homebrew, run the following code from the terminal:
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
After that, install GPUTILS. Again from the terminal, type:
brew install gputils
In order to burn the compiled hex to the chip, you need to install PK2CMD, version 1.20, available here. To install the command, use sudo to copy the file pk2cmd
to /usr/local/bin
and the file PK2DeviceFile.dat
to /usr/share/pk2
. Note that these commands need to be run from the terminal where the files were unzipped:
sudo cp pk2cmd /usr/local/bin sudo cp PK2DeviceFile.dat /usr/share/pk2
Then, make sure that /usr/share/ is in your PATH:
PATH=$PATH:/usr/share/pk2 export PATH
Here's a sample program that blinks an LED on GP1.
Now that these are installed, it's possible to compile and burn code to a chip. Once your programmer and chip are ready, it's as easy as this (replace 'filename' with the filename you're using). One caveat is that after the gplink
command, the file is named a.hex
:
gpasm -c filename.asm gplink filename.o pk2cmd -PPIC10F200 -M -Fa.hex
At this point, the code should be loaded onto your chip.
If you'd like to make this process less arduous, here is a bash script that simplifies it to a singe line.To use, enter the picburn
command, followed by the name of the program without a file extension, e.g.:
picburn blink
To place in your .bash_profile:
# Wrapper function for working with GPUTILS and pk2cmd # Also adds the pic information to the PATH on startup PATH=$PATH:/usr/share/pk2 export PATH function picburn { gpasm -c $1.asm echo "created object file from asm" gplink $1.o echo "created hex from object file" echo "burning hex to chip..." pk2cmd -PPIC10F200 -M -Fa.hex }
The best source for baseline PIC sample code I've come across has been from Gooligum Electronics here. They cover the basics of the PIC architecture, baseline PICs and assembly, and baseline PICs and C programming (and more):