Initialization

The following registers are enable-protected, meaning they can only be written when the USART is disabled (CTRL.ENABLE=0):

Any writes to these registers when the USART is enabled or is being enabled (CTRL.ENABLE is one) will be discarded. Writes to these registers while the peripheral is being disabled, will be completed after the disabling is complete.

When the USART is enabled or is being enabled (CTRLA.ENABLE=1), any writing attempt to these registers will be discarded. If the peripheral is being disabled, writing to these registers will be executed after disabling is completed. Enable-protection is denoted by the "Enable-Protection" property in the register description.

Before the USART is enabled, it must be configured by these steps:

  1. 1.Select either external (0x0) or internal clock (0x1) by writing the Operating Mode value in the CTRLA register (CTRLA.MODE).
  2. 2.Select either asynchronous (0) or or synchronous (1) communication mode by writing the Communication Mode bit in the CTRLA register (CTRLA.CMODE).
  3. 3.Select pin for receive data by writing the Receive Data Pinout value in the CTRLA register (CTRLA.RXPO).
  4. 4.Select pads for the transmitter and external clock by writing the Transmit Data Pinout bit in the CTRLA register (CTRLA.TXPO).
  5. 5.Configure the Character Size field in the CTRLB register (CTRLB.CHSIZE) for character size.
  6. 6.Set the Data Order bit in the CTRLA register (CTRLA.DORD) to determine MSB- or LSB-first data transmission.
  7. 7.To use parity mode:
    1. 7.1.Enable parity mode by writing 0x1 to the Frame Format field in the CTRLA register (CTRLA.FORM).
    2. 7.2.Configure the Parity Mode bit in the CTRLB register (CTRLB.PMODE) for even or odd parity.
  8. 8.Configure the number of stop bits in the Stop Bit Mode bit in the CTRLB register (CTRLB.SBMODE).
  9. 9.When using an internal clock, write the Baud register (BAUD) to generate the desired baud rate.
  10. 10.Enable the transmitter and receiver by writing '1' to the Receiver Enable and Transmitter Enable bits in the CTRLB register (CTRLB.RXEN and CTRLB.TXEN).