Close

Simple buffered UART RX

A project log for eForth for cheap STM8S gadgets

Turn cheap modules from AliExpress into interactive development kits!

ThomasThomas 05/23/2020 at 15:540 Comments

The MODBUS project has buffered UART, which is necessary because the protocol works in the background.

A UART buffer for the Forth console also makes sense, especially when a baud rate higher than 9600 baud is to be used. The solution INTRX, with an ISRwritten in Forth, is really simple.

The In PulseView screenshot below shows a situation where the Background Task blocks the foreground console execution most of the time:

An interactive console still works. For some reason compiling is much more picky : the background task is allowed to run for a 2.5 out of 5 ms (that is 2-3 char intervals at 9600 baud). I still don't understand why but it has nothing to do with delays due to Flash programming.

Edit: the solution is, very simply, that the receive buffer wasn't big enough for this much delay. If I use 80 bytes (the same length as the TIB) uploading Forth code works without problems:

Also Flash programming works as expected - this is no surprise since the programming process starts at the end of a line and stalls all, also the background task.

Discussions