Some of the words supporting serial communications are in files, not the Forth ROM. The following files redefine some of them. See also QUAD SERIAL PORT, page 310 for additional ports.
Inputs to the serial ports can be true RS232 levels (at least �3.0V) or just TTL. The outputs are at least �5.0V under a 3k load. The steady state is the negative voltage, which is logic 1 in RS232 terms. The voltages are generated on the TDS2020F from the +5V output of the regulator. No negative supply is needed and the card can be run from a single battery of +6V to 16V.
To save power the serial port drive chip can be turned off. This is described in LOW POWER OPERATION, page 89.
SERIAL PORT 1
Serial Port 1 is a hardware UART built into the H8/532 microprocessor. See the Hardware Manual Section 14 for details not here or in the Word List. Baud rates supported on serial Port 1 are:
At power-up the default baud rate is 9600. Note the 31250 baud rate for MIDI use. Transmit and receive baud rates are always the same as each other. Serial Port 1 is used for developing software but can also form part of the application.
Change the baud rate as needed, e.g. 1200 BAUD . Include BAUD in the initialisation of your program if serial Port 1 is to be used at a speed other than 9600 baud. The default mode is 8 data bits, one start and one stop bit but can be changed to other protocols including synchronous use.
The input and output words on serial Port 1 are all vectored and can be redirected to other peripherals as needed. See EMIT in the word list for an example. See LIQUID CRYSTAL DISPLAYS, page 101 for others.
File #SHELTER.TDS is an interrupt driven version of the software for serial Port 1, available with the Update Service. Received characters will not be missed at 9600 baud even when the Forth program is busy doing other work-they are stored in a circular buffer until needed. The position and size of the buffer are user adjustable. The word SHELTER should be executed (once only) to initialise the system.
SHELTER revectors input to the new routine and so shelters the application program from any problem of fast serial input bursts. Its use is advised whenever receiving data from another computer but keypad input is usually slow enough not to require it.
An extended version #XONXOFF.TDS, also part of the Update Service, performs all the functions of #SHELTER.TDS but adds X-on X-off handshaking. There are also versions that use RAM memory in the 32-pin socket to allow bigger buffers.
SERIAL PORT 2
Serial Port 2 is implemented in software written in machine code. It is not built into the Forth ROM but comes as file #SERIAL2.TDS on disk. If you will be using serial Port 2 incorporate this as part of your applications software.
Although software, it allows a foreground program to continue while asynchronous data is input to serial Port 2. The data received is placed under interrupt into a circular buffer from where it can be taken as needed by the foreground program. This is broadly equivalent to #SHELTER.TDS for serial Port 1.
The interrupt routine uses the 8-bit timer and its associated output compare registers. They should not be used elsewhere in the application.
Put xxxx 2BAUD before second serial port will be needed (execute once only), ideally in the word executed at power-up, where xxxx is the baud rate, e.g. 1200 2BAUD .
Use *KEY and *EMIT to receive and send one byte on serial Port 2. Or use the structure <2 . something here . 2> to temporarily redirect EMIT and KEY to serial Port 2.
Both reception and transmission of each data bit occurs under interrupt so that the main program does not have to hang around servicing the serial port for the duration of the whole byte. Remember for example that after *EMIT the data will still be in the process of transmission while you are executing the words which follow *EMIT
Baud rates supported on serial Port 2 are:
Transmit and receive baud rates are always the same as each other but the program is capable of modification to make them different.
The data format is one start bit, 8 data bits and one or more stop bits. If 7 bits plus parity is needed this can be provided at a higher level. The software looks very like a real UART to the main program.
For use with 0V/+5V levels instead of RS232, see GPS SOFTWARE CUSTOMISATION, page 324.