English
Language : 

MC9S08JM16 Datasheet, PDF (321/386 Pages) Freescale Semiconductor, Inc – Microcontrollers
Universal Serial Bus Device Controller (S08USBV1)
appropriate course of action for future transactions — stalling the endpoint, canceling the transfer,
disabling the endpoint, etc.
17.4.4 USB Packet Processing
Packet processing for a USB device consists of managing buffers for IN (to the USB Host) and OUT (to
the USB device) transactions. Packet processing is further divided into request processing on Endpoint 0,
and data packet processing on the data endpoints.
17.4.4.1 USB Data Pipe Processing
Data pipe processing is essentially a buffer management task. The firmware is responsible for managing
the shared buffer RAM to ensure that a BD is always ready for the hardware to process (OWN bit = 1).
The device allocates buffers within the shared RAM, sets up the buffer descriptors, and waits for interrupts.
On receipt of a TOKDNE interrupt, the firmware reads the STAT register to determine which endpoint is
affected, then reads the corresponding BDT entry to determine what to do next.
When processing data packets, firmware is responsible for managing the size of the packet buffers to be
in compliance with the USB specification, and the physical limitations of this module. Packet sizes up to
64 bytes are supported on all endpoints. Isochronous endpoints also can only specify packet sizes up to 64
bytes.
Firmware is also responsible for setting the appropriate bits in the BDT. For most applications using bulk
packets (control, bulk, and interrupt-type transfers), the firmware will set the DTS, BC and EPADR fields
for each BD. For isochronous packets, firmware will set BC and EPADR fields. In all cases, firmware will
set the OWN bit to enable the endpoint for data transfers.
17.4.4.2 Request Processing on Endpoint 0
In most cases, commands to the USB device are directed to Endpoint 0. The host uses the “Standard
Requests” described in Chapter 9 of the USB specification to enumerate and configure the device. Class
drivers or product specific drivers running on the host send class (HID, Mass Storage, Imaging) and vendor
specific commands to the device on endpoint 0.
USB requests always follow a specific format:
• Host sends a SETUP token, followed by an 8-byte setup packet, and the device hardware can send
a handshake packet.
• If the setup packet specifies a data phase, the host and device may transfer up to 64 Kbytes of data
(either IN or OUT, not both).
• The request is terminated by a status phase.
Device firmware monitors the INTSTAT and STAT registers, the endpoint 0 buffer descriptors (BD’s), and
the contents of the setup packet to correctly execute the host’s request.
The flow for processing endpoint 0 requests is as follows:
1. Allocate 8-byte buffers for endpoint 0 OUT.
MC9S08JM16 Series Data Sheet, Rev. 2
Freescale Semiconductor
321