Datasheet
Section 14 Universal Serial Bus (USB)
Rev.7.00 Dec. 24, 2008 Page 508 of 698
REJ09B0074-0700
(2) Data Stage (Control-In)
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 in-transfer, one packet of data to be sent to the host is written to the FIFO. If
there is more data to be sent, this data is written to the FIFO after the data written first has been
sent to the host (EP0iTS in UIFR0 is set to 1).
The end of the data stage is identified when the host transmits an OUT token and the status
stage is entered.
USB function Firmware
Receive IN token
Transmit data to host
Set EP0i transmit
complete flag
(EP0iTS in UIFR0 = 1)
From setup stage
Write data to USB endpoint
data register 0i (UEDR0i)
Write 1 to EP0i packet
enable bit
(EP0iPKTE in UTRG0 = 1)
Clear EP0i transmit
complete flag
(EP0iTS in UIFR0 = 0)
Write 1 to EP0i packet
enable bit
(EP0iPKTE in UTRG0 = 1)
Write data to USB endpoint
data register 0i (UEDR0i)
1 written
to EP0sRDFN
in UTRG0?
Valid data
in EP0i FIFO?
NAK
NAK
No
No
Yes
Yes
ACK
EXIRQx
Note: If the size of the data transmitted by the function is smaller than the data size requested by the host,
the function indicates the end of the data stage by returnning to the host a packet shorter than the
maximum packet size. If the size of the data transmitted by the function is an integral multiple of the
maximum packet size, the function indicates the end of the data stage by transmitting a zero-length
packet.
Figure 14.13 Data Stage Operation (Control-In)