ETC GL602USB

Your Imagination, Our Creation
GL602USB
GL602USB-A
USB KEYBOARD
MICROCONTROLLER
SPECIFICATION 1.6
Feb. 28, 2001
Genesys Logic, Inc.
10F, No.11, Ln.3, Tsao Ti Wei, Shenkeng, Taipei, Taiwan
Tel: +886-2-2664-6655
Fax: +886-2-2664-5757
http://www.genesyslogic.com/
Index
1
FEATURES............................................................................................................4
2
FUNCTIONAL OVERVIEW...............................................................................5
3
PIN DEFINITIONS AND DESCRIPTIONS ......................................................6
3.1
3.2
4
FUNCTIONAL DESCRIPTION .........................................................................9
4.1
4.2
4.3
4.4
4.5
4.6
4.7
5
GL602USB ...............................................................................................................................6
GL602USB-A...........................................................................................................................7
MEMORY ORGANIZATION .................................................................................................9
USB FUNCTION REGISTERS .............................................................................................11
MCU FUNCTION REGISTERS............................................................................................16
GENERAL PURPOSE I/O PORTS .......................................................................................18
TIMER INTERRUPT .............................................................................................................18
USB ENGINE.........................................................................................................................19
INSTRUCTION SET SUMMARY ........................................................................................21
Firmware Programming Guide..........................................................................23
5.1
5.2
5.3
5.4
5.5
5.6
5.7
5.8
5.9
5.10
5.11
5.12
USB Power On Reset and Bus Reset Initialization.................................................................23
Suspend/Resume/Wakeup ......................................................................................................24
Receive Packet via Endpoint 0 ...............................................................................................25
Transmit Packet via Endpoint 0..............................................................................................26
Transmit Packet via Endpoint 1/2/3........................................................................................27
Timer Interrupt .......................................................................................................................28
Conditional Branch.................................................................................................................28
Change Register Bank ............................................................................................................28
Change Code Bank .................................................................................................................28
Receive Data from PS/2 Mouse Port ......................................................................................29
Scan Key Matrix .....................................................................................................................30
Turn LED On/Off ...................................................................................................................30
6
ABSOLUTE MAXIMUM RATINGS................................................................31
7
ELECTRICAL CHARACTERISTICS.............................................................31
8
PACKAGE DIAGRAMS ....................................................................................33
8.1
8.2
40-pin P-DIP...........................................................................................................................33
24-pin SOP .............................................................................................................................34
Revision 1.6
-2-
02/28/2000
Figures
Figure 3-1 40-pin DIP (GL602USB) ........................................................................... 7
Figure 3-2 24-pin SOP (GL602USB-A) ...................................................................... 8
Figure 4-1 Program Memory Space............................................................................. 9
Figure 4-2 Data Memory Space ................................................................................. 10
Figure 4-3 Differential Input Sensitivity over Entire Common Mode Range ........... 20
Figure 4-4 Receiver Jitter Tolerance.......................................................................... 20
Figure 4-5 Data Signal Rise and Fall Time................................................................ 21
Figure 7-3 Package outline dimension for 40-pin P-DIP........................................... 33
Figure 7-4 Package outline dimension for 24-pin SOP ............................................. 35
Tables
Table 3-1 GL602USB Pin Definitions and Descriptions............................................. 6
Table 3-2 GL602USB-A Pin Definitions and Descriptions......................................... 7
Table 4-1 USB Function Register Summary ............................................................. 11
Table 4-2 MCU Function Register Summary ............................................................ 16
Revision 1.6
-3-
02/28/2000
1. FEATURES
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Low-cost solution for low-speed USB keyboard
8-bit micro-controller
− Operation Speed: 6MHz clock input
− Performance: 3 MIPS @ 6MHz
− Single cycle instruction execution
− RISC-like architecture
− USB optimized instruction set
USB Specification Compliance
− Conforms to USB 12Mbps Specification, Version 1.1
− Conforms to USB HID Class Specification, Version 1.1
− Supports 1 device address and 4 endpoints (include endpoint 0)
I/O ports
− Up to 7(GL602USB)/5(GL602USB-A) general purpose I/O pins (OTP type is less a GPIO pin than mask
type).
− Up to 8 sense pins and 1 I/O pin with remote wakeup capability
− Up to 18(GL602USB)/8(GL602USB-A) output pins optimized for key matrix drive pin
− Up to 8(GL602USB)/4(GL602USB-A) output pins optimized for key matrix sense pin
− Up to 3(GL602USB)/1(GL602USB-A) I/O pins with LED drive capability
Internal memory
− 96 bytes of RAM
− 4K x 14 of program ROM
On-chip 3.3v output
− No external regulator required
Improved output drivers with slew-rate control to reduce EMI
6 MHz external clock
Internal power-on reset (POR)
Internal power-fail detector
Supports suspend/normal mode power management
− Suspend current lower than 400µA for the whole keyboard system (mask type)
8-bit free-running timer
Available in cost saving 40-pin(GL602USB) PDIP, 24-pin(GL602USB-A) SOP
Support a PS/2 mouse to USB mouse converter in the default firmware.
Revision 1.6
-4-
02/28/2000
2. FUNCTIONAL OVERVIEW
The GL602USB is an 8-bit RISC-like high performance microcontroller with a built-in 1.5Mbps SIE and
transceiver. The microcontroller features 33 instructions optimized for USB keyboard. There are 96 bytes onchip RAM and 4K x 14 bits program ROM incorporated into the micro-controller. The micro-controller features
18 output pins and 8 input pins to make a 18 x 8 key matrix. Additionally, 3 GPIO pins are strong enough to
drive LEDs. 4 GPIO pins can be used by any function, for example, support a PS/2 3D mouse to USB 3D mouse
converter in the default firmware. Legacy USB cable can be used for keyboard in USB mode. All GPIO ports
feature low EMI emissions as a result of improved output drivers with slew-rate control.
Revision 1.6
-5-
02/28/2000
3. PIN DEFINITIONS AND DESCRIPTIONS
3.1 GL602USB
Table 3-1 GL602USB Pin Definitions and Descriptions
Name
I/O
Description
GND
Ground
V3.3
O
3.3V output
D+
I/O
USB data+
DI/O
USB dataDRV1
O
Key matrix output drive 1, open drain output
DRV2
O
Key matrix output drive 2, open drain output
P1.1/MOUSE CLK
I/O
Port 1 bit 1 / PS2 mouse clock input
P1.2/MOUSE DATA
I/O
Port 1 bit 2 / PS2 mouse data input
P1.3/VPP
I/O
Port 1 bit 3 (for mask) / 12.75V programming power
(for OTP)
10
P1.4/PWRCTL
I/O
Port 1 bit 4 / PS2 mouse power control
11
DRV3
O
Key matrix output drive 3, open drain output
12
DRV4
O
Key matrix output drive 4, open drain output
13
DRV5
O
Key matrix output drive 5, open drain output
14
DRV6
O
Key matrix output drive 6, open drain output
15
DRV7
O
Key matrix output drive 7, open drain output
16
DRV8
O
Key matrix output drive 8, open drain output
17
DRV9
O
Key matrix output drive 9, open drain output
18
DRV10
O
Key matrix output drive 10, open drain output
19
DRV11
O
Key matrix output drive 11, open drain output
20
DRV12
O
Key matrix output drive 12, open drain output
21
DRV13
O
Key matrix output drive 13, open drain output
22
DRV14
O
Key matrix output drive 14, open drain output
23
DRV15
O
Key matrix output drive 15, open drain output
24
DRV16
O
Key matrix output drive 16, open drain output
25
DRV17
O
Key matrix output drive 17, open drain output
26
DRV18
O
Key matrix output drive 18, open drain output
27
SENSE1
I
Key matrix input sense 1, internal pull up 10K
28
SENSE2
I
Key matrix input sense 2, internal pull up 10K
29
SENSE3
I
Key matrix input sense 3, internal pull up 10K
30
SENSE4
I
Key matrix input sense 4, internal pull up 10K
31
SENSE5
I
Key matrix input sense 5, internal pull up 10K
32
SENSE6
I
Key matrix input sense 6, internal pull up 10K
33
SENSE7
I
Key matrix input sense 7, internal pull up 10K
34
SENSE8
I
Key matrix input sense 8, internal pull up 10K
35
P1.5/NUMLOCK
I/O
Port 1 bit 5/number lock indicator, internal pull up
36
P1.6/CAPSLOCK
I/O
Port 1 bit 6/caps lock indicator, internal pull up
37
P1.7/SCROLLLOCK
I/O
Port 1 bit 7/scroll lock indicator, internal pull up
38
VDD
Voltage supply
39
XTAL1
O
Ceramic resonator or crystal out
40
XTAL2
I
Ceramic resonator or crystal in
Note 1: Name or description after “/” means default function specified by Genesys Logic firmware
Pin No.
1
2
3
4
5
6
7
8
9
Revision 1.6
-6-
02/28/2000
GND
V3.3
D+
DDRV1
DRV2
P1.1/MOUST CLK
P1.2/MOUSE DATA
P1.3
P1.4/PWRCTL
DRV3
DRV4
DRV5
DRV6
DRV7
DRV8
DRV9
DRV10
DRV11
DRV12
1
40
39
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
XTAL2
XTAL1
VDD
P1.7SCROLOCK
P1.6/CAPSLOCK
P1.5/NUMLOCK
SENSE8
SENSE7
SENSE6
SENSE5
SENSE4
SENSE3
SENSE2
SENSE1
DRV18
DRV17
DRV16
DRV15
DRV14
DRV13
Figure 3-1 40-pin DIP (GL602USB)
3.2 GL602USB-A
Pin No.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Revision 1.6
Table 3-2 GL602USB-A Pin Definitions and Descriptions
Name
I/O
Description
GND
Ground
V3.3
O
3.3V output
D+
I/O
USB data+
DI/O
USB dataP1.1/MOUSE CLK
I/O
Port 1 bit 1/PS2 mouse clock input
P1.2/MOUSE DATA
I/O
Port 1 bit 2/PS2 mouse data input
P1.3/VPP
I/O
Port 1 bit 3 (for mask) / 12.75V programming power
(for OTP)
P1.4/PWRCTL
I/O
Port 1 bit 4 / PS2 mouse power control
DRV7
O
Key matrix output drive 7, open drain output
DRV8
O
Key matrix output drive 8, open drain output
DRV10
O
Key matrix output drive 10, open drain output
DRV12
O
Key matrix output drive 12, open drain output
DRV13
O
Key matrix output drive 13, open drain output
DRV15
O
Key matrix output drive 15, open drain output
DRV16
O
Key matrix output drive 16, open drain output
DRV17
O
Key matrix output drive 17, open drain output
SENSE1
I
Key matrix input sense 1, internal pull up 10K
SENSE3
I
Key matrix input sense 3, internal pull up 10K
SENSE6
I
Key matrix input sense 6, internal pull up 10K
SENSE8
I
Key matrix input sense 8, internal pull up 10K
P1.7/LED
I/O
Port 1 bit 7/LED indicator
VDD
Voltage supply
XTAL1
O
Ceramic resonator or crystal out
XTAL2
I
Ceramic resonator or crystal in
-7-
02/28/2000
Note 1: Name or description after “/” means default function specified by Genesys Logic firmware
GND
1
V3.3
2
3
4
D+
D-
DRV10
5
6
7
8
9
10
11
DRV12
12
P1.1/MOUSE CLK
P1.2/MOUSE DATA
P1.3/VPP
P1.4/PWRCTL
DRV7
DRV8
24
23
22
21
XTAL2
20
19
18
17
16
15
14
13
SENSE8
XTAL1
VDD
P1.7/LED
SENSE6
SENSE3
SENSE1
DRV17
DRV16
DRV15
DRV13
Figure 3-2 24-pin SOP (GL602USB-A)
Revision 1.6
-8-
02/28/2000
4. FUNCTIONAL DESCRIPTION
The Genesys Logic GL602USB micro-controller is optimized for PC keyboard. This USB microcontroller
conforms to the low-speed (1.5Mbps) requirements of the USB Specification version 1.1. The micro-controller is a
self-contained unit with an USB SIE, an USB transceiver, an 8-bit RISC-like microcontroller, a timer, data and
program memories. It supports one USB device address and four endpoints (include endpoint 0).
4.1 MEMORY ORGANIZATION
The memory in the microcontroller is organized into user program memory in program ROM and data memory
in SRAM space.
4.1.1 Program Memory Organization
The 12-bit Program Counter (PC) is capable of addressing 4K x 14 of program space. All of the 4K * 14 ROM
space can be used. The program memory space is divided into two functional groups: Interrupt Vectors and
program code. After a reset, the Program Counter points to location zero of the program space and all registers
are reset to the default value. After a timer interrupt, the Program Counter points the location 0x0004 of the
program space.
After Reset
→
After Timer Interrupt
→
Address
0x0000
0x0004
0x0005
Reset Vector
Timer Interrupt Vector
4K x 14 ROM
0x0FFF
Figure 4-1 Program Memory Space
4.1.2 Data Memory Organization
The data memory is partitioned into two Banks that contain the General Purpose Registers, MCU Function
Registers and USB Function Registers. Bit BS is the bank select bit.
BS (STATUS<5>) = 1 → Bank 1
BS (STATUS<5>) = 0 → Bank 0
The lower locations of each Bank are reserved for MCU Function Registers and USB Function Registers.
Above the MCU Function Registers and USB Function Registers are General Purpose Registers implemented
as SRAM. Both Bank 0 and Bank 1 contain MCU Function Registers. USB Function Registers are located in
Bank 0. Some “high use” MCU Function Registers from Bank 0 are mirrored in Bank 1 for code reduction and
quicker access.
Data
Memory
Address
00h
01h
02h
03h
04h
05h
06h
Revision 1.6
Data Memory
Address
INDR
TIMER
PCL
STATUS
INDAR
PORT1
80h
81h
82h
83h
84h
85h
86h
-9-
INDR
PSCON
PCL
STATUS
INDAR
PORT1CON
02/28/2000
07h
08h
09h
0Ah
0Bh
0Ch
0Dh
0Eh
0Fh
10h
11h
12h
13h
14h
15h
16h
17h
18h
19h
1Ah
1Bh
1Ch
1Dh
1Eh
1Fh
20h
PCHBUF
INTEN
87h
88h
89h
8Ah
8Bh
8Ch
8Dh
8Eh
8Fh
PCHBUF
INTEN
DEVCTL
EVTFLG
DEVADR
RXCTL0
TXCTL0
TXCTL123
FFDAT0
FFDAT123
DRVSEL
SENSE
FFRST
MODESEL
PS2CTL
EPSEL
SERCTL
SERDAT
General
Purpose
Registers
(96 bytes)
7Fh
Revision 1.6
FFh
Bank 0
Bank 1
Figure 4-2 Data Memory Space
-10-
02/28/2000
4.2 USB FUNCTION REGISTERS
Address
10h
11h
12h
13h
14h
15h
16h
17h
18h
19h
1Ah
1Bh
1Ch
1Dh
1Eh
1Fh
Name
DEVCTL
EVTFLG
DEVADR
RXCTL0
TXCTL0
TXCTL123
FFDAT0
FFDAT123
DRVSEL
SENSE
FFRST
MODESEL
Reserved
EPSEL
SERCTL
SERDAT
Table 4-1 USB Function Register Summary
Function
Device control register
Event flag register
USB device address register
Endpoint 0 receive control register
Endpoint 0 transmit control register
Endpoint 1/2/3 transmit control register
Endpoint 0 FIFO data port
Endpoint 1/2/3 FIFO data port
Key matrix drive pin control register
Key matrix sense register
FIFO reset register
USB mode select register
Endpoint select register
PS/2 mouse port control register
PS/2 mouse port data register
DEVCTL (Address 10h, Device control register)
R/W[1]
R/W
R/W
R/W
R/W
R/W
R/W
EP3STL
EP2STL
EP1STL
EP0STL
WAKE
WKDIS
PWRDN
EP3STL: Endpoint 3 stall bit
1: Endpoint 3 will respond with a STALL to a valid transaction
0: Endpoint 3 will not respond with a STALL to a valid transaction
EP2STL: Endpoint 2 stall bit
1: Endpoint 2 will respond with a STALL to a valid transaction
0: Endpoint 2 will not respond with a STALL to a valid transaction
EP1STL: Endpoint 1 stall bit
1: Endpoint 1 will respond with a STALL to a valid transaction
0: Endpoint 1 will not respond with a STALL to a valid transaction
EP0STL: Endpoint 0 stall bit
1: Endpoint 0 will respond with a STALL to a valid transaction.
0: Endpoint 0 will not respond with a STALL to a valid transaction
WAKE: Wake-up bit
1: Set this bit to wake up host controller by placing USB bus into K state
0: Clear this bit to force USB bus leave K state
WKDIS: Wake-up disable bit
1: Disable remote wake-up capability
0: Enable remote wake-up capability
PWRDN: Power-down mode bit
1: Entering power-down mode
If USB suspend is detected, firmware should set this bit to enter power-down mode. In power-down mode,
6MHz crystal clock will be stopped. Hardware will automatically clear PWRDN bit upon hardware reset,
USB D+/D- toggle, SENSE1~SENSE8 at logic ‘0’, or Port 1.1 at logic ‘0’.
Value on POR: “0 0 0 0 0 0 0 0”
Note 1: “R/W” means readable and writable bit
EVTFLG (Address 11h, Event flag register)
R/W1C[1]
R/W1C
R/W1C
R/W1C
WAKEUP RESUME
SUSPD
EP3TX
Revision 1.6
R/W1C
EP2TX
-11-
R/W1C
EP1TX
R/W1C
EP0TX
R/W1C
EP0RX
02/28/2000
WAKEUP: Remote wakeup bit
1: Remote wakeup from P1.1~P1.4 or SENSE1~SENSE8 was detected
0: Remote wakeup was not detected
RESUME: Global resume bit
1: Global resume (USB D+/D- toggle) was detected
0: Global resume was not detected
SUSPD: Global suspend bit
1: Global suspend (USB idle more than 3ms) was detected
0: Global suspend was not detected
EP3TX: Endpoint 3 transmitting status bit
1: Data has been sent from endpoint 3
0: Data has not been sent from endpoint 3
EP2TX: Endpoint 2 transmitting status bit
1: Data has been sent from endpoint 2
0: Data has not been sent from endpoint 2
EP1TX: Endpoint 1 transmitting status bit
1: Data has been sent from endpoint 1
0: Data has not been sent from endpoint 1
EP0TX: Endpoint 0 transmitting status bit
1: Data has been sent from endpoint 0
0: Data has not been sent from endpoint 0
EP0RX: Endpoint 0 receiving status bit
1: Data has been received by endpoint 0
0: Data has not been received by endpoint 0
Value on POR: “0 0 0 0 0 0 0 0”
Note 1: “R/W1C” means read-only and write “1” to clear bit
DEVADR (Address 12h, USB device address register)
R/W
R/W
R/W
R/W
DADR6
DADR5
DADR4
DADR3
Write this register to set the USB device address
Value on POR: “0 0 0 0 0 0 0 0”
R/W
DADR2
R/W
DADR1
R/W
DADR0
RXCTL0 (Address 13h, Endpoint 0 receive control register)
R/W
R/O[1]
R/O
R/O
R/W
R/W
R/W
R/W
RXDIS
RXST2
RXST1
RXST0
RXCNT3
RXCNT2
RXCNT1
RXCNT0
RXDIS: Endpoint 0 receiving not available bit
1: Endpoint 0 FIFO is not available. The received data cannot be pushed into FIFO. The USB controller will
respond with a NAK to a valid OUT transaction. This bit is set by hardware when endpoint 0 data is received
(both SETUP and OUT transaction).
0: Endpoint 0 FIFO is available for data receiving
RXST[2:0]: RXST[2:0] indicate the PID received.
Bit Value
Packet received
100
SETUP token with DATA0 packet
010
OUT token with DATA0 packet
011
OUT token with DATA1 packet
RXCNT[3:0]: Number of bytes received from endpoint 0.
Value on POR: “0 X X X X X X X”
Note 1: “R/O” means read-only bit
TXCTL0 (Address 14h, Endpoint 0 transmit control register)
R/W
R/W
R/W
TXSEQ
TXOE
TXCNT3
TXSEQ: Endpoint 0 transmitting sequence bit
1: Transmitting data use DATA1 as PID
0: Transmitting data use DATA0 as PID
Revision 1.6
-12-
R/W
TXCNT2
R/W
TXCNT1
R/W
TXCNT0
02/28/2000
TXOE: Endpoint 0 FIFO data ready bit
1: Endpoint 0 FIFO data are ready to be transmitted. Data will be transmitted when a valid IN token is
received. This bit is automatically cleared by hardware after the transaction complete (ACK is received).
0: Endpoint 0 FIFO data are not ready to be transmitted and respond with a NAK to a valid IN transaction.
TXCNT[3:0]: Number of bytes to be sent by endpoint 0 when IN token is received
Value on POR: “0 0 0 0 0 0 0 0”
TXCTL123(Address 15h, Endpoint 1/2/3 transmit control register)
R/W
R/W
R/W
R/W
R/W
R/W
TXSEQ
TXOE
TXCNT3
TXCNT2
TXCNT1
TXCNT0
TXSEQ: Endpoint 1/2/3 transmitting sequence bit
1: Transmitting data use DATA1 as PID
0: Transmitting data use DATA0 as PID
TXOE: Endpoint 1/2/3 FIFO data ready bit
1: Endpoint 1/2/3 FIFO data are ready to be transmitted. Data will be transmitted when a valid IN token is
received. This bit is automatically cleared by hardware after the transaction complete (ACK is received).
0: Endpoint 1/2/3 FIFO data are not ready to be transmitted and respond with a NAK to a valid IN transaction.
TXCNT[3:0]: Number of bytes to be sent by endpoint 0 when IN token is received
Value on POR: “0 0 0 0 0 0 0 0”
FFDAT0 (Address 16h, Endpoint 0 FIFO port)
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
FFDAT7
FFDAT6
FFDAT5
FFDAT4
FFDAT3
FFDAT2
FFDAT1
FFDAT0
Endpoint 0 FIFO data port
Endpoint 0 FIFO is a 8 bytes FIFO. Firmware can read/write this port 8 times to get/put the FIFO data.
Value on POR: “X X X X X X X X”
FFDAT1/2/3 (Address 17h, Endpoint 1/2/3 FIFO port)
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
FFDAT7
FFDAT6
FFDAT5
FFDAT4
FFDAT3
FFDAT2
FFDAT1
FFDAT0
Endpoint 1/2/3 FIFO data port
Endpoint 1 FIFO is 8 bytes FIFO. Firmware can read this port 8 times to get the FIFO data.
Endpoint 2 FIFO is 6 bytes FIFO. Firmware can read this port 6 times to get the FIFO data.
Endpoint 3 is 2 bytes FIFO only. Firmware can read this port 2 times to get the FIFO data.
Before read this register, firmware should selects endpoint via EPSEL register (address 1Dh).
Value on POR: “X X X X X X X X”
DRVSEL (Address 18h, Key matrix drive pin control register)
R/W
R/W
R/W
R/W
R/W
INVDRV
DRVOE
DRV4
DRV3
DRV2
INVDRV: Inverse drive signal. This function can be used to detected ghost keys.
1: Drive all DRV1-18 to low except the selected pin when DRVOE is set
0: Drive the selected pin to low only when DRVOE is set
DRVOE: DRV1-18 output enable
1: Enable DRV1-18 pins to drive key matrix
0: Disable DRV1-18 pins and not to drive key matrix
DRV[4:0]: Select DRV1 to DRV18 port to drive low if DRVOE is set.
5’h00 selects DRV1
5’h01 selects DRV2
5’h0f selects DRV16
5’h10 selects DRV17
5’h11 selects DRV18
5’h12 ~ 5’h1f are invalid.
Value on POR: “0 0 0 0 0 0 0 0”
R/W
DRV1
R/W
DRV0
SENSE (Address 19h, Key matrix sense resister)
Revision 1.6
-13-
02/28/2000
R/O
R/O
R/O
R/O
R/O
R/O
R/O
R/O
SENSE8
SENSE7
SENSE6
SENSE5
SENSE4
SENSE3
SENSE2
SENSE1
Key matrix sense input port
All SENSE1~SENSE8 bits indicate state of the corresponding SENSE1~SENSE8 pins.
Value on POR: “X X X X X X X X”
FFRST (Address 1Ah, FIFO reset register)
W/O
W/O
FFRST123
FFRST0
FFRST123: Reset endpoint 1/2/3 FIFO read/write pointer
Write “1” to this bit will reset endpoint 1/2/3 FIFO read/write pointer. Data in endpoint 1/2/3 FIFO remain
unchanged. Before data are written into endpoint 1/2/3 FIFO, EPSEL should be set correctly then FFRST123
should be set.
FFRST0: Reset endpoint 0 FIFO read/write pointer
Write “1” to this bit will reset endpoint 0 FIFO read/write pointer. Data in endpoint 0 FIFO remain
unchanged. Before data are read/written into endpoint 0 FIFO, FFRST0 should be set first.
MODESEL (Address 1Bh, Mode select register)
R/W
OSCSTP
R/W
PWRON
OSCSTP: Suspend clock stop control bit
1: Clock is stopped while suspend
0: Clock is not stopped while suspend
PWRON: Power reset indicator
1: Power on reset detected
0: USB bus reset detected
Value on POR: “- - - - - - 0 1”
USBIOCTL (Address 1Ch, I/O control register for USB D+/D-)
R/W
R/W
R/W
DMOE
DPOE
DM
DMOE: D- pin output enable control bit
1: D- pin digital output enable
0: D- pin digital output disable
DPOE: D+ pin output enable control bit
1: D+ pin digital output enable
0: D+ pin digital output disable
DM: Digital output value of D- pin. This pin is open drain output. Output high will be tri-stated.
DP: Digital output value of D+ pin. This pin is open drain output. Output high will be tri-stated.
Value on POR: “- - - - 1 1 0 0”
R/W
DP
EPSEL (Address 1Dh, Endpoint select register)
R/W
EPSEL3
R/W
EPSEL2
R/W
EPSEL1
EPSEL[3: 1]: Endpoint select control bits
Bit Value
Endpoint to be selected
001
Endpoint 1
010
Endpoint 2
100
Endpoint 3
Value on POR: “- - - - - X X X”
SERCTL (Address 1Eh, PS/2 or RS232 mouse port control register)
R/WC
RXFLG
R/W
SRXEN
RXFLG: Data received flag on PS/2 interface
1: Data received and saved in SERBUF
Revision 1.6
-14-
02/28/2000
0: No data received
SRXEN: Receiver enable bit for PS/2 interface
1: Enable serial port receiver
0: Disable serial port receiver
Value on POR: “- - - - - 0 - 0”
SERDAT (Address 1Fh, PS/2 mouse port data register)
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
SERDAT7 SERDAT6 SERDAT5 SERDAT4 SERDAT3 SERDAT2 SERDAT1 SERDAT0
SERDAT[7: 0]: PS/2 mouse data input port. This port is a 2 bytes FIFO. Therefore, about 1 mini-second delay is
allowed between RXFLG in SERCTL register set and to read the PS/2 mouse data. If the 2 bytes FIFO full,
GL602USB will drive the PS/2 clock low to avoid the mouse send more data.
Value on POR: “X X X X X X X X”
Revision 1.6
-15-
02/28/2000
4.3 MCU FUNCTION REGISTERS
Address
00h
Name
INDR
01h
02h
03h
04h
05h
06h
0Ah
0Bh
80h
TIMER
PCL
STATUS
INDAR
Reserved
PORT1
PCHBUF
INTEN
INDR
81h
82h
83h
84h
85h
86h
8Ah
8Bh
PSCON
PCL
STATUS
INDAR
Reserved
PORT1CON
PCHBUF
INTEN
Table 4-2 MCU Function Register Summary
Function
Addressing this location will use the content of INDAR to address data
memory (not a physical address)
Timer register
Program Counter’s low byte
Status register
Indirect address register
Port 1 data register
Write buffer of Program Counter’s bit 11-8
Interrupt enable register
Addressing this location will use the content of INDAR to address data
memory (not a physical address)
Prescaler control register
Program Counter’s low byte
Status register
Indirect address register
Port 1 direction control register
Write buffer of Program Counter’s bit 12-8
Interrupt enable register
INDR (Address 00h/80h)
INDR is not a physical register. Addressing INDR register will cause indirect addressing. Any instruction using the
INDF register actually accesses the register pointed by the INDAR register. The indirect addressing method only can
be used for general purpose registers.
TIMER (Address 01h, Timer register)
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
TIMER7
TIMER6
TIMER5
TIMER4
TIMER3
TIMER2
TIMER1
TIMER0
The timer starts to count up after power on reset. The TMROF bit at INTEN register will be set when the TIMER
register overflows from FFh to 00h. If both TMROEN and GIE bits at INTEN register are set, an interrupt will be
generated when TIMER register overflows.
Value on POR: “0 0 0 0 0 0 0 0”
PCL (Address 02h/82h, Program Counter’s low byte)
R/W
R/W
R/W
R/W
PCL7
PCL6
PCL5
PCL4
R/W
PCL3
R/W
PCL2
R/W
PCL1
R/W
PCL0
The Program Counter (PC) is 12-bits wide. The low byte comes from the PCL register, which is a readable and
writable register. The high byte is not directly readable or writable and comes from PCHBUF. The GL602USB has a 8
level deep x 11-bit wide hardware stake. The stake space is not part of either program or data space and the stack
pointer is not readable or writable. The PC is pushed onto the stack when a CALL instruction is executed or an
interrupt causes a branch. The stack is poped in the event of a RETIA, RETI or a RET instruction execution. PCHBUF
is not affected by a push or pop operation.
Because branch address gotten from stack or direct from instruction is only 11 bits long, the highest bit will be loaded
to PC from PCHBUF when branch instruction is executed.
When write to PCL command executed, all 4 bits of PCHBUF will be loaded to PC because PCL is only a 8 bits
register.
Value on POR: “0 0 0 0 0 0 0 0”
Revision 1.6
-16-
02/28/2000
STATUS (Address 03h, Status register)
R/W
R/W
R/W
R/W
BS
ZO
HC
CA
BS: Bank Select. Because only 7 bits (bit 0~bit 6) operand implied by instruction for register address, this bit is used
as address bit 7 when register access.
1: Bank 1 (80h-FFh)
0: Bank 0 (00h-7Fh)
ZO: Zero bit
1: The result of last arithmetic or logic operation is zero
0: The result of last arithmetic or logic operation is not zero
HC: Half Carry/Borrow bit
1: Carry or not borrow from the 4th low order bit
0: Borrow or not carry from the 4th low order bit
CA: Carry/Borrow bit
1: Carry or not borrow from the most significant bit
0: Borrow or not carry from the most significant bit
Value on POR: “- - 0 - - 0 0 0”
INDAR: (Address 04h/84h, Indirect address register)
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
INDAR7
INDAR6
INDAR5
INDAR4
INDAR3
INDAR2
INDAR1
INDAR0
Any instruction using the INDF register actually accesses the register pointed by the INDAR register.
Value on POR: “x x x x x x x x” [1]
Note 1: “x” means unknown
PORT1 (Address 06h, Port 1 data register)
R/W
R/W
R/W
R/W
R/W
R/W
R/W
PORT 1.7
PORT1.6
PORT1.5
PORT1.4
PORT1.3
PORT1.2
PORT1.1
PORT1 is a 7-bits latch for Port 1.1~Port 1.7. Reading the PORT1 register gets the status on the pins. Writing to it will
write to the port latch. All write operations are read-modify-write operations. PORT1CON is used to enable/disable
every bits of the port latch.
Value on POR: “x x x x x x x -”
PCHBUF (Address 0Ah/8Ah, Write buffer of Program Counter’s bit 11-8)
R/W
R/W
R/W
R/W
PCHBUF3 PCHBUF2 PCHBUF1 PCHBUF0
Write buffer for upper 4-bits of Program Counter. The upper byte of Program Counter is not directly accessible.
PCHBUF is a holding register for the PC[11:8] that are transferred to the upper byte of the Program Counter when
branch occur. Please see PCL register to get more detail information.
Value on POR: “- - - 0 0 0 0 0”
INTEN (Address 0Bh/8Bh, Interrupt enable register)
R/W
R/W
R/W
GIE
TMROEN
TMROF
GIE: Global interrupt enable bit
1: Enable all interrupts
0: Disable all interrupts
TMROEN: Timer overflow interrupt enable bit
1: Enable timer interrupt
0: Disable timer interrupt
TMROF: Timer overflow interrupt flag bit. This bit should be cleared to ‘0’ by firmware after it is set by hardware.
1: Timer register has overflowed
0: Timer register did not overflow
Value on POR: “0 - 0 - - 0 - -“
PSCON (Address 81h, Prescaler control register)
Revision 1.6
-17-
02/28/2000
R/W
PSDIS
R/W
PS2
R/W
PS1
R/W
PS0
PSDIS: Prescaler disable bit
1: Set prescaler disable
0: Set prescaler enable
PS[2:0]: Prescaler rate select bits. These bits are used to control timer speed. The following table means that how
many instruction cycles the TIMER register should be added by 1 when PSDIS = 0.
Bit Value
Timer Rate
(PSDIS = 0)
000
1:2
001
1:4
010
1:8
011
1:16
100
1:32
101
1:64
110
1:128
111
1:256
Value on POR: “- - - - 1 1 1 1”
PORT1CON (Address 86h, Port 1 direction control register)
R/W
R/W
R/W
R/W
R/W
R/W
R/W
P1CON7
P1CON6
P1CON5
P1CON4
P1CON3
P1CON2
P1CON1
There is a data direction control bit to match every pin of Port 1. The direction control bits can configure these pins as
output or input. Setting a PORT1CON register bit put the corresponding output driver in a hi-impedance mode.
Clearing a bit in the PORT1CON register puts the contents of the output latch on the selected pin.
Value on POR: “1 1 1 1 1 1 1 -”
4.4 GENERAL PURPOSE I/O PORTS
Interface with peripherals is conducted via up to 7 GPIO signals. The 7 signals are located at port 1. The port 1 data
register is located at data memory address 06h and direction control register is located at address 86h.
The GL602USB builds in a PS/2 host data receiver. While this receiver enabled, the Port 1.1 is treated as PS/2 CLK
and Port 1.2 is treated as PS/2 DATA. Firmware uses these 2 pins to implement a PS/2 mouse host controller. When
the PS/2 host want to send command to PS/2 device, firmware should drive the 2 I/O pins directly following PS/2
specification.
There are 2 bytes FIFO used as PS/2 data buffer. When the PS/2 receiver has received a data byte already and
firmware does not read it yet, the PS/2 receiver can receive the next data byte into FIFO still. If the firmware cannot
process the first byte until the second byte received complete, the PS/2 receiver will drive low on Port 1.1 (PS/2 CLK)
automatically to avoid the PS/2 device send data again.
P1.3 is VPP pin at OTP. This I/O pin can be used only at mask type.
The Port 1.5/Port 1.6/Port 1.7 can be treat as general purpose output pins in output mode. There are internal pull up
resistors on those pins. Firmware can drive high on these pins to turn off LEDs and drive low to turn off these pins.
External resistors are needed for these LED pins to sink current .
4.5 TIMER INTERRUPT
The Timer Interrupt is generated when the TIMER register overflows from FFh to 00h. This overflow sets bit TMROF
(INTEN<2>). The interrupt can be masked by clearing bit TMROEN (INTEN<5>). Bit TMROF must be cleared in
software by the Timer module interrupt service routine otherwise the Timer Interrupt will not be generated again. If
prescaler is disabled, the timer register will increase every instruction cycle. If prescaler is enabled, its increment cycle
depends on PS0~PS2 bits in PSCON register.
Revision 1.6
-18-
02/28/2000
4.6 USB ENGINE
The USB module contains three functional blocks: a 3.3-volt regulator, a low-speed USB transceiver, and the Serial
Interface Engine (SIE). The USB module is only enabled under USB mode. The following description is the function
of the regulator, transceiver, and SIE.
4.6.1 Voltage Regulator
The USB data lines are required by the USB specification to have a maximum output voltage between 2.8V and 3.6V.
Because the GL602USB is a low speed USB device, the D- lines also are required to have an external 1.5-kΩ pull-up
resistor connected between a data line and a voltage source between 3.0 V and 3.6 V. Since the power provided by the
USB cable is specified to be between 4.4V and 5.0V, an on-chip regulator is used to drop the voltage to the
appropriate level for sourcing the USB transceiver and external pull-up resistor. An output pin driven by the regulator
is provided to source the 1.5-kΩ external resistor.
4.6.2 USB Transceiver
The USB transceiver provides the physical interface to the USB D+ and D- data lines. The transceiver is composed of
two parts: an output driver circuit and a receiver.
The USB transceiver uses a differential output driver to drive the USB data signal onto the USB cable. The static
output swing of the driver in its low state is below the VOL of 0.3V with 1.5-kΩ load to 3.6V and in its high state is
above the VOH of 2.8V with 15-kΩ load to ground. The output swings between the differential high and low state are
well balanced to minimize signal skew. Slew rate control on the driver is used to minimize the radiated noise and cross
talk. The driver’s outputs support 3-state operation to achieve bi-directional half-duplex operation. The driver can
tolerate a voltage on the signal pins of –0.5V to 3.8V with respect to local ground reference without damage.
The rise and fall time of the signals on this cable are greater than 75ns to keep RFI (radio frequency interference)
emissions under FCC (Federal Communications Commission) class B limits and less than 300ns to limit timing delays,
signaling skews, and distortions. The driver reaches the specified static signal levels with smooth rise and fall times,
and minimal reflections and ringing when driving the cable. This driver is used only on segments between low-speed
devices and the ports to which they are connected.
USB data transmission is done with differential signals. A differential input receiver is used to accept the USB data
signal. A differential 1 on the bus is represented by D+ being at least 200mV more positive than D- as seen at the
receiver, and a differential 0 is represented by D- being at least 200mV more positive than D+ as seen at the receiver.
The signal cross over point must be between 1.3V and 2.0V.
The receiver features an input sensitivity of 200mV when both differential data inputs are in the range of 0.8V and
2.5V with respect to the local ground reference. This is called the common mode input voltage range. Proper data
reception also is achieved when the differential data lines are outside the common mode range. The receiver can
tolerate static input voltage between –0.5V to 3.8V with respect to its local ground reference without damage. In
addition to the differential receiver, there is a single-ended receiver for each of the two data lines.
Revision 1.6
-19-
02/28/2000
Minimum Differential Sensitivity (volts)
1.0
0.8
0.6
0.4
0.2
0.0
0.0
0.2 0.4
0.6
0.8 1.0
1.2
1.4
1.6 1.8
2.0
2.2 2.4
2.6
2.8 3.0
3.2
Common Mode Input Voltage (volts)
Figure 4-3 Differential Input Sensitivity over Entire Common Mode Range
The data receivers for all types of devices must be able to properly decode the differential data in the presence of
jitter. The more of the bit time that any data edge can occupy and still be decoded, the more reliable the data
transfer will be. Data receivers are required to decode differential data transitions that occur in a window plus and
minus a nominal quarter bit time from the nominal (centered) data edge position. Jitter will be caused by the delay
mismatches and by mismatches in the source and destination data rates (frequencies).
TPERIOD
Differential
Data Lines
TJR
TJR1
TJR2
Consecutive
Transitions
N * TPERIOD + TJR1
Paired
Transitions
N * TPERIOD + TJR2
Figure 4-4 Receiver Jitter Tolerance
The source of data can have some variation (jitter) in the timing of edges of the data transmitted. The time between
any set of data transitions is N*TPeriod ± jitter time, where N is the number of bits between the transitions and TPeriod
is defined as the actual period of the data rate. The data jitter is measured with the same capacitive load used for
maximum rise and fall times and is measured at the crossover points of the data lines.
For low-speed transmissions, the jitter time for any consecutive differential data transitions must be within ±25ns
and within ±10ns for any set of paired differential data transitions. These jitter numbers include timing variations
due to differential buffer delay, rise/fall time mismatches, internal clock source jitter, noise and other random
effects.
The output rise time and fall time are measured between 10% and 90% of the signal. Edge transition time for the
rising and falling edges of low-speed signals is 75ns (minimum) into a capacitive load (CL) of 50pF and 300ns
(maximum) into a capacitive load of 350pF. The rising and falling edges should be transitioning (monotonic)
smoothly when driving the cable to avoid excessive EMI.
Revision 1.6
-20-
02/28/2000
Rise Time
CL
Fall Time
90%
Differential
Data Lines
90%
10%
CL
10%
tR
Full Speed: 4 to 20ns at CL = 50pF
tF
Low Speed: 75ns at CL = 50pF, 300ns at CL = 350pF
Figure 4-5 Data Signal Rise and Fall Time
4.6.3 Serial Interface Engine (SIE)
The SIE manages data movement between the CPU and the transceiver. The SIE handles both transmit and
receive operations on the USB. It contains the logic used to manipulate the transceiver and the endpoint
registers.
The byte count buffer is loaded from TXCNT(TXCTL0<3~0>) during endpoint 0 transmit operations. This
same buffer is used for receive transactions to count the number of bytes received at endpoint 0 and, upon
the end of transaction, transfer the value to RXCNT(RXCTL0<3~0>).
When transmitting, the SIE handles parallel-to-serial conversion, CRC generation, NRZI encoding, and bit
stuffing. When receiving, the SIE handles sync detection, packet identification, end-of-packet detection, bit
(un)stuffing, NRZI decoding, CRC validation, and serial-to-parallel conversion. Errors detected by the SIE
include bad CRC, timeout while waiting for EOP, and bit stuffing violations.
All USB devices are required to have an endpoint 0 that is used to initialize and manipulate the device.
Endpoint 0 provides access to the device’s configuration information and allows generic USB status and
control accesses. Endpoint 0 can receive and transmit data. Both receive and transmit data share the same 8byte Endpoint 0 FIFO, FFDAT0. Received data may overwrite the data previously in the FIFO.
Transmission from endpoint 0 is controlled by TXCTL0 and receiving from endpoint 0 is controlled by
RXCTL0.
Endpoint 1/endpoint 2/endpoint 3 are of transmit only. Transmission from endpoint 1/endpoint 2/endpoint 3
is controlled by TXCTL123. The target endpoint should be chosen before writing to FFDAT123 and
TXCTL123. There are separated FIFO buffer for the 3 endpoints, but the programming interface for them is
unique, via FFDAT123 register. Size of endpoint 1 FIFO is 8 bytes, endpoint 2 FIFO is 6 bytes, and
endpoint 3 FIFO is 2 bytes.
4.7 INSTRUCTION SET SUMMARY
4.7.1 Operand Field Descriptions
Field
r
A
i
b
Description
Register address
Accumulator
Immediate data
Bit address within a 8-bit register
4.7.2 Instruction Set
Mnemonic,
Operands
Arithmetic Operations
Revision 1.6
Description
-21-
Cycles
Flags
Affected
02/28/2000
ADDAR r, A
Add r and A, r <- r + A
ADDAR A, r
Add A and r, A <- A + r
ADDAI i
Add A and i, A <- A + i
INCR r
Increment r, r <- r +1
INCR A, r
Increment r, A <- r + 1
INCRSZ r
Increment r, r <- r +1, skip if (r = 0)
INCRSZ A, r
Increment r, A <- r +1, skip if (A = 0)
SUBAR r, A
Subtract A from r, r <- r - A
SUBAR A, r
Subtract A from r, A <- r - A
SUBIA i
Subtract A from i, A <- i - A
DECR r
Decrement r, r <- r -1
DECR A, r
Decrement r, A <- r -1
DECRSZ r
Decrement r, r <- r-1, skip if (r = 0)
DECRSZ A, r
Decrement r, A <- r -1, skip if (A = 0)
CLRR r
Clear r, r <- 0
CLRA
Clear A, A <- 0
NOP
No operation
Logical Operations
ANDAR r, A
And r and A, r <- r & A
ANDAR A, r
And A and r, A <- A & r
ANDAI i
And A and i, A <- A & i
CMPR r
Complement r, r <- r ^ FF
CMPR A, r
Complement r, A <- r ^ FF
ORAR r, A
Inclusive OR r with A, r <- r | A
ORAR A, r
Inclusive OR A with r, A <- A | r
ORIA i
Inclusive OR i with A, A <- A | i
XORAR r, A
Exclusive OR r with A, r <- r ^ A
XORAR A, r
Exclusive OR A with r, A <- A ^ r
XORIA i
Exclusive OR i with A, A <- A ^ i
Bit-wise Operations
BCR r, b
Bit clear r, r.b <- 0
BSR r, b
Bit set r, r.b <- 1
BTRSC r, b
Bit test r, skip if (r.b = 0)
BTRSS r, b
Bit test r, skip if (r.b =1)
Data Movement Operations
MOV r, A
Move A into r, r <- A
MOV A, r
Move r into A, A <- r
MOVIA i
Move i into A, A <- i
Shift Operations
SWAPR r
Swap high and low nibbles in r,
result put into r
SWAPR A, r
Swap high and low nibbles in r,
result put into A
RLR r
Rotate r left through C, (C, r) <- (r, C)
RLR A, r
Rotate r left through C, (C, A) <- (r, C)
RRR r
Rotate r right through C, (r, C) <- (C, r)
RRR A, r
Rotate r right through C, (A, C) <- (C, r)
Control Transfer Operations
CALL i
Call subroutine
JUMP i
Jump to address
RETIA
Return and load i to A
RETI
Return from timer interrupt
RET
Return from subroutine
Revision 1.6
-22-
1
1
1
1
1
1 or 2
1 or 2
1
1
1
1
1
1 or 2
1 or 2
1
1
1
CA, HC, ZO
CA, HC, ZO
CA, HC, ZO
ZO
ZO
1
1
1
1
1
1
1
1
1
1
1
ZO
ZO
ZO
ZO
ZO
ZO
ZO
ZO
ZO
ZO
ZO
CA, HC, ZO
CA, HC, ZO
CA, HC, ZO
ZO
ZO
ZO
ZO
1
1
1 or 2
1 or 2
1
1
1
ZO
1
1
1
1
1
1
CA
CA
CA
CA
2
2
2
2
2
02/28/2000
5. FIRMWARE PROGRAMMING GUIDE
5.1 USB Power On Reset and Bus Reset Initialization
Pow er on reset
U SB reset
(Address 0)
No
U S B reset
detected
W ait host
controller to
initialize the U S B
device
Revision 1.6
PW RON = 1
Y es
D rive (0, 0) on (DP , D M )
about 200 m s
S et D P, D M to input
m ode
S et P W R O N = 0
W ait for U SB reset
-23-
02/28/2000
5.2
Suspend/Resume/Wakeup
SUSPD = 1
W r i te '1 ' t o c le a r
SUSPD
D is a b le e x t e r n a l
P S /2 m o u s e
p o w e r if n e e d e d
S e t P W R D N b it
to e n te r p o w e r d o w n m o d e
W a it f o r r e s u m e o r w a k e u p
No
No
RESUME = 1
Y es
W r it e '1 ' t o c le a r
W AKEUP
W r i te '1 ' t o c le a r
RESUME
K e y b o a r d is
r e a l ly p r e s s e d
?
E n a b le e x te r n a l
P S /2 m o u s e
p o w e r if n e e d e d
Y es
S uspend &
w a k e u p p ro c e s s
c o m p le t e
S e t W A K E b it t o d r i v e
'K ' s t a t e o n U S B
D e la y a b o u t 1 m s
t o c le a r W A K E b it
Revision 1.6
-24-
02/28/2000
5.3
Receive Packet via Endpoint 0
E P0RX = 1
P a c k e t r e c e iv e d
c o m p le t e
W r ite '1 ' to c le a r
E P 0 R X b it
G e t r e c e iv e d b y te
c o u n t fr o m
RXCNT
R e a d r e c e iv e d d a ta
c o n t in u o u s fr o m
F F D A T 0 ( to t a l R X C N T
b y te s )
C le a r R X D IS b it to
e n a b le e n d p o in t 0
r e c e iv e r
Yes
S E T U P d a ta
p a c k e t r e c e iv e d
c o m p le t e
Revision 1.6
R X S T = (1 , 0 ,
0)
No
O U T d a ta p a c k e t
r e c e iv e d c o m p le te
-25-
02/28/2000
5.4
Transmit Packet via Endpoint 0
S t a r t t o t r a n s m it
f u n c t io n
S e t F F R S T 0 to
re s e t F IF O
P u s h a ll
t r a n s m it t i n g d a t a
in t o F F D A T 0
( m a x im u m 8
b y te s )
S e t c o r r e c t d a t a t o g g le
s e q u e n c e v ia T X S E Q
and
S e t tra n s m it d a ta
le n g t h in t o T X C N T
S e t T X O E b it
S I E w il l t r a n s m it
t h e p a c k e t w h i le i t
r e c e iv e s a I N
to k e n
Revision 1.6
-26-
02/28/2000
5.5
Transmit Packet via Endpoint 1/2/3
S t a r t t o t r a n s m it
f u n c t io n
S e le c t ta rg e t
e n d p o i n t v ia
EPSEL
S e t F F R S T 1 2 3 to
re s e t F IF O
P u s h a ll
t r a n s m it t i n g d a t a
in t o F F D A T 1 2 3
( m a x im u m 8
b y te s )
S e t c o r r e c t d a t a t o g g le
s e q u e n c e v ia T X S E Q
and
S e t tra n s m it d a ta
le n g t h in t o T X C N T
S e t T X O E b it
S I E w il l t r a n s m it
t h e p a c k e t w h i le i t
r e c e iv e s a I N
to k e n
Revision 1.6
-27-
02/28/2000
5.6
Timer Interrupt
Because CPU may enter timer interrupt routine at any time, the timer interrupt routine should backup all
special registers at its entry point and restore them before return.
(Address 0x004)
TIMER_ENTRY: MOV
SWAPR
BCR
MOV
MOV
MOV
;
; Execute interrupt service routine
;
MOV
MOV
SWAPR
MOV
SWAPR
SWAPR
BCR
RETI
5.7
A_TEMP, A
A, STATUS
STATUS, BS
S_TEMP, A
A, INDAR
I_TEMP, A
A, I_TEMP
INDAR, A
A, S_TEMP
STATUS, A
A_TEMP
A, A_TEMP
INTEN, TMROF
Conditional Branch
Example: Conditional branch can be according to value of Accumulator. Firmware can use this method to
return value for lookahead table. Because Accumulator is only 8 bits wide, the higher 5 bits of Program
Counter should be load into PCHBUF before the conditional branch executed.
(Address 0x540)
LOOKAHEAD:
5.8
MOVIA
MOV
MOVIA
ADDAR
RETIA
RETIA
RETIA
.
.
.
0x05
PCHBUF, A
LOOKAHEAD_VAL
PCL, A
0
; Acc = 0
1
; Acc = 1
2
; Acc = 2
.
.
.
Change Register Bank
Usually keeps BS = 0. If firmware want to access register address 0x80 to 0x8F, set BS = 1. After process
register address 0x80 to 0x8F complete, clear BS = 0 to address 0x00 to 0x7F.
BSR
MOV
BCR
5.9
STATUS, BS
PORT1CON, A
STATUS, BS
Change Code Bank
Because PCL is only 11 bits wide, Program Counter can only jump in 2K boundary directly. If Program
Counter want to jump over 2K boundary, firmware should set PCHBUF to correct bank first.
Revision 1.6
-28-
02/28/2000
(Address 0x375)
MOVIA
MOV
JUMP
0x08
PCHBUF, A
DEST_ADDR
(Address 0x83A)
DEST_ADDR:
5.10
Receive Data from PS/2 Mouse Port
C h e c k P S /2
m o u s e d a ta
r e c e iv e r
RXFLG = 1
Yes
W r it e '1 ' t o c le a r
R XFLG
No
R e a d a n e w P S /2 d a ta
b y t e fr o m S E R D A T
P r o c e s s r e c e iv e d
P S /2 m o u s e d a ta
R e tu r n t o m a in
p ro g ra m
Revision 1.6
-29-
02/28/2000
5.11
Scan Key Matrix
S c an k ey m atrix
S et D R V O E to driv e
s elec ted D R V pin to
low
S ele c t fro m D R V 1 to
D R V 18
(w rite D R V [0..4] in
D R V S E L)
R ea d S E N S E re gis ter
if any b it is logic '0 ',
indic ate that the
s pec ific k e y is pres s ed
C lear D R V O E to
flo at all D R V pin s
No
S e t D R V O E and
IN V D R V to ena ble
all o ther D R V p ins
Y es
2 o r m ore b its are
logic '0' in S E N S E
regis te r ?
No
A ny s am e S E N S E
bit is lo gic '0' at
oth er D R V pin ?
No
S elec t n ex t D R V
pin
Y es
G hos t k e y
d etec ted s c a nned
m a trix inv alid.
A ll D R V pins hav e
been s c ann ed ?
Y es
S c an k ey m atrix
c om p lete
5.12
Turn LED On/Off
To turn LEDs on, the firmware should set corresponding I/O pins (Port 1.5~Port 1.7) to output low. An external
resistor should be added on every LED pins to limit sink current. To turn LEDs off, the firmware should output
high to corresponding I/O pins (Port 1.5~Port 1.7).
Revision 1.6
-30-
02/28/2000
6. ABSOLUTE MAXIMUM RATINGS
Maximum ratings are the extreme limits to which the micro-controller can be exposed without permanently
damaging it. The micro-controller contains circuitry to protect the inputs against damage from high static voltages;
however, do not apply voltages higher than those shown in the table. Keep VIN and VOUT within the range GND ≤
(VIN or VOUT) ≤ VCC. Connect unused inputs to the appropriate voltage level, either GND or VDD.
Symbol
TSTG
TOP
VCC
VIN
I
IMGND
IMVCC
VESD
Characteristic
Storage temperature
Operating temperature
Supply voltage
DC input voltage
Maximum current per pin excluding VDD and VSS
Maximum current out of GND
Maximum current out of VCC
Static discharge voltage
Value
-55 to +150
0 to +70
-0.5 to +7.0
-0.5 to +VCC + 0.5
25
100
100
>4000
Unit
°C
°C
V
V
mA
mA
mA
V
7. ELECTRICAL CHARACTERISTICS
FOSC = 6MHz; Operating Temperature = 0 to 85°C; VCC = 4.4 to 5.5V
Symbol
Characteristic
Min
Max
Units
General
ICC
Operating supply current
10
mA
ISB
Supply current – suspend
360
µA
mode
USB Interface
VOH
Static output high
2.8
3.6
V
VOL
Static output low
0.3
V
VDI
Differential input
0.2
V
sensitivity
VCM
Differential common mode 0.8
2.5
V
range
VSE
Single ended receiver
0.8
2.0
V
threshold
ILO
Hi-Z state data line leakage -10
+10
V
V3.3
Regulator supply voltage
3.0
3.6
V
GPIO Interface
VOH1
Static output high for
2.4
V
PORT1.1-4
VOL1
Static output low for
0.4
V
PORT1.1-4
VOH2
Static output high for
2.4
V
PORT1.5-7
VOL2
Static output low for
0.4
V
PORT1.5-7
VIH
Static input high
2.0
V
VIL
Static input low
0.9
V
ISINK1
Sink current for PORT1.1- 4
mA
4
ISINK2
Sink current for PORT1.5- 20
mA
7
IIN
Input leakage current
-1
+1
µA
USB Low-speed Source
fOP
Internal operating
1.5
1.5
MHz
Revision 1.6
-31-
Conditions
See note 1
RL of 15KΩ to GND
RL of 1.5KΩ to V3.3
|(D+) – (D-)|
Include VDI range
0V < VIN < 3.3V
IL = 4mA
VCC = 5V; IOH = 4mA
VCC = 5V; IOL = 4mA
VCC = 5V; IOH = 20mA
VCC = 5V; IOL = 20mA
VCC = 5V
VCC = 5V
VOUT = 0.4V;
VOUT = 0.4V;
VOUT = 0V or VCC
02/28/2000
tR
frequency
Transition time
Rise time
75
tF
Fall time
75
tRFM
VCRS
Rise/Fall time matching
Output signal crossover
voltage
Low speed data rate
80
1.3
300
120
2.0
ns
ns
ns
ns
%
V
1.4775
676.8
1.5225
666.0
Mbs
ns
1.5Mbs ± 1.5%
-25
-10
25
10
ns
ns
CL = 350pF measured at
crossover point
-75
-45
1.25
-40
75
45
1.50
100
ns
ns
µs
ns
CL = 350pF measured at
crossover point
Measured at crossover point
Measured at crossover point
ns
ns
Measured at crossover point
300
tDRATE
tUDJ1
tUDJ2
tDJR1
tDJR2
tEOPT
tDEOP
tEOPR1
tEOPR2
Source differential driver
jitter
To next transition
For paired transition
Receiver data jitter
tolerance
To next transition
For paired transition
Source EOP width
Differential to EOP
transition skew
Receiver EOP width
Must reject as EOP
Must accept
330
675
CL = 50pF
CL = 350pF
CL = 50pF
CL = 350pF
tR / tF
Notes:
1. ISB measured with USB in suspend mode; using external square wave clock source (FOSC = 6MHz); transceiver pullup resistor of 1.5KΩ between V3.3 and D- and 15KΩ termination resistors on D+ and D- pins; no port pins sourcing
current. The ISB value is including power consumed by external resistors.
Revision 1.6
-32-
02/28/2000
8. PACKAGE DIAGRAMS
E1
8.1 40-pin P-DIP
C
A
A1
F
e
B
B1
eB
D
e
eB
Min
-74
---2040
549
590
-640
Dimension in mil
Nom
160
75
18
50
10
2050
550
600
100
650
Max
-76
---2060
551
610
-660
Min
-1.880
---51.816
13.945
14.986
-16.256
θ
0ο
7.5ο
15ο
0ο
Symbol
A
A1
B
B1
C
D
E1
F
Dimension in mm
Nom
4.064
1.905
0.457
1.270
0.254
52.07
13.970
15.240
2.540
16.510
7.5ο
Max
-1.930
---52.324
13.995
15.494
-16.764
15ο
Figure 7-3 Package outline dimension for 40-pin P-DIP
Revision 1.6
-33-
02/28/2000
8.2 24-pin SOP
B
D
F
C
e
eB
A1
A
E1
C
θ
L
eB
Revision 1.6
-34-
02/28/2000
Symbol
A
A1
A2
B
C
D
E1
e
eB
L
θ
Dimension in mils
Min Nom Max
98
100
102
6
----39
41
43
--16
----10
--598
600
602
298
300
302
--50
--406
410 414
30
32
34
----5°
Dimension in mm
Min
Nom
Max
2.489
2.540
2.591
0.152
----0.991
1.041 1.092
--0.406
----0.254
--15.189 15.240 15.291
7.569
7.620
7.671
--1.270
--10.312 10.414
10.516
0.762
0.813
0.864
----5°
Figure 7-4 Package outline dimension for 24-pin SOP
Revision 1.6
-35-
02/28/2000