Syntax
#include
<SERIAL.bas>
' source in /Program Files/Coridium/BASIClib
SUB bbTXD(pin, ch)
Description
bbTXD (
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 bbTXD,
that is done using the bbBAUD(pin) array.
bbTXD 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.
Interrupts are also disabled during each byte for these
operations.
Example
#include <SERIAL.bas>
DIM Astr(10) as STRING
bbBAUD(2) = 19200
' set the baud rate for serial I/O on pin
2
'...
Astr = "Hello World"
GOSUB
PRINTSTR
'...
' Send a string of characters serially out pin
2
PRINTSTR:
I=0
WHILE
Astr(I)
bbTXD(2,Astr(I))
I=I+1
LOOP
RETURN
Differences from other BASICs
- no equivalent in Visual BASIC
- SEROUT in PBASIC
See also