Tiny Tinkering

PIC10F200 Guide ← back

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:

pic10f20X pinout pic programmer pinout

Setting up the breadboard

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.

Programmer Programmer and breadboard

Once you have a programming breadboard set up, you need to set up the software toolchain.

Installing OSX 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:

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.

Adding a Bash Alias

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

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

Sample code

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):

Creative Commons License

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.