- •Features
- •Disclaimer
- •Overview
- •Block Diagram
- •Pin Descriptions
- •Port B (PB7..PB0)
- •Port C (PC7..PC0)
- •Port D (PD7..PD0)
- •D-/SDATA
- •UGND
- •UVCC
- •UCAP
- •RESET/PC1/dW
- •XTAL1
- •XTAL2/PC0
- •AVR CPU Core
- •Introduction
- •Status Register
- •Stack Pointer
- •TABLE 1.
- •TABLE 2.
- •AVR AT90USB82/162 Memories
- •I/O Memory
- •Clock Systems and their Distribution
- •Clock Switch
- •Exemple of use
- •Swith from external clock to RC clock
- •Switch from RC clock to external clock
- •Clock Sources
- •Default Clock Source
- •External Clock
- •Internal PLL for USB interface
- •Idle Mode
- •Power-down Mode
- •Power-save Mode
- •Standby Mode
- •Analog Comparator
- •Brown-out Detector
- •Watchdog Timer
- •Port Pins
- •Resetting the AVR
- •Reset Sources
- •Power-on Reset
- •External Reset
- •Watchdog Reset
- •USB Reset
- •Watchdog Timer
- •TABLE 2.
- •TABLE 2.
- •Interrupts
- •TABLE 2.
- •Introduction
- •Configuring the Pin
- •Toggling the Pin
- •Reading the Pin Value
- •TABLE 3.
- •Unconnected Pins
- •Alternate Port Functions
- •Register Description for I/O-Ports
- •Timer/Counter0 and Timer/Counter1 Prescalers
- •Internal Clock Source
- •Prescaler Reset
- •External Clock Source
- •8-bit Timer/Counter0 with PWM
- •Overview
- •Registers
- •Definitions
- •Counter Unit
- •Normal Mode
- •Fast PWM Mode
- •8-bit Timer/Counter Register Description
- •Overview
- •Registers
- •Definitions
- •Counter Unit
- •Input Capture Unit
- •Noise Canceler
- •Force Output Compare
- •Normal Mode
- •Fast PWM Mode
- •16-bit Timer/Counter Register Description
- •TABLE 2.
- •TABLE 2.
- •Slave Mode
- •Master Mode
- •Data Modes
- •USART
- •Overview
- •Clock Generation
- •External Clock
- •Frame Formats
- •Parity Bit Calculation
- •TABLE 2.
- •TABLE 3.
- •TABLE 4.
- •Parity Generator
- •TABLE 3.
- •TABLE 2.
- •Receiver Error Flags
- •Parity Checker
- •Disabling the Receiver
- •TABLE 2.
- •Using MPCMn
- •Receiver Flow Control
- •Overview
- •Clock Generation
- •Frame Formats
- •TABLE 2.
- •Data Transfer
- •TABLE 3.
- •USB controller
- •Features
- •Block Diagram
- •Typical Application Implementation
- •Device mode
- •Bus Powered device
- •Introduction
- •Interrupts
- •Power modes
- •Idle mode
- •Power down
- •Freeze clock
- •Memory access capability
- •Memory management
- •PAD suspend
- •D+/D- Read/write
- •Registers description
- •USB general registers
- •USB Software Operating modes
- •USB Device Operating modes
- •Introduction
- •Power-on and reset
- •Endpoint reset
- •USB reset
- •Endpoint selection
- •Endpoint activation
- •Address Setup
- •Detach
- •Remote Wake-up
- •STALL request
- •Special consideration for Control Endpoints
- •STALL handshake and Retry mechanism
- •CONTROL endpoint management
- •Control Write
- •Control Read
- •Overview
- •“Manual” mode
- •Detailed description
- •IN endpoint management
- •“Manual” mode
- •Detailed description
- •Abort
- •Isochronous mode
- •Underflow
- •CRC Error
- •Overflow
- •Interrupts
- •Registers
- •USB device general registers
- •USB device endpoint registers
- •Characteristics
- •Analog Comparator
- •Application Section
- •Boot Reset Fuse
- •Simple Assembly Code Example for a Boot Loader
- •debugWIRE On-chip Debug System
- •Features
- •Overview
- •Physical Interface
- •Software Break Points
- •Limitations of debugWIRE
- •debugWIRE Related Register in I/O Memory
- •Fuse Bits
- •Latching of Fuses
- •Signature Bytes
- •Calibration Byte
- •Signal Names
- •Chip Erase
- •Reading the Flash
- •Reading the EEPROM
- •Electrical Characteristics
- •Absolute Maximum Ratings*
- •DC Characteristics
- •External Clock Drive Waveforms
- •External Clock Drive
- •Maximum speed vs. VCC
- •Supply Current of IO modules
- •Example 1
- •Example 2
- •Example 3
- •Instruction Set Summary
- •Packaging Information
- •TQFP32
USB Device Operating modes
Introduction
Power-on and reset
The USB device controller supports full speed data transfers. In addition to the default control endpoint, it provides four other endpoints, which can be configured in control, bulk, interrupt or isochronous modes:
•Endpoint 0: programmable size FIFO up to 64 bytes, default control endpoint
•Endpoints 1and 2: programmable size FIFO up to 64 bytes.
•Endpoints 3 and 4: programmable size FIFO up to 64 bytes in ping-pong mode.
The controller starts in the “idle” mode. In this mode, the pad consumption is reduced to the minimum.
The next diagram explains the USB device controller main states on power-on:
Figure 83. USB device controller states after reset
<any other
USBE=0 state>
|
USBE=0 |
Idle |
Reset |
USBE=1 |
|
|
UID=1 |
|
HW
RESET
Endpoint reset
The reset state of the Device controller is:
•the macro clock is stopped in order to minimize the power consumption (FRZCLK set),
•the USB device controller internal state is reset (all the registers are reset to their default value. Note that DETACH is set.)
•the endpoint banks are reset
•the D+ pull up are not activated (mode Detach)
The D+ pull-up will be activated as soon as the DETACH bit is cleared.
The macro is in the ‘Idle’ state after reset with a minimum power consumption and does not need to have the PLL activated to enter in this state.
The USB device controller can at any time be reset by clearing USBE.
An endpoint can be reset at any time by setting in the UERST register the bit corresponding to the endpoint (EPRSTx). This resets:
•the internal state machine on that endpoint,
•the Rx and Tx banks are cleared and their internal pointers are restored,
•the UEINTX, UESTA0X and UESTA1X are restored to their reset value.
The data toggle field remains unchanged.
The other registers remain unchanged.
The endpoint configuration remains active and the endpoint is still enabled.
192
7707A–AVR–01/07
|
|
|
|
|
|
|
|
The endpoint reset may be associated with a clear of the data toggle command (RSTDT bit) as |
|
|
|
|
|
an answer to the CLEAR_FEATURE USB command. |
|
USB reset |
When an USB reset is detected on the USB line (SEO state with a minimal duration of 100µs), |
|
|
the next operations are performed by the controller: |
|
|
• all the endpoints are disabled |
|
|
• the default control endpoint remains configured |
|
|
• The data toggle of the default control endpoint is cleared. |
|
|
If the hardware reset function is selected, a reset is generated to the CPU core without disabling |
|
|
the USB controller (that remains in the same state than after a USB Reset). |
|
Endpoint selection |
Prior to any operation performed by the CPU, the endpoint must first be selected. This is done |
|
|
by setting the EPNUM2:0 bits (in UENUM register) with the endpoint number which will be man- |
|
|
aged by the CPU. |
|
|
The CPU can then access to the various endpoint registers and data. |
Endpoint activation
The endpoint is maintained under reset as long as the EPEN bit is not set.
The following flow must be respected in order to activate an endpoint:
Figure 84. Endpoint activation flow:
Endpoint
Activation
UENUM
EPNUM=x
EPEN=1
UECFG0X
EPDIR
EPTYPE
...
UECFG1X
ALLOC
EPSIZE
EPBK
CFGOK=1
No
Yes
Select the endpoint
Activate the endpoint
Configure:
-the endpoint direction
-the endpoint type
-the Not Yet Disable feature
Configure:
-the endpoint size
-the bank parametrization Allocation and reorganization of the memory is made on-the-fly
Test the correct endpoint configuration
Endpoint activated |
ERROR |
As long as the endpoint is not correctly configured (CFGOK cleared), the hardware does not acknowledge the packets sent by the host.
CFGOK will not be set if the Endpoint size parameter is bigger than the DPRAM size.
193
7707A–AVR–01/07
Address Setup
Suspend, Wake-up
and Resume
Detach
A clear of EPEN acts as an endpoint reset (see Section , page 192 for more details). It also performs the next operation:
•The configuration of the endpoint is kept (EPSIZE, EPBK, ALLOC kept)
•It resets the data toggle field.
•The DPRAM memory associated to the endpoint is still reserved.
See Section , page 186 for more details about the memory allocation/reorganization.
The USB device address is set up according to the USB protocol:
•the USB device, after power-up, responds at address 0
•the host sends a SETUP command (SET_ADDRESS(addr)),
•the firmware records that address in UADD, but keep ADDEN cleared,
•the USB device sends an IN command of 0 bytes (IN 0 Zero Length Packet) to acknowledge the transaction,
•then, the firmware may enable the USB device address by setting ADDEN. The only accepted address by the controller is the one stored in UADD.
ADDEN and UADD shall not be written at the same time.
UADD contains the default address 00h after a power-up or an USB reset.
ADDEN is cleared by hardware:
•after a power-up reset,
•when an USB reset is received,
•or when the macro is disabled (USBE cleared)
When this bit is cleared, the default device address 00h is used.
After a period of 3 ms during which the USB line was inactive (J state), the controller setn the SUSPI flag and triggers the corresponding interrupt if enabled. The firmware may then set the FRZCLK bit.
The CPU can also, depending on software architecture, disable the PLL and/or enter in the idle mode to reduce the power consumption (especially in a bus powered application).
There are two ways to recover from the “Suspend” mode:
•First one is to clear the FRZCLK bit. This is possible if the CPU is not in the Idle mode.
•Second way, if the CPU is “idle”, is to enable the WAKEUPI interrupt (WAKEUPE set). Then, as soon as an non-idle signal is seen by the controller, the WAKEUPI interrupt is triggered. The firmware shall then clear the FRZCLK bit to restart the transfer.
There are no relationship between the SUSPI interrupt and the WAKEUPI interrupt: the WAKEUPI interrupt is triggered as soon as there are non-idle patterns on the data lines. Thus, the WAKEUPI interrupt can occurs even if the controller is not in the “suspend” mode.
When the WAKEUPI interrupt is triggered, if the SUSPI interrupt bit was already set, it is cleared by hardware.
When the SUSPI interrupt is triggered, if the WAKEUPI interrupt bit was already set, it is cleared by hardware.
The reset value of the DETACH bit is 1.
It is possible to re-enumerate a device, simply by setting and clearing the DETACH bit (the line discharge time must be taken in account).
194
7707A–AVR–01/07
