46.6.3.9.1 Data Transmit with the DMA in Host Mode

If Alternative Command mode is disabled (ACMEN bit set to ‘0’):

The DMA transfer size must be defined with the buffer size minus 1. The remaining character must be managed without DMA to ensure that the exact number of bytes are transmitted regardless of system bus latency conditions during the end of the buffer transfer period.

  1. Initialize the DMA (channels, memory pointers, size - 1, etc.);
  2. Configure the Host mode (DADR, CKDIV, MREAD = 0, etc.) or Client mode.
  3. Enable the DMA.
  4. Wait for the DMA status flag indicating that the buffer transfer is complete.
  5. Disable the DMA.
  6. Wait for the TXRDY flag in TWIHS_SR.
  7. Set TWIHS_CR.STOP.
  8. Write the last character in TWIHS_THR.
  9. (Only if peripheral clock must be disabled) Wait for the TXCOMP flag to be raised in TWIHS_SR.

If Alternative Command mode is enabled (ACMEN bit set to ‘1’):

  1. Initialize the transmit DMA (memory pointers, transfer size).
  2. Configure the Host mode (DADR, CKDIV, etc.) and TWIHS_ACR.
  3. Start the transfer by setting the DMA TXTEN bit.
  4. Wait for the DMA ENDTX flag either by using the polling method or ENDTX interrupt.
  5. Disable the DMA by setting the DMA TXTDIS bit.
  6. (Only if peripheral clock must be disabled) Wait for the TXCOMP flag to be raised in TWIHS_SR.