PIC16Cxx Microcontrollers and Forth

RAM Technology Systems is the only commercial supplier of a Forth compiler for the Microchip PIC16Cxx range of microcontrollers.

For those who know nothing of Forth the language is both interactive and modular. Forth encourages communication with the hardware of your project and allows bugs in the hardware to be sorted before the software is completed. Because if its simple design philosophy the overhead is small and your project functions reduced to small fractions of code called 'words'. These words are constructed from others and the basic 'primitives' of Forth, like fetch a value from a location '@' and store to a location '!'. So everything in Forth has a name and these names, words, are collected together in a dictionary that defines your project.

Let us look at an example of how this might work for a simple FAX machine.


The : in Forth indicates the start of a new definition, word. The space delimited text following will be word name, SEND, and added to the dictionary when this is compiled. The other words must already exist in the dictionary so we are starting at the top and working down to define the problem, but starting at the bottom and working up to implement it. The ; terminates the word definition as the Forth compiler interprets the text.


The word READ might be defined as:


Again READ is defined in terms of other words which in turn are defined from others. BEGIN...UNTIL is a structure that is part of the Forth kernel and defined to perform a loop until, in this case, PAGE-END is true. So Forth extends itself until it becomes the solution of your project. Each word may be executed independently and interactively to give bug free results.

Interactive Remote Target Compiler

The PIC has very little resources in terms of code and variable space. So IRTC678 for the PIC produces optimized machine code to make best use of the little there is. The 'words' are subroutines that use the 8 deep stack of the PIC and the compiler keeps track of the stack use to warn of wrap over. The PIC is programmed incrementally by the ICEPIC module that connects to a PC parallel port and connects to your project hardware. This allows any file location to be viewed and modified interactively from the PC keyboard. Indeed test routines may be written that run on the PC but serve @ and ! commands to the PIC to exercise your project hardware.


IRTC, written in Forth for the PC, transparently switches from programming to communication. A small 'kernel', called the Target Link

Monitor, allows your Forth project words to be executed and the parameter stack contents to be viewed and modified. IRTC extends

TLM into your project solution, which when complete is already programmed into the PIC ready for stand alone operation.