Initialization

For setting the USART in Full-Duplex mode, the following initialization sequence is recommended:

  1. 1.Set the TxD pin value high, and optionally set the XCK pin low (OUT[n] in PORTx.OUT).
  2. 2.Set the TxD and optionally the XCK pin as an output (DIR[n] in PORTx.DIR).
  3. 3.Set the baud rate (in the USARTn.BAUD register) and frame format.
  4. 4.Set the mode of operation (enables XCK pin output in Synchronous mode).
  5. 5.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:

  1. 1.Set the TxD/RxD pin value high, and optionally set the XCK pin low.
  2. 2.Optionally, write the ODME bit in the USARTn.CTRLB register to '1' for Wired-AND functionality.
  3. 3.Set the TxD/RxD and optionally the XCK pin as an output.
  4. 4.Select the baud rate and frame format.
  5. 5.Select the mode of operation (enables XCK pin output in Synchronous mode).
  6. 6.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.