Xilinx Vitis Drivers API Documentation
uartps Documentation

This driver supports the following features:- Dynamic data format (baud rate, data bits, stop bits, parity)

  • Polled mode
  • Interrupt driven mode
  • Transmit and receive FIFOs (32 byte FIFO depth)
  • Access to the external modem control lines

Initialization & Configuration

The XUartPs_Config structure is used by the driver to configure itself. Fields inside this structure are properties of XUartPs based on its hardware build.

To support multiple runtime loading and initialization strategies employed by various operating systems, the driver instance can be initialized in the following way:

  • XUartPs_CfgInitialize(InstancePtr, CfgPtr, EffectiveAddr) - Uses a configuration structure provided by the caller. If running in a system with address translation, the parameter EffectiveAddr should be the virtual address.

Baud Rate

The UART has an internal baud rate generator, which furnishes the baud rate clock for both the receiver and the transmitter. The input clock frequency can be either the master clock or the master clock divided by 8, configured through the mode register.

Accompanied with the baud rate divider register, the baud rate is determined by:

      baud_rate = input_clock / (bgen * (bdiv + 1)

where bgen is the value of the baud rate generator, and bdiv is the value of baud rate divider.


The FIFOs are not flushed when the driver is initialized, but a function is provided to allow the user to reset the FIFOs if desired.

The driver defaults to no interrupts at initialization such that interrupts must be enabled if desired. An interrupt is generated for one of the following conditions.

  • A change in the modem signals
  • Data in the receive FIFO for a configuable time without receiver activity
  • A parity error
  • A framing error
  • An overrun error
  • Transmit FIFO is full
  • Transmit FIFO is empty
  • Receive FIFO is full
  • Receive FIFO is empty
  • Data in the receive FIFO equal to the receive threshold

The application can control which interrupts are enabled using the XUartPs_SetInterruptMask() function.

In order to use interrupts, it is necessary for the user to connect the driver interrupt handler, XUartPs_InterruptHandler(), to the interrupt system of the application. A separate handler should be provided by the application to communicate with the interrupt system, and conduct application specific interrupt handling. An application registers its own handler through the XUartPs_SetHandler() function.

Data Transfer

The functions, XUartPs_Send() and XUartPs_Recv(), are provided in the driver to allow data to be sent and received. They can be used in either polled or interrupt mode.


The default configuration for the UART after initialization is:

  • 9,600 bps or XPAR_DFT_BAUDRATE if defined
  • 8 data bits
  • 1 stop bit
  • no parity
  • FIFO's are enabled with a receive threshold of 8 bytes
  • The RX timeout is enabled with a timeout of 1 (4 char times)
Ver   Who    Date       Changes

1.00a drg/jz 01/12/10 First Release 1.00a sdm 09/27/11 Fixed compiler warnings and also a bug in XUartPs_SetFlowDelay where the value was not being written to the register. 1.01a sdm 12/20/11 Removed the InputClockHz parameter from the XUartPs instance structure and the driver is updated to use InputClockHz parameter from the XUartPs_Config config structure. Added a parameter to XUartPs_Config structure which specifies whether the user has selected Modem pins to be connected to MIO or FMIO. Added the tcl file to generate the xparameters.h 1.02a sg 05/16/12 Changed XUARTPS_RXWM_MASK to 0x3F for CR 652540 fix. 1.03a sg 07/16/12 Updated XUARTPS_FORMAT_7_BITS and XUARTPS_FORMAT_6_BITS with the correct values for CR 666724 Added defines for XUARTPS_IXR_TOVR, XUARTPS_IXR_TNFUL and XUARTPS_IXR_TTRIG. Modified the name of these defines XUARTPS_MEDEMSR_DCDX to XUARTPS_MODEMSR_DDCD XUARTPS_MEDEMSR_RIX to XUARTPS_MODEMSR_TERI XUARTPS_MEDEMSR_DSRX to XUARTPS_MODEMSR_DDSR XUARTPS_MEDEMSR_CTSX to XUARTPS_MODEMSR_DCTS 1.05a hk 08/22/13 Added API for uart reset and related constant definitions. 2.0 hk 03/07/14 Version number revised. 2.1 hk 04/16/14 Change XUARTPS_MAX_RATE to 921600. CR# 780625. 2.2 hk 06/23/14 SW reset of RX and TX should be done when changing baud rate. CR# 804281. 3.0 vm 12/09/14 Modified source code according to misrac guideline. Support for Zynq Ultrascale Mp added. 3.1 kvn 04/10/15 Modified code for latest RTL changes. Also added platform variable in driver instance structure. 3.1 adk 14/03/16 Include interrupt examples in the peripheral test when uart is connected to a valid interrupt controller CR#946803. 3.2 rk 07/20/16 Modified the logic for transmission break bit set 3.4 ms 01/23/17 Added xil_printf statement in main function for all examples to ensure that "Successfully ran" and "Failed" strings are available in all examples. This is a fix for CR-965028. ms 03/17/17 Added readme.txt file in examples folder for doxygen generation. 3.6 ms 02/16/18 Updates the flow control mode offset value in modem control register. 3.7 aru 08/17/18 Resolved MISRA-C:2012 compliance mandatory violations. 3.9 rna 12/03/19 Modified the XUARTPS_MAX_RATE macro. 3.9 sd 02/06/20 Added clock support