34.9.3.9.1 Data Transmit with the PDC in Host Mode
The PDC transfer size must be defined with the buffer size minus 1. The remaining character must be managed without PDC to ensure that the exact number of bytes are transmitted regardless of system bus latency conditions during the end of the buffer transfer period.
If Alternative Command mode is disabled (ACMEN bit set = 0):
- Initialize the transmit PDC (memory pointers, transfer size - 1).
- Configure Host mode (DADR, CKDIV, MREAD = 0, etc.).
- Start the transfer by setting the PDC TXTEN bit.
- Wait for the PDC ENDTX flag either by using the polling method or ENDTX interrupt.
- Disable the PDC by setting the PDC TXTDIS bit.
- Wait for the FLEX_TWI_SR.TXRDY flag.
- Set the STOP command in FLEX_TWI_CR.
- Write the last character in FLEX_TWI_THR.
- (Optional) Wait for the FLEX_TWI_SR.TXCOMP flag before disabling the peripheral clock if required.
If Alternative Command mode is enabled (ACMEN bit = 1):
- Initialize the transmit PDC (memory pointers, transfer size).
- Configure Host mode (DADR, CKDIV, etc.).
- Start the transfer by setting the PDC TXTEN bit.
- Wait for the PDC ENDTX flag by using either the polling method or the ENDTX interrupt.
- Disable the PDC by setting the PDC TXTDIS bit.
- (Optional) Wait for the FLEX_TWI_SR.TXCOMP flag before disabling the peripheral clock if required.
