24.3.1 Initialization
For setting the USART in full-duplex mode, the following initialization sequence is recommended:
- Set the TxD pin value high, and optionally set the XCK pin low (OUT[n] in PORT.OUT).
- Set the TxD and optionally the XCK pin as output (DIR[n] in PORT.DIR).
- Set the baud rate (USART.BAUD) and frame format.
- Set the mode of operation (enables XCK pin output in synchronous mode).
- Enable the transmitter or the receiver, depending on the usage.
For interrupt-driven USART operation, global interrupts should be disabled during the initialization.
Before doing a re-initialization with a changed baud rate or frame format, be sure that there are no ongoing transmissions while the registers are changed.
For setting the USART in one-wire mode, the following initialization sequence is recommended:
- Set the TxD/RxD pin value high, and optionally set the XCK pin low.
- Optionally, write the ODME bit in the USART.CTRLB register to '1' for Wired-AND functionality.
- Set the TxD/RxD and optionally the XCK pin as output.
- Select the baud rate and frame format.
- Select the mode of operation (enables XCK pin output in synchronous mode).
- Enable the transmitter or the receiver, depending on the usage.
For interrupt-driven USART operation, global interrupts should be disabled during the initialization.
Before doing a re-initialization with a changed baud rate or frame format, be sure that there are no ongoing transmissions while the registers are changed.