Benutzer-Werkzeuge

Webseiten-Werkzeuge


projects:430eforth:start

Dies ist eine alte Version des Dokuments!


eForth - a small Forth by Dr. Chen-Hanson Ting

There are many eForth variants that Ting did over the years. In the past the TI MSP430 was a good target, as the TI Launchpad was a low-cost option with included programmer.

Link zum eForth eBook - Vorschau auf den Inhalt des Buches
Link zur Forth-eBook-Serie

Appendix- Die 430eForth Kommandos

Here the documentation of a complete Forth on one page - ok it is a large one, but there is a link to print it as normal A4 pages https://wiki.forth-ev.de/doku.php/en:projects:430eforth:start

eForth Poster A1 - DOS Version.

MicroBox
MMT

Hoffentlich bald mehr dazu1).

Manfred Mahlow hat auf der Forthtagung 2017 einen Vortrag zum eForth gehalten, in dem die Eigenschaften des eForth herausgestellt worden sind. Das Video des Vortrags ist in Deutsch, die Folien des Vortrags gibt es in Deutsch und Englisch.

TI Launchpad

Nur etwa 4k gross fuer den MSP430G2553 im 20 Pin DIP.
Passt ideal in die MicroBox.

430eforth-ide - die Hex-Datei des eForth ist in der IDE2) enthalten, um mit dem TI Launchpad zu programmieren
Lektionen - Beispiele in eForth 430G25533)

Arduino UNO and Arduino Nano ceFORTH as SKETCH to get started with Forth

for example using an ATmega328P Nano V3 Development Board (Geekcreit).
eForth as Arduino Sketch (C Sourcecode), and in txt.

( This part is in English, as the link to this location is shared )

How can you simply carry out a few Forth instructions?
And understand how Forth works?
OK, the execution of commands online without additional hardware has already been shown elsewhere in this Wiki, in the A Start With Forth documentation, especially in chapters 4, 5, 6 and 7:
: https://wiki.forth-ev.de/doku.php/projects:a-start-with-forth:start0
and in English
https://wiki.forth-ev.de/doku.php/en:projects:a-start-with-forth:start0#a_start_with_forth_-_many_c_hapters_here_and_as_ebook_and_print_book

But it is something else to test this locally in your own (or borrowed) controller board. 4)

Arduino UNO and Arduino nano are widely used, so probably a good basis.
Normally, a programmer and special know-how is almost always required to get the Forth into the chip, as the Forth also needs the bootloader area. So, this area has to be overwritten which the Arduino IDE cannot do.

But we recently discovered this special eForth version from Ting, which unfortunately had been hidden very well until now.

Only this Arduino-specific sketch has to be downloaded using the link above and unpacked again. Upload it via the Aruino IDE and you're ready to program in Forth.

We soldered the headers on a nano pointing downwards, and the Arduino nano then fits wonderfully into a solderless breadboard for experiments.

arduino_nano_on_breadboard.jpg

For example here a link to a low cost ATmega328P Nano V3 Development Board as example (Geekcreit) if you ned one: https://uk.banggood.com/Geekcreit-ATmega328P-Nano-V3-Controller-Board-Improved-Version-Module-Development-Board-p-940937.html?gpla=1&gmcCountry=GB&currency=GBP&createTmp=1&utm_source=googleshopping&utm_medium=cpc_bgcs&utm_content=lijing&utm_campaign=pla-gbg-rm-all-purchase-pc&ad_id=323612825005&gclid=Cj0KCQjw-_j1BRDkARIsAJcfmTHNbV23Sl9zuJK9eh8oCP9oIJHQtR3dcUMdgcX3EYMRVgHzdnaJYtYaAiUTEALw_wcB&cur_warehouse=CN

The eForth is loaded as Arduino Sketch (C Sourcecode), similar to a text file, then compiled via the Arduino IDE and uploaded into the board. Generate a folder on your PC, download the ZIP, unpack it and flash it into the Arduino UNO or the nano via the Arduino IDE.

A little bit of background from Ting’s documentation

Ting’s introductory chapter and background to this version: This Forth can be easily loaded as an Arduino sketch and is immediately executable via a terminal program on the PC. OK, with a few drawbacks - but nothing is for free, please read the introductory chapter.

Terminal Program on your PC

Download and install a terminal program, if you do not have one already, e.g. Teraterm or termite, and then you are ready to go. Set to 115k baud rate.

https://ttssh2.osdn.jp/index.html.en

Enter (CR) and you see 0 0 0 0 ok> Test by entering words (CR) showing the list od words/commands

The original command list of this Forth

List as in the original documentation

All 180 words may be too much for someone who is just starting out, so let’s sort them a bit - sort by function for the easy ones - and the more difficult ones at the end.

And you are ready to go and test some commands, e.g. see what is happening on the stack.

Here are some examples.

And the Examples in the book

Some small Examples

The terminal display shows

0 0 0 0 ok> These four zeros show the top 4 values of the Data stack. with 1 (CR) 2 (CR) 3 (CR) 4 CR) it changes to 1 2 3 4 ok> now try . (CR) . (CR) . (CR) . (CR) and the 4 values are displayed and disappear from the stack and back to 0 0 0 0 ok>

The usual HELLO WORLD we can achieve like this:

Define a new Forth Word : HELLO1 .„ HELLO WORLD “ ; (CR) : start a new Word definition HELLO1 the name of the new Word .„ Start a text definition HELLO WORLD the text to be printed “ Marker for the end of the text ; end of new Word definition

And try it out:

hello1 (CR)HELLO WORLD

and format the output a bit:

: HELLO2 CR CR .„ HELLO WORLD “ CR ; (CR) a few additional CRs will make it better readable

hello2 (CR)

HELLO WORLD

And now let us control one Bit in the IO. Here the on-board LED

20 24 POKE (CR) \ will set bit 5 of the port to OUTPUT in the Data Direction Register 0 0 1 0 0 0 0 0 \ 20 is the data bit to be stored, and 24 is the DDR Register address in hex

20 25 POKE (CR) \ Will set Bit 5 in the OUTPUT Register to HIGH - LED is on 0 0 1 0 0 0 0 0 \ 20 is the OUTPUT bit to be stored and 25 in hex is the Output Port Register

00 25 POKE (CR) \ Will set Bit 5 in the OUTPUT Register to LOW - LED is off \ here 00 is stored in the Output Register

The data sheet I used is http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf

And for now only page 280 is important, which shows the addresses for the ports, especially here now Port B:
24 HEX is the DDR (DDR = Data Direction Register) to set bits to OUTPUT and 25 HEX for the OUTPUT Register to set bits to 1 or 0 HIGH or LOW.

And the relevant file of these examples

Try out other bits, or other ports, but then you have to add LEDs to the relevant output.

More to come

An important difference between the Arduino IDE and Forth

With Forth we can poke around in all internals using the Forth commands, read and write IOs - even mess up the CPU – so please be careful as you might have to restart the Forth and loose the work done before. And this is done using only 2 commands, added especially to this eForth version: PEEK - Read the contents at memory location xx POKE - Overwrite contents at memory location xx with new data yy.

And if you have now licked blood and have the appropriate know-how and tools, you can flash in the extended version of this eForth - but then the bootloader will be overwritten.

The complete zip of this project you can find at http://forth.org/OffeteStore/OffeteStore.html

and here especially, as this version working with RAM http://forth.org/OffeteStore/2162_ceForth_328.zip

and the full version where new words are stored permanently in flash memory http://forth.org/OffeteStore/2159_328eforth.zip


This page is work in progress! Last change and more to come as time allows: 04/05/_2020

1)
Oktober 2016
2)
Die 430eForth-IDE ist eine angepasste Reimplementation der 4e4th-IDE von Dirk Brühl - http://www.somersetweb.com/430eForth/430eForth-IDE.zip
3)
eForth ist case sensitive, alle Forth Worte sind in GROSSCHREIBUNG.
4)
By the way - this ceForth version is not sensitive to upper and lower case use.
projects/430eforth/start.1590338015.txt.gz · Zuletzt geändert: 2020-05-24 18:33 von juergenuk