AT32F425
Series Reference Manual
2022.03.30
Page 347
Ver 2.01
3. Device IN endpoint transmit FIFO#1 size register (OTGFS_DIEPTXF1)
OTGFS_DIEPTXF1.INEPTXFSTADDR = OTGFS_GNPTXFSIZ.NPTXF tx_fifo_size[0]
4. Device IN endpoint transmit FIFO#2 size register (OTGFS_DIEPTXF2)
OTGFS_DIEPTXF2.INEPTXFSTADDR = OTGFS_DIEPTXF1.INEPTXF
tx_fifo_size[1]
5. Device IN endpoint transmit FIFO#i size register (OTGFS_DIEPTXFi)
OTGFS_DIEPTXFi.INEPTXFSTADDR = OTGFS_DIEPTXFi-1.INEPTXFtx_fifo_size[i-
1]
6. After SRAM allocation, refresh transmit FIFO and receive FIFO to ensure normal FIFO running.
OTGFS_GRSTCTL.TXFNUM = 0x10
OTGFS_GRSTCTL.TXFFLSH = 0x1
OTGFS_GRSTCTL.RXFFLSH = 0x1
The application cannot perform other operations on the controller until the TXFFLSH and RXFFLSH bits
are cleared.
20.5.2.2 Host mode
In host mode, the application must confirm the following status before changing FIFO SRAM allocation:
All channels have been disabled
All FIFOs are empty
After FIFO SRAM allocation is complete, the application must refreh all FIFOs in the controller through
the TXFNUM bit in the OTGFS_GRSTCTL register.
After allocation, the FIFO pointers must be reset by refreshing operation to ensure normal FIFO running.
Refer to Section Refresh controller tranmist FIFO for more information.
(
1
)
Receive FIFO SRAM allocation
Status information is written to the FIFO along with each received packet. Therefore, a minimum space
of (largest packet size/4) + 2 must be allocated to receirve data packets. If more synchronous endpints
are enabled, then at least two (largest packet size/4) + 2 spaces must be allocated to receive back-to-
back packets. In most cases, two (largest packet size/4) + 2 spaces are recommended so that the USB
can receive the subseqnet packet while the previous packet is being transferred to the AHB. If there is
a longer latecy on AHB, sufficient spaces must be reserved to receive multiple packets in order to prevent
synchronous data packet loss.
Transfer complete status information and channel abort information, along with the last packet in the
host channel is also pushed to the FIFO. Thus, two DWORDs must be allocated for this.
(
2
)
Transmit FIFO SRAM allocation
The minimum SRAM space required for the host non-periodic transmit FIFO is the largest packet size
of all non-periodic OUT channels. The more the space allocated to the non-periodic FIFO, the better the
USB performance, and this helps to avoid latency on the AHB line. Typically, two largest packet sizes of
space is recommended so that the AHB can get the next data packet while the current packet is being
transferred to the USB. If there is a longer latecy on AHB, sufficient spaces must be reserved to receive
multiple packets in order to prevent synchronous data packet loss.
(
3
)
Internal register storage space allocation
Table 20-3 OTGFS internal register storage space allocation
FIFO Name
Data SRAM Size
Receive FIFO
rx_fifo_size
Non-periodic transmit FIFO
tx_fifo_size[0]
Periodic transmit FIFO
tx_fifo_size[1]
Configure the following registers according to the above mentioned:
1. OTGFS receive FIFO size register (OTGFS_GRXFSIZ)
OTGFS_GRXFSIZ.RXFDEP = rx_fifo_size
;
2. OTGFS Non-periodic TX FIFO size register (OTGFS_GNPTXFSIZ)