Phwoar! This is really cool. I never got a chance to look at serial. Do you mind if I use this this code (with attribution, of course) for TurboForth?
Would you mind posting some example outputs from BAUD (i.e the value that gets written into BPS) for some example baud rates? I need to check UM/MOD implementation in TF :-)
Also, can you post your code for MS if you don't mind? :-)
It'll give me something to look at over Christmas (along with Lee's recent work of CF7 and variants) now that uni has stopped until January.
Of course you can use it, as long as I can re-used the fixes you find. :-)
Actually I am working on it on real iron and there is a bug with the baud rate setting for lower rates. 9600 and 19200 worked ok.
I found a table in an old TI book and it looked linear down to 600 Baud.
I am not sure if I can get handshaking correct for the receive side. I don't have an rs232 breakout box so it's painful.
Without interrupts of course you drop characters easily but for a console port TTYKEY is fast enough for human fingers.
A few machine code words would make it quicker.
The MS code is here in my cross-compiler Forth.
My little ticker is strange because it has to accommodate
1. My compiler can only build 8K images
2. I need to support cooperative multitasking
But it seems to work well on real hardware giving a consistent time. I have a constant in the code that compensates for Forth overhead and it might be better to be a variable that could be calibrated to a machine.
It could be much finer grained as a CODE word that stops the system, or I suppose it could trigger an interrupt.
Lots of ways to make it better.
The TMR! word starts the 9901 running continuously which broke Classic99 but Tursi fixed it for me. (Thanks Tursi)
Merry Christmas! :-)