AT32F425
Series Reference Manual
2022.03.30
Page 379
Ver 2.01
The application cannot transmit a zero-length data packet at the end of a transfer. But it can
transmit a single zero-length data packet in itself, provided packet count [epnum] = 1, mc[epnum] =
packet count [epnum]
2. The application can only schedule data transfers of one frame at a time
(OTGFS_DIEPTSIZx.MC – 1) * OTGFS_DIEPCTLx.MPS ≤OTGFS_DIEPTSIZx.XFERSIZ
≤OTGFS_DIEPTSIZx.MC * OTGFS_DIEPCTLx.MPS
OTGFS_DIEPTSIZx.PKTCNT = OTGFS_DIEPTSIZx.MC
If OTGFS_DIEPTSIZx.XFERSIZ < OTGFS_DIEPTSIZx.MC * OTGFS_DIEPCTLx.MPS, the last
data packet of the transfer is a short packet.
3. For periodic IN endpoints, one-frame data must be prefetched before the data transfer in the next
frame. This can be done by enabling periodic IN endpoint 1 frame before the scheduling of the frame to
be transmitted.
4. The complete data to be transmitted in a frame must be written to the transmit FIFO by the application
before the periodic IN token is received. Even when one-DWORD data to be transmitted per frame is
missing in the transmit FIFO while the periodic IN token is received, the controller behaves as when the
FIFO is empty. When the transmit FIFO is empty, a zero-length data packet would be transmitted on the
USB, and An NAK handshake signal would be transmitted for INTR IN endpoints.
【
Internal data flow
】
1. The application must set the transfer size and packet count bits of the endpoint registers, and enable
the endpoint to transmit the data.
2. The application must also write the required data to the associated transmit FIFO.
3. Each time the application writes a packet to the transmit FIFO, the transfer size for the endpoint is
decremented by the packet size. Continue to write data until the transfer size for the endpoint becomes
0
4. When an IN token for a periodic endpoint is received, the application writes the data to the FIFO (If
any). If the complete data for the frame is not present in the FIFO, the controller generates an
INTKNTXFEMP interrupt.
A zero-length data packet is transmitted on the USB for synchronous IN endpoints
An NAK handshake signal is transmitted on the USB for interrupt IN endpoints.
5. The packet count for the endpoints is decremented by one under the following conditions:
For synchronous endpoints, when a zero-or non-zero-length data packet is transmitted
For interrupt endpoints, when an ACK handshake is transmitted
When the transfer size and packet count are both 0, the transfer complete interrupt for the
endpoint is generated and the endpoint enable bit is cleared.
6. In the “Periodic frame interval” (by the PERFRINT bit in the OTGFS_DCFG register), when the
controller finds non-emtpy any one of the IN endpoint FIFOs scheduled for the current frame non-empty,
the controller generates an INCOMPISOIN interrupt in the OTGFS_GINTSTS register.
【
Application programming sequence (frame transfers)
】
1. Program the OTGFS_DIEPTSIZx register
2. Program the OTGFS_DIEPCTLx register based on endpoint characteristics, and set the CNAK and
endpoint enable bits
3. Write the data to be transmitted into the transmit FIFO.
4. The assertion of the INTKNTXFEMP interrupt indictes that the application has not yet written all data
to be transferred into the transmit FIFO.
5. If the interrupt endpint is already enabled while this interrupt is detected, ignore the interrupt. If it is
not enabled, enable the endpoint to transmit data on the next IN token. If it is enabled while the interrupt
is detected, refere to “Incomplete synchronous IN data transfers”.
6. When the interrupt IN endpoint is set as a periodic endpoint, the controller internally can process the
timeout on the interrupt IN endpoint, without the need of the application intervention. Therefore, the
application can never detect the TIMEOUT interrupt (in the OTGFS_DIEPINTx register) on the periodic
interrup IN endpoints.
7. The assertion of the XFERC interrupt in the OTGFS_DIEPINTx register but without the
INTKNTXFEMP interrupt indicates the successful completion of a synchronous IN transfer. When