Forth: STM32F0  SWD terminal alternative to USART - Page 1
Forum section: electronics / general

author: techman-001
author_rank: Frequent Contributor
timestamp: September 30, 2020, 08:56:45 am
content: This project:A STM32 technology demonstrator showcasing the advantages of using the SWD (Serial Wire Debugging) interface as a Forth Terminal instead of the legacy serial USART. This is made to use a STMicro STM32F0 Discovery board but can use a SWD-USB Programmer and a STM32F0xx mcu instead.License:This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, seehttp://www.gnu.org/licenses/.Credits:SWDcom Demo written by Terry Porter terry@tjporter.com.auSWDcom by Jan Bramkamphttps://github.com/Crest/swdcomMecrisp-Stellaris by Matthias Kochhttps://sourceforge.net/projects/mecrisp/Serial communications.Forth is one of the oldest programming languages in existence having been developed in the early 70's. In those days a computer running Forth usually communicated with a serial device, perhaps a Teletype or later a Wyse dedicated electronic terminal to allow interactive development and program uploading.The availability of the IBM PC in the early 80's (and other readily available portable computers) allowed the use of terminal emulators such as Picocom, Minicom etc running on the PC itself instead of dedicated terminals.Developer unfriendly Usart based Forth legacy serial communications issues:Slow, most Forths don't go above 115200 Baud.No serial flow control. This requires 'end of line delays' to prevent the Forth compiler 'choking' on uploaded source code. These can be as large as 200 milliseconds (depending on the speed of the Forth mcu) making source uploads glacial.Changing the mcu clock speed is tedious as the usart Baudrate is derived from it.An external 'USB to 3.3v Serial Dongle' is required for most 'development boards' and stand alone mcus to talk to the PC.Resetting the mcu requires entering 'reset' into the Forth consoleMaking Forth developer friendly in 2020.Swdcom, provides a SWD based usart replacement along with a PC based terminal client that works with Linux and FreeBSD plus offers upload times equal to or faster than the equivalent GCC with Stlink on the same PC. Forth realtime interactivity also further reduces project development time.Swdcom advantages:Works across a range of the same class of mcu free from usart/pin dependencies.Fast, faster than a equivalent 460800 Baud serial terminal.Inbuilt ACK flow control, no compiler 'choking' issues.Clock speed agnostic as long as the MCU clock is running the swd2 terminal functions perfectly.Uses a single USB cable from the PC to most development boards or a usb/swd programmer for standalone mcus.Resetting the mcu is easily done by hitting CTRL+C on the PC keyboard.Running this DemoThis demo has been tested under Debian-10.6-xfce and FreeBSD so it should work for you on those platforms. It can be freely downloaded from the url below, testing comments and feedback welcome.https://mecrisp-stellaris-folkdoc.sourceforge.io/swdcom.html