UART0 and UART1 support is built into the BASIC
compiler. UART1 and BAUDx support added in 7.13 firmware.
Support for UART2 and UART3 is done with library routines in UART17.bas in
the BASIClib directory for the SuperPRO and PROplus.
Interface
DEBUGIN variable | string
PRINT [expressionlist] [(, | ;)] ...
FUNCTION RXD0
FUNCTION RXD1
SUB TXD0 (
expr)
SUB TXD1 (expr)
SUB BAUD0 (
expr)
SUB BAUD1 (expr)
Description
DEBUGIN gives the programmer a way to accept
strings or numbers from the USB serial port. In many BASICs this uses
INPUT, but in ARMbasic INPUT is used to control the direction of one of the
IO pins. So a simplified replacement of the normal BASIC INPUT has been
added, called DEBUGIN.
DEBUGIN has a limited edit capacity: it allows to erase
characters using the backspace key. If a better user interface is needed, a
custom input routine should be used.
PRINT will send strings or numbers to the debug serial
port (UART0), which may be displayed in BASICtools, or can be interpreted by a
user program running on the PC. Simple formating is accomplished by
seperating expressions with a comma (for TAB) or semicolon for no space
seperation. A semicolon at the end of a PRINT suppresses carriage
return.
RXD0 uses the hardware UART,
so the CPU is not tied up. Also when RXD0 is read and no data is
available -1 is returned immediately, RXD0 uses interupts and has a buffer
of 256 characters that are filled by interrupt running in the background.
TXD0 uses the hardware serial port
to send data out the USB debug port. Data is transfered into a 16 byte
FIFO, when that FIFO is full the CPU will wait until space is available.
On the ARMexpress/ARMexpress LITE
these routines are all limited to 19.2Kb due to the level translators for
RS-232. If the connection to the ARMexpress/LITE is short (less than a
couple inches), then higher baud rates can be used.
Added in version 7.13 --
BAUD0 will set the baud rate for
TXD0, RXD0, the default is 19.2Kbaud.
BAUD1 will set the baud rate for
TXD1, RXD1 and will enable that serial channel (in ARMmite these pins are
general purpose IOs IO(0)switches to RXD1 and IO(1) switches to TXD1.
RXD1 uses the hardware UART,
so the CPU is not tied up. Also when RXD1 is read and no data is
available -1 is returned immediately, RXD1 uses interupts and has a buffer
of 256 characters that are filled by interrupt running in the background.
TXD1 uses the hardware serial port
to send data out the IO(1) on the ARMmite. Data is transfered into a 16
byte FIFO, when that FIFO is full the CPU will wait until space is
available.
Example
'
simple example of serial write and read
BAUD0 (2400)
' change the default baud rate
...
TXD0("X")
ch = RXD0
WHILE ch <
0 ' wait for a
character to come in
ch = RXD0
LOOP
...
Differences from other
BASICs
- Visual BASIC
-
PBASIC has similar functions, DEBUGIN allows a string
to be printed before input