42.7.3.8.1 Data Transmit with the DMA in Host Mode

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.