BASTERM v3 (now with RTS/CTS, port scan, and FindBaud!)
Posted: Mon Jan 20, 2025 7:52 am
I've never coded up flow control for a UART, so after tons of trial and error - I think I finally got it stable with BASTERM (a serial-terminal done using BASLOAD/BASIC for X16).
Whatever I did, I was able to transfer the entire script of Bee Movie in text file form (49KB) in a continuous stream without a single dropped character. The CTS/RTS lights on the little USB/serial adapter seem correct.
Now, it can't be (easily) helped that under BASIC, we can only stream at about 200 Bytes Per Seconds. That's just the price of a constantly interpreted runtime even at 8MHz. But with all the steps now figured out, I'll do a C version next and see if we can ramp up the performance. The point was, even if I up the serial connection to 115200 (in BASIC), I can still transfer the file without error. And I no longer have to play games inserting a delay between characters when sending text files.
The spec sheet wasn't clear to me at all in how to do this. Things got so bad, I even actually turned to ChatGPT! But it wasn't really any help either. After hours of reading and walking the history of the Bell 103 to the TR1402 on up to the 2651 and 8250, and learning about 16x up-sampling and "2 of 3" hits to find start bits, I finally came across a discussion on why the FIFO interrupt hits at 14 (i.e. "almost full") instead of 16. And turns out, the slow-ness of BASIC needs even a bit longer runway!
All I know is I've gone from having to artificially add 16ms delay between characters, to now 0ms delay and use whatever baud rate, and things go without any drops.
So this VERSION3 of BASLOAD will work with both the SERIAL and NETWORK "sides" of the TexElec serial card, but will require CTS/RTS be enabled (which is fairly universal these days, so not an issue). You can keyboard-TYPE stuff without flow control (as most keyboards can't even type much past 300 or 600 baud equivalent, in terms of overall data-rate), but any kind of sustained streaming really needs an assist.
I've also added two other neat features:
- a "port scanning" mode to find which serial ports you have (another trial and error process, but I think I got it figured out)
- a "baud rate finder" feature, so if you forget or just don't know what your device was left at (and it has no display to show it), this can automatically just try them in sequence and find what works.
Hope this helps as a starting reference for some on how to program the serial card. More to come, but this was a helpful step to getting things reliable (and even in BASIC!).
Whatever I did, I was able to transfer the entire script of Bee Movie in text file form (49KB) in a continuous stream without a single dropped character. The CTS/RTS lights on the little USB/serial adapter seem correct.
Now, it can't be (easily) helped that under BASIC, we can only stream at about 200 Bytes Per Seconds. That's just the price of a constantly interpreted runtime even at 8MHz. But with all the steps now figured out, I'll do a C version next and see if we can ramp up the performance. The point was, even if I up the serial connection to 115200 (in BASIC), I can still transfer the file without error. And I no longer have to play games inserting a delay between characters when sending text files.
The spec sheet wasn't clear to me at all in how to do this. Things got so bad, I even actually turned to ChatGPT! But it wasn't really any help either. After hours of reading and walking the history of the Bell 103 to the TR1402 on up to the 2651 and 8250, and learning about 16x up-sampling and "2 of 3" hits to find start bits, I finally came across a discussion on why the FIFO interrupt hits at 14 (i.e. "almost full") instead of 16. And turns out, the slow-ness of BASIC needs even a bit longer runway!
All I know is I've gone from having to artificially add 16ms delay between characters, to now 0ms delay and use whatever baud rate, and things go without any drops.
So this VERSION3 of BASLOAD will work with both the SERIAL and NETWORK "sides" of the TexElec serial card, but will require CTS/RTS be enabled (which is fairly universal these days, so not an issue). You can keyboard-TYPE stuff without flow control (as most keyboards can't even type much past 300 or 600 baud equivalent, in terms of overall data-rate), but any kind of sustained streaming really needs an assist.
I've also added two other neat features:
- a "port scanning" mode to find which serial ports you have (another trial and error process, but I think I got it figured out)
- a "baud rate finder" feature, so if you forget or just don't know what your device was left at (and it has no display to show it), this can automatically just try them in sequence and find what works.
Hope this helps as a starting reference for some on how to program the serial card. More to come, but this was a helpful step to getting things reliable (and even in BASIC!).