All these years, I have been looking for microcontroller platforms on which I can teach people how to program in the FORTH language. I designed a training course I called Firmware Engineering Workshop. I could train an open minded engineer to program in FORTH in about a week, with a reasonable capable platform, i.e., a microcontroller evaluation board with a FORTH operating system loaded. Good platforms are expansive, and low-cost platforms are inadequate. What I did was to grab any microcontroller board at hand and used it. It did not work well because what I taught could not be easily replicated by people at home. People got frustrated when they could not reproduce results I demonstrated. Then, I found the Arduino Uno Board.
The microcontroller evaluation board I need must have a microcontroller with reasonable capabilities. An 8-bit microcontroller with a fast clock is adequate. 16-bit of 32-bit microcontrollers are of course much better. The board must have at least 8 KB of ROM memory and 1 KB of RAM memory. It must also have a USART port to communicate with a terminal emulator on a host PC. Any other I/O devices will be icings on the cake. The more the better.
Arduino Uno has all of the components I listed above. It is also inexpensive, costing only $29. It uses ATmega328P, a very interesting microcontroller which has 32 KB of flash memory, enough to host a FORTH operating system, 2 KB of RAM and many I/O devices to build substantial applications. Arduino Uno also has a USB port which connects to a PC and an USART device in ATmega328P. This serial interface is necessary for a FORTH system so that you can run and program ATmega328P interactively from a terminal emulator on the PC – as the complete Forth is on the chip.
Arduino Uno is a lovely machine. You connect it through a USB cable to your PC, and you can program it to do many interesting things. Its microcontroller ATmega328P, running at 16 MHz, is very capable of running many interesting applications.
The template of a sketch, which is the software in Arduino 0022, captures the essence of firmware programming in casting user applications in two statements: setup() and loop(). It eliminates all the syntactic statements required by a normal C program and exposes to you only the core of an application.
However, Arduino software insulates you from the intricate nature of ATmega328P microcontroller, its instruction set, and its I/O devices. Instead, you are given a library of useful routines which are used to build applications. The insulation initially helps you to program the microcontroller in a C-like high level programming language. However, being an 8 bit microcontroller, ATmega328P in C language will run out of gas when application demands performance. At this point, you will have to get down to the bare metal to push ATmega328P to its limit. Then, you have to learn its instruction set and all its I/O devices, and perhaps program it in assembly language.
The best alternative approach is to program ATmega328P in the FORTH language. FORTH exposes ATmega328P to you. You can interactively examine its RAM memory, its flash memory, and all the I/O devices surrounding the CPU. You can incrementally add small pieces of code, and test them exhaustively. An interactive programming and debugging environment greatly accelerates program development, and ensures the quality of the program.
Since 1990, I have been promoting a simple FORTH language model called eForth. This model consists of a kernel of 30 primitive FORTH commands which have to be implemented in machine instructions of a host microcontroller, and 190 compound FORTH commands constructed from the primitive commands and other compound commands. By isolating machine dependent commands from machine independent commands, the eForth model can be easily ported to many different microcontrollers. This model is ported to ATmega328P, and the result is the 328eForth system.
Book year: 2018
Book pages: 254
Book language: en
File size: 5.41 MB
File type: epub
Published: 07 November 2019 - 16:00
5 min ago
7 min ago
8 min ago