Connecting a Serial Terminal

Mecrisp Stellaris is programmed via a serial terminal, often running on a PC. Communication parameters are serial, at 115200 baud, 8N1.

USB-3.3v Dongle or cables

USB serial Dongles or cables are usually the easiest way to connect a PC running Picocom to a STM32 Discovery Board. Don’t forget to buy at least four female to female pin connecting cables for a dongle. These are usually available online in bundles.

Picture of Unix friendly PL2303 chipset dongle, usually about $0.70 AUD each in a pack of 5 on Ebay

_images/usb-3_3v-serial-dongle.jpg

Picture of a USB-3.3v cable

_images/usb-3_3V-cable.jpg

Warning

Don’t use RS-232 cables or you may blow up your Board/MCU from overvoltage

Supported Device Communications Paramaters

Board MCU Comms Type TX RX USB serial bridge ?
Stellaris Launchpad LM4F120 UART 0 ? ? Y
Chinese QF-LM4F232 LM4F232H5QC ? ? ? ?
Tiva Connected Launchpad TM4C1294 UART 0 ? ? Y
TI MSP432 Launchpad MSP432P401R USCI 0 P1.3 P1.2 Y
Standalone MCU LPC1114FN28 UART P1.7 P1.6 N
Standalone MCU LPC1115FBD48 UART P1.7 P1.6 N
Standalone MCU STM32F030F4 USART1 PA9 PA10 N
STM32F0 Discovery STM32F051R8 USART1 PA9 PA10 N
STM L053 Discovery STM32L053C8 USART1 PA9 PA10 N
STM VL Discovery STM32F100RB USART1 PA9 PA10 N
Shenzhen LC mini STM32 STM32F103C8T6 USART1 PA9 PA10 N
STM Nucleo L152RE STM32L152RE USART2 PA9 PA10 Y
STM F3 Discovery STM32F303VCT6 USART1 PA9 PA10 N
STM Nucleo 401RE STM32F401RE USART2 PA2 PA3 Y
STM F429 Discovery STM32F429ZIT6 USART1 PA9 PA10 N
STM F4 Discovery STM32F407VGT6 USART2 PA2 PA3 N
STM Nucleo 411RE STM32F411RET6 USART2 PA2 PA3 Y
STM L476 Discovery STM32L476VG USART2 PD5 PD6 Y
STM F746 Discovery STM32F746NG ? ? ? ?
Freescale Freedom FRDM?KL25Z KL25Z128VLK4 UART0 ? ? Y
Teensy 3.1 MK20DX256VLH7 UART0 Pin3 Pin2 Pin18/19 CTS/RTS
nRFgo Starter Kit nRF51822 ? ? ? ?
Infineon XMC2GO XMC1100Q024F0064 ? ? ? ?
EFM32 Giant Gecko EFM32GG990F1024 ? ? ? ?

Forth Explorer (fe.py)

A Serial Terminal Emulator Specifically for Mecrisp-Stellaris

  • Author: Kfoltman

Features:

  • No end of line delay needed: FE waits for the ‘ok’ emitted by Mecrisp-Stellaris before sending the next line. Uploading Forth programs doesn’t get any faster than this.

  • Previous Command Recall: up arrow recalls previous commands from your session for reuse, a BIG timesaver, and FE now saves this between sessions so when you use FE next time, commands used in earlier sessions are still available with the up arrow.

  • Error checking: will stop on the most errors, alerting you to that ”;” you forgot ;-) including :-
    • Not Found
    • Redefine
    • Unterminated string constant
    • Structures don’t match
  • AUDIBLE ERROR ALERT: FE now plays configurable SOUND BITEs on file upload :
    • file error audible alert
    • file completion audible alert
  • Comment stripping to speed things up.

  • NEW –> Dumb Terminal Mode, switch between Smart and Dumb terminal on the fly !

Note

FE Dependencies

  • Python
  • py-serial
  • sox
  • a couple of wav files to play for completed and error uploads, (set these in FE itself).

FE commands

Note: See the GNU Readline manual for all available commands

Description Notes
python fe.py /dev/cuaU1 starts the FE terminal emulator in Smart mode
Ctrl + D quit FE, (only in Smart mode)
!S <file> or Ctrl+R upload a file, defaults to last file
!T or Ctrl+T switch to a dumb TTY mode
Ctrl+X switch back to Smart Terminal mode

FE Notes

  • Very stable on a Freebsd machine to a STM32Fo Discovery via a USB/serial dongle
  • Forth Explorer (fe.py) is in this repo, or can be downloaded from the link below
  • [http://128.199.141.78/fe.py]

Screenpic

This is a example of a Mecrisp-Stellaris terminal session
using kfoltmans fe.py

# python fe.py  /dev/cuaU7
<-  Mecrisp-Stellaris 2.2.4 with M0 core for STM32F051
by Matthias Koch

Forth> !s adc-config.txt
->

< editor comment: manual code snip of file upload for brevity>

-> : ADC_CHSELR-PRINT-LOOP.
<-   ok.
-> 0 <#
<-   ok.
-> 18 0 DO
<-   ok.
-> # 32 HOLD LOOP
<-   ok.
-> # #>
<-   ok.
-> TYPE ;
<-   ok.
-> 
<-   ok.
-> : ADC_CHSELR-PRINT. cr
<-   ok.
-> ." B|T|V|P|P|P|P|P|P|P|P|P|P|P|P|P|P|P|P" cr
<-   ok.
-> ." A|E|O|C|C|C|C|C|C|B|B|A|A|A|A|A|A|A|A" cr
<-   ok.
-> ." T|M|L|5|4|3|2|1|0|1|0|7|6|5|4|3|2|1|0 " cr
<-   ok.
-> @ binary ADC_CHSELR-PRINT-LOOP. decimal cr ;

< editor comment: manual code snip for brevity, the code has
successfully uploaded without error>

Forth> 

< editor comment: now about to run a word called "t" >

Forth> T
-> T
<-  *** STM32F0xx ADC Configuration Printer ***
<- 
<- ADC-CLOCK ON (RCC_APB2ENR bit 9 = 1) 
<- ADC is ENABLED (ADC_ADEN bit 0 = 1)
<- EOC (End Of Conversion) = 0 (ADC_ISR bit 2 Read Only), NO ADC
 conversion is waiting to be read 
<- EOCIE (EOC Interrupt Enable) = 0 (ADC_EOCIE bit 2 Read Only) EOC
 Interrupt Disabled 
<- ADC_CHSELR: NO ADC CHANNELS are being scanned! 
<- 1 in any bit position (3rd line below) means the ADC will scan that
 channel/pin during a conversion 
<- B|T|V|P|P|P|P|P|P|P|P|P|P|P|P|P|P|P|P
<- A|E|O|C|C|C|C|C|C|B|B|A|A|A|A|A|A|A|A
<- T|M|L|5|4|3|2|1|0|1|0|7|6|5|4|3|2|1|0 
<- 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<- ADC BATtery measurement is DISABLED (ADC_CCR bit 24 = 0) 
<- ADC TEMperature Sensor is DISABLED (ADC_CCR bit 23 = 0) 
<- ADC VOLtage Reference is DISABLED (ADC_CCR bit 22 = 0) 
<- 
<- 
<-  ok.
Forth>

Picocom

A useful serial terminal to use with Mecrisp Stellaris is Picocom https://github.com/npat-efault/picocom

To connect Picocom it is run this way :-

picocom -b 115200 /dev/cuaU0 –imap lfcrlf,crcrlf –omap delbs,crlf –send-cmd “ascii-xfr -s -l200”

Command Description
picocom excutable
-b 115200 baud rate of 115200
/dev/cuaU0 the PC serial device, yours may differ
–imap lfcrlf,crcrlf input char mapping
–omap delbs,crlf output char mapping
–send-cmd “ascii-xfr -s -l200 200mS line delay to give the compiler time when uploading files
Some useful Picocom Commands
Action Description Notes
quit <ctrl> A Q  
upload a file <ctrl> A S this command has TAB completion

Picocom screen capture

_images/picocom.jpg