AT32WB415
Series Reference Manual
2022.04.13
Page 325
Ver 2.00
20.5.4.20
Periodic IN (interrupt and synchronous) data transfers
This section describes a typical periodic IN data transfer.
To initialize the controller after power-on reset, the application must perform the steps list in OTGFS
Initializtion. Before communicating with a host, the controller must follow the steps defined in Endpoint
Initializtion to initialize endpoints.
【
Application requirements
】
1. Application requirements in “Non-periodic (bulk and control) IN data transfers” also apply to periodic
IN data transfers, except for a slight difference of requirement 2.
The application can only transmit multiples of largest-packet-size data packets, and a short
packet. To transmit several largest-packet-size data packets and a short packet, the following
conditions must be met:
Transfer size [epnum] = n * mps[epnum] + sp
(where n
and
i are integers ≥ 0, and 0 ≤ sp < mps[epnum])
If (sp > 0), packet count [epnum] = n + 1. Otherwise, packet count [epnum] = n, mc[epnum] = packet
count [epnum]
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-