Syntax
#include
<SERIAL.bas>
' source in /Program Files/Coridium/BASIClib
SUB TXD(pin, ch)
Description
TXD (
pin, ch) will send a single
byte of data that is shifted out as an asynchronous serial stream on
pin. This function is similar
to SEROUT, but is a more efficient implementation. The
baudrate for the pin should be set before using TXD, that is done using
the BAUD(pin) array.
TXD will transmit 0-255 as a single byte of data with an
added START bit and trailing STOP bit. As this function is done by the CPU (often referred to as bit-banging, the program
will stay at this instruction until the shifting is completed. So the processor is
consumed during these operations. Interupts are also disabled during each byte for these
operations.
Example
DIM A$(10)
BAUD(2) = 19200 ' set the baud rate for serial I/O
on pin 2
...
A$ = "Hello World"
GOSUB PRINTSTR
...
' Send a string of characters serially out pin 2
PRINTSTR:
I=0
WHILE A$(I)
TXD(2,A$(I))
I=I+1
LOOP
RETURN
Differences from other BASICs
- no equivalent in Visual BASIC
- SEROUT in PBASIC
See also