
Architecture
1627
SPRUH82C – April 2013 – Revised September 2016
Copyright © 2013–2016, Texas Instruments Incorporated
Universal Serial Bus 2.0 (USB) Controller
When the endpoint is first configured (following a SET_CONFIGURATION or SET_INTERFACE command
on Endpoint 0), the lower byte of PERI_RXCSR should be written to set the CLRDATATOG bit (bit 7).
This will ensure that the data toggle (which is handled automatically by the USB controller) starts in the
correct state.
Also if there are any data packets in the FIFO (indicated by the RXPKTRDY bit (bit 0 of PERI_RXCSR)
being set), they should be flushed by setting the FLUSHFIFO bit (bit 4 of PERI_RXCSR).
NOTE:
It may be necessary to set this bit twice in succession if double buffering is enabled.
34.2.7.1.2.2.2 Operation
When a data packet is received by a Bulk Rx endpoint, the RXPKTRDY bit (bit 0 of PERI_RXCSR) is set
and an interrupt is generated. The software should read the RXCOUNT register for the endpoint to
determine the size of the data packet. The data packet should be read from the FIFO, then the
RXPKTRDY bit should be cleared.
The packets received should not exceed the size specified in the RXMAXP register (as this should be the
value set in the wMaxPacketSize field of the endpoint descriptor sent to the host). When a block of data
larger than wMaxPacketSize needs to be sent to the function, it will be sent as multiple packets. All the
packets will be wMaxPacketSize in size, except the last packet which will contain the residue. The
software may use an application specific method of determining the total size of the block and hence when
the last packet has been received. Alternatively it may infer that the entire block has been received when it
receives a packet which is less than wMaxPacketSize in size. (If the total size of the data block is a
multiple of wMaxPacketSize, a null data packet will be sent after the data to signify that the transfer is
complete.)
In the general case, the application software will need to read each packet from the FIFO individually. If
large blocks of data are being transferred, the overhead of calling an interrupt service routine to unload
each packet can be avoided by using DMA.
34.2.7.1.2.2.3 Error Handling
If the software wants to shut down the Bulk OUT pipe, it should set the SENDSTALL bit (bit 5 of
PERI_RXCSR). When the controller receives the next packet it will send a STALL to the host, set the
SENTSTALL bit (bit 6 of PERI_RXCSR) and generate an interrupt.
When the software receives an interrupt with the SENTSTALL bit (bit 6 of PERI_RXCSR) set, it should
clear this bit. It should however leave the SENDSTALL bit set until it is ready to re-enable the Bulk OUT
pipe.
NOTE:
If the host failed to receive the STALL packet for some reason, it will send another packet,
so it is advisable to leave the SENDSTALL bit set until the software is ready to re-enable the
Bulk OUT pipe. When a Bulk OUT pipe is re-enabled, the data toggle sequence should be
restarted by setting the CLRDATATOG bit (bit 7) in the PERI_RXCSR register.
34.2.7.1.3 Peripheral Mode: Interrupt Transactions
An Interrupt IN transaction uses the same protocol as a Bulk IN transaction and can be used the same
way. Similarly, an Interrupt OUT transaction uses almost the same protocol as a Bulk OUT transaction
and can be used the same way.
Tx endpoints in the USB controller have one feature for Interrupt IN transactions that they do not support
in Bulk IN transactions. In Interrupt IN transactions, the endpoints support continuous toggle of the data
toggle bit.
This feature is enabled by setting the FRCDATATOG bit in the PERI_TXCSR register (bit 11). When this
bit is set, the controller will consider the packet as having been successfully sent and toggle the data bit
for the endpoint, regardless of whether an ACK was received from the host.