Datasheet

Section 14 Universal Serial Bus (USB)
Rev.7.00 Dec. 24, 2008 Page 509 of 698
REJ09B0074-0700
(3) Data Stage (Control-Out)
The firmware first analyzes the command data that is sent from the host in the setup stage, and
determines the subsequent data stage direction. If the result of command data analysis is that
the data stage is out-transfer, data from the host is waited for, and after data is received
(EP0oTS in UIFR0 is set to 1), data is read from the FIFO. Next, the firmware writes 1 to the
EP0o read complete bit, empties the receive FIFO, and waits for reception of the next data.
The end of the data stage is identified when the host transmits an IN token and the status stage
is entered.
USB function Firmware
Receive OUT token
Receive data from host
Receive OUT token
Set EP0o receive
complete flag
(EP0oTS in UIFR0 = 1)
Clear EP0o receive
complete flag
(EP0oTS in UIFR0 = 0)
Read data from USB endpoint
receive data size register 0o
(UESZ0o)
Write 1 to EP0o read
complete bit
(EP0oRDFN in UTRG0 = 1)
Read data from USB endpoint
data register 0o (UEDR0o)
1 written
to EP0sRDFN
in UTRG0?
1 written
to EP0oRDFN
in UTRG0?
NAK
NAK
ACK
No
Yes
No
Yes
EXIRQx
Figure 14.14 Data Stage Operation (Control-Out)