GEX thesis source code, full text, references
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
gex-thesis/ch.unit.usart.tex

100 lines
2.4 KiB

\section{USART Unit}
The USART unit provides access to one of the microcontroller's USART peripherals. All USART parameters can be configured to match the application's needs. The peripheral is capable of driving RS485 transceivers with the Driver Enable (DE) output for switching between reception and transmission.
The unit implements asynchronous reception and transmission using DMA and a circular buffer. Received data is sent to the host in asynchronous events when either half of the buffer is filled, or after a fixed timeout from the last received byte.
\subsection{USART Configuration}
\begin{inicode}
[USART:ser@6]
# Peripheral number (UARTx 1-4)
device=1
# Pin mappings (TX,RX,CK,CTS,RTS/DE)
# USART1: (0) A9,A10,A8,A11,A12 (1) B6,B7,A8,A11,A12
# USART2: (0) A2,A3,A4,A0,A1 (1) A14,A15,A4,A0,A1
# USART3: (0) B10,B11,B12,B13,B14
# USART4: (0) A0,A1,C12,B7,A15 (1) C10,C11,C12,B7,A15
remap=0
# Baud rate in bps (eg. 9600)
baud-rate=115200
# Parity type (NONE, ODD, EVEN)
parity=NONE
# Number of stop bits (0.5, 1, 1.5, 2)
stop-bits=1
# Bit order (LSB or MSB first)
first-bit=LSB
# Word width (7,8,9) - including parity bit if used
word-width=8
# Enabled lines (RX,TX,RXTX)
direction=RXTX
# Hardware flow control (NONE, RTS, CTS, FULL)
hw-flow-control=NONE
# Generate serial clock (Y,N)
clock-output=N
# Clock polarity: 0,1
cpol=0
# Clock phase: 0,1
cpha=0
# Generate RS485 Driver Enable signal (Y,N) - uses RTS pin
de-output=N
# DE active level: 0,1
de-polarity=1
# DE assert time (0-31)
de-assert-time=8
# DE clear time (0-31)
de-clear-time=8
\end{inicode}
\subsection{USART Events}
\begin{tabularx}{\textwidth}{p{\fldwcode}Xp{\fldwpld}}
\toprule
\textbf{Code} & \textbf{Meaning} & \textbf{Payload} \\
\midrule
0 & \flname{DATA\_RECEIVED}
Data was received on the serial port.
& \makecell[tl]{
\fld{u8[]} received bytes
} \\
\bottomrule
\end{tabularx}
\subsection{USART Commands}
\begin{tabularx}{\textwidth}{p{\fldwcode}Xp{\fldwpld}}
\toprule
\textbf{Code} & \textbf{Function} & \textbf{Payload} \\
\midrule
0 & \flname{WRITE}
Add data to the transmit buffer. Sending is asynchronous, but the command may wait for free space in the DMA buffer.
& \makecell[tl]{
\fldreq
\fld{u8[]} bytes to write
} \\
1 & \flname{WRITE\_SYNC}
Add data to the transmit buffer and wait for the transmission to complete.
& \makecell[tl]{
\fldreq
\fld{u8[]} bytes to write
} \\
\bottomrule
\end{tabularx}