CForth for STM32G431, STM32F042 and STM32L476

CForth is a Forth interpreter system completely written in C language.
The intention is to make a straightforward user oriented Forth system,
specifically to organize interactive electronic control of art objects and installations or similar process control.

Primarily CForth is developed for a 32pin LQFP STM32G431KB processor.
I am a fan of these compact, high featured and easy to solder chips. Though originally bought for another project, the lockout time stimulated me to start this Forth development. My first Forth about 1992 was e-Forth with an 80C31 processor. Later I programmed some Forth for 68HC11 and AT90/ATmega. My last Forth interest was early 2000 a Windows console version written in C, which served as a first template for the actual project.

The first hardware design was a compact 1 layer etched PCB (not published). Because it is complicated to etch PCBs without appropriate tools, another Veroboard compatible layout (processor soldered on DIL breakout board like Adafruit 1163) was developed, which is presented here. A minimal breadboard setup is described in the DIY instruction, too.

As a side product, firmware and a Veroboard compatible hardware for 20pin TSSOP STM32F042F6 is developed too. It also works with STM32F070F6.
This firmware is compatible with a minimized STM32F042 board design, which is described at another place of this website.

Another side product is a CForth version for STM32L476 Nucleo-64. It is optimized for a hardware design described at another place of this website.

Last not least a reduced version for an unmodified STM32G431 Nucleo-64 is derived.
But I am very disappointed about this Nucleo, it is an absolute downgrade of the Nucleo concept. Because the ST-LINK unit cannot be cut off and be used as a standalone programmer, it's effectively a playaround gadget and not useful for real projects. If I had known before, I would not have ordered it. Because the firmware modification for this board is quite easy, it is supported too.

Veroboard compatible PCB designs
Veroboard compatible PCB designs for CForth with STM32G431 and STM32F042

Most essential features of CForth:

  • A basic set of standard Forth kernel operators ("words") is implemented
  • No attempt is made to comply with established Forth standards. Nevertheless, all typical features of most Forth dialects are supported.
  • No attempt is made to "program Forth by Forth". At the expensive of code length everything is programmed on rather flat subroutine nesting.
  • Where standard Forth systems compile sniblets of assembler code to manage runtime behaviour,
    I have introduced several specific "doAll" runtime operators for loops, conditionals, VARiables and CONSTants. So I think, I have got an acceptably fast and easy to understand and to manage Forth system.
  • Loops are organized more "C-programming style" than in traditional Forth.
  • A simple background process is implemented: selected Forth operators can be called via Terminal while another Forth thread is executing.
    This way constants and variables of the main thread can be modified externally during runtime,
    which allows interactive flow control of the executing thread.
    Furthermore single step execution can be switched on and off at any time and some debug information (like memory content) can be displayed via terminal during runtime of the main thread.
  • Any Forth User thread can be replaced by a new programmed one without "ripping" up the compiled code memory and complile it new. Change can be undone without reprogramming. This may be useful when a good idea comes later.
  • Line-end delimiter is "Carriage Return" (ASCII 13) only. To modify it into "Line Feed" (ASCII 10), exchange the numeric values of CRR and LFF in source file "globaldefines.h" and recompile.
A detailled Forth Operating Manual is provided here (PDF file),
and a DIY Construction Manual is provided here (PDF file).

A good tool for Forth source code upload is my DTerm Windows terminal software. It is surely not the best terminal emulator, but has been developed over the years for best fitness with my actual projects.

Downloads:
The subsequently downloadable material is copyrighted (c)2020 by Wolfgang Schemmert.
Assembly of the devices, programming and use of the software is permitted for free by everybody for any purpose ("freeware"). For commercial use, possible restrictions of third-party software contributors must be respected.
All information is based on best knowledge, but "as is" and without any warranty. Any responsibility is excluded.

PCB layout for the "STM32G431 board" PCB (1:1 TIF format. BOTTOM layer as well as component placement view are "from component side", i.e. BOTTOM layer shown mirrored "through the PCB" (as needed for PCB production))

PCB layout for the "STM32F042 board" PCB (1:1 TIF format. BOTTOM layer as well as component placement view are "from component side", i.e. BOTTOM layer shown mirrored "through the PCB" (as needed for PCB production))

Firmware "CForth-G431-48.hex" rev 3.45 for Veroboard compatible PCB, SysClock = 48MHz
(Version 3.45 , 02 July 2020 - bugfix Flash load and save, minor improvements)

Firmware "CForth-G431-144.hex" rev 3.45 for Veroboard compatible PCB, SysClock = 144MHz
(Version 3.45 , 02 July 2020 - bugfix Flash load and save, minor improvements)

Source code "CForth-G431.zip" (state 02 July 2020)
This source code is provided as complete "Segger Embedded Studio" project (ZIP file, 425 kB. Parts published by Segger are under license of Segger&|Rowley, parts published by STM are under license of STM, parts programmed by me are provided under GNU GPL3 license.)

Firmware "CForth-F042.hex" rev 2.19 for Veroboard compatible PCB
(Version 2.19 , 25 June 2020)

Source code "CForth-F042.zip" (state 25 June 2020)
This source code is provided as complete "Segger Embedded Studio" project (ZIP file, 283 kB. Parts published by Segger are under license of Segger&|Rowley, parts published by STM are under license of STM, parts programmed by me are provided under GNU GPL3 license.)

Firmware "CForth-L476.hex" rev 2.17 for a Nucleo board without ST-LINK module.
The L476 on-chip USB and USART is supported for communication
(Version 2.17 , 02 July 2020 - bugfix Flash load and save, minor improvements)

Firmware "CForth-NucleoL476-unmod.hex" rev 2.17
reduced version for an unmodified STM32 Nucleo L476 board
(Version 2.17 , 02 July 2020 - bugfix Flash load and save, minor improvements0)

Source code "CForth-L476.zip" (state 02 July 2020)
This source code is provided as complete "Segger Embedded Studio" project (ZIP file, 392 kB. Parts published by Segger are under license of Segger&|Rowley, parts published by STM are under license of STM, parts programmed by me are provided under GNU GPL3 license.)

Firmware "CForth-NucleoG431-48.hex" rev 1.3, SysClock = 48MHz
reduced version for an unmodified STM32 Nucleo G431 board
(Version 1.3 , 02 July 2020 - bugfix Flash load and save, minor improvements)

Firmware "CForth-NucleoG431-144.hex" rev 1.3, SysClock = 144MHz
reduced version for an unmodified STM32 Nucleo G431 board
(Version 1.3 , 02 July 2020 - bugfix Flash load and save, minor improvements)

Source code "CForth-NucleoG431.zip" (state 02 July 2020)
This source code is provided as complete "Segger Embedded Studio" project (ZIP file, 3665 kB. Parts published by Segger are under license of Segger&|Rowley, parts published by STM are under license of STM, parts programmed by me are provided under GNU GPL3 license.)

These projects are programmed directly on register level, no external libraries (except "cmsis" and startup code), no external drivers or HAL are used.



* State of information July 2020.
* Right of technical modifications reserved. Provided 'as is' - without any warranty. Any responsibility is excluded.
* This description is for information only. No product specifications are assured in juridical sense.
* Trademarks and product names cited in this text are property of their respective owners.