USB Transactions
13-60
In response to the endpoint interrupt, the local host must read the EPN_STAT
register to identify the endpoint causing the interrupt, then write a 1 to the inter-
rupt bit to clear it. The local host must set EP_Num to the endpoint number,
EP_Dir to 1 (to signal an IN endpoint), and EP_Sel to 1, then read the endpoint
status. The NAK bit is set to indicate that the endpoint sent a NAK handshake
to the USB host. If the local host has data to transmit to the USB host, it must
fill the TX FIFO following the process indicated above. The local host must then
clear the EP_Sel bit. This clears the NAK bit for this endpoint and allows the
next transaction status to be written to the STAT_FLG register. Signaling NAK
does not cause the endpoint’s TX FIFO to be cleared (since the local host still
retains control of the FIFO).
Signaling NAK handshake for several endpoint transactions in a row can
cause the PC host to discard the transaction, so NAK may not be a good mech-
anism in cases where the local host is not able to service a request for long
periods of time.
13.3.2.2
Non-Isochronous IN Transaction Error Conditions
STALLed Transactions
The USB module sends a STALL handshake to the USB host during the data
phase of the transaction to the IN endpoint either if the endpoint’s EP_Halted
flag bit is set (as shown in the third case in Figure 13–4) or if a request error
occurs (control transaction only). A STALL handshake indicates that the de-
vice endpoint is in a condition where it is not able to transfer data and that the
USB host must not retry the transaction. The device typically requires interven-
tion via some other mechanism to clear the condition, typically a control trans-
fer via endpoint 0. The local host can set the endpoint EP_Halted bit by writing
the appropriate value in the EP_NUM register to select it. It can then set the
endpoint’s Set_Halt bit and clear it by selecting the endpoint and setting the
endpoint’s Clr_Halt bit. When the endpoint EP_Halt bit bit is set, the endpoint
signals STALL for its IN transactions until the HALT condition is cleared. When
the STALL handshake is sent in response to a transaction to the endpoint,
the STALL bit is set, and an endpoint-specific interrupt to the local host is
generated.
In response to the endpoint interrupt, the local host must read EPN_STAT reg-
ister to identify the endpoint causing the interrupt, then write a 1 to the interrupt
bit to clear it. The local host must set EP_Num to the endpoint number, EP_Dir
to 1 (to signal an IN endpoint), and EP_Sel to 1, then read the endpoint status.
The STALL bit is set to indicate that the endpoint sent a STALL handshake to
the USB host. The local host must then clear the EP_Sel bit. This clears the
STALL bit for this endpoint and allows the next transaction status to be written
to the STAT_FLG register