
C161U
USB Interface Controller
Data Sheet
326
2001-04-19
The device SW provides a new packet by setting up the new source and destination
pointer within the EPEC. Since the packet length of the last packet is either 0 or less than
the maximum defined packet length, the EPEC provides a 10-bit byte counter. After
reaching its terminal count value, the EPEC stops transferring data, sets the
EPEC_DONEn pulse signalizing to the USB core the end of packet and sets the EPEC
interrupt. The counter will be loaded by SW for each packet to be transmitted.
The new packet transfer is started by setting the EPEC_STARTn bit in the EPEC register
EPEC_CMD. This bit will enable the word transfer request USBD_INT_TXREQ
generated by the Transmit FIFO.
Whether the last EPEC transfer was a word or byte transfer will be handled by the EPEC
for transmit data.
By this mechanism only a minimum of SW transaction will be required which guarantees
minimum latency times for the UDC handshake procedure.
OUT Transactions (Host to Device: RX)
The host transmits device data by using the OUT transaction. The OUT transaction
mechanism handled by the device HW/SW is shown in
Figure 104
.
Since the UDC requests data handshake from the application within 4 UDC clock cycles
(@12MHz) the SW has to provide the next empty receive buffer to the Receive FIFO in
time, in order to prevent the FIFO from overflow resulting in a NACK to the host. This can
be achieved by either polling for the USBD_RXDONEn bit for being asserted, indicating
an empty Receive FIFO or by providing the next receive buffer as soon as the previous
packet has been received completely using the interrupt USBD_INT_RXDONE directly.
The USBD provides a 10-bit byte counter USBD_RXBYTECNTn for each endpoint
Receive FIFO counting the data strobe pulses asserted by the UDC. A completed packet
transfer over the application bus (either XferAck or XferNack) will stop the byte counter
and the counter value will be copied into the USBD_RXBYTECNTn register along with
a packet status information (e.g. packet valid). As soon as the complete packet has been
transferred by the EPEC, an endpoint receive interrupt USBD_INT_RXDONE will be
generated.
A new packet can only be received if the RX FIFO is empty, i.e. the EPEC has transfered
the last byte/word. The next packet cannot be accepted by the very same Receive FIFO
until the counter value has been cleared by a CPU read access. Therefore, once the
counter is read and cleared the EPEC is enabled again, the SW has to load the EPEC
with a new source and destination pointers
before
reading the counter register. This will
enable the word transfer request USBD_INT_RXREQ generated by the Receive FIFO
and EPEC starts transferring words.