RXD
 
Syntax


#include <SERIAL.bas>

bbRXD ( pin )

Description


bbRXD (pin) will receive a single byte of data that is shifted as an asynchronous serial stream.  This function is similar to SERIN, but has less overhead and only receives a single byte.  The baudrate for the pin should be set before using bbRXD, that is done using the bbBAUD(pin) function.

RXD will return 0-255 if there was data present. bbRXD will timeout after 0.5 seconds and return -1 (&HFFFFFFFF) if there is no serial stream detected on pin

These routines are "bit-banged" by the processor, so the processor is consumed during these operations.  Interrupts are also disabled during each byte for these operations. 

As of version 6.21 the 0.5 second timeout can be changed by SERINtimeout.

Baudrates can be up to 57 Kbaud for all pins.

Example

#include <SERIAL.bas>

bbBAUD(1) = 9600      ' set the baud rate for serial I/O on pin 1

' Wait for serial input on pin 1
DO
    MyByte = bbRXD(1)
UNTIL MyByte >= 0

Differences from other BASICs

See also