
Programmer’s Reference
MOTOROLA
USB Device Module
21-37
At power-up time, the USB module contains no configuration information. The UDC module does not
know how many endpoints it has available or how to find the descriptors. To initialize the device,
download this information to the appropriate memories and configure the data path to match the intended
application. The following steps are involved in the initialization process:
1. Perform a hard reset or a software reset (RST bit in USB_ENAB register).
2. Wait for the device to be properly reset (after writing to RST bit, wait for it to clear) before
accessing the device registers.
3. Wait for the CFG bit in the USB_CFGSTAT register to assert before attempting to
communicate with the UDC. The RST bit set will make the ENAB bit set automatically.
4. Download configuration data (EndPtBufs) to the device via the USB_DDAT register. See
5. Program the USB interrupt mask register (USB_MASK) to enable USB general interrupts.
6. Program each endpoint’s control (USB_EPn_STATCR) and interrupt (USB_EPn_MASK)
registers to support the intended data transfer modes and interrupts.
7. Program endpoint type, direction, and maximum packet size in the USB_EPn_STATCR
register for each endpoint.
8. Program frame mode, granularity (USB_EPn_FCTRL), alarm level (USB_EPn_FALRM),
and so on for each enabled endpoint. Normally, all endpoints should be programmed with
FRAME mode enabled. To ensure proper operation of the DMA request lines for frame
mode endpoints, program the alarm level to the packet size or a multiple of the packet size,
depending on the depth of the FIFO buffer (that is, for 8-byte packets and a 16-byte FIFO,
the alarm would be programmed to 8 bytes).
9. Enable the USB for processing (USB_ENA bit in USB_CTRL).
Module initialization is a time-critical process. The USB host waits about 100 ms after powering on or for
a connection event to begin enumerating devices on the bus. This device must have all of the configuration
information available when the host requests it.
Once the device is enumerated, the USB host selects a specific configuration and set of interfaces on the
device. Software on the device must be aware of USB configuration changes in order to maintain proper
communication with the USB Host. The software retains sole responsibility for knowing the current
configuration and alternate interface at any given time. The CFG_CHG interrupt in the USB_GEN_ISR
register reports changes in device configuration and alternate interface settings to the software. The
software is required to respond to the CFG_CHG interrupt. To prevent the state of the device from
becoming out of sync with respect to the host, the device halts further traffic on the USB while this
interrupt is pending.
21.7.2 Configuration Download
The configuration download process initializes five endpoint buffers (EndPtBufs) within the UDC module
that defines its personality on the USB. The first EndPtBuf is reserved for the default pipe (control
endpoint) and should contain the value 0x0000080000.
The endpoint buffers are 40-bit data strings per physical endpoint (pipe) that are loaded directly into the
UDC module. They associate “l(fā)ogical” endpoint numbers in the USB software stack with hardware within
the UDC. Specifically, they attach each endpoint to a USB configuration, interface, and alternate setting.
Then they specify transfer type, packet size, data direction, and hardware FIFO number, among other
characteristics.