25.3.2.4 Data Reception
The USART receiver samples the reception line to
detect and interpret the received data. Therefore, the pin direction must be configured as an
input by writing a ‘0’ to the corresponding bit in the Data Direction
(PORTx.DIR) register.
The receiver accepts data when a valid Start bit is detected. Each bit that follows the Start bit will be sampled at the baud rate or XCK clock and shifted into the receive shift register until the first Stop bit of a frame is received. A second Stop bit will be ignored by the receiver. When the first Stop bit is received and a complete serial frame is present in the receive shift register, the contents of the shift register will be moved into the receive buffer. The Receive Complete (RXC) interrupt flag in the Status (USARTn.INTFLAGS) register is then set, and an interrupt is generated if enabled.
The RXDATA registers are part of the double-buffered RX buffer that can be read by application software when the RXC flag is set. If only one frame has been received, the data and status bits for that frame are pushed directly to the RXDATA registers. If two frames are present in the RX buffer, the RXDATA registers contain the data for the frame that was received first.
The buffer shifts out data either when RXDATAL or RXDATAH is read, depending on the configuration. The register which does not lead to data being shifted must be read first to be able to read both bytes before shifting. When the Character Size (CHSIZE) bit field in the Control D (USARTn.CTRLD) register is configured to 9-bit (low byte first), reading RXDATAH shifts the receive buffer. Otherwise, reading RXDATAL shifts the buffer.
