Skip to content

STM8 eForth FAQ

Thomas edited this page Jul 27, 2020 · 11 revisions

Frequently Asked Questions

Why a Forth for the STM8?

Thanks for asking :-) One answer is here. Other authors and contributors found the minimal system intriguing/useful/funny or otherwise interesting, and that's how this Forth system came to be.

Isn't a µC with 1K RAM and 8K Flash too small for interactive development?

You can certainly use such a small µC for interactive development and get something done. If your embedded application benefits from "interactive" properties (e.g. scripting, parameters, in-field adaptations) you'll be surprised how far you'll get by programming "the Forth way"!

What do I need to get started?

You need an STM8 board, an inexpensive programmer, and a serial terminal program. Refer to the Breakout Boards page for details, or open an issue if you have more questions.

Why do my NVM definitions disappear after a reset?

After defining words in NVM mode you need to "persist" temporary dictionary pointers by using the word RAM or WIPE. Otherwise the core variables CONTEXT and LAST won't be saved to Flash memory, and after the next reset the new dictionary entries will be lost (see issue #153 for details).

Why are some of the eForth words that I expect missing from the dictionary?

In order to save memory space many of the original STM8EF words have been removed from the dictionary. The "unlinked words" can be accessed with the alias definitions in out/<BOARD>/target, which is very easy to do when you use e4thcom or codeload.py (just type #require mymissingword). It's also possible to keep dictionary entries for the hidden words in the EEPROM. Please refer to the details in Using Alias Words.

It's also possible to build targets with a different selection of words linked to the dictionary (see here for a complete list of words, and here for an example configuration). Please refer to issue #152 for a detailed discussion.

Can I run code from the EEPROM?

No, that's not possible by "virtue" of the STM8 memory bridge, and attempting to do that will cause a reset (unless you copy it to the Flash or RAM).

However, the STM8 eForth ALIAS feature allows storing dictionary entries in the EEPROM, which will free up Flash memory for storing code. Please refer to lib/EEALIAS, example STM8 eForth EECORE configuration, and explanation on HaD.

Why can't I ALLOT more than 32 bytes for my VARIABLE in NVM mode?

RAM is a scarce resource in a low-end STM8S device, and therefore a quota of just 32 bytes RAM is reserved for the VARIABLE definitions in a COLD or WIPE cycle. However, you can define as much as you like (within the limits of your device, of course) if you don't use the allotting RAM in after defining it, but start a new cycle instead, e.g.:

#require WIPE
NVM
32 CONSTANT P0_WIDTH                 \ bytes in a payload. 1-32 bytes
   VARIABLE MYBUFF P0_WIDTH 2- ALLOT
   VARIABLE RXBUFF P0_WIDTH 2- ALLOT
WIPE

Is it possible to make autostart applications?

Yes, that's easy to do. You can even make autostart applications that still have an interactive console by running your application in the background or in a idle task.

How do I Propose a New Entry for the FAQ?

That's simple: just raise an issue and ask your question.

Clone this wiki locally