
Epson Research and Development
Page 117
Vancouver Design Center
Programming Notes and Examples
S1D13A05
Issue Date: 2002/08/21
X40A-G-003-04
10.4.4 “EP2 Valid Bit” in USB Status can be erroneously set by firmware
“Endpoint 2 Valid” is the only bit in USB Status which is not written as a “Yes/CLR” bit.
Therefore, the firmware must do a read-modify-write sequence when clearing other bits in
Interrupt Status Register 0 (REG[4004h]), to preserve the state of “Endpoint 2 Valid”.
However, this read-modify-write could lead to erroneously setting the EP2 Valid bit if the
following sequence occurs with “EP2 Valid” set True:
1. Firmware reads Interrupt Status Register 0 to do a read-modify-write
2. Data from EP2 is sent to Host PC, causing S1D13A05 to clear EP2 Valid
3. Firmware writes modified value to Interrupt Status Register 0
In this case, the firmware has set EP2 Valid in Step 3 after it was cleared by the Host PC,
erroneously validating EP2 for the next IN token from the Host.
Work Around
First, the firmware should do the read-modify-write operation as described above anytime
it is modifying bits in “USB Status”.
Second, when the firmware recognizes an interrupt for “EP2 Packet Transmitted”, it should
immediately write a ‘0’ to USB Status Register. This will clear the EP2 Valid bit in the
unlikely event that it was erroneously set during a read-modify-write operation.
10.4.5 Setting EP4 FIFO Valid bit while NAKing IN token
Bit 5 of REG[402Ch] indicates to the S1D13A05 controller when data in the endpoint 4
FIFO is ready to be transferred to the host computer. Changing the state of this bit at certain
times may generate an error.
When the S1D13A05 USB controller receives an endpoint 4 IN request and endpoint 4 is
not ready to transmit data (REG[402Ch] bit 5 = 0), the response is a NAK packet. If
endpoint 4 is toggled to a ready to transmit state just before a NAK response packet is sent,
the controller may erroneously send a zero length packet instead. When this happens, the
data toggle state will be incorrectly set for the next endpoint 4 data transmit.
The following timing diagram shows the error occurring in section 3.
This unexpected occurrence of a zero length packet may cause file system handling errors
for some operating systems.
Host to Device
Device to Host
CPU Write to
EP4_VALID = 1
12
3
IN EP4 Token PKT
NAK RPLY
DATA PKT RPLY
ZERO Length PKT