English
Language : 

MC9S08JM16 Datasheet, PDF (322/386 Pages) Freescale Semiconductor, Inc – Microcontrollers
Universal Serial Bus Device Controller (S08USBV1)
2. Create BDT entries for Endpoint 0 OUT, and set the DTS and OWN bits to 1.
3. Wait for interrupt TOKDNE.
4. Read STAT register.
— The status register must show Endpoint 0, RX. If it does not, then assert the EPSTALL bit in
the endpoint control register.
5. Read Endpoint 0 OUT BD.
— Verify that the token type is a SETUP token. If it is not, then assert the EPSTALL bit in the
endpoint control register.
6. Decode and process the setup packet.
— If the direction field in the setup packet indicates an OUT transfer, then process the out data
phase to receive exactly the number of bytes specified in the wLength field of the setup packet.
— If the direction field in the setup packet indicates an IN transfer, then process the in data phase
to deliver no more than the number of bytes specified in the wLength field. Note that it is
common for the host to request more bytes than it needs, expecting the device to only send as
much as it needs to.
7. After processing the data phase (if there was one), create a zero-byte status phase transaction.
— This is accomplished for an OUT data phase (IN status phase) by setting the BC to 0 in the next
BD, while also setting OWN=1. For an IN data phase (OUT status phase), the host will send a
zero-byte packet to the device.
— Firmware can verify completion of the data phase by verifying the received token in the BD on
receipt of the TOKDNE interrupt. If the data phase was of type IN, then the status phase token
will be OUT. If the data phase was of type OUT, then the status phase token will be IN.
17.4.4.3 Endpoint 0 Exception Conditions
The USB includes a number of error checking and recovery mechanisms to ensure reliable data transfer.
One such exception occurs when the host sends a SETUP packet to a device, and the host never receives
the acknowledge handshake from the device. In this case, the host will retry the SETUP packet.
Endpoint 0 request handlers on the device must be aware of the possibility that after receiving a correct
SETUP packet, they could receive another SETUP packet before the data phase actually begins.
17.4.5 Start of Frame Processing
The USB host allocates time in 1.0 ms chunks called “Frames” for the purposes of packet scheduling. The
USB host starts each frame with a broadcast token called SOF (start of frame) that includes an 11-bit
sequence number. The TOKSOF interrupt is used to notify firmware when an SOF token was received.
Firmware can read the current frame number from the FRMNUML/FRMNUMH registers.
In general, the SOF interrupt is only monitored by devices using isochronous endpoints to help ensure that
the device and host remain synchronized.
MC9S08JM16 Series Data Sheet, Rev. 2
322
Freescale Semiconductor