Uart, Uart0, Uart1, Uart2, Uart3

Uartn are the interfaces for the serial Uart of the controller (RS232, RS485, ..).

Properties (write only)

Name Description Values
.Baud Setup baud rate Baud rate (word)
.Recv/.Rxd Receive on/off .enable, .disable
.Send/.Txd Transmit on/off .enable, .disable
.Recv.Fifo=bytes Setup / initialize receive Fifobuffer. 2-65534 (Constant)
.Send.Fifo=bytes Setup / initialize transmit Fifobuffer. 2-65534 (Constant)
.DirPin=<portpin> TX / RX pin Direction define for protocols that require a signal to adjust the data direction (RE / DE) such, Ex. with RS485 transceivers. All Uartfunktionen automatically set this pin then, depending on the output direction (also in FIFO mode). <port>.<pin>
.DirPin.Mode=<modus> Setting logic mode of DirPin (optional). Default is High during writing. Inverted Low is in writing. normal/inverted
.IsrSend Set service routine for send complete Isr-Name
.IsrRecv Set service routine for Receive-complete Isr-Name
.IsrEmpty Set service routine for Data-empty Isr-Name
.IsrSend Interrupt Send-complete on/off .enable, .disable
.IsrRecv Interrupt Receive-complete on/off .enable, .disable
.IsrEmpty Interrupt Data-empty on/off .enable, .disable

Properties (read only)

Name Description Typ
.ByteAvailable Queries whether a character is available and can be read. byte (0=false)
.RxReady same to .ByteAvailable byte (0=false)
.TxReady Queries whether a character can be sent. byte (0=false)
.RxOverrun Queries whether the receive buffer during the previous operation overflowed (only available with FIFO). byte (0=false)
.Status Uart-Status (Bitvektor), see Atmel-Documentation for Port „USR“ byte(0=false)

Methods

Name Description Typ r/w
.Print Output of several values, see Print. - write
.InpStr([echo,[breakChar]]) Reads up to 254 characters from the interface and stops when breakChar (default value: 13) arrives. Note: The received bytes are stored temporary onto the program stack! The input stops if the end of stack space is reached! Is echo zero (default value: 1), an echo is suppressed to the transmitter. The two parameters are optional. string read
.GetByte Read byte directly without status check ( 0x00 if no byte are received). byte read
.ReadByte Read byte (wait until byte available) byte read
.ReadWord Read word (wait until byte available) word read
.ReadInteger Read integer (wait until byte available) integer read
.ReadLong Read long (wait until byte available) long read
.ReadSingle Read single (wait until byte available) single read
.Read sramAdresse,Anzahl Specified number bytes read and write to the memory (wait until all characters read). - read
.ReadC sramAdresse Read Bytes and in the memory write (waits until a null byte is read, the null character is not saved.). - read
.ReadP sramAdresse Read Bytes and in the memory write (The first character received estimates the number to be read bytes. Wait until all the characters read.). - read
.PutByte Byte schreiben (direkt, ohne Statusprüfung) byte write
.WriteByte Byte schreiben (wait until output is ready) byte write
.WriteWord Word schreiben (wait until output is ready) word write
.WriteInteger Integer schreiben (wait until output is ready) integer write
.WriteLong Long schreiben (wait until output is ready) long write
.WriteSingle Single schreiben (wait until output is ready) single write
.Write sramAdresse,Anzahl Write specified number of characters from memory (waiting until all characters written). - write
.WriteC sramAdresse Write characters from memory until zero byte appears (waiting until all the characters are written. Zero byte is ignored). - write
.WriteP sramAdresse Write characters from memory, the first character defines the number of bytes (wait until all characters written). - write
.CWrite flashAdresseBytes,Anzahl Write specified number of characters from flash memory (waiting until all characters written). - write
.CWriteC flashAdresseBytes Write characters from flash memory until zero byte appears (waiting until all characters written. Zero byte is ignored). - write
.CWriteP flashAdresseBytes Write characters from flash memory, the first character defines the number of bytes (wait until all characters written). - write
.Flush Clear/Reset Receive buffer - call
.Dump Hexdump-Ausgabe zum Debugging, siehe Dump. - call

The use of Uart always refers to the set standard interface. The default is Uart0. This also affects the functions Print and InpStr. With a global effective property, the default standard interface are set once the program starts:

Additional property for „Uart“ (write only)
Name Beschreibung Werte
Uart.Interface = interfaceName Set default interface when using „UART“ (without number). Uart0, Uart1, Uart2 oder Uart3
' Simple Terminal with Echo
Uart0.Baud = 19200
Uart0.Recv.enable
Uart0.Send.enable
 
dim char as byte
do
  char = Uart0.ReadByte   ' Wait characters available and then read
  select case char
  case 0,10               ' ignoe zero bytes and line feed
  case 13                 ' Return?
    Uart0.WriteByte 13    ' output CR
    Uart0.WriteByte 10    ' output LF
  caseelse
    Uart0.WriteByte char  ' Output character back (Echo)
  end select
loop

See also: Idle-EndIdle