AT32F425
Series Reference Manual
2022.03.30
Page 358
Ver 2.01
4. The OTGFS host attempts to send an IN token in the next frame (odd)
5. The OTGFS host generates a RXFLVL interrupt as soon as an IN packet is received and written to
the receive FIFO
6. To handle the RXFLVL interrupt, read the received packet status to determine the number of bytes
received, then read the receive FIFO. The application must mask the RXFLVL interrupt before reading
the receive FIFO, and unmask the interrupt after reading the entire packet
7. The controller generates the RXFLVL interrupt when the transfer complete status is written to the
receive FIFO. The application must read and ignore the receive packet when the receive packet is not
an IN packet
8. The controller generates an XFERC interrupt as soon as the receive packet is read
9. To handle the XFERC interrupt, read the PKTCN bit in the OTGFS_HCTSIZ2 register. If the PKTCNT
bit in the OTGFS_HCTSIZ2 is not equal to 0, disable the channel before re-initializing the channel for
the next transfer. If PKTCNT == 0 in the OTGFS_HCTSIZ2 register, re-initialize the channel for the next
transfer. In this case, the application must reset the ODDFRM bit in the OTGFS_HCCHAR2 register.
(
2
)
Handling interrupts
The following code describes the interrupt service routine related to the channel during interrupt IN
transfer
Unmask (NAK/XACTERR/XFERC/BBLERR/STALL/FRMOVRUN/DATATGLERR)
if (XFERC)
{
Reset Error Count
Mask ACK
if (HCTSIZx.PKTCNT == 0)
{
De-allocate Channel
}
else
{
Transfer Done = 1
Unmask CHHLTD
Disable Channel
}
}
else if (STALL or FRMOVRUN or NAK or DATATGLERR or BBLERR)
{
Mask ACK
Unmask CHHLTD
Disable Channel
if (STALL or BBLERR)
{
Reset Error Count
Transfer Done = 1
}
else if (!FRMOVRUN)
{
Reset Error Count
}
}
else if (XACTERR)
{
Increment Error Count