16. USART2
A96G150 User's manual
228
16.8
USART2 receiver
USART2 Receiver is enabled by setting the RXE bit in the UCTRL1 register. When the Receiver is
enabled, normal pin operation of RXD2 pin is overridden by the USART2 as the serial input pin of the
Receiver. Baud rate, mode of operation and frame format must be set before serial reception. If
synchronous or SPI operation is used, a clock on the XCK pin will be used as a transfer clock. If the
USART2 operates in SPI mode, SS2 pin is used as SS2 input pin in slave mode or can be configured
as SS2 output pin in master mode. This can be done by setting SPISS bit in UCTRL3 register.
16.8.1
Receiving Rx data
When USART2 is in synchronous or asynchronous operation mode, the Receiver starts data reception
when it detects a valid start bit (LOW) on RXD2 pin. Each bit following the start bit is sampled at pre-
defined baud rate (asynchronous) or sampling edge of XCK (synchronous), and shifted into a receive
shift register until the first stop bit of a frame is received.
Even if there’s 2nd stop bit in the frame, the 2nd
stop bit is ignored by the Receiver. That is, receiving
the first stop bit means that a complete serial frame is present in the receiver shift register and contents
of the shift register are to be moved into the receive buffer. The receive buffer is read by reading the
UDATA register.
If 9-bit characters are used (USIZE[2:0] = 7), the ninth bit is stored in RX8 bit field in the UCTRL3
register. The 9th bit must be read from the RX8 bit before reading the low 8 bits from the UDATA register.
Likewise, error flags FE, DOR, PE must be read before reading data from UDATA register. This is
because the error flags are stored in the same FIFO position of the receive buffer.
16.8.2
Receiver flag and interrupt
The USART2 Receiver has one flag that indicates the Receiver state. Receive Complete (RXC) flag
indicates whether there are unread data present in the receive buffer. This flag is set when there are
unread data in the receive buffer and cleared when the receive buffer is empty. If the Receiver is
disabled (RXE=0), the receiver buffer is flushed and the RXC flag is cleared.
When Receive Complete Interrupt Enable (RXCIE) bit in the UCTRL2 register is set and Global Interrupt
is enabled, USART2 Receiver Complete Interrupt is generated while RXC flag is set.
The USART2 Receiver has three error flags such as Frame Error (FE), Data OverRun (DOR) and Parity
Error (PE). These error flags can be read from USTAT register. As data received are stored in the 2-
level receive buffer, these error flags are also stored in the same position of receive buffer. So, before
reading received data from UDATA register, read the USTAT register first which contains error flags.
Содержание A96G150
Страница 126: ...12 Timer 0 1 2 3 4 5 A96G150 User s manual 126 Figure 43 16 bit Timer Counter Mode Operation Example...
Страница 136: ...12 Timer 0 1 2 3 4 5 A96G150 User s manual 136 Figure 51 16 bit Timer Counter Mode Operation Example...
Страница 147: ...A96G150 User s manual 12 Timer 0 1 2 3 4 5 147 Figure 59 16 bit Timer Counter Mode Operation Example...
Страница 157: ...A96G150 User s manual 12 Timer 0 1 2 3 4 5 157 Figure 67 16 bit Timer Counter Mode Operation Example...
Страница 171: ...A96G150 User s manual 14 12 bit ADC 171 Figure 79 ADC Operation Flow Sequence...
Страница 333: ...A96G150 User s manual Revision history 333 Revision history Revision Date Notes 1 00 2022 06 22 First creation...