Frank Sergeant's Pikme (PIC) Programming Page
(edited 25 April 2010)
"Pikme" is pronounced to rhyme with "Pygmy". One day Pikme may grow
into a full Forth for the Microchip PIC series of microprocessors. It
begins with merely a bootloader. This is really just a sketch at this
time. I haven't really looked at it since July, 2006 (and,
unfortunately, I can't even look at it now). The new version
(20100425) includes some corrections and enhancements by Byron Jeff
The Pikme bootloader is "The World's Simplest PIC Bootloader".
It requires only one-half of an I/O pin (that is, it can use an
input-only pin), and even that pin can be used for other purposes
in your application provided it doesn't wiggle when the PIC powers
The serial code is bit-banged. It does not require a PIC with a
hardware serial port. Equates in boot.asm make it easy to select
which pin will be used. (It defaults to the RA5/Vpp/MCLR* pin
which cannot be an output pin, thus conserving output pins for the
The serial interface is "inverted TTL serial", which means the PIC
does not need an RS232 inverter (such as a MAX232).
It is set up to work with the PIC16F819 but is easy to modify for
other PIC chips that allow "in-application" programming of their
flash memory. The bootloader itself calculates the value for the
org statement and sets ZOrgShouldBe to that value, providing you
set the equate ZFlashSize correctly for your PIC variant.
Full source code is included. The code (both the PIC-side and the host
PC-side) is heavily commented.
Liberal MIT/BSD-style license
The bootloader uses the first 32-word block (for jumping to the
bootloader proper in high memory and for the interrupt vector)
plus approximately 183 words of high memory.
The host PC software is a Python program that runs anywhere that
Python (and the Python serial module) run: at least Windows,
It is easy to set up the application code so that its resulting
hex file can be used with the bootloader or directly with a
hardware programmer. The file skeleton.asm shows how.
When the PIC powers up, the bootloader is in control. It checks
the serial line to see if it is wiggling. If so, it prepares to
download a new application and burn it into flash memory. If the
serial line is not wiggling, it jumps directly to the application
that has already been burned into flash. (The bootloader includes
a dummy application, which simply jumps back to the start of the
It has two parts:
- PIC chip side
- As a one-time action, burn the bootloader (boot.hex) into
the PIC chip with a hardware programmer.
- Host PC side
- Thereafter, download your application's hex file to the
chip via the serial port with picbl.py, e.g.
python picbl.py dummy1.hex 0 for the first
serial port (COM1: under Windows or /dev/ttyS0 under Linux) or
python picbl.py dummy1.hex 1 for the second
serial port (COM2: under Windows or /dev/ttyS1 under Linux)
Pikme PIC bootloader
(81K) (Includes everything. Unzip it into its own directory or put
it anywhere convenient.)
I'll be glad to receive comments, suggestions, spelling/typo/grammar
corrections, factual corrections, improvements, etc. Feel free to
Return to my home page