35.6.7.9.1 Collision Detection

When the receiver and transmitter lines are connected together either through pin configuration internally or externally, transmit collision can be detected after selecting the Collision Detection Enable bit in the CTRLB register (CTRLB.COLDEN = 1). To detect collision, the receiver, and transmitter must be enabled (CTRLB.RXEN = 1 and CTRLB.TXEN = 1). Collision detection is performed for each bit transmitted by comparing the received value with the transmit value, as shown in the following figure. While the transmitter is idle (no transmission in progress), characters can be received on RxD without triggering a collision.

Important: Collision detect is only valid for the following configurations:
  1. ISO 7816 mode, CTRLA.FORM = 0x7.
  2. 2-wire RS485 half-duplex arrangements, CTRLA.TXPO = 0x3, where the external RS485 transceiver Rx and Tx are enabled at the same time to form a loop back. Refer to the Typical USART Half Duplex RS-485 Asynchronous Example with no Flow Control).
Figure 35-27. ISO 7816 Collision Checking Example

The figure below illustrates the conditions for a collision detection. In this case, the Start bit and the first Data bit are received with the same value as transmitted. The second received Data bit is found to be different than the transmitted bit at the detection point, which indicates a collision.

Figure 35-28. ISO 7816 Collision Detection Detail

When a collision is detected, the USART follows this sequence:

  1. Abort the current transfer.
  2. Flush the transmit buffer.
  3. Disable transmitter (CTRLB.TXEN = 0).
    • This is done after a synchronization delay. The CTRLB Synchronization Busy bit (SYNCBUSY.CTRLB) will be set until this is complete.
    • After disabling, the TxD pin will be tri-stated.
  4. Set the Collision Detected bit (STATUS.COLL) along with the Error Interrupt Flag (INTFLAG.ERROR).
  5. Set the Transmit Complete Interrupt Flag (INTFLAG.TXC), since the transmit buffer no longer contains data.

After a collision, software must manually enable the transmitter again before continuing, after assuring that the CTRLB Synchronization Busy bit (SYNCBUSY.CTRLB) is not set.