manufacturer of I/O-rich SBCs, operator interfaces, handheld instruments, and development tools for embedded control low cost single board computers, embedded controllers, and operator interfaces for scientific instruments & industrial control development tools for embedded control order our low cost I/O-rich embedded control products embedded controller manufacturer profile single board computers & embedded controllers development tools & starter kits for your embedded design operator interfaces with touchscreens and graphical user interface plug-in expansion modules for digital & analog I/O C language & Forth language integrated development tools, IDE single board and embedded computer accessories embedded controller enclosures, bezels, environmental gaskets
Table of Contents


Serial Communications Basics




UART Wildcard Hardware

Connecting To Mosaic Controller

Selecting the Module Address

RS422/485 Configuration Jumpers

Protocol Configuration and Direction Control Registers

Modem Handshaking Signals

UART Module Field Header

Cable Connections


Overview of the Software Device Driver Functions

Installing the UART Module Driver Software

Using the Driver Code with C

Using the Driver Code with Forth

UART Direction Control in a Multitasking System


Overview of Glossary Notation

Glossary Quick Reference

Glossary Entries

C Demonstration Program (in pdf)

Forth Demonstration Program (in pdf)

Hardware Schematics (in pdf)

UART Wildcard User Guide

<< Previous | Next>>


A package of pre-coded device driver functions is provided to make it easy to control the UART Wildcard. This code is available as a pre-compiled "kernel extension" library to C and Forth programmers. Both C and Forth source code versions of a demonstration program are provided. This demo program illustrates how to initialize and use the UART Wildcard in an RS232 multitasking application.

Overview of the Software Device Driver Functions

The UART Wildcard driver code makes it easy to configure the baud rate, data format, and protocol for each channel, send and receive characters, and control the direction of an RS485 channel. A demonstration program shows how to use the functions, and how to revector the serial primitives so that standard I/O print routines (such as ." in Forth and printf in C) will automatically use a specified serial channel on the UART Wildcard.

Most of the functions accept as input parameters the channel number (1 or 2), and the UART Wildcard number (0 through 7). The constants CHANNEL1 and CHANNEL2 are synonyms for 1 and 2, respectively; they are provided to allow for clean readable code. The Wildcard number passed to the software functions must correspond to the hardware jumper settings as described in Table 1-1 above.

The initialization functions are Set_UART_Number, Set_Baud, Set_Data_Format, and Set_Protocols. Set_UART_Number sets a variable that holds the Wildcard number used by the channel-specific serial I/O routines described below; this value can be read using the function Read_UART_Number. Set_Baud sets the bit frequency to a specified integer value that can span standard rates from 300 up to 56000 bits per second.

Set_Data_Format accepts parameters that specify the number of data bits, number of stop bits, and parity for the specified channel. A set of pre-defined constants makes it easy to specify the desired parity; they are: NO_PARITY, EVEN_PARITY, ODD_PARITY, HIGH_PARITY, and LOW_PARITY. See the "Serial Communications Basics: Data Format" section above for a description of the parity modes. The standard controller serial ports operate with 8 data bits, 1 stop bit, no parity, and a baud rate of 9600 or 19200.

The fundamental serial I/O routines are called Emit_UART, Ask_Key_UART, and Key_UART. Each accepts a channel number and Wildcard number as input parameters. Emit_UART also accepts an input character, which it queues in the outgoing FIFO for transmission on the specified serial channel. Ask_Key_UART tests whether an input character is pending in the receiver FIFO; if so, it returns a true (-1) flag, and if not, it returns a false (0) flag. Key_UART returns the next pending character in the input FIFO; if the FIFO is empty, it waits for a character and returns it.

The channel-specific serial I/O routines are called Ch1_Emit, Ch2_Emit, Ch1_Ask_Key, Ch2_Ask_Key, Ch1_Key, and Ch2_Key. These routines have the correct parameter list to enable revectoring of serial I/O functions as illustrated in the demonstration program. Each uses the Wildcard number that has been set using the Set_UART_Number function, and the channel number suggested by the function name. Ch1_Emit and Ch2_Emit queue a specified character in the outgoing FIFO for transmission. Ch1_Ask_Key and Ch2_Ask_Key test whether an input character is pending in the receiver FIFO; if so, a true (-1) flag is returned. Ch1_Key and Ch2_Key return the next pending character in the input FIFO. Full duplex protocols (RS232 and RS422) operate with both transmitters and receivers active at all times. The half duplex RS485 protocol requires that the channel be either transmitting or receiving. The functions RS485_Xmit_UART and RS485_Rcv_When_Xmit_Done control the RS485 direction for the specified channel and Wildcard number. As expected, the former function establishes the transmit mode. The latter establishes the receive mode after all pending outgoing characters have been sent, thereby avoiding errors caused by shutting off the transmitter in the middle of a character transmission.

Additional functions allow the application to send break characters, and set and read the modem handshaking signals.

For detailed specifications on control of the communications port, refer to the UART data sheet (Texas Instruments Part# TL16C552A).

<< Previous | Next>>

Home|Site Map|Products|Manuals|Resources|Order|About Us
Copyright (c) 2006 Mosaic Industries, Inc.
Your source for single board computers, embedded controllers, and operator interfaces for instruments and automation