
12
MAX3421E Programming Guide
Programming BULK-OUT Transfers
The MAX3421E sends BULK data to a peripheral using OUT packets, SNDFIFO data, and
handshakes.
The CPU first checks for SNDBAVIRQ = 1 (page
) to see if the send buffer is available for
loading. (The SIE sets this interrupt request bit whenever an OUT transfer successfully
completes.) If the buffer is available, the CPU writes up to 64 data bytes into the SNDFIFO
(page
) by repeatedly writing R2. Then the CPU writes the byte count (the number of bytes it
loaded into the SNDFIFO) into the SNDBC register (page
). Loading the SNDBC register
causes the SIE to negate the SNDBAVAIRQ bit.
Note:
If the second buffer of the double-buffered SNDFIFO is free, the SIE immediately
reasserts the SNDBAVIRQ bit.
The CPU
may
need to initialize the data toggle value for the desired endpoint:
•
If the transfer is to a new endpoint, the CPU initializes the data toggle to the last saved
value for the endpoint.
•
If the endpoint is the same as for the last transfer, the CPU does not need to initialize the
data toggle value. The SIE updates the data toggle after each transfer.
Finally, the CPU loads the HXFR register with the value 0010eeee (Table 4) where eeee is the
endpoint number to which it is sending the data. The HXFR register is load-sensitive, which
means that when the CPU loads the HXFR register, the SIE initiates the transfer.
The SIE sends an OUT token, the address in the PERADDR register, the endpoint number in
EP[3:0], a CRC5, and EOP. The SIE immediately follows this by sending a DATA0 or DATA1
PID (depending on the state of the toggle bit), SNDBC bytes from the SNDFIFO, and a CRC16.
Then the SIE waits 6.5 bit times for the peripheral to respond.
Note:
If SNDBC = 0, the SIE sends no data bytes, but does send the DATA0/1 PID.
When the SIE receives a handshake or bus timeout, it sets HXFRDNIRQ = 1 and indicates the
results in the HRSLT[3:0] bits (page
).
If the peripheral returns the ACK handshake, the SIE also complements the data toggle, indicates
a successful transfer (HRSLT[3:0] = 0000), and asserts the SNDBAVIRQ indicating “Send
Buffer Available.”
If the peripheral did not ACK the transfer, the data may need to be resent. For example, a NAK
handshake is a common response used by a peripheral to indicate that it is not ready to accept the
data. The CPU discovers the cause of a non-ACK’d OUT transfer by examining the HRSLT bits.
The CPU relaunches the OUT transfer simply by rewriting HXFR = 0010eeee. The SIE uses the
same values of PERADDR and SNDBC to send the same data in the SNDFIFO.