The German electronics Magazin Elektor distributed in its December 2005 issue a Renesas-R8C-Board produced by Glyn. The Software by Glyn distributed in the Magazin contained a C-Cross-Compiler for Windows. But it is more interesting to have a Forth System on this CPU.
The System is now production quality.
romthe user can switch between compilation in (Flash-) ROM and RAM .
:dovaris located at an address ($C0FE) that allows modification to point to other Doer (using
savesystemstores a copy of the RAM in Flash-ROM, this allows turnkey application. The dataflash can be reprogrammed more frequently than the Data-Flash and allows experimentation with the system. The word
emptyresets the whole system and clears the memory.
tt.fs) fits in 4K ROM.
The current Development Version of Gforth can be loaded using pserver CVS. For Windows-User without ambition to install Cygwin, there is a Snapshot as a
setup.exe Installer containing the current Development Version of GForth.
The Gforth-R8C can be loaded and flashed in the R8C Flash as a S-Record-File.
Prior to installing Cygwin and compiling Gforth from the Source (
./configure && make), it is recommended to install libffi to be able to interface with C-Libraries.
All required libraries are available out-of-the box when using the supplied
setup.exe Installer. The Windows Program Menü additionaly contains the entry „Bash“ which opens a BASH-Shell. All following Commands are given for a freshly opened BASH-Shell (for Cygwin-User: in Gforth-Directory).
rom-r8c.mot can be build using
(will be the same as
gforth-r8c.mot). There will also be a File
data-r8c.mot created, which canbe used to repair a corrupted Data-Flash. The File
rom-r8c.mot is loaded in Flash. Now we can connect to the R8C using a standard Terminal using 38400 Baud 8N1 (for example with Hyperterm, which is in the default Windows install — Set connection to „COMx“) and interactivly with the Forth in the R8C. The communication will go over the same serial Interface that is used to flash the R8C — no need for recabling. Downloading Forth Source with a normal Terminal Program is not possible, because Xon/Xoff is to slow. It is possible to cur'n'paste Forth Sorucecode to the Terminal when the Linefeed delay is set to 250ms.
You can play around with the Forth in the R8C, for example
1 2 + . lcdpage s" Hello World" lcdtype adc@ .
All possible Forth commands (words) can be listed with
showing last defined words first.
The GForth „build-in“ terminal can be started using the command
By default, the communication will be over COM2 — if needed, the source file can be edited to support a defferent COM-Port, or — when using an USB Converter — map the USB Serial Interface to COM2 using the Windows Devicemanager. In Linux the Device
/dev/ttyUSB0 is used by default. This default can also be cahnged by editing the source.
Using the terminal, the ported Tetris-for-Terminals by von Dirk Zoller can be started:
(this will take a while — the R8C is compiling the code itself). Start Tetris with
A simple „Blinkenlights“ Demo, that will autostart after Reset:
rom : light! led! &100 ms ; : runlight 1 light! 2 light! 4 light! 8 light! 4 light! 2 light! ; : blinkenlights BEGIN lauf key? UNTIL ; ' blinkenlights is bootmessage ram savesystem
The program will run until a key on the terminal is pressed.
A loop that reads from the ADC (Analog to Digital Converter) and prints the value on the LCD:
: adcmeter BEGIN 6 adc@ 0 <# #s #> lcdpage lcdtype &200 ms key? UNTIL ;
This a simple Multitasker that allows exactly one backgroundtask:
rom Variable bgtask ram $20 cells allot rom :noname bgtask @ 0= ?EXIT rp@ bgtask @ sp@ cell+ bgtask ! sp! rp! ; IS pause : task r> bgtask $20 cells + ! bgtask $20 cells + bgtask $10 cells + ! bgtask $10 cells + bgtask ! ; :noname echo @ IF BEGIN pause key? UNTIL THEN (key) ; is key ram
An adapted version of the Blinkenlights Demo above:
rom : light! led! &100 ms ; : run 1 light! 2 light! 4 light! 8 light! 4 light! 2 light! ; : blinkenlights task BEGIN run AGAIN ; ram
Similar to the Blinkenlights we can create a Text Scroller. The scroll speed is controlled with the potentiometer on ADC channel 6.
rom Create text ," GNU Forth EC R8C -- Microprozessor -- " Create ledtable 1 c, 2 c, 4 c, 8 c, 4 c, 2 c, Variable /text : scroller task BEGIN text count /text @ over mod /string 16 min dup >r lcdpage lcdtype r@ 16 < IF text 1+ 16 r@ - lcdtype THEN rdrop 1 /text +! /text @ 6 mod ledtable + c@ led! 6 adc@ 2/ ms AGAIN ; ram