Close

New release 0.20, STM8 eForth updated to 2.2.27.pre2, better board support pattern

A project log for MODBUS Things with STM8 eForth

Projects (and mishaps) for talking MODBUS to STM8 eForth

thomasThomas 02/06/2021 at 18:300 Comments

A request from @niuyingxian for STM8EF-MODBUS support for the STM8S001J3RS485 board was a good reason to finally apply some of the improvements in STM8 eForth 2.2.26 for improving board support. One of the challenges addressed by the current STM8 eForth release was dealing with STM8 device hardware dependencies. While working on the code I realized that moving from Ubuntu 16.04 to 20.04 removed Python 2.7 support, which made using the current development version 2.2.27.pre2 necessary. STM8EF-MODBUS uses the "modular build" method, and "make depend" automatically loads the configured STM8 eForth release.

The top level Makefile now handles multiple board variants at the top level, and targets are split between "MODBOARD" and "BOARD" targets:

On the target support side, I added a board.fs and BUSCTRL for the STM8S001J3RS485 board:

STM8S001J3M3 MODBUS moduleThe Forth console communication works with a simulated serial interface through PC5 (J2.4). The way the UART is used for the RS485 communication (RX/TX through PD5 in "half duplex mode" and direction through PD6) created a spurious RX receive event when switching the bus from TX back to RX. A dummy read of UART_DR and toggling the RX interrupt enbale in BUSCTRL solved the problem.

There is one minor hardware issue with the RX/TX LED: it has the bus activity the wrong way, i.e. it's lit when the RS485 bus is idle. A new board revision V1.2 will fix that.

I also tested the code with a C0135 - everything should work as expected.

Discussions