Using PIC Forth
Links
PIC FORTH
gForth binaries

gForth home

Hardware
GPMPU28
APP2

If you program the PIC, you probably use assembly language. Assembly language is great because it gives you such control over the processor and its resources. Most high-level languages force you to compromise, and you wind up with bigger programs (which means fewer features on a chip with 4 or 8K of program space).

However, there is one programming language that builds a simple idea into a powerful system and still gives you a great deal of control over your program: Forth. Forth isn't new -- it has been around seemingly forever. But it is extremely well-suited to small processors like the PIC.

I had started writing a Forth system for the PIC about a year ago. It wasn't the first Forth I've written, and I did get a version of it working. However, I stumbled upon an open source project called PIC Forth (by Samuel Tardieu) that is based on the GNU gForth compiler. It was so amazing, I gave up on my pitiful Forth compiler.

Forth is a great language to run with our GPMPU28 or APP-II boards. It targets any 16F87x processor. It has plenty of features including two ways to write multitasking programs!

If you are running Linux, it is pretty simple to install gForth and PIC Forth following the instructions. If you are using Windows, just download the Windows binary for gForth (see the link to the left). The current Windows version is gforth-0.5.0.exe. Then you can simply grab gForth from its home page.

If you are using Cygwin (and if you are a Unix/Linux guy running Windows you HAVE to have Cygwin) the situation is a bit more complicated. You can grab the source distribution of gForth. Then you need to do two things before compiling:

1) Add this to the end of engine/io.h:

#ifndef FIONREAD
#define FIONREAD TIOCINQ
#endif

2) When you run ./configure, add the --enable-indirect-threaded flag. Then run "make", and if successful, "make install"  to set up gForth on your system.

Then you can download PIC Forth and you are ready to go. Continue with this tutorial to see some of the things you can do.

Home Next