PDA

View Full Version : Forth Serial Transmit Buffer


Mark Bresler
04-20-10, 10:07 PM
Hi,
My program is crashing and I think it is because I am asking it to send a lot of characters out the serial port. I have an untimed loop that takes sensor data, manipulates it and sends it to the serial port. I want to stay at 9600 baud because I have a radio transeiver that only works at that rate.
Questions:
1) how many characters can be put into the transmit buffer?
2) How do I check how full the buffer is?
3) Is there a difference between Forth 3.3 and Forth 3.5E ?

I will look at the program and try to trim unneeded characters, but I expect it could be 40 characters per loop.

From a look at the HC11 manual, I think there is a 1 character buffer shared between transmit and receive.

Thanks in advance for your thoughts,
Mark

RMDumse
04-21-10, 09:05 AM
Questions:
1) how many characters can be put into the transmit buffer?


There's no interrupt structure or buffering on the HC11 code as is. All the hooks are there so you can add a buffered serial driver if you wish. But we tried to keep the simplest posible interface, without overhead in the users way, but still provide the hooks so fancier routines could be easily added.


2) How do I check how full the buffer is?


Basically, you don't check the buffer. If you call the transmit routing with a character say using EMIT or something like ." that calls EMIT, that one character is passed on the stack. The control passes through UEMIT to our standard routine that checks for a buffer empty flag, then takes the thing from the stack and puts it in the hardware buffer register. The buffer is only one deep. So it can be shifting one character out, while holding one ready to go. So you don't get control back from EMIT until the character in the buffer moves to the output shift register, and the buffer becomes open to take one new character.


3) Is there a difference between Forth 3.3 and Forth 3.5E ?


In this regard? Not any really.

Mark Bresler
04-21-10, 11:08 AM
When I use ." XXXXXXXXXXX " , are the characters moved to the stack or somewhere else waiting to be put out or does ." just move through the line in place one character at a time?
Thanks,
Mark

RMDumse
04-21-10, 02:29 PM
There's the compile time action of ." and then there's the run time action of the primative (.") that ." compiles. (.") is a word with a loop that types the counted string following it compiled into memory. ." puts the (.") primative into the definition then counts the string to the next" and moves it into the definition following the (."). So at run time (.") calls TYPE which picks up a character and EMITs it. EMIT hands until the hardware can take the character, then goes back. TYPE gets control and picks up the next character and calls EMIT again. And so on, until TYPE finishes getting all the characters out. Then TYPE ends and passes control back to (.") which branches to the next command after the string ending character.