Notes on UART Protocol ??
Notes on UART Protocol ??
STARTTX
STARTRX
RXD-5
RXD TXD STOPTX
STOPRX RXD-4 TXD
(signal)
RXD-3 (signal)
RXD-2
RXD-1
RXTO
RXD
RXDRDY TXDRDY
Functional description
Listed here are the main features of UART.
Full-duplex operation
Automatic flow control
Parity checking and generation for the 9th data bit
As illustrated in Fig ure 1, the UART uses the TXD and RXD registers directly to transmit and receive data.
The UART uses one stop bit.
Pin configuration
The different signals RXD, CTS (Clear To Send, active low), RTS (Request To Send, active low), and TXD
associated with the UART are mapped to physical pins according to the configuration specified in the
PSELRXD, PSELCTS, PSELRTS, and PSELTXD registers respectively.
If a value of 0xFFFFFFFF is specified in any of these registers, the associated UART signal will not be
connected to any physical pin. The PSELRXD, PSELCTS, PSELRTS, and PSELTXD registers and their
configurations are only used as long as the UART is enabled, and retained only for the duration the device is
in ON mode. PSELRXD, PSELCTS, PSELRTS and PSELTXD must only be configured when the UART is disabled.
To secure correct signal levels on the pins by the UART when the system is in OFF mode, the pins must be
configured in the GPIO peripheral as described in Pin config uration.
Only one peripheral can be assigned to drive a particular GPIO pin at a time. Failing to do so may result in
unpredictable behavior.
UART pin Direction Output value
RTS Output 1
TXD Output 1
Shared resources
The UART shares registers and other resources with other peripherals that have the same ID as the UART.
Therefore, you must disable all peripherals that have the same ID as the UART before the UART can be
configured and used. Disabling a peripheral that has the same ID as the UART will not reset any of the
registers that are shared with the UART. It is therefore important to configure all relevant UART registers
explicitly to ensure that it operates correctly.
See the Instantiation table in Instantiation for details on peripherals and their IDs.
T ransmission
A UART transmission sequence is started by triggering the STARTTX task.
Bytes are transmitted by writing to the TXD register. When a byte has been successfully transmitted the
UART will generate a TXDRDY event after which a new byte can be written to the TXD register. A UART
transmission sequence is stopped immediately by triggering the STOPTX task.
If flow control is enabled a transmission will be automatically suspended when CTS is deactivated and
resumed when CTS is activated again, as illustrated in Fig ure 2. A byte that is in transmission when CTS is
deactivated will be fully transmitted before the transmission is suspended. For more information, see
Suspending the UART.
STC
D XT
0 1 2 N-2 N-1 N
YDRD XT
YDRD XT
YDRD XT
YDRD XT
YDRD XT
en i l ef i L
1 2 3 5 5 6
1- N = D XT
XTTR AT S
N = D XT
XT POT S
0 = D XT
1 = D XT
2 = D XT
The UART receiver chain implements a FIFO capable of storing six incoming RXD bytes before data is
overwritten. Bytes are extracted from this FIFO by reading the RXD register. When a byte is extracted from
the FIFO a new byte pending in the FIFO will be moved to the RXD register. The UART will generate an
RXDRDY event every time a new byte is moved to the RXD register.
When flow control is enabled, the UART will deactivate the RTS signal when there is only space for four
more bytes in the receiver FIFO. The counterpart transmitter is therefore able to send up to four bytes after
the RTS signal is deactivated before data is being overwritten. To prevent overwriting data in the FIFO, the
counterpart UART transmitter must therefore make sure to stop transmitting data within four bytes after
the RTS line is deactivated.
The RTS signal will first be activated again when the FIFO has been emptied, that is, when all bytes in the
FIFO have been read by the CPU, see Fig ure 3.
The RTS signal will also be deactivated when the receiver is stopped through the STOPRX task as illustrated
in Fig ure 3. The UART is able to receive four to five additional bytes if they are sent in succession
immediately after the RTS signal has been deactivated. This is possible because the UART is, even after the
STOPRX task is triggered, able to receive bytes for an extended period of time dependent on the configured
baud rate. The UART will generate a receiver timeout event (RXTO) when this period has elapsed.
To prevent loss of incoming data the RXD register must only be read one time following every RXDRDY
event.
To secure that the CPU can detect all incoming RXDRDY events through the RXDRDY event register, the
RXDRDY event register must be cleared before the RXD register is read. The reason for this is that the UART
is allowed to write a new byte to the RXD register, and therefore can also generate a new event,
immediately after the RXD register is read (emptied) by the CPU.
STR
DXR
A B C F M-2 M-1 M
YDRDXR
YDRDXR
YDRDXR
YDRDXR
YDRDXR
YDRDXR
YDRDXR
YDRDXR
YDRDXR
OTXR
enil e fiL
1 2 3 4 5 6 7 5 6 7
DXR = 2 -M
DXR = 1 -M
DXR = A
XRTR AT S
DXR = M
DXR = B
DXR = C
DXR = D
DXR = F
XRPOT S
DXR = E
As indicated in occurrence 2 in the figure, the RXDRDY event associated with byte B is generated first after
byte A has been extracted from RXD.
Following a SUSPEND task, an ongoing TXD byte transmission will be completed before the UART is
suspended.
When the SUSPEND task is triggered, the UART receiver will behave in the same way as it does when the
STOPRX task is triggered.
Error conditions
An ERROR event, in the form of a framing error, will be generated if a valid stop bit is not detected in a
frame. Another ERROR event, in the form of a break condition, will be generated if the RXD line is held
active low for longer than the length of a data frame. Effectively, a framing error is always generated before
a break condition occurs.
Parity configuration
When parity is enabled, the parity will be generated automatically from the even parity of TXD and RXD for
transmission and reception respectively.
Registers
Table 2. Instances
Register Offset Description
SHORT S
Address offset: 0x200
Shortcut register
Bit number 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Id B A
Reset 0x00000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0000 0 000
INT ENSET
Address offset: 0x304
Enable interrupt
Bit number 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Id F E D CBA
Reset 0x00000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 000 0 0 0 0
Disable interrupt
Bit number 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Id F E D CBA
Reset 0x00000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 000 0 0 0 0
ERRORSRC
Address offset: 0x480
Error source
Bit number 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Id DCBA
Reset 0x00000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0000 0 0 0 0
ENABLE
Address offset: 0x500
Enable UART
Bit number 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Id AAAA
Reset 0x00000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0000 0 0 0 0
PSELRT S
Address offset: 0x508
Bit number 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Id A A A A A A A A A A A A A A A A A A A A A A AA AAAA AAAA
Reset 0xFFFFFFFF 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 11 1111 1111
Bit number 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Id A A A A A A A A A A A A A A A A A A A A A A AA AAAA AAAA
Reset 0xFFFFFFFF 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 11 1111 1111
PSELCT S
Address offset: 0x510
Bit number 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Id A A A A A A A A A A A A A A A A A A A A A A AA AAAA AAAA
Reset 0xFFFFFFFF 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 11 1111 1111
PSELRXD
Address offset: 0x514
Bit number 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Id A A A A A A A A A A A A A A A A A A A A A A AA AAAA AAAA
Reset 0xFFFFFFFF 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 11 1111 1111
RXD
Address offset: 0x518
RXD register
Bit number 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Id AAAA AAAA
Reset 0x00000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0
TXD register
Bit number 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Id AAAA AAAA
Reset 0x00000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0
BAUDRAT E
Address offset: 0x524
Baud rate
Bit number 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Id A A A A A A A A A A A A A A A A A A A A A A AA AAAA AAAA
Reset 0x04000000 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0000 0000
CONFIG
Address offset: 0x56C
Electrical specification
1 Higher baud rates may require GPIOs to be set as High Drive, see GPIO chapter for more details.