# Forth/PSoC Forth
## How to install PSoC Forth

Ingredients:
* A PSoC microcontroller
* A PSoC flash-burner such as the ICE-Cube (it lets you debug, set breakpoints, single-step through your code, etc.) or the MiniProg (costs less).
* A PC that can run PSoC Designer for Windows or the M8Cutils for Linux.
* Create the hex file "psoc_forth.hex": either
** If you have a Windows box, use PSoC Designer (details below), or
** If you have a Linux box or a Macintosh, use M8Cutils.
** (Both development tools are free downloads.)
* Use the PSoC programmer to burn the hex file into the microcontroller.

## Creating the hex file with M8Cutils

One-time install:
* Install the M8Cutils for Linux http://m8cutils.sourceforge.net/.

## Creating the hex file with PSoC designer

Unfinished -- needs work
One-time install:
* Install PSoC Designer for Windows http://www.cypress.com/psocdesigner.
* Run PSoC Designer to create a new project
** Create new project. New project name: "interactive" (without quotes). Base part: 27443.
** Generate 'Main' file using: Assembler. Finish.
* Download "One Wire User Module" by Wes Randall from http://www.psocdeveloper.com/uploads/media/OneWire_v1.3.3.zip , and install the "OneWireSW" custom user module. (FIXME: how?)
* In the "user module selection view", choose the "user modules" you might need: (You can select and place one at a time, or select all of them, then place all of them).
** Digital Comm: Uart (double-click on it to create UART_1)
** Temperature: FlashTemp
** Three "SAR6" modules—rename them "sar1", "sar2", and "sar3".
** One "OneWireSW" module
** One INSAMP—rename it "amp".
* In "interconnect view", place all the user modules (right-click on each one and choose "place"). (The "placed" modules have a thick colored rectangle around them. The ones you haven't placed yet don't have any rectangle or only a thin black rectangle around them.)
* In the "ApplicationEditor" view, hit "Build" (F7).
** You should get the message "0 error(s) 0 warning(s)".
* Copy the psoc_forth.asm source code into a file "psoc_forth.asm", in the same directory as the "main.asm" we just created.
* Download "Algorithm - Unsigned Multiplication - AN2032" by Dave Van Ess, and extract the file "unsignedmath.inc" and put it in the same directory as "psoc_forth.asm":
** (Um... wouldn't "Algorithm - Signed Multi-Byte Multiplication - AN2038" be better?)
* In the "ApplicationEditor" view, select Project | Add to project | Files... and select "psoc_forth.asm".
* In the "ApplicationEditor" view, hit "Build" (F7).
** You should get the message "0 error(s) 0 warning(s)". (FIXME: ... I never got this far ...)
* Edit the source file "main.asm" and just before the ".terminate", add the line
* In the "ApplicationEditor" view, hit "Build" (F7) to create the hex file.

## Interactive development

* Connect serial port on the microcontroller to a terminal. (Perhaps the same PC used above, running a terminal emulator; or a PDA serial port, or a dumb terminal.)

## The source: alternate

Some slight changes and notes by Gus Calabrese and Bill Goodrich, in hopes of creating a workable version for newer PSOCs, like our CY8C29466.
David, is this a good technique, wiki-wise, to include changes we've made? - Bill
Sure, that's great. After I figure out what your changes mean, I'll edit Wikibooks:PSoC Forth so it shows only one version—the latest and greatest.
Does this latest version still support all the chips that the original one ran on? (People can always go to Wikibooks:PSoC Forth history to see the original version or any other version).
"What is rp? Return pointer?" Yes, it's the pointer to the top of the "return stack". Would it be less confusing if we did a search-and-replace to rename it "RSP", so we're using the same terminology as Brad Rodríguez and the FigUK: "The Heart of Forth" articles?
Right now the most mystifying (to me) change is adding "w" to a bunch of comments—for example, I see ";drop ( x -- ) drop TOS" changed to ";w drop ( x -- ) drop TOS" . Does that "w" mean anything to you?
I found that it is not very practical to try to fit this to the newer 466 chips. The best I could do was to get the newer chips to "emulate" Pforth, which was not very useful. It would be better to start from scratch. Chris Burns

## History

* 2003: Originally written by Christopher W. Burns.
* 2006: Maintenance taken over by David Cary (starting from version 2.01 ).
* 2008 - Is anyone still interested in PSOC Forth? Chris Burns
* 2008 - Am I the only one still interested in a PSoC Forth? -- DavidCary

## Further reading

* Embedded Systems/Cypress PSoC Microcontroller FAQ
* Gainer wiki discusses GAINER, an open-source environment for creating user interfaces and/or media installations using the Cypress PSoC.
* M8Cutils for Linux
* The latest version of PSoC Designer can be downloaded from http://www.cypress.com/psocdesigner. The free download includes everything except the C compiler, which we won't need for this project.