Part Number Hot Search : 
FFV36AK 20N36 RF2105 RAPH2SG 08100 FCX61903 6EJMS1 60040215
Product Description
Full Text Search
 

To Download AT43USB326-AC Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
 Features
* * * * * * * * * * * * * * *
AVR(R) 8-bit RISC Microcontroller with 83 ns Instruction Cycle Time USB Hub with One Attached and Two External Ports USB Keyboard Function with Three Programmable Endpoints 16 KB Program Memory, 512 Bytes Data SRAM 32 x 8 General-purpose Working Registers 32 Programmable I/O Port Pins Support for 18 x 8 Keyboard Matrix Keyboard Scan Inputs with Pull-up Resistor Four LED Driver Outputs One 8-bit Timer/Counter with Separate Pre-scaler External and Internal Interrupt Sources Programmable Watchdog Timer 6 MHz Oscillator with On-chip PLL 5V Operation with On-chip 3.3V Power Supply 48-lead LQFP Package
Multimedia USB Keyboard Controller with Embedded Hub AT43USB326
Description
The Atmel AT43USB326 is an 8-bit microcontroller based on the AVR RISC architecture. By executing powerful instructions in a single clock cycle, the AT43USB326 achieves throughputs approaching 12 MIPS. The AVR core combines a rich instruction set with 32 general-purpose working registers. All 32 registers are directly connected to the ALU allowing two independent registers to be accessed in one single instruction executed in one clock cycle. The resulting architecture is more code efficient while achieving throughputs up to ten times faster than conventional CISC microcontrollers. Furthermore, the AT43USB326 features an on-chip 16-Kbyte program memory and 512 bytes of data memory. It is supported by a standard set of peripherals such as timer/counter modules, watchdog timer and internal and external interrupt sources. The major peripheral included in the AT43USB326 is the USB Hub with an embedded keyboard controller function.
3313D-USB-04/06
1
Pin Configuration
Figure 1. AT43USB326 48-lead LQFP
PC5 PC6 PC1 PC2 PC3 PC4 PC7 PA0 PA1 PA2 PA3 26 PA4 25
36
35
34
33
32
31
30
29
28
PC0 PD0 PD1 VSS2 CEXT2 DP3 DM3 DP2 DM2 DP0 DM0 RESETN
27
37 38 39 40 41 42 43 44 45 46 47 48 10 11 12 1 2 3 4 5 6 7 8 9
24 23 22 21 20
PA5 PA6 PA7 PB0 PB1 PB2 PB3 PB4 PB5 PB6 PB7 PE0
AT43USB326
19 18 17 16 15 14 13
VSS1
XTAL1
XTAL2
CEXT1
VCC
PE4
PE5
PE6
PE7
TEST
2
AT43USB326
3313D-USB-04/06
PE1
LFT
AT43USB326
Pin Assignment
Pin# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 Signal TEST VSS1 LFT XTAL1 XTAL2 CEXT1 VCC PE4 PE5 PE6 PE7 PE1/COL17 PE0/COL16 PB7/COL15 PB6/COL14 PB5/COL13 PB4/COL12 PB3/COL11 PB2/COL10 PB1/COL9 PB0/COL8 PA7/COL7 PA6/COL6 PA5/COL5 Type Input Power Supply/Ground Output Input Output Power Supply/Ground Power Supply/Ground Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Pin# 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 Signal PA4/CL4 PA3/CL3 PA2/CL2 PA1/CL1 PA0/CL0 PC7/ROW7 PC6/ROW6 PC5/ROW5 PC4/ROW4 PC3/ROW3 PC2/ROW2 PC1/ROW1 PC0/ROW0 PD0 PD1 VSS2 CEXT2 DP3 DM3 DP2 DM2 DP0 DM0 RESETN Type Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Power Supply/Ground Power Supply/Ground Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional
3
3313D-USB-04/06
Signal Description
Name VCC VSS1, 2 CEXT1, 2 XTAL1 XTAL2 LFT Type Power Supply/Ground Power Supply/Ground Power Supply/Ground Input Output Input Function 5V Digital Power Supply Ground External Capacitors for Power Supplies - High quality 2.2 F capacitors must be connected to CEXT1 and 2 for proper operation of the chip. Oscillator Input - Input to the inverting oscillator amplifier. Oscillator Output - Output of the inverting oscillator amplifier. PLL Filter - For proper operation of the PLL, this pin should be connected through a 0.01 F capacitor in parallel with a 100 resistor in series with a 0.1 F capacitor to ground (VSS). Both capacitors must be high quality ceramic. Upstream Plus USB I/O - This pin should be connected to CEXT1 through an external 1.5 k. Upstream Minus USB I/O Downstream Plus USB I/O - Each of these pins should be connected to VSS through an external 15 k resistor. DP[2,3] and DM[2,3] are the differential signal pin pairs to connect downstream USB devices. Downstream Minus USB I/O - Each of these pins should be connected to VSS through an external 15 k resistor. Port A[0:7] - Bi-directional 8-bit I/O port with controlled slew rate. These pins are used as eight of the keyboard matrix column output strobes. PA[0:7] = COL[0:7]. Port B[0:7] - Bi-directional 8-bit I/O port controlled slew rate. These pins are used as the eight of the keyboard matrix column output strobes: PB[0:7] = COL[8:15]. Port C[0:7] - Bi-directional 8-bit I/O port with internal pull-ups. These pins are used as keyboard matrix row input signals. PC[0:7] = ROW [0:7]. Port D[0:1] - Bi-directional I/O ports. Port E[0:1] - Bi-directional I/O port with controlled slew rate which can be used as two additional keyboard column output strobes, COL 16, 17. PE[4:7] have built-in series limiting resistors and can be used to drive LEDs directly. Test Pin - This pin should be tied to ground. Reset - Active Low.
DPO DMO DP[2,3]
Bi-directional Bi-directional Bi-directional
DM[2,3] PA[0:7] PB[0:7] PC[0:7] PD[0:1] PE[0:1] PE[4:7] TEST RESETN
Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Bi-directional Input Input
4
AT43USB326
3313D-USB-04/06
AT43USB326
Figure 2. The AT43USB326 Enhanced RISC Architecture with USB Keyboard Controller and Hub
8 x 16 Program Memory
Program Counter
Status and Control
Interrupt Unit
Instruction Register
32 x 8 General-purpose Registers
8-bit Timer/Counter
Watchdog Timer ALU Instruction Decoder 18 Strobe Outputs
Control Lines
512 x 8 SRAM 8 Strobe Inputs
2 GPIO Lines 4 LED Drives
USB Hub and Function
5
3313D-USB-04/06
Architectural Overview
The AT43USB326 is a USB microcontroller with special peripherals for use as a programmable keyboard controller. The peripherals and features of the AT43USB326 microcontroller are similar to those of the AT90S8515, with the exception of the following modifications: * * * * * * * * A masked ROM for program memory No EEPROM No external data memory accesses No UART No SPI No 16-bit timer/counter Idle mode not supported USB Hub with attached function
The embedded USB hardware of the AT43USB326 is a compound device, consisting of a 3 port hub with a permanently attached function on one port. The hub and attached function are two independent USB devices, each having its own device addresses and control endpoints. The hub has its dedicated interrupt endpoint, while the USB function has two additional programmable endpoints with 8-byte FIFOs. The microcontroller always runs from a 12 MHz clock that is generated by the USB hardware. While the nominal and average period of this clock is 83.3 ns, it may have single cycles that deviate by 20.8 ns during a phase adjustment by the SIE's clock/data separator of the USB hardware. The microcontroller shares most of the control and status registers of the megaAVR Microcontroller Family. The registers for managing the USB operations are mapped into its SRAM space. The I/O section on page 14 summarizes the available I/O registers. The "AVR Register Set" on page 34 covers the AVR registers. Please refer to the Atmel AVR manual for more information. The fast-access register file contains 32 x 8-bit general-purpose working registers with a single clock cycle access time. This means that during one single clock cycle, one Arithmetic Logic Unit (ALU) operation is executed. Two operands are output from the register file, the operation is executed, and the result is stored back in the register file - in one clock cycle. Six of the 32 registers can be used as three 16-bit indirect address register pointers for Data Space addressing - enabling efficient address calculations. One of the three address pointers is also used as the address pointer for look-up tables in program memory. These added function registers are the 16-bit X-, Y- and Z-registers. The ALU supports arithmetic and logic operations between registers or between a constant and a register. Single register operations are also executed in the ALU. Figure 2 on page 5 shows the AT43USB326 AVR Enhanced RISC microcontroller architecture. In addition to the register operation, the conventional memory addressing modes can be used on the register file as well. This is enabled by the fact that the register file is assigned the 32 lowest Data Space addresses ($00 - $1 F), allowing them to be accessed as though they were ordinary memory locations. The I/O memory space contains 64 addresses for CPU peripheral functions as Control Registers, Timer/Counters, and other I/O functions. The I/O Memory can be accessed directly, or as the Data Space locations following those of the register file, $20 - $5F. The AVR uses a Harvard architecture concept - with separate memories and buses for program and data. The program memory is executed with a single-level pipelining. While one
6
AT43USB326
3313D-USB-04/06
AT43USB326
instruction is being executed, the next instruction is pre-fetched from the program memory. This concept enables instructions to be executed in every clock cycle. The program memory is a downloadable SRAM or a mask programmed ROM. With the relative jump and call instructions, the whole 24K address space is directly accessed. Most AVR instructions have a single 16-bit word format. Every program memory address contains a 16- or 32-bit instruction. During interrupts and subroutine calls, the return address Program Counter (PC) is stored on the stack. The stack is effectively allocated in the general data SRAM, and consequently, the stack size is only limited by the total SRAM size and the usage of the SRAM. All user programs must initialize the Stack Pointer (SP) in the reset routine (before subroutines or interrupts are executed). The 10-bit SP is read/write accessible in the I/O space. The 1-Kbyte data SRAM can be easily accessed through the five different addressing modes supported in the AVR architecture. The memory spaces in the AVR architecture are all linear and regular memory maps. A flexible interrupt module has its control registers in the I/O space with an additional global interrupt enable bit in the status register. All interrupts have a separate interrupt vector in the interrupt vector table at the beginning of the program memory. The interrupts have priority in accordance with their interrupt vector position. The lower the interrupt vector address, the higher the priority.
The Generalpurpose Register File
Table 1. AVR CPU General-purpose Working Register
Register R0 R1 R2 .. R13 R14 R15 R16 R17 .. R26 R27 R28 R29 R30 R31 $1A $1B $1C $1D $1E $1F X-register low byte X-register high byte Y-register low byte Y-register high byte Z-register low byte Z-register high byte $0D $0E $0F $10 $11 Address $00 $01 $02 Comment
All register operating instructions in the instruction set have direct and single cycle access to all registers. The only exception is the five constant arithmetic and logic instructions SBCI, SUBI, CPI, ANDI, and ORI between a constant and a register, and the LDI instruction for load
7
3313D-USB-04/06
immediate constant data. These instructions apply to the second half of the registers in the register file - R16..R31. The general SBC, SUB, CP, AND, and OR and all other operations between two registers or on a single register apply to the entire register file. As shown in Table 1, each register is also assigned a data memory address, mapping them directly into the first 32 locations of the user Data Space. Although not being physically implemented as SRAM locations, this memory organization provides great flexibility in access of the registers, as the X-, Y-, and Z-registers can be set to index any register in the file.
X-, Y- and ZRegisters
Registers R26..R31 contain some added functions to their general-purpose usage. These registers are address pointers for indirect addressing of the Data Space. The three indirect address registers X, Y, and Z are defined as:
X-register
15 7
XH 0 R27 ($1B) 7
XL
0 0
R26 ($1A)
Y-register
15 7
YH 0 R29 ($1D) 7
YL
0 0
R28 ($1C)
Z-register
15 7
ZH 0 R30 ($1F) 7
ZL
0 0
R31 ($1E)
In the different addressing modes these address registers have functions as fixed displacement, automatic increment and decrement (see the descriptions for the different instructions).
ALU - Arithmetic Logic Unit
The high-performance AVR ALU operates in direct connection with all 32 general-purpose working registers. Within a single clock cycle, ALU operations between registers in the register file are executed. The ALU operations are divided into three main categories - arithmetic, logical and bit-functions. The AT43USB326 contains 16K bytes on-chip masked programmable ROM. Since all instructions are 16- or 32-bit words, the program memory is organized as 8K x 16. The AT43USB326 Program Counter (PC) is 13 bits wide, thus addressing the 8,192 program memory addresses. Constant tables can be allocated within the entire program memory address space (see the LPM - Load Program Memory instruction description).
Program Memory
8
AT43USB326
3313D-USB-04/06
AT43USB326
SRAM Data Memory
Table 3 summarizes how the AT43USB326 SRAM Memory is organized. The lower 608 Data Memory locations address the Register file, the I/O Memory and the internal data SRAM. The first 96 locations address the Register File + I/O Memory, and the next 512 locations address the internal data SRAM. The five different addressing modes for the data memory cover: Direct, Indirect with Displacement, Indirect, Indirect with Pre-decrement and Indirect with Postincrement. In the register file, registers R26 to R31 feature the indirect addressing pointer registers. Direct addressing reaches the entire data space. The Indirect with Displacement mode features 63 address locations that reach from the base address given by the Y- or Z-register. When using register indirect addressing modes with automatic pre-decrement and post-increment, the address registers X, Y, and Z are decremented and incremented. The 32 general-purpose working registers, 64 I/O registers and the 512 bytes of internal data SRAM in the AT43USB326 are all accessible through these addressing modes. To manage the USB hardware, a special set of registers is assigned. These registers are mapped to SRAM space between addresses $1F00 and 1FFF. Table 3 and Table 4 give an overview of these registers.
9
3313D-USB-04/06
Table 2. SRAM Organization
Register File R0 R1 Data Address Space $0000 $0001
R30 R31 I/O Registers $00 $01
$001E $001F
$0020 $0021
$3E $3F
$005E $005F Internal SRAM $0060 $0061
$025E $045F USB Registers $1F00
$1FFE $1FFF
10
AT43USB326
3313D-USB-04/06
AT43USB326
Table 3. USB Hub and Function Registers
Address $1FFD $1FFC $1FFB $1FFA $1FF9 $1FF8 $1FF7 $1FF6 $1FF5 $1FF3 $1FF2 $1FEF $1FEE $1FE7 $1FE5 $1FE4 $1FE3 $1FDF $1FDD $1FDC $1FDB $1FD7 $1FD5 $1FD4 $1FD3 $1FCF $1FCD $1FCC $1FCB $1FC7 $1FC5 $1FBA $1FB9 $1FB8 $1FB2 Name FRM_NUM_H FRM_NUM_L GLB_STATE SPRSR SPRSIE SPRSMSK UISR UIMSKR UIAR UIER UOVCER HADDR FADDR HENDP0_CNTR FENDP0_CNTR FENDP1_CNTR FENDP2_CNTR HCSR0 FCSR0 FCSR1 FCSR2 HDR0 FDR0 FDR1 FDR2 HBYTE_CNT0 FBYTE_CNT0 FBYTE_CNT1 FBYTE_CNT2 HSTR HPCON HPSTAT3 HPSTAT2 HPSTAT1 HPSCR3 Function Frame Number High Register Frame Number Low Register Global State Register Suspend/Resume Register Suspend/Resume Interrupt Enable Register Suspend/Resume Interrupt Mask Register USB Interrupt Status Register USB Interrupt Mask Register USB Interrupt Acknowledge Register USB Interrupt Enable Register Overcurrent Detect Register Hub Address Register Function Address Register Hub Endpoint 0 Control Register Function Endpoint 0 Control Register Function Endpoint 1 Control Register Function Endpoint 2 Control Register Hub Controller Endpoint 0 Service Routine Register Function Controller Endpoint 0 Service Routine Register Function Controller Endpoint 1 Service Routine Register Function Controller Endpoint 2 Service Routine Register Hub Endpoint 0 FIFO Data Register Function Endpoint 0 FIFO Data Register Function Endpoint 1 FIFO Data Register Function Endpoint 2 FIFO Data Register Hub Endpoint 0 Byte Count Register Function Endpoint 0 Byte Count Register Function Endpoint 1 Byte Count Register Function Endpoint 2 Byte Count Register Hub Status Register Hub Port Control Register Hub Port 3 Status Register Hub Port 2 Status Register Hub Port 1 Status Register Hub Port 3 Status Change Register
11
3313D-USB-04/06
Table 3. USB Hub and Function Registers (Continued)
Address $1FB1 $1FB0 $1FAA $1FA9 $1FA7 $1FA5 $1FA4 $1FA3 Name HPSCR2 HPSCR1 PSTATE3 PSTATE2 HCAR0 FCAR0 FCAR1 FCAR2 Function Hub Port 2 Status Change Register Hub Port 1 Status Change Register Hub Port 3 Bus State Register Hub Port 2 Bus State Register Hub Endpoint 0 Control and Acknowledge Register Function Endpoint 0 Control and Acknowledge Register Function Endpoint 1 Control and Acknowledge Register Function Endpoint 2 Control and Acknowledge Register
12
AT43USB326
3313D-USB-04/06
AT43USB326
Table 4. USB Hub and Function Registers
Name GLB_STATE SPRSR SPRSIE SPRSMSK UISR UIMSKR UIAR UIER UOVCER HADDR FADDR HENDP0_CNTR FENDP0_CNTR FENDP1_CNTR FENDP2_CNTR HCSR0 FCSR0 FCSR1 FCSR2 HDR0 FDR0 FDR1 FDR2 HBYTE_CNT0 FBYTE_CNT0 FBYTE_CNT1 FBYTE_CNT2 HSTR HPCON HPSTAT3 HPSTAT2 HPSTAT1 HPSCR3 HPSCR2 HPSCR1 PSTATE3 PSTATE2 HCAR0 FCAR0 FCAR1 FCAR2 Address $1FFB $1FFA $1FF9 $1FF8 $1FF7 $1FF6 $1FF5 $1FF3 $1FF2 $1FEF $1FEE $1FE7 $1FE5 $1FE4 $1FE3 $1FDF $1FDD $1FDC $1FDB $1FD7 $1FD5 $1FD4 $1FD3 $1FCF $1FCD $1FCC $1FCB $1FC7 $1FC5 $1FBA $1FB9 $1FB8 $1FB2 $1FB1 $1FB0 $1FAA $1FA9 $1FA7 $1FA5 $1FA4 $1FA3 Bit 7 - - - - SOF INT SOF MSK SOF INTACK SOF IE - SAEN FEN EPEN EPEN EPEN EPEN - - - - DATA7 DATA7 DATA7 DATA7 - - - - - - - - - - - - - - CTL DIR CTL DIR CTL DIR CTL DIR Bit 6 KB INT EN - - - EOF2 INT SOF2 MSK EOF2 INTACK EOF2 IE - HADD6 FADD6 - - - - - - - - DATA6 DATA6 DATA6 DATA6 - - - - - HPCON2 LSP LSP LSP - - - - - DATA END DATA END DATA END DATA END Bit 5 - - - - - - - - - HADD5 FADD5 - - - - - - - - DATA5 DATA5 DATA5 DATA5 BYTCT5 BYTCT5 BYTCT5 BYTCT5 - HPCON1 PPSTAT PPSTAT PPSTAT - - - - - FORCE STALL FORCE STALL FORCE STALL FORCE STALL Bit 4 SUSP FLG - - - - - - - - HADD4 FADD4 - - - - - - - - DATA4 DATA4 DATA4 DATA4 BYTCT4 BYTCT4 BYTCT4 BYTCT4 - HPCON0 PRSTAT PRSTAT PRSTAT RSTSC RSTSC RSTSC - - TX PACKET READY TX PACKET READY TX PACKET READY TX PACKET READY Bit 3 RESUME FLG - - - HEP0 INT HEP0 MSK HEP0 INTACK HEP0 IE - HADD3 FADD3 DTGLE DTGLE DTGLE DTGLE STALL SENT STALL SENT STALL SENT STALL SENT DATA3 DATA3 DATA3 DATA3 BYTCT3 BYTCT3 BYTCT3 BYTCT3 OVLSC - POCI POCI POCI POCIC POCIC POCIC - - STALL_SENT-ACK STALL_SENT-ACK STALL_SENT-ACK STALL_SENT-ACK Bit 2 RMWUPE FRWUP FRWUP IE FRWUP MSK FEP2 INT FEP2 MSK FEP2 INTACK FEP2 IE OVC HADD2 FADD2 EPDIR EPDIR EPDIR EPDIR RX SETUP RX SETUP RX SETUP RX SETUP DATA2 DATA2 DATA2 DATA2 BYTCT2 BYTCT2 BYTCT2 BYTCT2 LPSC HPADD2 PSSTAT PSSTAT PSSTAT PSSC PSSC PSSC - - RX_SETUP_ACK RX_SETUP_ACK RX_SETUP_ACK RX_SETUP_ACK Bit 1 CONFG RSM RSM IE RSM MSK FEP1 INT FEP1 MSK FEP1 INTACK FEP1 IE - HADD1 FADD1 EPTYPE1 EPTYPE1 EPTYPE1 EPTYPE1 RX OUT PACKET RX OUT PACKET RX OUT PACKET RX OUT PACKET DATA1 DATA1 DATA1 DATA1 BYTCT1 BYTCT1 BYTCT1 BYTCT1 OVI HPADD1 PESTAT PESTAT PESTAT PESC PESC PESC DPSTATE DPSTATE RX_OUT_PACKET_ACK RX_OUT_PACKET_ACK RX_OUT_PACKET_ACK RX_OUT_PACKET_ACK Bit 0 HADD EN GLB SUSP GLB SUSP IE GLB SUSP MSK FEP0 INT FEP0 MSK FEP0 INTACK FEP0 IE - HADD0 FADD0 EPTYPE0 EPTYPE0 EPTYPE0 EPTYPE0 TX CEMPLETE TX COMPLETE TX COMPLETE TX COMPLETE DATA0 DATA0 DATA0 DATA0 BYTCT0 BYTCT0 BYTCT0 BYTCT0 LPS HPADD0 PCSTAT PCSTAT PCSTAT PCSC PCSC PCSC DMSTATE DMSTATE TX_COMPLETE-ACK TX_COMPLETE-ACK TX_COMPLETE-ACK TX_COMPLETE-ACK
13
3313D-USB-04/06
I/O Memory
The I/O space definition of the AT43USB326 is shown in the following table: Table 5. I/O Memory Space
I/O (SRAM) Address $3F ($5F) $3E ($5E) $3D ($5D) $3B ($5B) $3A ($5A) $39 ($59) $38 ($58) $35 ($55) $33 ($53) $32 ($52) $21 ($41) $1B ($4B) $1A ($3A) $19 ($39) $18 ($38) $17 ($37) $16 ($36) $12 ($32) $11 ($31) $10 ($30) $03 ($23) $02 ($22) $01 ($21) Name SREG SPH SPL GIMSK GIFR TIMSK TIFR MCUCR TCCR0 TCNT0 WDTCR PORTA DDRA PINA PORTB DDRB PINB PORTD DDRD PIND PORTE DDRE PINE Function Status Register Stack Pointer High Stack Pointer Low General Interrupt Mask Register General Interrupt Flag Register Timer/Counter Interrupt Mask Register Timer/Counter Interrupt Mask Register MCU General Control Register Timer/Counter0 Control Register Timer/Counter0 (8 bit) Watchdog Timer Counter Register Data Register, Port A Data Direction Register, Port A Input Pins, Port A Data Register, Port B Data Direction Register, Port B Input Pins, Port B Data Register, Port D Data Direction Register, Port D Input Pins, Port D Data Register, Port E Data Direction Register, Port E Input Pins, Port E
All AT43USB326 I/O and peripherals, except for the USB hardware registers, are placed in the I/O space. The I/O locations are accessed by the IN and OUT instructions transferring data between the 32 general-purpose working registers and the I/O space. I/O registers within the address range $00 - $1F are directly bit-accessible using the SBI and CBI instructions. In these registers, the value of single bits can be checked by using the SBIS and SBIC instructions. Refer to the instruction set documentations of the AVR for more details. When using the I/O specific commands, IN and OUT, the I/O address $00 - $3F must be used. When addressing I/O registers as SRAM, $20 must be added to this address. All I/O register addresses throughout this document are shown with the SRAM address in parentheses. For compatibility with future devices, reserved bits should be written to zero if accessed. Reserved I/O memory addresses should never be written.
14
AT43USB326
3313D-USB-04/06
AT43USB326
USB Hub
A block diagram of the USB hardware of the AT43USB326 is shown in Figure 3. The USB hub of the AT43USB326 has 3 downstream ports. The embedded function is permanently attached to Port 1. Ports 2 and 3 are available as external ports. The actual number of ports used is strictly defined by the firmware of the AT43USB326 and can vary from 0 to 2. Because the exact configuration is defined by firmware, ports 2 and 3 may even function as permanently attached ports as long as the Hub Descriptor identifies them as such. The embedded USB function has its own device address and has a default endpoint plus 2 other programmable endpoints with their own 8-byte FIFOs. Endpoints 1 and 2 can be programmed as interrupt IN or OUT or bulk IN or OUT endpoints.
USB Function
15
3313D-USB-04/06
Figure 3. USB Hardware
Port 0 XCVR
Port 2 XCVR
Hub Repeater
Port 3 XCVR Serial Interface Engine
Hub Interface Unit
Port 1 Function Interface Unit
Data Address Control
AVR Microcontroller
16
AT43USB326
3313D-USB-04/06
AT43USB326
Functional Description
On-chip Power Supply
The AT43USB326 contains two on-chip power supplies that generate 3.3V with a capacity of 30 mA each from the 5V power input. The on-chip power supplies are intended to supply the AT43USB326 internal circuit and the 1.5K pull-up resistor only and should not be used for other purposes. External 2.2 F filter capacitors are required at the power supply outputs, CEXT1 and CEXT2. The internal power supplies can be disabled as described in the next paragraph. The user should be careful when the GPIO pins are required to supply high-load currents. If the application requires that the GPIO supply currents beyond the capability of the on-chip power supply, the AT43USB326 should be supplied by an external 3.3V power supply. In this case, the 5V VCC power supply pin should be left unconnected and the 3.3V power supplied to the chip through the CEXT1 and CEXT2 pins.
I/O Pin Characteristics
The I/O pins of the AT43USB326 should not be directly connected to voltages less than VSS or more than the voltage at the CEXT pins. If it is necessary to violate this rule, insert a series resistor between the I/O pin and the source of the external signal source that limits the current into the I/O pin to less than 2 mA. Under no circumstance should the external voltage exceed 5.5V. To do so will put the chip under excessive stress. All clock signals required to operate the AT43USB326 are derived from an on-chip oscillator. To reduce EMI and power dissipation, the oscillator is designed to operate with a 6 MHz crystal. An on-chip PLL generates the high frequency for the clock/data separator of the Serial Interface Engine. In the suspended state, the oscillator circuitry is turned off. The oscillator of the AT43USB326 is a special, low-drive type, designed to work with most crystals without any external components. The crystal must be of the parallel resonance type requiring a load capacitance of about 10 pF. If the crystal requires a higher value capacitance, external capacitors can be added to the two terminals of the crystal and ground to meet the required value. To assure quick start-up, a crystal with a high Q, or low ESR, should be used. To meet the USB hub frequency accuracy and stability requirements for hubs, the crystal should have an accuracy and stability of better than 100 PPM. The use of a ceramic resonator in place of the crystal is not recommended because a resonator would not have the necessary frequency accuracy and stability. The clock can also be externally sourced. In this case, connect the clock source to the XTAL1 pin, while leaving XTAL2 pin floating. The switching level at the OSC1 pin can be as low as 0.47V and a CMOS device is required to drive this pin to maintain good noise margins at the low switching level. For proper operation of the PLL, an external RC filter consisting of a series RC network of 100 and 0.1 F in parallel with a 0.01 F capacitor must be connected from the LFT pin to VSS. Use only high-quality ceramic capacitors.
Oscillator and PLL
17
3313D-USB-04/06
Figure 4. Oscillator and PLL
U1 XTAL1
Y1 6.000 MHz
XTAL2 AT43USB326 R1 100 LFT C1 0.22 UF C2 0.01 UF
Reset and Interrupt Handling
The AT43USB326 provides 12 different interrupt sources with 4 separate reset vectors, each with a separate program vector in the program memory space. Nine of the interrupt sources share 2 interrupt reset vectors. These nine are the USB related interrupts. All interrupts are assigned individual enable bits which must be set (one) together with the I-bit in the status register in order to enable the interrupt. The lowest addresses in the program memory space are automatically defined as the Reset and Interrupt vectors. The complete list of vectors is shown in Table 6. The list also determines the priority levels of the different interrupts. The lower the address, the higher is the priority level. RESET has the highest priority, and next is INT0 - the USB Suspend and Resume Interrupt, etc. Table 6. Reset and Interrupt Vectors
Vector No. 1 2 8 13 Program Address $000 $002 $00E $018 Source RESET INT0 TIMER0, OVF USB HW Interrupt Definition External Reset, Power-on Reset and Watchdog Reset USB Suspend and Resume Timer/Counter0 Overflow USB Hardware
18
AT43USB326
3313D-USB-04/06
AT43USB326
The most typical and general program setup for the Reset and Interrupt Vector Addresses are:
Address $000 $002 $00E Overflow Handler $018 ; $00d start $00e $00f $010 $011
Labels
Code jmp jmp jmp RESET EXT_INT0 TIM0_OVF
Comments ; Reset Handler ; IRQ0 Handler ; Timer0
jmp
USB_HW
; USB Handler
MAIN:
ldi r16, high (RAMEND)
; Main Program
out SPH, r16 ldi r16, low (RAMEND) out SPL, r16 xxx
...
...
...
...
USB related interrupt events are routed to reset vectors 13 and 2 through a separate set of interrupt, interrupt enable and interrupt mask registers that are mapped to the data SRAM space. These interrupts must be enabled though their control register bits. In the event an interrupt is generated, the source of the interrupt is identified by reading the interrupt registers. The USB frame and transaction related interrupt events, such as Start of Frame interrupt, are grouped in one set of registers: USB Interrupt Flag Register, USB Interrupt Enable Register and USB Interrupt Mask Register. The USB Bus reset and suspend/resume are grouped in another set of registers: Suspend/Resume Register, Suspend/Resume Interrupt Enable Register and Suspend/Resume Interrupt Mask Register.
19
3313D-USB-04/06
Figure 5. AT43USB326 Interrupt Structure
USB Interrupt Flag Register SOF USB EOF2 13 USB Interrupt Enable Register USB Interrupt Mask Register Microcontroller Interrupt Logic
FEP2
FEP1
FEP0
TIMER0 OVF 8
HEP0
Suspend/Resume Register FRMWUP
Suspend/Resume Interrupt Enable Register
Suspend/Resume Interrupt Mask Register
INT0 RSM RESET GLB SUSP 2 1
Reset Sources
The AT43USB326 has four sources of reset: * * * * Power-on Reset - The MCU is reset when the supply voltage is below the power-on reset threshold. External Reset - The MCU is reset when a low level is present on the RESET pin for more than 50 ns. Watchdog Reset - The MCU is reset when the watchdog timer period expires and the watchdog is enabled. USB Reset - The AT43USB326 has a feature to separate the USB and microcontroller resets. This feature is enabled by setting the BUS INT EN, bit 3 of the SPRSIE register. A USB bus reset is defined as a SE0 (single ended zero) of at least 4 slow speed USB clock cycles received by Port0. The internal reset pulse to the USB hardware and microcontroller lasts for 24 oscillator periods. - - Resets not separated: A USB bus reset will also reset the microcontroller. Separated reset: A USB bus reset will only reset the USB hardware, while an interrupt to the microcontroller will be generated if the BUS INT MSK bit, bit 3 of SPRSMSK register, is also set.
20
AT43USB326
3313D-USB-04/06
AT43USB326
When the USB hardware is reset, the compound device is de-configured and has to be reenumerated by the host. When the microcontroller is reset, all I/O registers are then set to their initial values, and the program starts execution from address $000. The instruction placed in address $000 must be a JMP instruction to the reset handling routine. If the program never enables an interrupt source, the interrupt vectors are not used, and regular program code can be placed at these locations. The circuit diagram in Figure 6 shows the reset logic. The user can select the start-up time according to typical oscillator start-up. The number of WDT oscillator cycles used for each time-out is shown in Table 7. Figure 6. Reset Logic
USB Reset
VCC
POR Ckt
OR RSTN Reset Ckt
S
ON
Cntr Reset Watchdog Timer FSTRT
System Clock Divider
14-bit Cntr
R
Table 7. Number of Watchdog Oscillator Cycles
FSTRT Programmed Unprogrammed Time-out at VCC = 5V 1.1 ms 16.0 ms Number of WDT cycles 1K 16K
Power-on Reset
A Power-on Reset (POR) circuit ensures that the device is reset from power-on. An internal timer clocked from the Watchdog timer oscillator prevents the MCU from starting until after a certain period after VCC has reached the power-on threshold voltage, regardless of the VCC rise time. If the build-in start-up delay is sufficient, RESET can be connected to VCC directly or via an external pull-up resistor. By holding the pin low for a period after VCC has been applied, the Power-on Reset period can be extended.
21
3313D-USB-04/06
External Reset
An external reset is generated by a low-level on the RESET pin. Reset pulses longer than 200 ns will generate a reset. Shorter pulses are not guaranteed to generate a reset. When the applied signal reaches the Reset Threshold Voltage - VRST on its positive edge, the delay timer starts the MCU after the Time-out period tTOUT has expired. Figure 7. External Reset During Operation
VCC
RESET
VRST
tTOUT
TIME-OUT
INTERNAL RESET
Watchdog Timer Reset
When the watchdog times out, it will generate a short reset pulse of 1 XTAL cycle duration. On the falling edge of this pulse, the delay timer starts counting the Time-out period tTOUT. Figure 8. Watchdog Reset During Operation
VCC
RESET
1 XTAL Cycle WDT TIME-OUT
tTOUT
RESET TIME-OUT
INTERNAL RESET
Non-USB Related Interrupt Handling
The AT43USB326 has two non-USB 8-bit Interrupt Mask control registers; GIMSK (General Interrupt Mask Register) and TIMSK (Timer/Counter Interrupt Mask Register). When an interrupt occurs, the Global Interrupt Enable I-bit is cleared (zero) and all interrupts are disabled. The user software can set (one) the I-bit to enable nested interrupts. The I-bit is set (one) when a Return from Interrupt instruction, RETI, is executed. For Interrupts triggered by events that can remain static (e.g. the Output Compare register1 matching the value of Timer/Counter1) the interrupt flag is set when the event occurs. If the interrupt flag is cleared and the interrupt condition persists, the flag will not be set until the event occurs the next time. When the Program Counter is vectored to the actual interrupt vector in order to execute the interrupt handling routine, hard-ware clears the corresponding flag that generated the interrupt. Some of the interrupt flags can also be cleared by writing a logic one to the flag bit position(s) to be cleared.
22
AT43USB326
3313D-USB-04/06
AT43USB326
If an interrupt condition occurs when the corresponding interrupt enable bit is cleared (zero), the interrupt flag will be set and remembered until the interrupt is enabled, or the flag is cleared by software. If one or more interrupt conditions occur when the global interrupt enable bit is cleared (zero), the corresponding interrupt flag(s) will be set and remembered until the global interrupt enable bit is set (one), and will be executed by order of priority. Note that external level interrupt does not have a flag, and will only be remembered for as long as the interrupt condition is active.
23
3313D-USB-04/06
General Interrupt Mask Register - GIMSK
Bit 7 - R 0 6 INT0 R/W 0 5 - R 0 4 - R 0 3 - R 0 2 - R 0 1 - R 0 0 - R 0 GIMSK
$3B ($5B)
Read/Write Initial Value
* Bit 7 - Res: Reserved Bit * Bit 6 - INT0: Interrupt Request 0 (Suspend/Resume Interrupt) Enable When the INT0 bit is set (one) and the I-bit in the Status Register (SREG) is set (one), the external pin interrupt is enabled. The Interrupt Sense Control0 bits 1/0 (ISC01 and ISC00) in the MCU general Control Register (MCUCR) defines whether the external interrupt is activated on rising or falling edge of the INT0 pin or level sensed. Activity on the pin will cause an interrupt request even if INT0 is configured as an output. The corresponding interrupt of Interrupt Request 0 is executed from program memory address $002. See also "External Interrupts" on page 26. * Bits 5..0 - Res: Reserved Bits These bits are reserved bits in the AT43USB326 and always read as zero. General Interrupt Flag Register - GIFR
Bit $3A ($5A) Read/Write Initial Value 7 - R 0 6 INT F0 R/W 0 5 - R 0 4 - R 0 3 - R 0 2 - R 0 1 - R 0 0 - R 0 GIFR
* Bit 7 - Res: Reserved Bit * Bit 6 - INTF0: Interrupt Flag0 (Suspend/Resume Interrupt Flag) When an event on the INT0 (that is, a USB event-related interrupt) triggers an interrupt request, INTF0 becomes set (one). If the I-bit in SREG and the INT0 bit in GIMSK are set (one), the MCU will jump to the interrupt vector at address $002. The flag is cleared when the interrupt routine is executed. Alternatively, the flag can be cleared by writing a logical one to it. * Bits 5..0 - Res: Reserved Bits These bits are reserved bits in the AT43USB326 and always read as zero.
24
AT43USB326
3313D-USB-04/06
AT43USB326
Timer/Counter Interrupt Mask Register - TIMSK
Bit $39 ($59) Read/Write Initial Value 7 - R 0 6 - R 0 5 - R 0 4 - R 0 3 - R 0 2 - R 0 1 TOIE0 R/W 0 0 - R 0 TIMSK
* Bit 7:2 - Res: Reserved Bits These bits are reserved bits in the AT43USB326 and always read zero. * Bit 1 - TOIE0: Timer/Counter0 Overflow Interrupt Enable When the TOIE0 bit is set (one) and the I-bit in the Status Register is set (one), the Timer/Counter0 Overflow interrupt is enabled. The corresponding interrupt (at vector $007) is executed if an overflow in Timer/Counter0 occurs, i.e., when the TOV0 bit is set in the TIFR. * Bit 0 - Res: Reserved Bit This bit is a reserved bit in the AT43USB326 and always reads zero.
Timer/Counter Interrupt Flag Register - TIFR
Bit $38 ($58) Read/Write Initial Value 7 - R 0 6 - R 0 5 - R 0 4 - R 0 3 - R 0 2 - R 0 1 TOV0 R/W 0 0 - R 0 TIFR
* Bit 7:2 - Res: Reserved Bits These bits are reserved bits in the AT43USB326 and always read zero. * Bit 1 - TOV: Timer/Counter0 Overflow Flag The bit TOV0 is set (one) when an overflow occurs in Timer/Counter0. TOV0 is cleared by the hardware when executing the corresponding interrupt handling vector. Alternatively, TOV0 is cleared by writing a logic one to the flag. When the SREG I- bit, and TOIE0 (Timer/Counter0 Overflow Interrupt Enable), and TOV0 are set (one), the Timer/Counter0 Overflow interrupt is executed. * Bit 0 - Res: Reserved Bit This bit is a reserved bit in the AT43USB326 and always reads zero.
25
3313D-USB-04/06
External Interrupts Interrupt Response Time
While in the suspend state, the depression of any key will trigger a resume interrupt. This is the only available external interrupt in the AT43USB326. The interrupt execution response for all the enabled AVR interrupts is 4 clock cycles minimum. 4 clock cycles after the interrupt flag has been set, the program vector address for the actual interrupt handling routine is executed. During this 4 clock cycle period, the Program Counter (2 bytes) is pushed onto the Stack, and the Stack Pointer is decremented by 2. The vector is normally a jump to the interrupt routine, and this jump takes 3 clock cycles. If an interrupt occurs during execution of a multi-cycle instruction, this instruction is completed before the interrupt is served. A return from an interrupt handling routine (same as for a subroutine call routine) takes 4 clock cycles. During these 4 clock cycles, the Program Counter (2 bytes) is popped back from the Stack, the Stack Pointer is incremented by 2, and the I flag in SREG is set. When the AVR exits from an interrupt, it will always return to the main program and execute one more instruction before any pending interrupt is served.
26
AT43USB326
3313D-USB-04/06
AT43USB326
MCU Control Register - MCUCR
Bit $35 ($55) Read/Write Initial Value 7 - R 0 6 - R 0 5 SE R/W 0 4 SM R/W 0 3 - R 0 2 - R 0 1 - R 0 0 - R 0 MCUCR
* Bit 7, 6 - Res: Reserved Bits * Bit 5 - SE: Sleep Enable The SE bit must be set (1) to make the MCU enter the sleep mode when the SLEEP instruction is executed. To avoid the MCU entering the sleep mode, unless it is the programmer's purpose, it is recommended to set the Sleep Enable SE bit just before the execution of the SLEEP instruction. * Bit 4 - SM: Sleep Mode This bit selects between the two available sleep modes. When SM is cleared (zero), Idle Mode is selected as Sleep Mode. When SM is set (1), Power Down mode is selected as sleep mode. The AT43USB326 does not support the Idle Mode and SM should always be set to one when entering the Sleep Mode. * Bit 3:0 - Res: Reserved Bits
27
3313D-USB-04/06
USB Interrupt Sources
The USB interrupts are described below. Table 8. USB Interrupt Sources
Interrupt SOF Received EOF2 Function EP0 Interrupt Function EP1 Interrupt Description Whenever USB hardware decodes a valid Start of Frame. The frame number is stored in the two Frame Number Registers. Activated whenever the hub's frame timer reaches its EOF2 time point. See "Control Transfers at Control Endpoint EP0" on page 47 for details. For an OUT endpoint it indicates that Function Endpoint 1 has received a valid OUT packet and that the data is in the FIFO. For an IN endpoint it means that the endpoint has received an IN token, sent out the data in the FIFO and received an ACK from the Host. The FIFO is now ready to be written by new data from the microcontroller. For an OUT endpoint it indicates that Function Endpoint 2 has received a valid OUT packet and that the data is in the FIFO. For an IN endpoint it means that the endpoint has received an IN token, sent out the data in the FIFO and received an ACK from the Host. The FIFO is now ready to be written by new data from the microcontroller. See "Control Transfers at Control Endpoint EP0" on page 47 for details. USB hardware has received a embedded function remote wakeup request. USB hardware has received global suspend signaling and is preparing to put the hub in the suspend mode. The microcontroller's firmware should place the embedded function in the suspend state. USB hardware received resume signaling and is propagating the resume signaling. The microcontroller's firmware should take the embedded function out of the suspended state.
Function EP2 Interrupt
Hub EP0 Interrupt FRWUP GLB SUSP
RSM
All interrupts have individual enable, status, and mask bits through the interrupt enable register and interrupt mask register. The Suspend and Resume interrupts are cleared by writing a 0 to the particular interrupt bit. All other interrupts are cleared when the microcontroller sets a bit in an interrupt acknowledge register.
28
AT43USB326
3313D-USB-04/06
AT43USB326
USB Endpoint Interrupt Sources
An assertion or activation of one or more bits in the endpoint's Control and Status Register triggers the endpoint interrupts. These triggers are different for control and non-control endpoints as described in the table below. Please refer to the Control and Status Register for more information.
Table 9. USB Endpoint Interrupt Sources
Bit RX_OUT_PACKET TX_COMPLETE STALL_SENT RX_SETUP Endpoint type CONTROL, OUT CONTROL, IN CONTROL, IN CONTROL
USB Interrupt Status Register - UISR
Bit $1FF7 Read/Write Initial Value 7 SOF INT R 0 6 EOF2 INT R 0 5 - R 0 4 - R 0 3 HEP0 INT R 0 2 FE2 INT R 0 1 FE1 INT R 0 0 FE0 INT R 0 UISR
* Bit 7 - SOF INT: Start of Frame Interrupt This bit is asserted after the USB hardware receives a valid SOF packet. * Bit 6 - EOF2 INT: EOF2 Interrupt This bit is asserted 10 clocks before the expected start of a frame. * Bit 5, 4 - Res: Reserved Bits These bits are reserved and always read as zero. * Bit 3 - HEP0 INT: Hub Endpoint 0 Interrupt * Bit 2 - FEP2 INT: Function Endpoint 2 Interrupt * Bit 1 - FEP1 INT: Function Endpoint 1 Interrupt * Bit 0 - FEP0 INT: Function Endpoint 0 Interrupt The hub and function interrupt bits will be set by the hardware whenever the following bits in the corresponding endpoint's Control and Status Register are modified by the USB hardware: 1. RX OUT Packet is set (control and OUT endpoints) 2. TX Packet Ready is cleared AND TX Complete is set (control and IN endpoints) 3. RX SETUP is set (control endpoints only) 4. TX Complete is set
29
3313D-USB-04/06
USB Interrupt Mask Register - UIMSKR
Bit $1FF6 Read/Write Initial Value 7 SOF IMSK R/W 0 6 EOF2 IMSK R/W 0 5 - R 0 4 - R 0 3 HEP0 IMSK R/W 0 2 FEP2 IMSK R/W 0 1 FEP1 IMSK R/W 0 0 FEP0 IMSK R/W 0 UIMSKR
* Bit 7 - SOF IMSK: Enable Start of Frame Interrupt Mask When the SOF IMSK bit is set (1), the Start of Frame Interrupt is masked. * Bit 6 - EOF2 IMSK: Enable EOF2 Interrupt When the EOF2 IMSK bit is set (1), the EOF2 Interrupt is masked. * Bit 5, 4 - Res: Reserved Bits These bits are reserved and always read as zero. * Bit 3 - HEP0 IMSK: Enable Endpoint 0 Interrupt When the HEP0 IMSK bit is set (1), the Hub Endpoint 0 Interrupt is masked. * Bit 2 - FEP2 IMSK: Enable Endpoint 2 Interrupt When the FE2 IMSK bit is set (1), the Function Endpoint 2 Interrupt is masked. * Bit 1 - FEP1 IMSK: Enable Endpoint 1 Interrupt When the FE1 IMSK bit is set (1), the Function Endpoint 1 Interrupt is masked. * Bit 0 - FEP0 IMSK: Enable Endpoint 0 Interrupt When the FE0 IMSK bit is set (1), the Function Endpoint 0 Interrupt is masked.
30
AT43USB326
3313D-USB-04/06
AT43USB326
USB Interrupt Acknowledge Register - UIAR
Bit $1FF5 Read/Write Initial Value 7 SOF INTACK W 0 6 EOF2 INTACK W 0 5 - R 0 4 - R 0 3 HEP0 INTACK W 0 2 FEP2 IMSK W 0 1 FEP1 INTACK W 0 0 FEP0 INTACK W 0 UIAR
* Bit 7 - SOF INTACK: Start of Frame Interrupt Acknowledge The microcontroller firmware writes a 1 to this bit to clear the SOF INT bit. * Bit 6 - EOF2 INTACK: EOF2 Interrupt Acknowledge The microcontroller firmware writes a 1 to this bit to clear the EOF2 INT bit. * Bit 5, 4 - Res: Reserved Bits These bits are reserved and are always read as zero. * Bit 3 - HEP0 INTACK: Hub Endpoint 0 Interrupt Acknowledge The microcontroller firmware writes a 1 to this bit to clear the HEP0 INT bit. * Bit 2 - FEP2 INTACK: Function Endpoint 2 Interrupt Acknowledge The microcontroller firmware writes a 1 to this bit to clear the FEP2 bit. * Bit 1 - FEP1 INTACK: Function Endpoint 1 Interrupt Acknowledge The microcontroller firmware writes a 1 to this bit to clear the FEP1 bit. * Bit 0 - FEP0 INTACK: Function Endpoint 0 Interrupt Acknowledge The microcontroller firmware writes a 1 to this bit to clear the FEP0 INT bit.
31
3313D-USB-04/06
USB Interrupt Enable Register - UIER
Bit $1FF3 Read/Write Initial Value 7 SOF IE R/W 0 6 EOF2 IE R/W 0 5 - R 0 4 - R 0 3 HEP0 IE R/W 0 2 FEP2 IE R/W 0 1 FEP1 IE R/W 0 0 FEP0 IE R/W 0 UIER
* Bit 7 - SOF IE: Enable Start of Frame Interrupt When the SOF IE bit is set (1), the Start of Frame Interrupt is enabled. * Bit 6 - EOF2 IE: Enable EOF2 Interrupt When the EOF2 IE bit is set (1), the EOF2 Interrupt is enabled. * Bit 5, 4 - Res: Reserved Bits These bits are reserved and always read as zero. * Bit 3 - HEP0 IE: Enable Endpoint 0 Interrupt When the HEP0 IE bit is set (1), the Hub Endpoint 0 Interrupt is enabled. * Bit 2 - FEP2 IE: Enable Endpoint 2 Interrupt When the FE2 IE bit is set (1), the Function Endpoint 2 Interrupt is enabled. * Bit 1 - FEP1 IE: Enable Endpoint 1 Interrupt When the FE1 IE bit is set (1), the Function Endpoint 1 Interrupt is enabled. * Bit 0 - FEP0 IE: Enable Endpoint 0 Interrupt When the FE0 IE bit is set (1), the Function Endpoint 0 Interrupt is enabled. Suspend/Resume Register - SPRSR
Bit $1FFA Read/Write Initial Value 7 - R 0 6 - R 0 5 - R 0 4 - R 0 3 - R 0 2 FRWUP R 0 1 RSM R 0 0 GLB SUSP R 0 SPRSR
* Bit 7..3 - Res: Reserved Bits These bits are reserved and are always read as zeros. * Bit 2 - FRWUP: Function Remote Wakeup The USB hardware sets this bit to signal that External Interrupt 1 is detected indicating remote wakeup. An interrupt is generated if the FRWUP IE bit of the SPRSIE register is set. * Bit 1 - RSM: Resume The USB hardware sets this bit when a USB resume signaling is detected at any of its port except Port 1. An interrupt is generated if the RSM IE bit of the SPRSIE register is set. * Bit 0 - GLB SUSP: Global Suspend The USB hardware sets this bit when a USB global suspend signaling is detected. An interrupt is generated if the GLBSUSP IE bit of the SPRSIE register is set.
32
AT43USB326
3313D-USB-04/06
AT43USB326
Suspend/Resume Interrupt Enable Register - SPRSIE
Bit $1FF9 Read/Write Initial Value 7 - R 0 6 - R 0 5 - R 0 4 - R 0 3 - R 0 2 FRWUP R 0 1 RSM R 0 0 GLB SUSP R 0 SPRSIE
* Bit 7..3 - Res: Reserved Bits These bits are reserved and are always read as zeros. * Bit 2 - FRWUP IE: Function Remote Wakeup Interrupt Enable Setting the FRWUP IE bit will initiate an interrupt whenever the FRWUP bit of SPRSR is set. * Bit 1 - RSM IE: Resume Interrupt Enable Setting the RSM IE bit will initiate an interrupt whenever the RSM bit of SPRSR is set. * Bit 0 - GLB SUSP IE: Global Suspend Interrupt Enable Setting the GLB SUSP IE bit will initiate an interrupt whenever the GLB SUSP bit of SPRSR is set.
Suspend/Resume Interrupt Mask Register - SPRSMSK
Bit $1FF8 Read/Write Initial Value 7 - R 0 6 - R 0 5 - R 0 4 - R 0 3 - R 0 2 FRWUP MSK W 0 1 RSM W 0 0 GLB SUSP W 0 SPRSMSK
The bits of the Suspend/Resume Mask Register are used to make an interrupt caused by an event in the Suspend/Resume Register visible to the microcontroller. The Suspend/Resume Interrupt Enable Register bits enable the interrupt while the Suspend/Resume Interrupt Mask Register allows the microcontroller to control when it wants visibility to an interrupt. 1 = Enable Mask, 0 = Disable Mask. * Bit 7..3 - Res: Reserved Bits These bits are reserved and are always read as zeros. * Bit 2 - FRWUP MSK: Function Remote Wakeup Interrupt Mask * Bit 1 - RSM MSK: Resume Interrupt Mask * Bit 0 - GLB SUSP MSK: Global Suspend Interrupt Enable
33
3313D-USB-04/06
AVR Register Set
Status Register and Stack Pointer
Status Register - SREG
Bit $3F ($5F) Read/Write Initial Value 7 I R/W 0 6 T R/W 0 5 H R/W 0 4 S R/W 0 3 V R/W 0 2 N R/W 0 1 Z R/W 0 0 C R/W 0 SREG
* Bit 7 - I: Global Interrupt Enable The global interrupt enable bit must be set (one) for the interrupts to be enabled. The individual interrupt enable control is then performed in separate control registers. If the global interrupt enable bit is cleared (zero), none of the interrupts are enabled independent of the individual interrupt enable settings. The I-bit is cleared by the hardware after an interrupt has occurred, and is set by the RETI instruction to enable subsequent interrupts. * Bit 6 - T: Bit Copy Storage The bit copy instructions BLD (Bit LoaD) and BST (Bit STore) use the T bit as source and destination for the operated bit. A bit from a register in the register file can be copied into T by the BST instruction, and a bit in T can be copied into a bit in a register in the register file by the BLD instruction. * Bit 5 - H: Half Carry Flag The half carry flag H indicates a half carry in some arithmetic operations. See the Instruction Set Description for detailed information. * Bit 4 - S: Sign Bit, S = NV The S-bit is always an exclusive or between the negative flag N and the two's complement overflow flag V. See the Instruction Set Description for detailed information. * Bit 3 - V: Two's Complement Overflow Flag The two's complement overflow flag V supports two's complement arithmetics. See the Instruction Set Description for detailed information. * Bit 2 - N: Negative Flag The negative flag N indicates a negative result after the different arithmetic and logic operations. See the Instruction Set Description for detailed information. * Bit 1 - Z: Zero Flag The zero flag Z indicates a zero result after the different arithmetic and logic operations. See the Instruction Set Description for detailed information. * Bit 0 - C: Carry Flag The carry flag C indicates a carry in an arithmetic or logic operation. See the Instruction Set Description for detailed information. Note that the status register is not automatically stored when entering an interrupt routine and restored when returning from an interrupt routine. This must be handled by software.
34
AT43USB326
3313D-USB-04/06
AT43USB326
Stack Pointer Register - SP
Bit $3E ($5E) $3D ($5D) 15 I SP7 7 Read/Write R/W R/W Initial Value 0 0 14 T SP6 6 R/W R/W 0 0 13 H SP5 5 R/W R/W 0 0 12 S SP4 4 R/W R/W 0 0 11 V SP3 3 R/W R/W 0 0 10 N SP2 2 R/W R/W 0 0 9 Z SP1 1 R/W R/W 0 0 8 C SP0 0 R/W R/W 0 0 SPH SPL
The Stack Pointer points to the data SRAM stack area where the Subroutine and Interrupt Stacks are located. This Stack space in the data SRAM must be defined by the program before any subroutine calls are executed or interrupts are enabled. The stack pointer must be set to point above $60. The Stack Pointer is decremented by one when data is pushed onto the Stack with the PUSH instruction, and it is decremented by two when an address is pushed onto the Stack with subroutine calls and interrupts. The Stack Pointer is incremented by one when data is popped from the Stack with the POP instruction and it is incremented by two when an address is popped from the Stack with return from subroutine RET or return from interrupt RETI.
Sleep Modes
To enter the sleep modes, the SE bit in MCUCR must be set (one) and a SLEEP instruction must be executed. If an enabled interrupt occurs while the MCU is in a sleep mode, the MCU awakes, executes the interrupt routine, and resumes execution from the instruction following SLEEP. The contents of the register file, SRAM and I/O memory are unaltered. If a reset occurs during sleep mode, the MCU wakes up and executes from the Reset vector. When the SM bit is set (one), the SLEEP instruction forces the MCU into the Power Down Mode. In this mode, the external oscillator is stopped, while the external interrupts continue operating. Only an external reset, an external level interrupt on INT0 or INT1, can wake up the MCU. Note that when a level triggered interrupt is used for wake-up from power down, the low level must be held for a time longer than the reset delay time-out period tTOUT. Otherwise, the MCU will fail to wake up.
Power Down Mode
35
3313D-USB-04/06
Timer/Counter
The AT43USB326 provides one general-purpose 8-bit Timer/Counter (T/C). The Timer/Counter has prescaling selection from a 10-bit prescaling timer. The Timer/Counter can either be used as a timer with an internal clock timebase or as a counter with an external pin connection which triggers the counting. The four different prescaled selections are: CK/8, CK/64, CK/256 and CK/1024 where CK is the oscillator clock. Added selections such as CK, external source and stop, can be selected as clock sources.
Timer/Counter Prescaler
Figure 9. Timer/Counter Prescaler
CK 10-bit T/C Prescaler CK/8 CK/64 CK/256 0 CK/1024
T0
CS00 CS01 CS02
Timer/Counter0 Clock Source TCK0
36
AT43USB326
3313D-USB-04/06
AT43USB326
8-bit Timer/Counter0
The 8-bit Timer/Counter0 can select clock source from CK, prescaled CK or an external pin. In addition it can be stopped as described in the specification for the Timer/Counter0 Control Register (TCCR0). The overflow status flag is found in the Timer/Counter Interrupt Flag Register (TIFR). Control signals are found in the Timer/Counter0 Control Register (TCCR0). The interrupt enable/disable settings for Timer/Counter0 are found in the Timer/Counter Interrupt Mask Register - TIMSK. When Timer/Counter0 is externally clocked, the external signal is synchronized with the oscillator frequency of the CPU. To assure proper sampling of the external clock, the minimum time between two external clock transitions must be at least one internal CPU clock period. The external clock signal is sampled on the rising edge of the internal CPU clock. The 8-bit Timer/Counter0 features both a high resolution and a high accuracy usage with the lower prescaling opportunities. Similarly, the high prescaling opportunities make the Timer/Counter0 useful for lower speed functions or exact timing functions with infrequent actions. Figure 10. Timer/Counter0 Block Diagram
T/C0 Overflow IRQ
8-bit Data Bus
TOIE1 OICIE1A
OICIE1B
TICIE1
TOIE0
Timer Int. Mask Register (TIMSK)
Timer Int. Flag Register (TIFR) TOV1 OCF1A OCF1B TOV0 ICF1
TOV0
T/C0 Control Register (TCCR0) CS02 CS01 CS00
7 Timer/Counter0 (TCNT0)
0 T/C Clock Source
Control Logic
CK T0
37
3313D-USB-04/06
Timer/Counter0 Control Register - TCCR0
Bit $33 ($53) Read/Write Initial Value 7 - R 0 6 - R 0 5 - R 0 4 - R 0 3 - R 0 2 CS02 R/W 0 1 CS01 R/W 0 0 CS00 R/W 0 TCCR0
* Bits 7..3 - Res: Reserved Bits These bits are reserved bits in the AT43USB355 and always read as zero. * Bits 2, 1, 0 - CS02, CS01, CS00: Clock Select0, bit 2, 1 and 0 The Clock Select0 bits 2, 1 and 0 define the prescaling source of Timer/Counter0. Table 10. Clock 0 Prescale Select
CS02 0 0 0 0 1 1 1 1 CS01 0 0 1 1 0 0 1 1 CS00 0 1 0 1 0 1 0 1 Description Stop, the Timer/Counter0 is stopped CK CK/8 CK/64 CK/256 CK/1024 External Pin T0, falling edge External Pin T0, rising edge
The Stop condition provides a Timer Enable/Disable function. The CK down divided modes are scaled directly from the CK oscillator clock. If the external pin modes are used for Timer/Counter0, transitions on PB0/(T0) will clock the counter even if the pin is configured as an output. This feature can give the user SW control of the counting. Timer/Counter0 - TCNT0
Bit $32 ($52) Read/Write Initial Value 7 MSB R/W 0 6 - R/W 0 5 - R/W 0 4 - R/W 0 3 - R/W 0 2 - R/W 0 1 - R/W 0 0 LSB R/W 0 TCNT0
The Timer/Counter0 is realized as an up-counter with read and write access. If the Timer/Counter0 is written and a clock source is present, the Timer/Counter0 continues counting in the clock cycle following the write operation.
38
AT43USB326
3313D-USB-04/06
AT43USB326
Watchdog Timer
The Watchdog Timer is clocked from a 1 MHz clock derived from the 6 MHz on chip oscillator. By controlling the Watchdog Timer prescaler, the Watchdog reset interval can be adjusted, see Table 11 for a detailed description. The WDR (Watchdog Reset) instruction resets the Watchdog Timer. Eight different clock cycle periods can be selected to determine the reset period. If the reset period expires without another Watchdog reset, the AT43USB326 resets and executes from the reset vector. To prevent unintentional disabling of the watchdog, a special turn-off sequence must be followed when the watchdog is disabled. Refer to the description of the Watchdog Timer Control Register for details. Figure 11. Watchdog Timer
1 MHz Clock
Watchdog Prescaler OSC/1024K
0 WDP0 R/W 0 WDTCR
OSC/16K
OSC/32K
OSC/64K
OSC/128K
OSC/256K
1 WDP1 R/W 0
Watchdog Reset
WDP0 WDP1 WDP2
WDE
MCU Reset
Watch Dog Timer Control Register - WDTCR
Bit $21 ($41) Read/Write Initial Value 7 - R 0 6 - R 0 5 - R 0 4 WDTOE R/W 0 3 WDE R/W 0 2 WDP2 R/W 0
* Bits 7..5 - Res: Reserved Bits These bits are reserved bits in the AT43USB326 and will always read as zero. * Bit 4 - WDTOE: Watch Dog Turn-Off Enable This bit must be set (one) when the WDE bit is cleared. Otherwise, the watchdog will not be disabled. Once set, the hardware will clear this bit to zero after four clock cycles. Refer to the description of the WDE bit for a watchdog disable procedure. * Bit 3 - WDE: Watch Dog Enable When the WDE is set (one) the Watchdog Timer is enabled, and if the WDE is cleared (zero) the Watchdog Timer function is disabled. WDE can only be cleared if the WDTOE bit is set (one). To disable an enabled watchdog timer, the following procedure must be followed: 39
3313D-USB-04/06
OSC/512K
OSC/8K
1. In the same operation, write a logical one to WDTOE and WDE. A logical one must be written to WDE even though it is set to one before the disable operation starts. 2. Within the next four clock cycles, write a logical 0 to WDE. This disables the watchdog. * Bits 2..0 - WDP2, WDP1, WDP0: Watch Dog Timer Prescaler 2, 1 and 0 The WDP2, WDP1 and WDP0 bits determine the Watchdog Timer prescaling when the Watchdog Timer is enabled. The different prescaling values and their corresponding Time-out Periods are shown in Table 11. Table 11. Watchdog Timer Prescale Select
WDP2 0 0 0 0 1 1 1 1 Note: WDP1 0 0 1 1 0 0 1 1 WDP0 0 1 0 1 0 1 0 1 Number of WDT Oscillator cycles 8K cycles 16K cycles 32K cycles 64K cycles 128K cycles 256K cycles 512K cycles 1,024K cycles Time-out 8.2 ms 16.4 ms 33.8 ms 65.6 ms 0.131 s 0.262 s 0.524 s 1.048 s
The WDR (Watchdog Reset) instruction should always be executed before the Watchdog Timer is enabled. This ensures that the reset period will be in accordance with the Watchdog Timer prescale settings. If the Watchdog Timer is enabled without reset, the watchdog timer may not start to count from zero. To avoid unintentional MCU reset, the Watchdog Timer should be disabled or reset before changing the Watchdog Timer Prescale Select.
I/O Ports
All AVR ports have true Read-Modify-Write functionality when used as general digital I/O ports. This means that the direction of one port pin can be changed without unintentionally changing the direction of any other pin with the SBI and CBI instructions. The same applies for changing drive value if configured as output or enabling/disabling of pull-up resistors if configured as input. The keyboard matrix strobe output pins, PA[0:7], PB[0:7] and PE[0:1] have controlled slope drivers. With a load of 100 pF, the output fall time ranges between 75 ns and 300 ns. The keyboard matrix strobe input pins, PC[0:7] have built-in pull-up resistors, 20 K nominal value, to the internal 3.3V power supply. PE[4:7] have 5V tolerant outputs and each has a built-in series resistor of 330 nominal value. These output pins are designed for driving an LED connected to the 5V supply. The dedicated functions are summarized in Table 12. Table 12. GPIO Function Assignments
Function Scan out[0:7] Scan out[8:15] Scan out[16,17] Scan in[0:7] LED drivers GPIO PA[0:7] PB[0:7] PE[0,1] PC[0:7] PE[4:7]
40
AT43USB326
3313D-USB-04/06
AT43USB326
Port A
Port A is an 8-bit bi-directional I/O port with open drain outputs and controlled slew rate. It is designed for use as the column driver in a keyboard controller. The Port A output buffers can sink or source 4 mA. Three I/O memory address locations are allocated for the Port A, one each for the Data Register PORTA, $1B($3B), Data Direction Register (DDRA), $1A($3A) and the Port A Input Pins (PINA) $19($39). The Port A Input Pins address is read only, while the Data Register and the Data Direction Register are read/write. Port A Data Register - PORTA
Bit $1B ($3B) Read/Write Initial Value 7 PORTA7 R/W 0 6 PORTA6 R/W 0 5 PORTA5 R/W 0 4 PORTA4 R/W 0 3 PORTA3 R/W 0 2 PORTA2 R/W 0 1 PORTA1 R/W 0 0 PORTA0 R/W 0 PORTA
Port A Data Direction Register - DDRA
Bit $1A ($3A) Read/Write Initial Value 7 DDA7 R/W 0 6 DDA6 R/W 0 5 DDA5 R/W 0 4 DDA4 R/W 0 3 DDA3 R/W 0 2 DDA2 R/W 0 1 DDA1 R/W 0 0 DDA0 R/W 0 DDRA
Port A Input Pins Address - PINA
Bit $19 ($39) Read/Write Initial Value 7 PINA7 R N/A 6 PINA6 R N/A 5 PINA5 R N/A 4 PINA4 R N/A 3 PINA3 R N/A 2 PINA2 R N/A 1 PINA1 R N/A 0 PINA0 R N/A PINA
The Port A Input Pins address (PINA) is not a register, and this address enables access to the physical value on each Port A pin. When reading PORTA the Port A Data Latch is read, and when reading PINA, the logical values present on the pins are read.
41
3313D-USB-04/06
Port B
Port B is an 8-bit bi-directional I/O port with open drain outputs and controlled slew rate. It is designed for use as the column driver in a keyboard controller. The Port B output buffers can sink or source 4 mA. Three I/O memory address locations are allocated for the Port B, one each for the Data Register - PORTB, $18($38), Data Direction Register (DDRB), $17($37) and the Port B Input Pins (PINB), $16($36). The Port B Input Pins address is read only, while the Data Register and the Data Direction Register are read/write. Port B Data Register - PORTB
Bit $18 ($38) Read/Write Initial Value 7 PORTB7 R/W 0 6 PORTB6 R/W 0 5 PORTB5 R/W 0 4 PORTB4 R/W 0 3 PORTB3 R/W 0 2 PORTB2 R/W 0 1 PORTB1 R/W 0 0 PORTB0 R/W 0 PORTB
Port B Data Direction Register - DDRB
Bit $17 ($37) Read/Write Initial Value 7 DDB7 R/W 0 6 DDB6 R/W 0 5 DDB5 R/W 0 4 DDB4 R/W 0 3 DDB3 R/W 0 2 DDB2 R/W 0 1 DDB1 R/W 0 0 DDB0 R/W 0 DDRB
Port B Input Pins Address - PINB
Bit $16 ($36) Read/Write Initial Value 7 PINB7 R N/A 6 PINB6 R N/A 5 PINB5 R N/A 4 PINB4 R N/A 3 PINB3 R N/A 2 PINB2 R N/A 1 PINB1 R N/A 0 PINB0 R N/A PINB
The Port B Input Pins address (PINB) is not a register, and this address enables access to the physical value on each Port B pin. When reading PORTB, the Port B Data Latch is read, and when reading PINB, the logical values present on the pins are read.
42
AT43USB326
3313D-USB-04/06
AT43USB326
Port C
Port C is an 8-bit bi-directional I/O port with an internal pull-up resistor at each pin. Port C is designed for use as the row inputs of a keyboard controller. Its output buffers can sink 4 mA. Three I/O memory address locations are allocated for the Port C, one each for the Data Register - PORTC, $15($35), Data Direction Register - DDRC, $14($34) and the Port C Input Pins - PINC, $13($33). The Port C Input Pin's address is read only, while the Data Register and the Data Direction Register are read/write. Port C Data Register - PORTC
Bit $15 ($35) Read/Write Initial Value 7 PORTC7 R/W 0 6 PORTC6 R/W 0 5 PORTC5 R/W 0 4 PORTC4 R/W 0 3 PORTC3 R/W 0 2 PORTC2 R/W 0 1 PORTC1 R/W 0 0 PORTC0 R/W 0 PORTC
Port C Data Direction Register - DDRC
Bit $14 ($34) Read/Write Initial Value 7 DDC7 R/W 0 6 DDC6 R/W 0 5 DDC5 R/W 0 4 DDC4 R/W 0 3 DDC3 R/W 0 2 DDC2 R/W 0 1 DDC1 R/W 0 0 DDC0 R/W 0 DDRC
Port C Input Pins Address - PINC
Bit $13 ($33) Read/Write Initial Value 7 PINC7 R N/A 6 PINC6 R N/A 5 PINC5 R N/A 4 PINC4 R N/A 3 PINC3 R N/A 2 PINC2 R N/A 1 PINC1 R N/A 0 PINC0 R N/A PINC
The Port C Input Pins address (PINC) is not a register, and this address enables access to the physical value on each Port C pin. When reading PORTC, the Port C Data Latch is read, and when reading PINC, the logical values present on the pins are read.
43
3313D-USB-04/06
Port D
Port D is a 2-bit bi-directional I/O port. Its output buffers can sink or source 2 mA. Three I/O memory address locations are allocated for the Port D, one each for the Data Register - PORTD, $12($32), Data Direction Register (DDRD), $11($31) and the Port D Input Pins (PIND), $10($30). The Port D Input Pins address is read only, while the Data Register and the Data Direction Register are read/write. Port D Data Register - PORTD
Bit $12 ($32) Read/Write Initial Value 7 - R 0 6 - R 0 5 - R 0 4 - R 0 3 - R 0 2 - R 0 1 PORTD1 R/W 0 0 PORTD0 R/W 0 PORTD
Port D Data Direction Register - DDRD
Bit $11 ($31) Read/Write Initial Value 7 - R 0 6 - R 0 5 - R 0 4 - R 0 3 - R 0 2 - R 0 1 DDD1 R/W 0 0 DDD0 R/W 0 DDRD
Port D Input Pins Address - PIND
Bit $10 ($30) Read/Write Initial Value 7 - R N/A 6 - R N/A 5 - R N/A 4 - R N/A 3 - R N/A 2 - R N/A 1 PIND1 R N/A 0 PIND0 R N/A PIND
The Port D Input Pins address (PIND) is not a register, and this address enables access to the physical value on each Port D pin. When reading PORTD, the Port D Data Latch is read, and when reading PIND, the logical values present on the pins are read.
44
AT43USB326
3313D-USB-04/06
AT43USB326
Port E
Port E[0,1] are bi-directional I/O ports with open drain outputs and controlled slew rate and are designed for use as the column drivers in a keyboard controller. The Port E[0,1] output buffers can sink 4 mA. Port E[4:7] are bi-directional I/O with open drain outputs capable of driving LEDs directly. Each pin of Port E[4:7] has a series resistor to limit the LEDs current. Three I/O memory address locations are allocated for the Port E, one each for the Data Register - PORTE, $03($23), Data Direction Register - DDRE, $02($22) and the Port E Input Pins - PINE, $01($21). The Port E Input Pin's address is read only, while the Data Register and the Data Direction Register are read/write. Port E Data Register - PORTE
Bit $03($23) Read/Write Initial Value 7 PORTE7 R/W 0 6 PORTE6 R/W 0 5 PORTE5 R/W 0 4 PORTE4 R/W 0 3 - R 0 2 - R 0 1 PORTE1 R 0 0 PORTE0 R 0 PORTE
Port E Data Direction Register - DDRE
Bit $02 ($22) Read/Write Initial Value 7 DDE7 R/W 0 6 DDE6 R/W 0 5 DDE5 R/W 0 4 DDE4 R/W 0 3 - R 0 2 - R 0 1 DDE1 R/W 0 0 DDE0 R/W 0 DDRE
Port E Input Pins Address - PINE
Bit $01 ($21) Read/Write Initial Value 7 PINE7 R/W N/A 6 PINE6 R/W N/A 5 PINE5 R/W N/A 4 PINE4 R/W N/A 3 - R N/A 2 - R N/A 1 PINE1 R N/A 0 PINE0 R N/A PINE
The Port E Input Pins Address - PINE (Port E Input Pins) - is not a register, and this address enables access to the physical value on each Port E pin. When reading PORTE the Port E Data Latch is read, and when reading PINE, the logical values present on the pins are read.
45
3313D-USB-04/06
Programming the USB Module
The USB hardware consists of two devices, hub and function, each with their own device address and endpoints. Its operation is controlled through a set of memory mapped registers. The exact configuration of the USB device is defined by the software and it can be programmed to operate as a compound device, or as a hub only or as a function only. The hub has the required control and interrupt endpoints. The number of external downstream ports is programmable from 0 to 2. The DP and DM pins of the unused port(s) must be connected to ground. The USB function has one control endpoint and 2 programmable endpoints. All the endpoints have their own 8-byte FIFOs. If the hub is disabled, one extra endpoint becomes available to the function. The USB function hardware is designed to operate in the single packet mode and to manage the USB protocol layer. It consists of a Serial Interface Engine (SIE), endpoint FIFOs and a Function Interface Unit (FIU). The SIE performs the following tasks: USB signaling detection/generation, data serialization/de-serialization, data encoding/decoding, bit stuffing and unstuffing, clock/data separation, and CRC generation/checking. It also decodes and manages all packet data types and packet fields. The endpoint FIFO buffers the data to be sent out or data received. The FIU manages the flow of data between the SIE, FIFO and the internal microcontroller bus. It controls the FIFO and monitors the status of the transactions and interfaces to the CPU. It initiates interrupts and acts upon commands sent by the firmware. The USB function hardware of the AT43USB326 makes the physical interface and the protocol layer transparent to the user. To start the process, the firmware must first enable the endpoints and which place them in receive mode by default. The device address by default is address 0. The USB function hardware then waits for a setup token from the host. When a valid setup token is received, it automatically stores the data packet in endpoint 0 FIFO and responds with an ACK. It then notifies the microcontroller through an interrupt. The microcontroller reads the FIFO and parses the request. Transactions for the non-control endpoints are even simpler. Once the endpoint is enabled, it waits for an IN or an OUT token depending whether it is programmed as an IN or OUT endpoint. For example, if it is an IN endpoint, the microcontroller simply loads the data into the endpoint's FIFO and sets a bit in the control and status register. The USB hardware will assemble the data in a USB packet and waits for an IN token. When it receives one, it automatically responds by transmitting the data packet and completes the transaction by waiting for the host's ACK. When one is received, the USB hardware will signal the microcontroller that the transaction has been completed successfully. Retries and data toggles are performed automatically by the USB hardware. When the IN endpoint is not ready to send data, in the case where the microcontroller has not filled the FIFO, it will automatically respond with a NAK. Similarly, an OUT endpoint will wait for an OUT token. When one is received, it will store the data in the FIFO, completes the transaction and interrupt the microcontroller, which then reads the FIFO and enables the endpoint for the next packet. If the FIFO is not cleared, the USB hardware will responds with a NAK. A detailed description of how USB transactions are handled is described in the following sections. First for a control endpoint and then for non-control endpoints.
The USB Function
46
AT43USB326
3313D-USB-04/06
AT43USB326
Control Transfers at Control Endpoint EP0 The description given below is for the function control endpoint, but applies to the hub control endpoint as well if the proper registers are used. The following illustration describes the three possible types of control transfers - Control Write, Control Read and No-data control:
Setup Stage Control Write Control Read SETUP(0)
DATA0
Data Stage OUT(1)
DATA1
Status Stage ... OUT(0/1)
DATA0/1
OUT(0)
DATA0
IN(1)
DATA1(0)
SETUP(0)
DATA0
IN(1)
DATA1
IN(0)
DATA0
...
IN(0/1)
DATA0/1
OUT(1)
DATA1(0)
Setup Stage No-data Control SETUP(0)
DATA0
Status Stage Legend: IN(1)
DATA1(0) DATAn DATA1(0) Data packet with PID's data toggle bit equal to n Zero length DATA1 packet
The following state diagram shows how the various state transitions are triggered. Additional decision making may take place within the response states to determine the next expected state. Unmarked arcs represent transitions that trigger immediately following completion of the response state processing. Stable states, those requiring an interrupt to exit having no unmarked arcs as exit paths, are shown in bold.
(ANY STABLE STATE)
RX_SETUP_INT
Setup Response
RX_OUT_INT
TX_COMPLETE_INT
TX_COMPLETE_INT
Control Write Data Response Control Read Data Response No-data Status Response
RX_OUT_INT
TX_COMPLETE_INT TX_COMPLETE_INT RX_OUT_INT
Control Write Status Response
Control Read Status Response
Idle
47
3313D-USB-04/06
The following information describes how the AT43USB326's USB hardware and firmware operates during a control transfer between the host and the hub's or function's control endpoint.
Legend: DATA1/DATA0 = Data packet with DATA1 or DATA2 PID DATA1(0) = Zero length DATA1 packet
Idle State Setup Response State
This is the default state from power-up. The Function Interface Unit (FIU) receives a SETUP token with 8 bytes of data from the Host. The FIU stores the data in the FIFO, sends an ACK back to the host and asserts an RX_SETUP interrupt.
Hardware 1. SETUP token, Data from Host 2. ACK to Host 3. Store data in FIFO 4. Set RX SETUP INT 5. Read UISR 6. Read CSR0
Firmware
7. Read Byte Count 8. Read FIFO 9. Parse command data 10. Write to H/FCAR0: a. If Control Read: set DIR, clear RX SETUP, fill FIFO, set TX Packet Ready in CAR0 b. If Control Write: clear DIR in CAR0 c. If no Data Stage: set Data End, clear DIR, set Force STALL in CAR0 11. Set UIAR[EP0 INTACK] to clear the interrupt source
48
AT43USB326
3313D-USB-04/06
AT43USB326
No-data Status Response State The Function Interface Unit receives an IN token from the Host. The FIU responds with a zero length DATA1 packet until receiving an ACK from the host, then asserts a TX_COMPLETE interrupt.
Hardware 1. IN token from Host 2. Send DATA1(0) 3. ACK from Host 4. Set TX COMPLETE INT 5. Read UISR 6. Read CSR0
Firmware
7. If SET ADDRESS, program the new Address, set ADD_EN bit 8. Clear TX_COMPLETE, clear Data End, set Force STALL in CAR0 9. Set UIAR[EP0 INTACK] Control Read Data Response State The Function Interface Unit receives an IN token from the Host. The FIU responds with NAKs until TX_PACKET_READY is set. The FIU then sends the data in the FIFO upstream, retrying until it successfully receives an ACK from the host. Finally, the FIU clears the TX_PACKET_READY bit and asserts a TX_COMPLETE interrupt.
Hardware 1. IN token from Host 2. a. If TX Packet Ready = 1, send DATA0/DATA1 b. If TX Packet Ready = 0, send NAK 3. ACK from Host 4. Clear TX Packet Ready Set TX Complete INT 5. Read UISR 6. Read CSR0
Firmware
7. Clear TX COMPLETE in CAR0: a. If more data: fill FIFO, set TX Packet Ready, set DIR in CAR0 b. If no more data: set Force STALL, set DATA END in CAR0 8. Set UIAR[EP0 INTACK] to clear interrupt source
Repeat steps 1 through 8
49
3313D-USB-04/06
Control Read Status Response State
The Function Interface Unit receives an OUT token from the Host with a zero length DATA1 packet. The FIU responds with a NAK until TX_COMPLETE is cleared. The FIU will then ACK the retried OUT token from the Host and assert an RX_OUT interrupt.
Hardware 1. OUT token from Host 2. DATA1(0) from Host 3. TX Complete = 0 ? a. If yes, ACK to Host Set RX OUT INT b. If no, NAK to Host 4. Read UISR 5. Read CSR0
Firmware
6. Clear RX OUT, set Data End, set Force Stall in H/FCAR0. Note: A SETUP token will clear Data End, therefore, it is not cleared by FW in case Host retries. 7. Set UIAR[EP0 INTACK] to clear interrupt source Control Write Data Response State The Function Interface Unit receives an OUT token from the Host with a DATA packet. The FIU places the incoming data into the FIFO, issues an ACK to the host, and asserts an RX_OUT interrupt.
Hardware 1. OUT token from Host 2. Put DATA0/DATA1 into FIFO 3. ACK to Host 4. Set RX OUT INT 5. Read UISR 6. Read CSR0 7. Read FIFO
Firmware
8. Clear RX OUT If last data packet, set Force STALL, set DATA END. 9. Set UIAR[EP0 INTACK] to clear the interrupt source
Repeat steps 1 through 9 until last DATA PACKET:
50
AT43USB326
3313D-USB-04/06
AT43USB326
Control Write Status Response State The Function Interface Unit receives an IN token from the Host. The FIU responds with a zero length DATA1 packet, retrying until it receives an ACK back from the Host. The FIU then asserts a TX_COMPLETE interrupt.
Hardware 1. IN token from Host 2. Send Data1(0) 3. ACK from Host 4. Set TX Complete INT 5. Read UISR 6. Read CSR0
Firmware
7. Clear TX COMPLETE, clear Data End, set Force STALL in CAR0 8. Set UIAR[EP0 INTACK] to clear the interrupt source
51
3313D-USB-04/06
Interrupt/Bulk IN Transfers at Function Endpoint
The firmware must first condition the endpoint through the Endpoint Control Register, FENDP1/2_CNTR: Set endpoint direction: set EPDIR Set interrupt or bulk: EPTYPE = 11 or 10 Enable endpoint: set EPEN The Function Interface Unit receives an IN token from the Host. The FIU responds with NAKs until TX_PACKET_READY is set. The FIU then sends the data in the FIFO upstream, retrying until it successfully receives an ACK from the host. Finally, the FIU clears the TX_PACKET_READY bit and asserts a TX_COMPLETE interrupt. 1. Read UISR 2. Read FCSR1/2 3. Clear TX_COMPLETE If more data: fill FIFO, set TX Packet Ready Wait for TX_COMPLETE interrupt If no more data: set DATA END in FCAR1/2 4. Set UIAR[FEP1/2 INTACK] to clear the interrupt source
Interrupt/Bulk OUT Transfers at Function Endpoint EP1 and 2
The firmware must first condition the endpoint through the Endpoint Control Register, FENDP1/2_CNTR: Set endpoint direction: clear EPDIR Set interrupt or bulk: EPTYPE = 11 or 10 Enable endpoint: set EPEN The Function Interface Unit receives an OUT token from the Host with a DATA packet. The FIU places the incoming data into the FIFO, issues an ACK to the host, and asserts an RX_OUT interrupt. 1. Read UISR 2. Read FCSR1/2 3. Read FIFO 4. Clear RX_OUT If more data: Wait for RX_OUT interrupt If no more data: set DATA END 5. Set UIAR[FEP1/2 INTACK] to clear the interrupt source
52
AT43USB326
3313D-USB-04/06
AT43USB326
USB Registers
The following sections describe the registers of the AT43USB326's USB hub and function units. Reading a bit for which the microcontroller does not have read access will yield a zero value result. Writing to a bit for which the microcontroller does not have write access has no effect. Hub Address Register - HADDR The USB hub contains an address register that contains the hub address assigned by the host. This Hub Address Register must be programmed by the microcontroller once it has received a SET_ADDRESS request from the host. The USB hardware uses the new address only after the status phase of the transaction is completed when the microcontroller has enabled the new address by setting bit 0 of the Global State Register. After power-up or reset, this register will contain the value of 0x00. Hub Address Register - HADDR
Bit $1FEF Read/Write Initial Value 7 SAEN R/W 0 6 HADD6 R/W 0 5 HADD5 R/W 0 4 HADD4 R/W 0 3 HADD3 R/W 0 2 HADD2 R/W 0 1 HADD1 R/W 0 0 HADD0 R/W 0 HADDR
* Bit 7 - SAEN: Single Address Enable The Single Address Enable bit allows the microcontroller to configure the AT43USB326 into a single address or a composite device. Once this capability is enabled, the hub endpoint 0 (HEP0) is converted from a control endpoint to a programmable function endpoint FEP3; all the endpoints would then operate on the single address. * Bit 6..0 - HADD6...0: Hub Address[6:0]
53
3313D-USB-04/06
Function Address Register - FADDR
The USB function contains an address register that contains the function address assigned by the host. This Function Address Register must be programmed by the microcontroller once it has received a SET_ADDRESS request from the host and completed the status phase of the transaction. After power up or reset, this register will contain the value of 0x00. Function Address Register - FADDR
Bit $1FEE Read/Write Initial Value 7 FEN R/W 0 6 FADD6 R/W 0 5 FADD5 R/W 0 4 FADD4 R/W 0 3 FADD3 R/W 0 2 FADD2 R/W 0 1 FADD1 R/W 0 0 FADD0 R/W 0 FADDR
* Bit 7 - FEN: Function Enable The Function Enable bit (FEN) allows the firmware to enable or disable the function endpoints. The firmware will set this bit after receipt of a reset through the hub, SetPortFeature[PORT_RESET]. Once this bit is set, the USB hardware passes to and from the host. When the Single Address bit is set, the condition of FEN is ignored. * Bit 6..0 - FADD6...0: Function Address[6:0]
Endpoint Registers
Hub Endpoint 0 Control Register - HENDP0_CR Function Endpoint 0 Control Register - FENDP0_CR
Bit $1FE7 $24 ($44) Read/Write Initial Value 7 EPEN EPEN R/W 0 6 - - R 0 5 - - R 0 4 - - R 0 3 DTGLE DTGLE R/W 0 2 EPDIR EPDIR R/W 0 1 EPTYPE1 EPTYPE1 R/W 0 0 EPTYPE0 EPTYPE0 R/W 0 HENDP0_CR FENDP0_CR
* Bit 7 - EPEN: Endpoint Enable 0 = Disable endpoint 1 = Enable endpoint * Bit 6..4 - Reserved These bits are reserved in the AT43USB326 and will read as zero. * Bit 3 - DTGLE: Data Toggle Identifies DATA0 or DATA1 packets. This bit will automatically toggle and requires clearing by the firmware only in certain special circumstances. * Bit 2 - EPDIR: Endpoint Direction 0 = Out 1 = In * Bit 1, 0 - EPTYPE: Endpoint Type These bits must be programmed as 0, 0.
54
AT43USB326
3313D-USB-04/06
AT43USB326
Function Endpoint 1, 2 Control Register - FENDP1,2_CR
Bit $1FE4 $1FE3 Read/Write Initial Value 7 EPEN EPEN R/W 0 6 - - R 0 5 - - R 0 4 - - R 0 3 DTGLE DTGLE R/W 0 2 EPDIR EPDIR R/W 0 1 EPTYPE1 EPTYPE1 R/W 0 0 EPTYPE0 EPTYPE0 R/W 0 FENDP1_CR FENDP2_CR
* Bit 7 - EPEN: Endpoint Enable 0 = Disable endpoint 1 = Enable endpoint * Bit 6..4 - Reserved These bits are reserved in the AT43USB326 and will read as zero. * Bit 3 - DTGLE: Data Toggle Identifies DATA0 or DATA1 packets. This bit will automatically toggle and requires clearing by the firmware only in certain special circumstances. * Bit 2 - EPDIR: Endpoint Direction 0 = Out 1 = In * Bit 1, 0 - EPTYPE: Endpoint Type These bits program the type of endpoint.
Bit1 0 1 1 Bit0 1 0 1 Type Isochronous Bulk Interrupt
55
3313D-USB-04/06
Hub Endpoint 0 Data Register - HDR0 Function Endpoint 0..2 Data Register - FDR0..2
Bit $1FD7 $1FD5 $1FD4 $1FD3 Read/Write Initial Value 7 DATA7 DATA7 DATA7 DATA7 R/W 0 6 DATA6 DATA6 DATA6 DATA6 R/W 0 5 DATA5 DATA5 DATA5 DATA5 R/W 0 4 DATA4 DATA4 DATA4 DATA4 R/W 0 3 DATA3 DATA3 DATA3 DATA3 R/W 0 2 DATA2 DATA2 DATA2 DATA2 R/W 0 1 DATA1 DATA1 DATA1 DATA1 R/W 0 0 DATA0 DATA0 DATA0 DATA0 R/W 0 HDR0 FDR0 FDR1 FDR2
This register is used to read data from or to write data to the Hub Endpoint 0 FIFO. * Bit 7..0 - FDAT7..0: FIFO Data Hub endpoint 1 has a single byte data register instead of a FIFO. This data register contains the hub and port status change bitmap. This data register is automatically updated by the USB hardware and is not accessible by the firmware. The bits in this register when read by the host will be:
Bit $ Read/Write Initial Value 7 - R/W 0 6 - R/W 0 5 - R/W 0 4 - R/W 0 3 P3 SC R/W 0 2 P2 SC R/W 0 1 P1 SC R/W 0 0 H SC R/W 0 HDR1
* Bit 7...4 - Reserved These bits are reserved in the AT43USB326 and will read as zero. * Bit 3 - P3 SC: Port 3 Status Change * Bit 2 - P2 SC: Port 2 Status Change * Bit 1 - P1 SC: Port 1 Status Change * Bit 0 - H SC: Hub Status Change
56
AT43USB326
3313D-USB-04/06
AT43USB326
Hub Endpoint 0 Byte Count Register - HBYTE_CNT0 Function Endpoint 0..2 Byte Count Register - FBYTE_CNT0..2 The contents of these registers stores the number of bytes to be sent or that was received by USB Hub and Function endpoints. This count includes the 16-bit CRC. To get the actual byte count of the data, subtract the count in the register by 2. The maximum byte count supported by the AT43USB326 is 8 bytes. Hub endpoint 1 has no byte count register.
Bit Hub EP0 $1FCF Function EP0 $1FCD Function EP1 $1FCC Function EP2 $1FCB Read/Write Initial Value 7 - - - - R 0 6 - - - - R 0 5 BYTCT5 BYTCT5 BYTCT5 BYTCT5 R 0 4 BYTCT4 BYTCT4 BYTCT4 BYTCT4 R/W 0 3 BYTCT3 BYTCT3 BYTCT3 BYTCT3 R/W 0 2 BYTCT2 BYTCT2 BYTCT2 BYTCT2 R/W 0 1 BYTCT1 BYTCT1 BYTCT1 BYTCT1 R/W 0 0 BYTCT0 BYTCT0 BYTCT0 BYTCT0 R/W 0 HBYTE_CNT0 FBYTE_CNT0 FBYTE_CNT1 FBYTE_CNT2
* Bit 7..6 - Reserved These bits are reserved in the AT43USB326 and will read as zero. * Bit 5..0 - BYTCT5..0: Byte Count - Length of Endpoint Data Packet
57
3313D-USB-04/06
Hub Endpoint 0 Service Routine Register - HCSR0 Function Endpoint 0 Service Routine Register - FCSR0
Bit Function EP0 $1FDF Function EP0 $1FDD Read/Write Initial Value 7 - - R 0 6 - - R 0 5 - - R 0 4 - - R 0 3 STALL SENT STALL SENT R 0 2 RX SETUP RX SETUP R 0 1 RX OUT PACKET RX OUT PACKET R 0 0 TX COMPLETE TX COMPLETE R 0 HCSR0 FCSR0
* Bit 7..4 - Reserved These bits are reserved in the AT43USB326 and will read as zero. * Bit 3 - STALL SENT The USB hardware sets this bit after a STALL has been sent to the host. The firmware uses this bit when responding to a Get Status[Endpoint] request. It is a read only bit and that is cleared indirectly by writing a one to the STALL_SENT_ACK bit of the Control and Acknowledge Register. * Bit 2 - RX SETUP: Setup Packet Received This bit is used by control endpoints only to signal to the microcontroller that the USB hardware has received a valid SETUP packet and that the data portion of the packet is stored in the FIFO. The hardware will clear all other bits in this register while setting RX SETUP. If interrupt is enabled, the microcontroller will be interrupted when RX SETUP is set. After the completion of reading the data from the FIFO, firmware should clear this bit by writing a one to the RX_SETUP_ACK bit of the Control and Acknowledge Register. * Bit 1 - RX OUT PACKET The USB hardware sets this bit after it has stored the data of an OUT transaction in the FIFO. While this bit is set, the hardware will NAK all OUT tokens. The USB hardware will not overwrite the data in the FIFO except for an early set-up. RX OUT Packet is used for the following operations: 1. Control write transactions by a control endpoint. 2. OUT transaction with DATA1 PID to complete the status phase of a control endpoint. Setting this bit causes an interrupt to the microcontroller if the interrupt is enabled. FW clears this bit after the FIFO contents have been read by writing a one to the RX_OUT_PACKET_ACK bit of the Control and Acknowledge Register. * Bit 0 - TX COMPL: Transmit Completed This bit is used by a control endpoint hardware to signal to the microcontroller that it has successfully completed certain transactions. TX Complete is set at the completion of a: 1. Control read data stage. 2. Status stage without data stage. 3. Status stage after a control write transaction. This bit is read only and is cleared indirectly by writing a one to the TX_COMPLETE_ACK bit of the Control and Acknowledge Register.
58
AT43USB326
3313D-USB-04/06
AT43USB326
Hub Endpoint 0 Control and Acknowledge Register - HCAR0 Function Endpoint 0 Control and Acknowledge Register - FCAR0
Bit Hub EP0 $1FA7 7 6 DATA END 5 FORCE STALL 4 TX PACKET READY TX PACKET READY R/W 0 3 STALL_ SENT_ ACK STALL_ SENT_ ACK R/W 0 2 RX_ SETUP_ ACK RX_ SETUP_ ACK R/W 0 1 RX_OUT_ PACKET_ ACK RX_OUT_ PACKET_ ACK R/W 0 0 TX_ COMPLETE_ ACK TX_ COMPLETE_ ACK R/W 0
DIR
HCAR0
Function EP0 $1FDD Read/Write Initial Value
DIR
DATA END R/W 0
FORCE STALL R/W 0
FCAR0
R/W 0
* Bit 7 - DIR: Control transfer direction It is set by the microcontroller firmware to indicate the direction of a control transfer to the USB hardware. The FW writes to this bit location after it receives an RX SETUP interrupt. The hardware uses this bit to determine the status phase of a control transfer. 0 = control write or no data stage 1 = control read * Bit 6 - DATA END When set to 1 by firmware, this bit indicate that the microcontroller has either placed the last data packet in FIFO, or that the microcontroller has processed the last data packet it expects from the Host. This bit is used by control endpoints only together with bit 4 (TX Packet Ready) to signal the USB hardware to go to the STATUS phase after the packet currently residing in the FIFO is transmitted. After the hardware completes the STATUS phase it will interrupt the microcontroller without clearing this bit. * Bit 5 - FORCE STALL This bit is set by the microcontroller to indicate a stalled endpoint. The hardware will send a STALL handshake as a response to the next IN or OUT token, or whenever there is a control transfer without a Data Stage. The microcontroller sets this bit if it wants to force a STALL. A STALL is sent if any of the following condition is encountered: 1. An unsupported request is received. 2. The host continues to ask for data after the data is exhausted. 3. The control transfer has no data stage. * Bit 4 - TX PACKET READY: Transmit Packet Ready When set by the firmware, this bit indicates that the microcontroller has loaded the FIFO with a packet of data. This bit is cleared by the hardware after the USB Host acknowledges the packet. For ISO endpoints, this bit is cleared unconditionally after the data is sent. This bit is used for the following operations: 1. Control read transactions by a control endpoint. 2. IN transactions with DATA1 PID to complete the status phase for a control endpoint, when this bit is zero but Data End set high (bit 4). 3. By a BULK IN or ISO IN or INT IN endpoint. The microcontroller should write into the FIFO only if this bit is cleared. After it has completed writing the data, it should set this bit. This data can be of zero length.
59
3313D-USB-04/06
Hardware clears this bit after it receives an ACK. If the interrupt is enabled and if the TX Complete bit is set, clearing the TX Packet Ready bit by the hardware causes an interrupt to the microcontroller. * Bit 3 - STALL_SENT_ACK: Acknowledge Stall Sent Interrupt Firmware sets this bit to clear STALL SENT, CSR bit 3. The 1 written in the CSRACK3 bit is not actually stored and thus does not have to be cleared. * Bit 2 - RX_SETUP_ACK: Acknowledge RX SETUP Interrupt Firmware sets this bit to clear RX SETUP, CSR bit2. The 1 written in the CSRACK2 bit is not actually stored and thus does not have to be cleared. * Bit 1 - RX_OUT_PACKET_ACK: Acknowledge RX OUT PACKET Interrupt Firmware sets this bit to clear RX OUT PACKET, CSR bit1. The 1 written in the CSRACK1 bit is not actually stored and thus does not have to be cleared. * Bit 0 - TX_COMPLETE_ACK: Acknowledge TX COMPLETE Interrupt Firmware sets this bit to clear TX COMPLETE, CSR bit0. The 1 written in the CSRACK0 bit is not actually stored and thus does not have to be cleared. Function Endpoint 1,2 Service Routine Register - FCSR1,2
Bit Function EP1 $1FDC Function EP2 $1FDB Read/Write Initial Value 7 - - R 0 6 - - R 0 5 - - R 0 4 - - R 0 3 STALL SENT STALL SENT R 0 2 - - R 0 1 RX OUT PACKET RX OUT PACKET R 0 0 TX COMPLETE TX COMPLETE R 0 FCSR1 FCSR2
* Bit 7..4 - Reserved These bits are reserved in the AT43USB326 and will read as zero. * Bit 3 - STALL SENT The USB hardware sets this bit after a STALL has been sent to the host. The firmware uses this bit when responding to a Get Status[Endpoint] request. It is a read only bit and that is cleared indirectly by writing a one to the STALL_SENT_ACK bit of the Control and Acknowledge Register. * Bit 2 - Reserved This bit is reserved in the AT43USB326 and will read as zero. * Bit 1 - RX OUT PACKET The USB hardware sets this bit after it has stored the data of an OUT transaction in the FIFO. While this bit is set, the hardware will NAK all OUT tokens. The USB hardware will not overwrite the data in the FIFO except for an early set-up. RX OUT Packet is used by a BULK OUT or ISO OUT or INT OUT endpoint. Setting this bit causes an interrupt to the microcontroller if the interrupt is enabled. FW clears this bit after the FIFO contents have been read by writing a one to the RX_SETUP_ACK bit of the Control and Acknowledge Register. * Bit 0 - TX COMPLETE: Transmit Completed This bit is used by the endpoint hardware to signal to the microcontroller that the IN transaction was completed successfully. This bit is read only and is cleared indirectly by writing a one to the TX_COMPLETE_ACK bit of the Control and Acknowledge Register.
60
AT43USB326
3313D-USB-04/06
AT43USB326
Function Endpoint 1,2 Control and Acknowledge Register - FCAR1,2
Bit Function EP1 $1FA4 7 - 6 DATA END DATA END R/W 0 5 FORCE STALL FORCE STALL R/W 0 4 TX PACKET RDY TX PACKET RDY R/W 0 3 STALL_SENTACK STALL_SENTACK R/W 0 2 - 1 RX_OUT_PACKET _ACK RX_OUT_PACKET _ACK R/W 0 0 TX_COMPLETE _ACK TX_COMPLETE -ACK R/W 0 FCAR1
Function EP2 $1FA3 Read/Write Initial Value
- R 0
- R 0
FCAR2
* Bit 7 - Reserved This bit is reserved in the AT43USB326 and will read as zero. * Bit 6 - DATA END When set to 1 by firmware, this bit indicate that the microcontroller has either placed the last data packet in FIFO, or that the microcontroller has processed the last data packet it expects from the Host. * Bit 5 - FORCE STALL This bit is set by the microcontroller to indicate a stalled endpoint. The hardware will send a STALL handshake as a response to the next IN or OUT token. The microcontroller sets this bit if it wants to force a STALL. A STALL is send if the host continues to ask for data after the data is exhausted. * Bit 4 - TX PACKET RDY: Transmit Packet Ready When set by the firmware, this bit indicates that the microcontroller has loaded the FIFO with a packet of data. This bit is cleared by the hardware after the USB Host acknowledges the packet. For ISO endpoints, this bit is cleared unconditionally after the data is sent. The microcontroller should write into the FIFO only if this bit is cleared. After it has completed writing the data, it should set this bit. This data can be of zero length. The hardware clears this bit after it receives an ACK. If the interrupt is enabled and if the TX Complete bit is set, clearing the TX Packet Ready bit by the hardware causes an interrupt to the microcontroller. * Bit 3 - STALL_SENT_ACK: Acknowledge Stall Sent Interrupt Firmware sets this bit to clear STALL SENT, CSR bit 3. The 1 written in the CSRACK3 bit is not actually stored and thus does not have to be cleared. * Bit 2 - Reserved This bit is reserved in the AT43USB326 and will read as zero. * Bit 1 - RX_OUT_PACKET_ACK: Acknowledge RX OUT PACKET Interrupt Firmware sets this bit to clear RX OUT PACKET, CSR bit1. The 1 written in the CSRACK1 bit is not actually stored and thus does not have to be cleared. * Bit 0 - TX_COMPLETE_ACK: Acknowledge TX COMPLETE Interrupt Firmware sets this bit to clear TX COMPLETE, CSR bit0. The 1 written in the CSRACK0 bit is not actually stored and thus does not have to be cleared.
61
3313D-USB-04/06
USB Hub
The hub in a USB system provides for the electrical interface between USB devices and the host. The major functions that the hub must supports are: * * * * * Connectivity Power management Device connect and disconnect Bus fault detection and recovery Full speed and low speed device support
A hub consists of two major components: a hub repeater and a hub controller. The hub repeater is responsible for: * * * * * * * * Providing upstream connectivity between the selected device and the Host Managing connectivity setup and tear-down Handling bus fault detection and recovery Detecting connect/disconnect on each port Hub enumeration Providing configuration information to the host Providing status of each port to the host Controlling each port per host command
The Hub Controller is responsible for:
The first two tasks of the hub are similar to that of a USB function and are described in detail in the following section. The descriptions will cover the features of the AT43USB326's hub and how to program it to make a USB-compliant hub. Control transactions for the hub control endpoint proceed exactly the same way as those described for the embedded function. The operation of the hub's endpoint 1 is fully implemented in the hardware and does not need any firmware support. Any status changes within the hub will automatically update hub endpoint 1, which will be sent to the host at the next IN token that is addressed to it. If no change has occurred, the interrupt endpoint will respond with a NAK.
62
AT43USB326
3313D-USB-04/06
AT43USB326
Hub General Registers Global State Register - GLB_STATE
Bit $1FFB Read/Write Initial Value 7 - R 0 6 - R 0 5 - R 0 4 SUSP FLG R 0 3 RESUME FLG R 0 2 RMWUPE R/W 0 1 CONFG R/W 0 0 HADD EN R/W 0 GLB_STATE
* Bit 7...5 - Reserved Bits These bits are reserved in the AT43USB326 and will read as zeros. * Bit 4 - SUSP FLG: Suspend Flag This bit is set to 1 while the USB hardware is in the suspended state. This bit is a firmware read only bit. It is set and cleared by the USB hardware. * Bit 3 - RESUME FLGL Resume Flag When the USB hardware receives a resume signal from the upstream device it sets this bit. This bit will stay set until the USB hardware completes the downstream resume signaling. This bit is a firmware read only bit. It is set and cleared by the USB hardware. * Bit 2 - RMWUPE: Remote Wakeup Enable This bit is set if the host enables the hub's remote wakeup feature. * Bit 1 - CONFG: Configured This bit is set by firmware after a valid SET_CONFIGURATION request is received. It is cleared by a reset or by a SET_CONFIGURATION with a value of 0. * Bit 0 - HADD EN: Hub Address Enabled This bit is set by firmware after the status phase of a SET_ADDRESS request transaction so the hub will use the new address starting at the next transaction.
63
3313D-USB-04/06
Hub Status Register
In the AT43USB326 overcurrent detection and port power switch control output processing is done in firmware. The hardware is designed so that various types of hubs are possible just through firmware modifications. 1. Hub local power status, bits 0 and 2, are optional features and apply to hubs that report on a global basis. If this feature is not used, both these bits should be programmed to 0. To use this feature, the firmware needs to know the status of the local power supply, which requires an input pin and extra internal or external circuitry. 2. Hub overcurrent status, bits 1 and 3, apply to self powered hubs with bus powered SIE only, or hubs that are programmable as self/bus powered. The firmware should clear these two bits to 0. The firmware uses bits 1 and 3 to generate bit 0 of the Hub and Port Status Change Bitmap which is transmitted through the Hub Endpoint1 Data Register. Bit 0 of this register is a 1 whenever bit 1 or 3 of HSTATR is a 1. Hub Status Register - HSTR
Bit $1FC7 Read/Write Initial Value 7 - R 0 6 - R 0 5 - R 0 4 - R 0 3 OVLSC R/W 0 2 LPSC R/W 0 1 OVI R/W 0 0 LPS R/W 0 HSTR
* Bit 7..4 - Reserved These bits are reserved in the AT43USB326 and will read as zero. * Bit 3 - OVLSC: Overcurrent Status Change 0 = No change has occurred on Overcurrent Indicator 1 = Overcurrent Indicator has changed * Bit 2 - LPSC: Hub Local Power Status Change 0 = No change has occurred on Local Power Status 1 = Local Power Status has changed * Bit 1 - OVI: Overcurrent Indicator 0 = All power operations normal 1 = An overcurrent exist on a hub wide basis * Bit 0 - LPS: Hub Local Power Status 0 = Local power supply is good 1 = Local power supply is lost (inactive)
64
AT43USB326
3313D-USB-04/06
AT43USB326
Hub Port Control Register - HPCON
Bit $1FC5 Read/Write Initial Value 7 - R 0 6 HPCON2 R/W 0 5 HPCON1 R/W 0 4 HPCON0 R/W 0 3 - R 0 2 HPADD2 R/W 0 1 HPADD1 R/W 0 0 HPADD0 R/W 0 HPCON
* Bit 7 - Reserved This bits is reserved in the AT43USB326 and will read as zero. * Bit 6..4 - HPCON2..0: Hub Port Control Command These bits are written by firmware to control the port states upon receipt of a Host request.
Bit6 0 0 0 0 1 Bit5 0 0 1 1 0 Bit4 0 1 0 1 0 Action Disable port Enable port Reset and enable port Suspend port Resume port
Disable Port = ClearPortFeature(PORT_ENABLE) Action: USB hardware places addressed port in disabled state. Port 1 is placed in disabled state by firmware. Enable Port = SetPort Feature(PORT_ENABLE) Action: USB hardware places addressed port in enabled state. Firmware is responsible for placing Port 1 in enabled state. Reset and Enable Port = SetPort Feature(PORT_RESET) Action: USB hardware drives reset signaling through addressed port. USB hardware and firmware resets their embedded function registers to the default state. Suspend Port = SetPortFeature(PORT_SUSPEND) Action: USB hardware places port in idle state and stops propagating traffic through the addressed port. Firmware places Port 1 in suspend state by disabling its endpoints and placing the peripheral function in its low power state. Resume Port = ClearPortFeature(PORT_SUSPEND) Action: USB hardware sends resume signaling to addressed port and then enables port. Firmware takes the embedded function out of the suspend state and enables Port 1's endpoints. * Bit 3 - Reserved This bits is reserved in the AT43USB326 and will read as zero. * Bit 2..0 - HPCON2..0: Hub Port Address
65
3313D-USB-04/06
These bits define which port is being addressed for the command defined by bits [2:0].
Bit2 0 0 Bit1 1 1 Bit0 1 0 Port addresses Port3 Port2
66
AT43USB326
3313D-USB-04/06
AT43USB326
Selective Suspend and Resume The host can selectively suspend and resume a port through the Set Port Feature (PORT_SUSPEND) and Clear Port Feature (PORT_SUSPEND). A port enters the suspend state after the microcontroller interprets the suspend request and sets the appropriate bits of the Hub Port Control Register, HPCON. From this point on he hub repeater hardware is responsible for proper actions in placing Ports 2:3 in the suspend mode. For Port 1, the embedded function port, the hardware will stop responding to any normal bus traffic, but the microcontroller firmware must place all external circuitry associated with the function in the low-power state. A port exits from the suspend state when the hub receives a Clear Port Feature (PORT_SUSPEND) or Set Port Feature (PORT_RESET). If the Clear Port Feature (PORT_SUSPEND) is directed towards Ports 2:3, the USB hardware drives a "K" downstream for at least 20 ms followed by a low speed EOP. It then places the port in the enabled state. A Clear Port Feature (PORT_SUSPEND) to Port 1 (the embedded function) causes the firmware to wait 20 ms, take the embedded function out of the suspended state and then enable the port. The ports can also exit from the suspended state through a remote wakeup if this feature is enabled. For Ports 2:3, this means detection of a connect/disconnect or an upstream directed J to K signaling. Remote wakeup for the embedded function is initiated through an external interrupt at INT0.
67
3313D-USB-04/06
Hub Port Status Register
The bits in this register are used by the microcontroller firmware when reporting a port's status through the Port Status Field, wPortStatus. Bits 3 (POCI) and 5 (PPSTAT) are used by the USB hardware and are the only two bits that the firmware should set or clear. All other bits should not be modified by the firmware. Hub Port Status Register - HPSTAT2, 3
Bit Port1 $1FB8 Port2 $1FB9 Port3 $1FBA Read/Write Initial Value 7 - - - R 0 6 LSP LSP LSP R 0 5 PPSTAT PPSTAT PPSTAT R/W 0 4 PRSTAT PRSTAT PRSTAT R 0 3 POCI POCI POCI R/W 0 2 PSSTAT PSSTAT PSSTAT R 0 1 PESTAT PESTAT PESTAT R 0 0 PCSTAT PCSTAT PCSTAT R 0 HPSTAT1 HPSTAT2 HPSTAT3
* Bit 7 - Reserved This bit is reserved in the AT43USB326 and will read as zero. * Bit 6 - LSP: Low-speed Device Attached 0 = Full-speed device attached to this port 1 = Slow-speed device attached to this port Set to 0 for Port 1 (full-speed only). Set and cleared by the hardware upon detection of device at EOF2. * Bit 5 - PPSTAT: Port Power Status 0 = Port is powered OFF 1 = Port is powered ON Set to 1 for Port 1. Set and cleared based on present status of port power. * Bit 4 - PRSTAT: Port Reset Status 0 = Reset signaling not asserted 1 = Reset signaling asserted Set and cleared by the hardware as a result of initiating a port reset by Port Control Register. * Bit 3 - POCI: Port Overcurrent Indicator 0 = Power normal 1 = Overcurrent exist on port Set to 0 for Port 1. Set and cleared by firmware upon detection of an overcurrent or removal of an overcurrent. * Bit 2 - PSSTAT: Port Suspend Status 0 = Port not suspended 1 = Port suspended Set and cleared by the hardware as controlled through Port Control Register. * Bit 1 - PESTAT: Port Enable Status 0 = Port is disabled 1 = Port is enabled
68
AT43USB326
3313D-USB-04/06
AT43USB326
Set and cleared by the hardware as controlled through Port Control register. * Bit 0 - PCSTAT: Port Connect Status 0 = No device on this port 1 = Device present on this port Set to 1 for Port 1. Set and cleared by the hardware after sampling of connect status at EOF2. Overcurrent Detect Register - UOVCER
Bit $1FF2 Read/Write Initial Value 7 - R 0 6 - R 0 5 - R 0 4 - R 0 3 - R 0 2 PORT2 R/W 0 1 - R 0 0 - R 0 UOVCER
* Bit 7..3 - Reserved These bits are reserved in the AT43USB326 and will read as zero. * Bit 2 - PORT 2 Setting this bit enables the hub to detect an overcurrent on Port 2 while the hub is in the suspend state. * Bit 1, 0 - Reserved These bits are reserved in the AT43USB326 and will read as zero. Hub Port State Register - HPSTAT2, 3
Bit Port2 $1FA9 Port3 $1FAA Read/Write Initial Value 7 - - R 0 6 - - R 0 5 - - R 0 4 - - R 0 3 - - R 0 2 - - R 0 1 DPSTATE DPSTATE R 0 0 DMSTATE DMSTATE R 0 PSTATE2 PSTATE3
These registers contain the state of the ports' DP and DM pins, which will be sent to the host upon receipt of a GetBusState request. * Bit 7..2 - Reserved These bits are reserved in the AT43USB326 and will read as zero. * Bit 1 - DPSTATE: DPlus State Value of DP at last EOF. Set and cleared by hardware at EOF2. Set to 1 for Port 1. * Bit 0 - DMSTATE: DMinus State Value of DM at last EOF. Set and cleared by hardware at EOF2. Set to 0 for Port 1.
69
3313D-USB-04/06
Hub Port Status Change Register - PSCR1..3
Bit Port1 $1FB0 Port2 $1FB1 Port3 $1FB2 Read/Write Initial Value 7 - - - R 0 6 - - - R 0 5 - - - R 0 4 RSTSC RSTSC RSTSC R 0 3 POCIC POCIC POCIC R 0 2 PSSC PSSC PSSC R 0 1 PESC PESC PESC R 0 0 PCSC PCSC PCSC R 0 PSCR1 PSCR2 PSCR3
The microcontroller firmware uses the bits in this register to monitor when a port status change has occurred, which then gets reported to the host through the Port Change Field wPortChange. Except for bit 3, the Port Overcurrent Indicator Change, the bits in this register are set by the USB hardware. Otherwise, the firmware should only clear these bits. * Bit 7..5 - Reserved These bits are reserved in the AT43USB326 and will read as zero. * Bit 4 - RSTSC: Port Reset Status Change 0 = No change 1 = Reset complete This bit is set by the USB hardware after it completes RESET signaling which is initiated when the Reset and Enable Port command is detected at the Port Control Register, HPCON. The firmware sends this command when it decodes a SetPortFeature(PORT_RESET) request from the host. At EOF2 after the hardware completes the port reset, the hardware sets the Port Enable Status bit and clears the Port Reset Status bit of the Hub Port Status Register, HPSTAT. Cleared by firmware, ClearPortFeature(PORT_RESET). * Bit 3 - POCIC: Port Overcurrent Indicator Change 0 = No change has occurred on Overcurrent Indicator 1 = Overcurrent Indicator has changed This bit is relevant to hubs with individual overcurrent reporting only. The firmware sets this bit as a result of detecting overcurrent at the ports OVC# pin. The firmware clears bit through ClearPortFeature(PORT_OVER_CURRENT). For Port 1, this bit is always cleared. * Bit 2 - PSSC: Port Suspend Status Change 0 = No change 1 = Resume completed Port 2, 3 set by hardware upon completion of firmware initiated resume process. Port 1 set by firmware 20 ms after the next EOF2 after completion of resume process. RESUME signaling is initiated through global resume, selective resume and remote wakeup. Cleared by firmware via host request ClearPortFeature(PORT_SUSPEND). * Bit 1 - PESC: Port Enable/Disable Status Change 0 = No change has occurred on Port Enable/Disable Status 1 = Port Enable/Disable status has changed
70
AT43USB326
3313D-USB-04/06
AT43USB326
Set by hardware due to babble, physical disconnect or overcurrent except for Port 1 in which case it is set by hardware at EOF2 due to hardware events. Cleared by firmware via Host request ClearPortFeature(PORT_ENABLE). * Bit 0 - PCSC: Port Connect Status Change 0 = No change has occurred on Current Connect Status 1 = Current Connect Status has changed This bit is set by hardware at EOF2 after it detects a connect or disconnect at a port, except for Port 1. Hardware sets this bit for Port 5 after a hub reset. Cleared by firmware via Host request ClearPortFeature(PORT_CONNECTION). Hub and Port Power Management The embedded hub in a keyboard will most likely be a bus-powered hub even though the hardware of the AT43USB326 is designed to accommodate both types of hubs. Management of the downstream port power is also defined by the firmware: per port or global overcurrent sensing, individual or gang power switching. While the interface to the external power supply monitoring and switching is achieved through the microcontroller's GPIO pins, the USB hardware of the AT43USB326 contains the circuitry to handle all the possible combinations port power management tasks. If programmed for global overcurrent protection, the AT43USB326 is capable of detecting an overcurrent in its downstream port even while it is in the suspend state. This mode is enabled through the Overcurrent Detect Register, UOVCER, which controls the PD0 pin used for overcurrent input sensing. 1. Global Overcurrent Protection - In this mode, the Port Overcurrent Indicator and Port Overcurrent Indicator Change should be set to 0's. For the AT43USB326 an external solid state switch, such as the Micrel MIC2545-2, is required to switch power to the external USB ports. The FLG# output of the switch should be connected to PD0. When an overcurrent occurs, FLG# is asserted and the firmware should set the Hub Overcurrent Indicator and Hub Overcurrent Indicator Change and switch off power to the hub. 2. Individual Port Over-current Protection - The Hub Overcurrent Indicator and Hub Overcurrent Indicator Change bits should be set to 0's. One MIC2026-2 is required for the two USB ports. Each of the FLG# outputs of the MIC2026-2 should be connected to an unused microcontroller port. An overcurrent is indicated by assertion of FLG#. The firmware sets the corresponding port's Overcurrent Indicator and the Overcurrent Indicator Change bits and switches off power to the port. At the next IN token from the Host, the AT43USB326 reports the status change. Port Power Switching 1. Gang Power Switching - One of the microcontroller I/O port pins must be programmed as an output to control the external switch, PWRN. Switch ON is requested by the USB Host through the SetPortFeature(PORT_POWER) request. Switch OFF is executed upon receipt of a ClearPortFeature(PORT_POWER) or upon detecting an overcurrent condition. The firmware clears the Power Control Bit. Only if all of the Power Control Bits of ports 2 and 3 are cleared should the firmware de-assert the PWRN pin. 2. Individual Power Switching - One microcontroller I/O port pin must be assigned for each USB port to control the external switch, PWRxN, where x = 2, 3. Each of the Power Control Bits controls one PWRxN. 3. Multiple Ganged Overcurrent Protection - Overcurrent sensing is grouped physically into one or more gangs, but reported individually.
Overcurrent Sensing
71
3313D-USB-04/06
Figure 12 shows a simplified diagram of a power management circuit of an AT43USB326 based hub design with global overcurrent protection and ganged power switching for the two external downstream ports. The over-current protection and port power switching for the AT43USB326 is best implemented in the so-called multiple gang. The Hub Characteristic's bits in the Hub Descriptor are set as follows: * * Logical Power Switching is Individual, D1D0 = 01 Overcurrent Protection is Individual, D4D3 = 01
When an over-current condition at one of the external ports is detected, the over-current bits of both external ports are set. The host will switch off power to the external port, but the keyboard will continue to operate. The external port power is switched on as soon as one port's power is enabled, but switched off only when the power to both ports is disabled. Figure 12. Port Power Management
BUS_POWER GND
GND
VCC
AT43USB326
PWRN
OVCN
CTL IN
FLG OUT
PORT2_POWER PORT2_GND PORT3_POWER PORT3_GND
SWITCH
Suspend and Resume
The AT43USB326 enters suspend only when requested by the USB host through bus inactivity for at least 3 ms. The USB hardware would detect this request, sets the GLB_SUSP bit of SPRSR, Suspend/Resume Register, and interrupts the microcontroller if the interrupt is enabled. The microcontroller should shut down any peripheral activity and enter the Power Down mode by setting the SE and SM bits of MCUCR and then executes the SLEEP instruction. The USB hardware shuts off the oscillator and PLL.
72
AT43USB326
3313D-USB-04/06
AT43USB326
Global Resume Global resume is signaled by a J to K state change on Port0. The USB hardware enables the oscillator/PLL, propagates the RESUME signaling, and sets the RSM bit of the SPRSR, which generates an interrupt. The microcontroller starts executing where it left off and services the interrupt. As part of the ISR, the firmware clears the GLB_SUSP bit. While the AT43USB326 is in global suspend, resume signaling is also possible through remote wakeup if the remote wakeup feature is enabled. Remote wakeup is defined as a port connect, port disconnect or resume signaling received at a downstream port or, in case of the embedded function, through an external interrupt. A remote wakeup initiated at a downstream port is similar in many respects to a global resume. The USB hardware enables the oscillator/PLL, propagates the RESUME signaling, and sets the RSM bit of the SPRSR which generates an interrupt. The microcontroller starts executing where it left off and services the interrupt. As part of the ISR, the firmware clears the GLB_SUSP bit. A remote wakeup from the embedded function is initiated through INT0 or the external interrupt, INT1, which enables the oscillator/PLL and the USB hardware. The USB hardware drives RESUME signaling and sets the FRMWUP and RSM bits of SPRSR which generates an interrupt to the microcontroller. The microcontroller starts executing where it left off and services the interrupt. As part of the ISR, the firmware clears the GLB SUSP bit. At completion of RESUME signaling, the USB hardware sets the Port Suspend Status Change bits of the Hub Port Status Change Registers. Selective Suspend and Resume Suspend and Resume Process Global Suspend The Host stops sending packets, the hardware detects this as global suspend signaling and stops all downstream signaling. Finally, the hardware asserts the GLB_SUSP interrupt. Hardware 1.Host stops sending packets 2. Global suspend signaling detected 3. Stop downstream signaling 4. Set GBL SUS bit interrupt 5. Shut down any peripheral activity 6. Set Sleep Enable and Sleep Mode bits of MCUCR 7. Set GPIO to low power state if required 8. Set UOVCER bit 2 9. Execute SLEEP instruction 10. SLEEP bit detected 11. Shut off oscillator Firmware See section on Hub Port Control Register, HPCON.
Remote Wakeup
73
3313D-USB-04/06
Global Resume
The Host resumes signaling, the hardware detects this as global resume and propagates this signaling to all downstream ports. Finally, the hardware enables the oscillator and asserts the RSM interrupt. Hardware 1.Host resumes signaling 2. Resume signaling detected 3. Propagate signaling downstream 4. Enable oscillator 5. Set RSM bit interrupt 6. Reset RSM and GBL SUSP bits 7. Restore GPIO states if required 8. Clear UOVCER bit 2 9. Enable peripheral activity Firmware
Remote Wake-up, Downstream Ports
The hardware detects a connect/disconnect/port resume and propagates resume signaling upstream. Finally, the hardware enables the oscillator and asserts the RSM interrupt. Hardware 1. Connect/disconnect/port resume detected 2. Propagate resume signaling 3. Enable Oscillator 4. Set RSM bit interrupt 5. Reset RSM and GBL SUSP bits 6. Restore GPIO states if required 7. Clear UOVCER bit 2 8. Enable peripheral activity Firmware
Remote Wake-up, Embedded Function
The hardware detects an INT0/INT1 and propagates resume signaling upstream. Finally, the hardware enables the oscillator and asserts the RSM and FRWUP interrupts. Hardware Firmware
1.External event activates INT0/INT1 2. Propagate resume signaling 3. Enable Oscillator 4. Set RSM and FRMWUP bits interrupt 5. Clear GLB SUSP, RSM, FRMWUP bits 6. Restore GPIO states if required 7. Clear UOVCER bit 2 8. Enable peripheral activity
74
AT43USB326
3313D-USB-04/06
AT43USB326
Selective Suspend, Downstream Ports Hardware Firmware 1. Set or Clear Port Feature PORT_SUSPEND decoded 2. Write HPCON[2:0] and HPADD[2:0] bits 3. Suspend or resume port per command Selective Suspend, Embedded Function Hardware Firmware 1. Set Port Feature PORT_SUSPEND decoded 2. Disable Port 1's endpoints 3. Set GPIO to low power state if required Selective Resume, Embedded Function Hardware Firmware 1. Clear Port Feature PORT_SUSPEND decoded 2. Clear Port 1 suspend status bit 3. Restore GPIO states if required 4. Wait 23 ms, then set enable status bit and suspend change bit 5. Enable Port 1 endpoints 6. Send updated port status at next IN to endpoint1
75
3313D-USB-04/06
Electrical Specification
Absolute Maximum Ratings
Stresses beyond those listed below may cause permanent damage to the device. This is a stress rating only and functional operation of the device at these or any other conditions beyond those indicated in the operational sections of this specification is not implied. Exposure to absolute maximum rating conditions for extended periods may affect device reliability.
Table 13. Absolute Maximum Ratings
Symbol VCC5 VI VO TO TS Note: Parameter 5V Power Supply DC input voltage DC output voltage Operating temperature Storage temperature VCEXT is the voltage at CEXT1, CEXT2. -0.3V -0.3 -40 -65 Condition Min Max 5.5 VCEXT+0.3 4.6 max VCEXT+0.3 4.6 max +125 +150 Unit V V V C C
DC Characteristics
The values shown in this table are valid for TA = 0C to 85C, VCC = 4.4 to 5.25V, unless otherwise noted. Table 14. Power Supply
Symbol VCC ICC ICCS Parameter 5V Power Supply 5V Supply Current Suspended Device Current Condition Min 4.4 Max 5.25 40 600 Unit V mA uA
76
AT43USB326
3313D-USB-04/06
AT43USB326
Table 15. USB Signals: DPx, DMx
Symbol VIH VIHZ VIL VDI VCM VOL1 VOH1 VCRS VIN Parameter Input Level High (driven) Input Level High (floating) Input Level Low Differential Input Sensitivity Differential Common Mode Range Static Output Low Static Output High Output Signal Crossover Input Capacitance RL of 1.5 k to 3.6V RL of 15 k to GND 2.8 1.3 DPx and DMx 0.2 0.8 2.5 0.3 3.6 2.0 20 Condition Min 2.0 2.7 0.8 Max Unit V V V V V V V V pF
Table 16. PA, PB, PC, PD, PF
Symbol VOL2 RPU VIL3 VIH3 VIL4 VIH4 VOL4 VOH4 C Note: Parameter Output Low Level, PA, PB, PE[0:3] PC Pull-up resistor current Input Low Level, PC Input High Level, PC Input Low Level, PD[0,1] Input High Level, PD[0,1] Output Low Level, PD[0,1] Output High Level, PD[0,1] Input/Output capacitance IOL = 4 mA IOH = 4 mA 1 MHz 0.7 VCEXT 10 0.7 VCEXT 0.3 VCEXT 0.7 VCEXT 0.3 VCEXT Condition IOL = 4 mA V=0 90 Min Max 0.5 280 0.3 VCEXT Unit V A V V V V V V pF
VCEXT is the voltage at CEXT1, CEXT2.
77
3313D-USB-04/06
Table 17. Oscillator Signals: XTAL1, XTAL2
Symbol VLH VHL CX1 CX2 C12 tSU DL Note: Parameter OSC1 switching level OSC1 switching level Input capacitance, XTAL1 Output capacitance, XTAL2 OSC1/2 capacitance Start-up time Drive level XTAL2 must not be used to drive other circuitry. 6 MHz, fundamental Condition Min 0.47 0.67 Max 1.20 1.44 10 10 5 2 50 Unit V V pF pF pF ms W
Table 18. USB Driver Characteristics, Full-speed Operation
Symbol TR TF TRFM ZDRV Note: Parameter Rise time Fall time TR/TF matching Driver output resistance
(1)
Condition CL = 50 pF CL = 50 pF
Min 4 4 90
Max 20 20 110 44
Unit ns ns %
Steady state drive
28
1. With external 27 series resistor.
Figure 13. Full-speed Load
RS TxD+ CL
RS TxDCL
CL = 50 pF
78
AT43USB326
3313D-USB-04/06
AT43USB326
Table 19. USB Driver Characteristics, Low-speed Operation
Symbol TR TF TRFM Parameter Rise time Fall time TR/TF matching Condition CL = 200 - 600 pF CL = 200 - 600 pF Min 75 75 80 Max 300 300 125 Unit ns ns %
Figure 14. Low-speed Downstream Port Load
RS TxD+ CL 3.6V
1.5 K Ohm RS TxDCL
CL = 200 pF to 600 pF
Table 20. USB Source Timings, Full-speed Operation
Symbol TDRATE TFRAME TRFI TRFIADJ TDJ1 TDJ2 TFDEOP TDEOP TJR1 TJR2 TFEOPT TFEOPR TFST Note: Parameter Full Speed Data Rate Frame Interval
(1) (1)
Condition Average Bit Rate
Min 11.97 0.9995
Max 12.03 1.0005 42 126
Unit Mb/s ms ns ns ns
Consecutive Frame Interval Jitter(1) Consecutive Frame Interval Jitter Source Diff Driver Jitter To Next Transition For Paired Transitions Source Jitter for Differential Transition to SEO Transitions Differential to EOP Transition Skew Receiver Data Jitter Tolerance To Next Transition For Paired Transitions Source SEO interval of EOP Receiver SEO interval of EOP Width of SEO interval during differential transition 1. With 6.000 MHz, 100 ppm crystal.
(1)
No clock adjustment With clock adjustment -2 -1 -2 -2 -18.5 -9 160 82
2 1 5 5 18.5 9 175
ns ns ns ns ns
14
ns
79
3313D-USB-04/06
Figure 15. Differential Data Jitter
TPERIOD
Differential Data Lines
Crossover Points Consecutive Transitions N*TPERIOD + TXJR1 Paired Transitions N*TPERIOD + TXJR2
Figure 16. Differential-to-EOP Transition Skew and EOP Width
TPERIOD
Crossover Point Extended
Differential Data Lines
Diff. Data-toSE0 Skew
N*TPERIOD + TDEOP
Source EOP Width: TFEOPT
T LEOPT
Receiver EOP Width: TFEOPR
T LEOPR
Figure 17. Receiver Jitter Tolerance
TPERIOD Differential Data Lines TJR Consecutive Transitions N*TPERIOD + TJR1 Consecutive Transitions N*TPERIOD + TJR1 TJR1 TJR2
80
AT43USB326
3313D-USB-04/06
AT43USB326
Table 21. Hub Timings, Full-speed Operation
Symbol THDD2 THDJ1 THDJ2 TFSOP TFEOPD TFHESK Parameter Hub Differential Data Delay without cable Hub Diff Driver Jitter to Next Transition for Paired Transitions Data Bit Width Distortion after SOP Hub EOP Delay Relative to THDD Hub EOP Output Width Skew -3 -1 -5 0 -15 Condition Min Max 44 3 1 5 15 15 Unit ns
ns
ns ns ns
Table 22. Hub Timings, Low-speed Operation
Symbol TLHDD TLHDJ1 TLHDJ2 TLUHJ1 TLUHJ2 TSOP TLEOPD TLHESK Parameter Hub Differential Data Delay Downstr Hub Diff Driver Jitter to Next Transition, downst for Paired Transitions, downst to Next Transition, upstr for Paired Transitions, upstr Data Bit Width Distortion after SOP Hub EOP Delay Relative to THDD Hub EOP Output Width Skew -45 -15 -45 -45 -60 0 -300 Condition Min Max 300 45 15 45 45 60 200 300 Unit ns
ns
ns ns ns
81
3313D-USB-04/06
Table 23. Hub Event Timings
Symbol TDCNN Parameter Time to detect a downstream port connect event Time to detect a disconnect event on downstream port Awake Hub Suspended Hub Time from detecting downstream resume to rebroadcast Duration of driving reset to a downstream device Time to evaluate device speed after reset Time to detect a long K from upstream Time to detect a long SEO from upstream Duration of repeating SEO upstream Duration of sending SEO upstream after EOF1 Only for a SetPortFeature (PORT_RESET) request 10 2.5 2.5 2.5 Condition Min 2.5 Max 2000 Unit s
TDDIS
2.5 2.5
2000 12000
s
TURSM
100
s
TDRST TDSPDEV TURLK TURLSEO TURPSEO TUDEOP
20 1000 5.5 5.5 23 2
s s s s FS bits FS bits
82
AT43USB326
3313D-USB-04/06
AT43USB326
Figure 18. Hub Differential Delay, Differential Jitter and SOP Distortion
Upstream End of Cable VSS Differential Data Lines VSS A. Downstream Hub Delay With Cable Downstream Port VSS Crossover Point Upstream Port VSS Hub Delay Upstream THDD2 Crossover Point Crossover Point
50% Point of Initial Swing Hub Delay Downstream THDD1
B. Upstream Hub Delay Without Cable
Downstream Port VSS Upstream Port or End of Cable VSS
Crossover Point
Hub Delay Upstream THDD1,THDD2
Crossover Point
C. Upstream Hub Delay with or without Cable
Figure 19. Hub EOP Delay and EOP Skew
50% Point of Initial Swing Upstream End of Cable VSS Downstream Port VSS A. Upstream EOP Delay with Cable TEOPTEOP+ Upstream Port VSS Downstream Port VSS B. Downstream EOP Delay without Cable TEOPTEOP+ Crossover
Point Extended Crossover Point Extended
Downstream Port VSS Upstream Port or End of Cable VSS TEOP
Crossover Point Extended
TEOP+
Crossover Point Extended
C. Upstream EOP Delay with or without Cable
83
3313D-USB-04/06
Typical Application
The Atmel sample version of the AT43USB326 contains firmware that supports customization of the Vendor ID, Product ID, String Descriptor and the keyboard matrix. This information is stored in an external AT24C02A serial EEPROM. Data in the EEPROM is stored in the following format:
Address Range 0x00 - 0x01 0x02 - 0x03 0x04 onwards 0x70 - 0xFF Content EEPROM's signature Mask Bits VID, PID and strings Initial Check Byte Keyboard matrix
Detailed Description
Address Location 0x00 0x01 Value/Content 0x17 0x5A
Mask Bits
The mask bits identify what features are stored in the EEPROM. A "1" in the mask bit location means that the feature is stored and should be read. A "0" means that the feature is not stored and should not be read.
Address Location 0x02 0x03
Remark Mask 2 - Reserved for Future Use Mask 1
Bit 0: VID, PID, Version
Bit 1: Language String
Bit 2: Manufacturer String
Bit 3: Product String
Bit 4: Serial Number String
Bit 5: Extra Hot Key Codes
Bit 6: Reserved
Bit 7: Keyboard Matrix
84
AT43USB326
3313D-USB-04/06
AT43USB326
Address locations 0x04 through 0x6E store the VID, PID, Release Number and String Descriptors if they are enabled by the mask bits in location 0x03. The data are stored sequentially as described below: Table 24. VID and PID
VID Byte 1 VID Byte 2 PID Byte 1 PID Byte 2 Release # Byte 1 Release # Byte 2 Check Byte
Table 25. Language ID and Strings
Length (N) Byte 1 Byte 2 Byte N - 1 Check Byte
Initial Check Byte Keyboard Matrix
This check byte is located immediately after the last VID, PID or stings. It is computed as the truncated sum of Mask1 and all the string length specified. The keyboard matrix is 144 bytes. If specified, its check byte is located in address 0x6F while the matrix itself is located from address 0x70 - 0xFF. 0x70 = Col 0, Row 0 0x71 = Col 0, Row 1 ....... 0x78 = Col 1, Row 0 0x79 = Col 1, Row 1 ..... 0xF8 = Col 17, Row 0 0xF9 = Col 17, Row 1 ..... 0xFF = Col 17, Row 7
Example of SEEPROM Data
Table 26 through Table 34 illustrate the contents of a SEEPROM for a typical AT43USB326based keyboard. Table 26. Preamble
Address 00 01 02 03 Data 17 5A 00 BF Description Fixed ID Fixed ID Reserved Mask bits
85
3313D-USB-04/06
The mask bits in location 03 are used to indicate whether a particular function is supported or not. 0 = Function not supported 1 = Function supported Bit 7 = Keyboard matrix Bit 6 = Reserved. Must be set to 0 Bit 5 = Extra Hot Key USB codes Bit 4 = Serial Number String Bit 3 = Product String Bit 2 = Manufacturer String Bit 1 = Language ID String Bit 0 = VendorID, ProductID, Version Table 27. Vendor ID, Product ID, Version Number
Address 04 05 06 07 08 09 0A Data 5E 04 1D 00 11 01 91 Description Vendor ID Vendor ID Product ID Product ID Version number Version number Checksum
Table 28. Language ID
Address 0B 0C 0D 0E 0F Data 04 03 09 10 20 Description Number of bytes The next 3 bytes specifies the Language ID - - Checksum
86
AT43USB326
3313D-USB-04/06
AT43USB326
Table 29. Manufacturer String
Address 10 11 12 13 14 15 16 17 18 19 1A 1B 1C Data 0C 03 41 00 74 00 6D 00 65 00 6C 00 02 Description Number of bytes, 2 bytes per character - A - t - m - e - l - Checksum
Table 30. Product String
Address 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C Data 12 03 4D 00 4D 00 4B 00 42 00 44 00 48 00 55 00 Description Number of bytes - M - M - K - B - D - H - U -
87
3313D-USB-04/06
Table 30. Product String (Continued)
Address 2D 2E 2F Data 42 00 5F Description B - Checksum
Table 31. Serial Number String
Address 30 31 32 33 34 35 36 37 38 Data 08 03 31 00 32 00 33 00 A1 Description Number of bytes - 1 - 2 - 3 - Checksum
Table 32. Extra Hot Keys
Address 39 3A 3B 3C 3D 3E 3F 40 Data 07 D0 23 02 D1 8A 01 58 Description Number of bytes KB matrix code First byte sent to host Second byte sent to host KB matrix code First byte sent to host Second byte sent to host Checksum
88
AT43USB326
3313D-USB-04/06
AT43USB326
Table 33. Miscellaneous Data
Address 41 Data F0 Description Checksum of Mask Byte + bytes in Language ID + bytes in Manuf String + bytes in Product String + bytes in Serial Number + bytes in extra hot keys (BF + 04 + 0C + 12 + 08 + 07 = F0) Don't cares. May be written with 0's Checksum of keyboard matrix codes
42 through 6E 6F
- 2D
Table 34. Keyboard Matrix
Address 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 80 81 82 83 84 85 86 87 88 Data 28 31 50 3F 30 3E 2A 2E 36 07 06 25 0E 20 08 0C 63 5E 5B 3D 61 3C 4C 49 37 KB Row 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 KB Col 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 Description KB Enter KB \ Left Arrow F6 ] F5 Backspace = Comma D C KB 8 K KB 3 E I KP Period KP 6 KP 3 F4 KP 9 F3 Delete Insert Period
89
3313D-USB-04/06
Table 34. Keyboard Matrix (Continued)
Address 89 8A 8B 8C 8D 8E 8F 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC Data 2F 0F 41 12 40 2D 26 05 0A 19 22 09 21 17 15 13 34 38 43 33 42 51 27 10 0D 11 24 0B 23 18 1C 68 69 6A 2C 78 KB Row 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 KB Col 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 7 7 7 7 7 Space Description [ L F8 O F7 9 B G V 5 F 4 T R P Quote / F10 ; F9 Down Arrow 0 M J N 7 H 6 U Y
90
AT43USB326
3313D-USB-04/06
AT43USB326
Table 34. Keyboard Matrix (Continued)
Address AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF D0 Data 4F E7 52 62 5D 5A 45 60 44 4D 4A 59 5C 57 65 5F 46 55 54 1B 1A 16 3B 1F 3A 4E 4B E4 6B D5 D4 E0 C0 39 D6 1D KB Row 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 KB Col 7 7 7 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 11 11 11 11 11 11 11 11 12 HK Calculator HK Media Left CTRL HK Suspend Caps Lock HK My Comp Z Description Right Arrow Right GUI Up Arrow KP 0 KP 5 KP 2 F12 KP 8 F11 End Home KP 1 KP 4 KP + Application KP 7 Print Screen KP * KP / X W S F2 2 F1 Page Down Page Up Right Ctrl
91
3313D-USB-04/06
Table 34. Keyboard Matrix (Continued)
Address D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF F0 F1 F2 F3 F4 Data 04 6D 35 14 29 2B 1E 6E C9 70 71 B0 72 73 74 E5 C8 C1 C2 E1 48 C4 C3 D7 E2 E6 53 DF 56 D9 D8 DD 74 DE 58 DC KB Row 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 KB Col 12 12 12 12 12 12 12 13 13 13 13 13 13 13 13 14 14 14 14 14 14 14 14 15 15 15 15 15 15 15 15 16 16 16 16 16 HK Refresh KP Enter HK Forward Right Shift HK Vol Increment HK Play/Pause HK Scan Next Left Shift Pause HK Stop HK Scan Previous HK WWW Left Alt Right Alt KP Num Lock HK Bookmark KP HK Search HK Email HK AC Stop HK Mute HK Vol Decrement ~ Q Escape Tab 1 Description A
92
AT43USB326
3313D-USB-04/06
AT43USB326
Table 34. Keyboard Matrix (Continued)
Address F5 F6 F7 F8 F9 FA FB FC FD FE FF Data 47 DB E3 00 00 00 00 00 00 00 00 KB Row 5 6 7 0 1 2 3 4 5 6 7 KB Col 16 16 16 17 17 17 17 17 17 17 17 Description Scroll Lock HK Back Left GUI
93
3313D-USB-04/06
Example Schematics
6
1
U1
VCC TEST
7
41
48
CEXT2
CEXT1
RESETN
15K
15K
15K
AT43USB326_AC
R10 R9
R11
XTAL2 R1 100 3 C2 0.01 UF C1 0.22 UF D3 D2 Scroll Lock Cap Lock D1 Num Lock VBUS LFT
Y1 6.000 MHz 5
C12 47 pF
C14 47 pF
C16 47 pF
R12
XTAL1
4
15K
VSS1
VSS2
2
R13
R15 15K
R16 15K
1 2 3 4 PE4 SCANO 13
A0 A1 A2 GND
VCC WP SSCL SDA AT24C02A
The following two pages show a schematic diagram of an AT43USB326 keyboard with an embedded hub and its BOM.
8 7 6 5
R14
U2
15K
15K
CEXT1
40
94
VBUS FB C3 2.2 UF CEXT1 + FB L2 C4 0.1 UF C6 0.33 UF R8 1.5 K R2 27 L3 R3 27 R4 27 R5 27 R6 27 + C11 47 pF C13 47 pF C15 47 pF R7 27 C7 220 UF L5 FB J3 4 3 2 1 L6 + C8 220 UF FB USB-A L4 FB FB C5 4.7 UF L1 J1 USB-B 1 2 3 4 C9 0.1 UF DM0 DP0 DM2 DP2 DM3 DP3 43 42 45 44 47 46 J2 1 2 3 4 C10 0.1 UF 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 PA0 PA1 PA2 PA3 PA4 PA5 PA6 PA7 PB0 PB1 PB2 PB3 PB4 PB5 PB6 PB7 PE0 PE1 USB-A 37 36 35 34 33 32 31 30 PC0 PC1 PC2 PC3 PC4 PC5 PC6 PC7 PE5 PE6 PE7 PE4 PE4 7 5 PD1 PD0 38 CEXT1 MIC2549A-2BM 39 1 2 9 10 11 8 R18 100K U3 IN IN CTL FLG OUT OUT ILIM GND 6 8 4 3 R17 100 SCANO 17 SCANO 16
AT43USB326
SCAN OUTPUTS
SCANO_0 SCANO_1 SCANO_2 SCANO_3 SCANO_4 SCANO_5 SCANO_6 SCANO_7 SCANO_8 SCANO_9 SCANO_10 SCANO_11 SCANO_12 SCANO_13 SCANO_14 SCANO_15 SCANO_16 SCANO_17
SCANI_0 SCANI_1 SCANI_2 SCANI_3 SCANI_4 SCANI_5 SCANI_6 SCANI_7
SCAN INPUTS
3313D-USB-04/06
AT43USB326
Table 35. AT43USB326 Keyboard/Hub Bill of Materials - May 2, 2002
Item 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Qty 1 1 3 1 1 1 2 6 1 2 3 6 1 6 1 8 1 1 1 1 Reference C1 C2 C4,C9,C10 C5 C3 C6 C8, C7 C11, C12, C13, C14, C15, C16 J1 J2, J3 D1, D2, D3 L1, L2, L3, L4, L5, L6 R1, R17 R2, R3, R4, R5, R6, R7 R8 R9, R10, R11, R12, R13, R14, R15, R16 R18 U1 U3 Y1 Part 0.22 UF, cer, Kemet(R) C1812C224K5RAC 0.01 UF, cer, Kemet C0805C103K5RAC 0.1 UF, cer, Kemet C1206C104M5UAC 4.7UF, el, Panasonic(R) ECE-V1ES4R7SR 2.2 UF, cer, Panasonic ECJ-2YF1C225Z 0.33 UF, cer, Kemet C1210C334M5UAC 100 UFD, el, Panasonic ECE-V1AA101SP 47 pF, cer, Kemet C1206C470J5GACTR USB-B, series B connector USB-A, series A connector LED, green Ferrite bead, Stewart HI 1806 N 750 R 100, Panasonic ERJ-GEYJ100 27, Panasonic ERJ-GEYJ27 1.5K, Panasonic ERJ-GEYJ1.5K 15K, Panasonic ERJ-GEYJ15K 100K, Panasonic ERJ-GEYJ100K AT43USB326-AC MIC2549A-2BM 6.000 MHz crystal, CTS ATS060SM-T Supplier Newark(R) 99F6389 Newark 93F2330 Newark 89F5966 Digikey(R) PCE3065CT-ND Digikey PCC1851TR-ND Newark Digikey PCE3176CT-ND Newark 93F2371 AMP 787780-1 AMP 787616-1 Jameco(R) 34606, XC2 Digikey 240-1-11-1-ND Digikey P-100-ACT-ND Digikey P-27-ACT-N Digikey P-1.5K-ACT-ND Digikey P-15K-ACT-ND Digikey P-100K-ACT-ND Atmel Micrel Digikey CTX505CT-ND
95
3313D-USB-04/06
Ordering Information
Ordering Code AT43USB326-AC AT43USB326-AU Package 48 LQFP 48 LQFP Operation Range Commercial (0C to 70C) Green, Industrial (-40C to +85C)
96
AT43USB326
3313D-USB-04/06
AT43USB326
Packaging Information
48AA - LQFP
PIN 1 B
PIN 1 IDENTIFIER
e
E1
E
D1 D C
0~7 A1 L
COMMON DIMENSIONS (Unit of Measure = mm) SYMBOL A A1 A2 D D1 E MIN - 0.05 1.35 8.75 6.90 8.75 6.90 0.17 0.09 0.45 NOM - - 1.40 9.00 7.00 9.00 7.00 - - - 0.50 TYP MAX 1.60 0.15 1.45 9.25 7.10 9.25 7.10 0.27 0.20 0.75 Note 2 Note 2 NOTE
A2
A
Notes:
1. This package conforms to JEDEC reference MS-026, Variation BBC. 2. Dimensions D1 and E1 do not include mold protrusion. Allowable protrusion is 0.25 mm per side. Dimensions D1 and E1 are maximum plastic body size dimensions including mold mismatch. 3. Lead coplanarity is 0.08 mm maximum.
E1 B C L e
10/5/2001 2325 Orchard Parkway San Jose, CA 95131 TITLE 48AA, 48-lead, 7 x 7 mm Body Size, 1.4 mm Body Thickness, 0.5 mm Lead Pitch, Low Profile Plastic Quad Flat Package (LQFP) DRAWING NO. 48AA REV. C
R
97
3313D-USB-04/06
Errata Sheet
Problem
Errata (All Date Codes): Missed Watchdog Timer Reset There is a synchronization problem between the watchdog clock and the AVR clock. Even though the clock inputs to both the watchdog timer and the AVR core are generated through the same crystal, the two clock sources are not going through the same PLL. The AVR is clocked at 12 MHz and the watchdog timer is clocked at 1MHz. The WDR (Watchdog Reset) instruction is a one-clock-cycle instruction. As such, when a watchdog timer reset occurs due to a WDR, the watchdog timer may miss the reset. This happens frequently if the AVR is clocked much faster than the watchdog timer. A workaround is to invoke the WDR repetitively to ensure that the watchdog timer will be able to receive the reset signal. If the AVR runs at 12 MHz, the WDR command must be invoked fourteen times back to back. The following is the sample code for resetting and arming the watchdog timer, assuming the AVR is running at 12 MHz:
asm ( "ldi r16,15\n WDR\n WDR\n WDR\n WDR\n WDR\n WDR\n WDR\n WDR\n WDR\n WDR\n WDR\n WDR\n WDR\n out 0x21,r16 " );
Fix/Workaround
To disarm and disable the watchdog, do the following:
asm ( "ldi r16,0x18\nldi r17,0x10\n\n out 0x21,r16\n out 0x21,r17 " );
Please note that if the AVR runs at 24 MHz, the WDR should be invoked twenty-six times.
98
AT43USB326
3313D-USB-04/06
AT43USB326
Revision History
Doc. Rev. Comments
*
3313B
Missing Data Correction: Inserted the section "Watchdog Timer" on page 39. Additions: Added an "Errata Sheet" on page 98, a "Revision History" on page 99, and a "Table of Contents" on page i. Data Correction: Corrected references to part number AT43USB325 to AT43USB326 in the section "Watchdog Timer" on page 39 and on "Example Schematics" on page 94. Additions: Added AT43USB326-AU part number to Ordering Information.
* *
3313C
3313D
*
99
3313D-USB-04/06
AT43USB326
Table of Contents
Features................................................................................................ 1 Description ........................................................................................... 1
Pin Configuration .................................................................................................. 2 Pin Assignment..................................................................................................... 3 Signal Description................................................................................................. 4
Architectural Overview........................................................................ 6 The General-purpose Register File .................................................... 7
X-, Y- and Z- Registers ......................................................................................... 8 ALU - Arithmetic Logic Unit.................................................................................. 8 Program Memory .................................................................................................. 8 SRAM Data Memory............................................................................................. 9 I/O Memory ......................................................................................................... 14 USB Hub............................................................................................................. 15
Functional Description...................................................................... 17
On-chip Power Supply ........................................................................................ I/O Pin Characteristics ........................................................................................ Oscillator and PLL .............................................................................................. Reset and Interrupt Handling.............................................................................. Reset Sources .................................................................................................... Power-on Reset .................................................................................................. External Reset .................................................................................................... Watchdog Timer Reset ....................................................................................... Non-USB Related Interrupt Handling.................................................................. External Interrupts .............................................................................................. Interrupt Response Time .................................................................................... USB Interrupt Sources........................................................................................ USB Endpoint Interrupt Sources......................................................................... 17 17 17 18 20 21 22 22 22 26 26 28 29
AVR Register Set ............................................................................... 34
Status Register and Stack Pointer...................................................................... 34 Sleep Modes....................................................................................................... 35
Timer/Counter .................................................................................... 36
Timer/Counter Prescaler..................................................................................... 36 8-bit Timer/Counter0........................................................................................... 37 Watchdog Timer ................................................................................................. 39
I/O Ports.............................................................................................. 40
Port A.................................................................................................................. Port B.................................................................................................................. Port C.................................................................................................................. Port D.................................................................................................................. 41 42 43 44
i
3313D-USB-04/06
Port E.................................................................................................................. 45
Programming the USB Module......................................................... 46
The USB Function .............................................................................................. USB Registers .................................................................................................... Endpoint Registers ............................................................................................. USB Hub............................................................................................................. Suspend and Resume ........................................................................................ 46 53 54 62 72
Electrical Specification ..................................................................... 76
Absolute Maximum Ratings ................................................................................ 76 DC Characteristics.............................................................................................. 76
Typical Application............................................................................ 84
Detailed Description............................................................................................ Initial Check Byte ................................................................................................ Keyboard Matrix.................................................................................................. Example of SEEPROM Data .............................................................................. Example Schematics .......................................................................................... 84 85 85 85 94
Ordering Information......................................................................... 96 Packaging Information ...................................................................... 97
48AA - LQFP ..................................................................................................... 97
Errata Sheet........................................................................................ 98
Problem .............................................................................................................. 98 Fix/Workaround .................................................................................................. 98
Revision History ................................................................................ 99 Table of Contents ................................................................................. i
ii
AT43USB326
3313D-USB-04/06
Atmel Corporation
2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 487-2600
Atmel Operations
Memory
2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 436-4314
RF/Automotive
Theresienstrasse 2 Postfach 3535 74025 Heilbronn, Germany Tel: (49) 71-31-67-0 Fax: (49) 71-31-67-2340 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906, USA Tel: 1(719) 576-3300 Fax: 1(719) 540-1759
Regional Headquarters
Europe
Atmel Sarl Route des Arsenaux 41 Case Postale 80 CH-1705 Fribourg Switzerland Tel: (41) 26-426-5555 Fax: (41) 26-426-5500
Microcontrollers
2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 436-4314 La Chantrerie BP 70602 44306 Nantes Cedex 3, France Tel: (33) 2-40-18-18-18 Fax: (33) 2-40-18-19-60
Biometrics/Imaging/Hi-Rel MPU/ High-Speed Converters/RF Datacom
Avenue de Rochepleine BP 123 38521 Saint-Egreve Cedex, France Tel: (33) 4-76-58-30-00 Fax: (33) 4-76-58-34-80
Asia
Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimshatsui East Kowloon Hong Kong Tel: (852) 2721-9778 Fax: (852) 2722-1369
ASIC/ASSP/Smart Cards
Zone Industrielle 13106 Rousset Cedex, France Tel: (33) 4-42-53-60-00 Fax: (33) 4-42-53-60-01 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906, USA Tel: 1(719) 576-3300 Fax: 1(719) 540-1759 Scottish Enterprise Technology Park Maxwell Building East Kilbride G75 0QR, Scotland Tel: (44) 1355-803-000 Fax: (44) 1355-242-743
Japan
9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chuo-ku, Tokyo 104-0033 Japan Tel: (81) 3-3523-3551 Fax: (81) 3-3523-7581
Literature Requests
www.atmel.com/literature
Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN ATMEL'S TERMS AND CONDITIONS OF SALE LOCATED ON ATMEL'S WEB SITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and product descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel's products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.
(c) Atmel Corporation 2006. All rights reserved. Atmel(R), logo and combinations thereof, Everywhere You Are (R), AVR (R) and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others.
Printed on recycled paper.
3313D-USB-04/06


▲Up To Search▲   

 
Price & Availability of AT43USB326-AC

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X