—256 bytes of RAM
—8 KB of PROM (CY7C64013, CY7C64113)
• Integrated Master/Slave I
• Hardware Assisted Parallel Interface (HAPI) for data transfer to external devices
• I/O ports
—Three GPIO ports (Port 0 to 2) capable of sinking 7 mA per pin (typical)
—An additional GPIO port (Port 3) capable of sinking 12 mA per pin (typical) for high current requir e ments: LEDs
—Higher current drive achievable by connecting multiple GPIO pins together to drive a common output
—Each GPIO port can be configured as inputs with internal pull-ups or open drain outputs or traditional CMOS outputs
—A Digital to Analog Conversion (DAC) port with programmable current sink outputs is available on the CY7C64113 devices
—Maskable interrupts on all I/O pins
• 12-bit free-running timer with one microsecond clock ticks
• Watchdog Timer (WDT)
• Internal Power-On Reset (POR)
• USB Specification Compliance
—Conforms to USB Specification, Version 1.1
—Conforms to USB HID Specification, Versi o n 1. 1
—Supports up to five user configured endpoints
Up to four 8-byte data endpoints
Up to two 32-byte data endpoints
—Integrated USB transceivers
• Improved output drivers to reduce EMI
• Operating voltage from 4.0V to 5.5V DC
• Operating temperature from 0 to 70 degrees Celsius
—CY7C64013 available in 28-pin SOIC and 28-pin PDIP packages
—CY7C64113 available in 48-pin SSOP packages
• Industry-standard programmer support
2
C-compatible Controller (100 kHz) enabled through General-Purpose I/O (GPIO) pins
CY7C64113
Document #: 38-08001 Rev. *APage 6 of 51
CY7C64013
2.0 Functional Overview
The CY7C64013 and CY7C64113 are 8-bit One Time Programmable microcontrollers that are designed for full-speed USB
applications. The instruction set has been optimized specifically for USB operations, although the microcontroll ers can be u sed
for a variety of non-USB embedded applications.
GPIO
The CY7C64013 features 19 GPIO pins to support USB and other applications. The I/O pins are grouped into three ports (P0[7:0],
P1[2:0], P2[6:2], P3[2:0]) where each port can be configured as inputs with internal pull-ups, open drain outputs, or traditional
CMOS outputs. There are 16 GPIO pins (Ports 0 and 1) which are rated at 7 mA typical sink current. Port 3 pins are rated at 12
mA typical sink current, a current sufficient to drive LEDs. Multiple GPIO pins can be connected together to drive a single output
for more drive current capacity. Additionally, each GPIO can be used to generate a GPIO interrupt to the microcontroller. All of
the GPIO interrupts share the same “GPIO” interrupt vector.
The CY7C64113 has 32 GPIO pins (P0[7:0], P1[7:0], P2[7:0], P3[7:0])
DAC
The 64113 has four programmable sink current I/O pins (DAC) pins (P4[7,2:0]). Ev ery DAC pin incl udes an integrat ed 14-kΩ pullup resistor. When a ‘1’ is written to a DAC I/O pin, the output current sink is disabled and the output pin is driven HIGH by the
internal pull-up resistor. When a ‘0’ is written to a DAC I/O pin, the internal pull-up resistor is disabled and the output pin provides
the programmed amount of sink current. A DAC I/O pin can be used as an input with an internal pull-up by writing a ‘1’ to the pin.
The sink current for each DAC I/O pin can be individually programmed to one of 16 values using dedicated Isink registers. DAC
bits P4[1:0] can be used as high-current outputs with a programmable sink cu rrent range of 3.2 to 16 mA (typical). DAC bits
P4[7,2] have a programmable current sink range of 0.2 to 1.0 mA (typical). Multiple DAC pins can be connected together to drive
a single output that requires more sink current capacity. Each I/O pin can be used to generate a DAC interrupt to the microcontroller. Also, the interrupt polarity for each DAC I/O pin is individually programmable.
Clock
The microcontroller uses an external 6-MHz crystal and an internal osci llator to provide a reference to an internal PLL-based
clock generator. This technology allows the customer application to use an inexpensive 6-MHz fundamental crystal that reduces
the clock-related noise emissions (EMI). A PLL clock generator provides the 6-, 12-, and 48-MHz clock signals for distribution
within the microcontroller.
Memory
The CY7C64013 and CY7C64113 have 8 KB of PROM.
Power on Reset, Watchdog and Free running Time
These parts include power-on reset logic, a Watchdog timer, and a 12-bit free-running timer. The power-on reset (POR) logic
detects when power is applied to the device, resets the logic to a known state, and begins executing instructions at PROM address
0x0000. The Watchdog timer is used to ensure the microcontroller recovers after a period of inactiv ity . The firmwar e may become
inactive for a variety of reasons, including errors in the code or a hardware failure such as waiting for an interrupt that never occurs.
I2C and HAPI Interface
The microcontroller can communicate with external electronics through th e GPIO pins. An I
dates a 100-kHz serial link with an external device. There is also a Hardware Assisted Parallel Interface (HAPI) which can be
used to transfer data to an external device.
Timer
The free-running 12-bit timer clocked at 1 MHz provides two interrupt sources, 128-µs a nd 1.0 24-ms. The timer can be used to
measure the duration of an event under firmware control by reading the timer at the start of the event and after the event is
complete. The difference between the two readings indicates the duration of the event i n microseconds. The u pper four bits of
the timer are latched into an internal register when the firmware reads the lower eight bits. A read from the upper four bits actually
reads data from the internal register, instead of the timer . This feature eliminates the need for firmware to try to compensate if the
upper four bits increment immediately after the lower eight bits are read.
Interrupts
The microcontroller supports 11 maskable interrupts in the vectored interrupt controller. Interrupt sources include the USB Bus
Reset interrupt, the 128-µs (bit 6) and 1.024-ms (bit 9) outputs from the free-running timer , five USB endpoints, the DAC port, the
GPIO ports, and the I
from LOW ‘0’ to HIGH ‘1.’ The USB endpoints interrupt after the USB host has written data to the endpoint FIFO or after the USB
controller sends a packet to the USB host. The DAC ports have an additional level of masking that allows the user to select which
DAC inputs can cause a DAC interrupt. The GPIO ports also have a level of masking to select which GPIO inputs can cause a
GPIO interrupt. For additional flexibility, the input transition polarity that causes an interrupt is programmable for each pin of the
DAC port. Input transition polarity can be programmed for each GPIO port as part of the port configuration. The interrupt polarity
can be rising edge (‘0’ to ‘1’) or falling edge (‘1’ to ‘0’).
2
C-compatible master mode interface. The timer bits cause an interrupt (if enabled) when the bit toggles
D+[0], D–[0]I/O6, 77, 87, 8Upstream port, USB differential data.
P0I/OP0[7:0]
10, 14, 11, 15,
12, 16, 13, 17
P1I/OP1[2:0]
25, 27, 26
P2I/OP2[6:2]
19, 9, 20, 8,
21
P3I/OP3[2:0]
23, 5, 24
DACI/ODAC[7,2:0]
XTAL
IN
XTAL
OUT
V
PP
V
CC
GNDIN4, 225, 2211, 16, 34, 40 Ground.
V
REF
NC38No Connect.
IN2226-MHz crystal or external clock input.
OUT1116-MHz crystal out.
IN181930Programming voltage supply, tie to ground during
IN282848Voltage supply.
IN333External 3.3V supply voltage for the differential data
P0[7:0]
11, 15, 12, 16,
13, 17, 14, 18
P1[2:0]
26, 4, 27
P2[6:2]
20, 10, 21,
9, 23
P3[2:0]
24, 6, 25
P0[7:0]
20, 26, 21, 27,
22, 28, 23, 29
P1[7:0]
6, 43, 5, 44,
4, 45, 47, 46
P2[7:0]
18, 32, 17, 33,
15, 35, 14, 36
P3[7:0]
13, 37, 12, 39,
10, 41, 7, 42
19, 25, 24, 31
GPIO Port 0 capable of sinking 7 mA (typical).
GPIO Port 1 capable of sinking 7 mA (typical).
GPIO Port 2 capable of sinking 7 mA (typical). HAPI
is also supported through P2[6:2].
GPIO Port 3, capable of sinking 12 mA (typical).
DAC Port with programmable current sink outputs.
DAC[1:0] offer a programmable range of 3.2 to 16 mA
typical. DAC[7,2] have a programmable sink current
range of 0.2 to 1.0 mA typical.
normal operation.
output buffers and the D+ pull-up.
CY7C64013
CY7C64113
4.2I/O Register Summary
I/O registers are accessed via the I/O Read (IORD) and I/O Write (IOWR, IOWX) instructions. IORD reads data from the selected
port into the accumulator. IOWR performs the reverse; it writes data from the accumulator to the selected port. Indexed I/O Write
(IOWX) adds the contents of X to the address in the instruction to form the port address and writes data from the accumulator to
the specified port. Specifying address 0 (e.g., IOWX 0h) means the I/O register is selected solely by the contents of X.
All undefined registers are reserved. It is important not to write to reserved registers as this may cause an undefined operati on
or increased current consumption during operation. When writing to registers with reserved bits, the rese rved bits must be written
with ‘0.’
Table 4-2. I/O Register Summary
Register NameI/O AddressRead/WriteFunctionPage
Port 0 Data0x00R/WGPIO Port 0 Data 19
Port 1 Data0x01R/WGPIO Port 1 Data19
Port 2 Data0x02R/WGPIO Port 2 Data19
Port 3 Data0x03R/WGPIO Port 3 Data20
Port 0 Interrupt Enable0x04WInterrupt Enable for Pins in Port 021
Port 1 Interrupt Enable0x05WInterrupt Enable for Pins in Port 121
Port 2 Interrupt Enable0x06WInterrupt Enable for Pins in Port 221
Port 3 Interrupt Enable0x07WInterrupt Enable for Pins in Port 321
Document #: 38-08001 Rev. *APage 10 of 51
CY7C64013
Table 4-2. I/O Register Summary (continued)
Register NameI/O AddressRead/WriteFunctionPage
GPIO Configuration0x08R/WGPIO Port Configurations20
HAPI and I2C Configuration0x09R/WHAPI Width and I2C Position Configuration24
USB Device Address A0x10R/WUSB Device Address A34
EP A0 Counter Register0x11R/WUSB Address A, Endpoint 0 Counter 35
EP A0 Mode Register0x12R/WUSB Address A, Endpoint 0 Configuration 34
EP A1 Counter Register0x13R/WUSB Address A, Endpoint 1 Counter 35
EP A1 Mode Register0x14R/WUSB Address A, Endpoint 1 Configuration 35
EP A2 Counter Register0x15R/WUSB Address A, Endpoint 2 Counter 35
EP A2 Mode Register0x16R/WUSB Address A, Endpoint 2 Configuration 35
USB Status & Control0x1FR/WUSB Upstream Port Traffic Status and Control34
Global Interrupt Enable0x20R/WGlobal Interrupt Enable 29
Endpoint Interrupt Enable0x21R/WUSB Endpoint Interrupt Enables29
Timer (LSB)0x24RLower 8 Bits of Free-running Timer (1 MHz)23
Timer (MSB)0x25RUpper 4 Bits of Free-running Timer 24
WDT Clear0x26WWatchdog Timer Clear18
2
C Control & Status0x28R/WI2C Status and Control25
I
2
C Data0x29R/WI2C Data25
I
DAC Data0x30R/WDAC Data22
DAC Interrupt Enable0x31WInterrupt Enable for each DAC Pin23
DAC Interrupt Polarity0x32WInterrupt Polarity for each DAC Pin23
DAC Isink0x38-0x3FWI nput Sink Current Control for each DAC Pin22
Reserved0x40Reserved
EP A3 Counter Register0x41R/WUSB Address A, Endpoint 3 Counter35
EP A3 Mode Register0x42R/WUSB Address A, Endpoint 3 Configuration34
EP A4 Counter Register0x43R/WUSB Address A, Endpoint 4 Counter35
EP A4 Mode Register0x44R/WUSB Address A, Endpoint 4 Configuration35
Reserved0x48Reserved
Reserved0x49Reserved
Reserved0x4AReserved
Reserved0x4BReserved
Reserved0x4CReserved
Reserved0x4DReserved
Reserved0x4EReserved
Reserved0x4FReserved
Reserved0x50Reserved
Reserved0x51Reserved
Processor Status & Control0xFFR/WMicroprocessor Status and Control Register26
CY7C64113
Document #: 38-08001 Rev. *APage 11 of 51
CY7C64013
4.3Instruction Set Summary
Refer to the CYASM Assembler User’s Guide for more details.
The 14-bit program counter (PC) allows access to up to 8 KB of PROM available wi th the CY7C 64x13 archite ctu re . The to p 32
bytes of the ROM in the 8 Kb part are reserved for testing purposes. The program counter is cleared during reset, such that the
first instruction executed after a reset is at address 0x0000h. Typically, this is a jump instruction to a reset handler that initializes
the application (see Interrupt Vectors on page 30).
The lower eight bits of the program counter are incremented a s instructions are lo ade d and exec uted. The up per six bits of the
program counter are incremented by executi ng an XPAGE instruction. As a result, the last instruction executed within a 256-byte
“page” of sequential code should be an XPAGE instruction. The assembler directive “XPAGEON” causes the assembler to insert
XPAGE instructions automatically. Because instructions can be either one or two bytes long, the assembler may occasionally
need to insert a NOP followed by an XPAGE to execute correctly.
The address of the next instruction to be executed, the carry flag, and the zero flag are saved as two bytes on the program stack
during an interrupt acknowledge or a CALL instruction. The program counter, carry flag, and zero flag are restored from the
program stack during a RETI instruction. Only the program counter is restored during a RET instruction.
The program counter cannot be accessed directly by the firmware. The program stack can be examined by reading SRAM from
location 0x00 and up.
CY7C64113
Document #: 38-08001 Rev. *APage 13 of 51
5.1.1Program Memory Organization
after resetAddress
14-bit PC0x0000Program execution begins here after a reset
0x0002USB Bus Reset interrupt vector
0x0004128-µs timer interrupt vector
0x00061.024-ms timer interrupt vector
0x0008USB address A endpoint 0 interru pt vector
0x000AUSB address A endpoint 1 interrupt vector
0x000CUSB address A endpoint 2 interrupt vector
0x000EUSB address A endpoint 3 interrupt vector
CY7C64013
CY7C64113
0x0010USB address A endpoint 4 interru pt vector
0x0012Reserved
0x0014DAC interrupt vector
0x0016GPIO interrupt vector
0x0018
0x001A
2
I
C interrupt vector
Program Memory begins here
0x1FDF8 KB (-32) PROM ends here (CY7C64013, CY7C64113)
Document #: 38-08001 Rev. *APage 14 of 51
CY7C64013
5.28-Bit Accumulator (A)
The accumulator is the general-purpose register for the microcontroller.
5.38-Bit Temporary Register (X)
The “X” register is availabl e to the firmware for temporary storage of intermediate results. The microcontroller can perform indexed
operations based on the value in X. Refer to Section 5.6.3 for additional information.
5.48-Bit Program Stack Pointer (PSP)
During a reset, the program stack pointer (PSP) is set to 0x00 and “grows” upward from this address. The PSP may be set by
firmware, using the MOV PSP,A instruction. The PSP supports interrupt service under hardware control and CALL, RET, and
RETI instructions under firmware control. The PSP is not readable by the firmware.
During an interrupt acknowledge, interrupts are disabled and the 14-bit program counter, carry flag, and zero flag are written as
two bytes of data memory . The first byte is stored in the memory addressed by the PSP , then the PSP is incremented. The second
byte is stored in memory addressed by the PSP, and the PSP is incremented again. The overall effect is to store the program
counter and flags on the program “stack” and increment the PSP by two.
The Return from Interrupt (RETI) instruction decrements the PSP , then restores the second byte from memory addressed by the
PSP. The PSP is decremented again and the first byte is restored from memory addressed by the PSP. After the program counter
and flags have been restored from stack, the interrupts are enabled. The overall effect is to restore the program counter and flags
from the program stack, decrement the PSP by two, and reenable interrupts.
The Call Subroutine (CALL) instruction stores the program counter and flags on the program stack and increments the PSP by
two.
The Return from Subroutine (RET) instruction restores the program counter but not the flags from the program stack and decrements the PSP by two.
CY7C64113
5.4.1Data Memory Organization
The CY7C64x13 microcontrollers provide 256 bytes of data RAM. Normally, the SRAM is partitioned into four areas: program
stack, user variables, data stack, and USB endpoint FIFOs. The following is one example of where the program stack, data stack,
and user variables areas could be located.
After resetAddress
8-bit DSP8-bit PSP0x00Program Stack Growth
(Move DSP
8-bit DSP
Notes:
1. Refer to Section 5.5 for a description of DSP.
2. Endpoint sizes are fixed by the Endpoint Size Bit (I/O register 0x1F, Bit 7), see Table 18-1.
[1]
)
user selectedData Stack Growth
User variables
USB FIFO space for five endpoints
0xFF
[2]
Document #: 38-08001 Rev. *APage 15 of 51
CY7C64013
5.58-Bit Data Stack Pointer (DSP)
The data stack pointer (DSP) supports PUSH and POP instructions that use the data stack for temporary storage. A PUSH
instruction pre-decrements the DSP, then writes data to the memory location addressed by the DSP. A POP instruction reads
data from the memory location addressed by the DSP, then post-increments the DSP.
During a reset, the DSP is reset to 0x00. A PUSH instruction when DSP equals 0x00 writes data at the top of the data RAM
(address 0xFF). This writes data to the memory area reserved for USB endpoint FIFOs. Therefore, the DSP should be indexed
at an appropriate memory location that does not compromise the Program Stack, user-defined memory (variables), or the USB
endpoint FIFOs.
For USB applications, the firmware should set the DSP to an appropriate location to avoid a memory conflict with RAM dedicated
to USB FIFOs. The memory requirements for the USB endpoints are described in Section 18.2. Example assembly instructions
to do this with two device addresses (FIFOs begin at 0xD8) are shown below:
MOV A,20h; Move 20 hex into Accumulator (must be D8h or less)
SWAP A,DSP ; swap accumulator value into DSP register
5.6Address Modes
The CY7C64013 and CY7C64113 microcontrollers support three addressing modes for instructions that require data operands:
data, direct, and indexed.
5.6.1Data (Immediate)
“Data” address mode refers to a data operand that is actually a constant encoded in the instruction. As an example, consider the
instruction that loads A with the constant 0xD8:
• MOV A,0D8h
This instruction requires two bytes of code where the first byte identifies the “MOV A” instruction with a data operand as the
second byte. The second byte of the instruction is the constant “0xD8.” A constant may be referred to by name if a prior “EQU”
statement assigns the constant value to the name. For example, the following code is equivalent to the example shown above:
• DSPINIT: EQU 0D8h
• MOV A,DSPINIT
CY7C64113
5.6.2Direct
“Direct” address mode is used when the data operand is a variable stored in SRAM. In that case, the one byte address of the
variable is encoded in the instruction. As an example, consider an instruction that loads A with the contents of memory address
location 0x10:
• MOV A,[10h]
Normally, variable names are assigned to variable addresses using “EQU” statements to improve the readability of the assembler
source code. As an example, the following code is equivalent to the example shown above:
• buttons: EQU 10h
• MOV A,[buttons]
5.6.3Indexed
“Indexed” address mode allows the firmware to manipulate arrays of data stored in SRAM. The address of the data operand is
the sum of a constant encoded in the instruction and the contents of the “X” register . Normally , the constant is the “base” address
of an array of data and the X register contains an index that indicates which element of the array is actually addressed:
• array: EQU 10h
•MOV X,3
• MOV A,[X+array]
This would have the effect of loading A with the fourth element of the SRAM “array” that begins at address 0x10. The fourth
element would be at address 0x13.
Document #: 38-08001 Rev. *APage 16 of 51
6.0 Clocking
XTALOUT
(pin 1)
CY7C64013
CY7C64113
XTALIN
(pin 2)
30 pF
Figure 6-1. Clock Oscillator On-Chip Circuit
The XTALIN and XTALOUT are the clock pins to the microcontroller. The user can connect an external oscillator or a crystal to
these pins. When using an external crystal, keep PCB traces between the chip leads and crystal as short as possible (less than
2 cm). A 6-MHz fundamental frequency parallel resonant crystal can be connected to these pins to provide a reference frequency
for the internal PLL. The two internal 30-pF load caps appear in series to the external crystal and would be equivalent to a 15-pF
load. Therefore, the crystal must have a required load capacitance of about 15–18 pF. A ceramic resonator does not allow the
microcontroller to meet the timing specifications of full speed USB and therefore a cera mic resonator is n ot recommende d with
these parts.
An external 6-MHz clock can be applied to the XTALIN pin if the XTALOUT pin is left open. Grounding the XTALOUT pin when
driving XTALIN with an oscillator does not work because the internal clock is effectively shorted to ground.
To Internal PLL
30 pF
7.0 Reset
The CY7C64x13 supports two resets: Power-On Reset (POR) and a Watchdog Reset (WDR). Each of these resets causes:
• all registers to be restored to their default states,
• the USB Device Address to be set to 0,
• all interrupts to be disabled,
• the PSP and Data Stack Pointer (DSP) to be set to memory address 0x00.
The occurrence of a reset is recorded in the Processor Status and Control Register, as described in Section 15.0. Bits 4 and 6
are used to record the occurrence of POR and WDR, resp ectively. Firmware can interrogate these bits to determine the cause
of a reset.
Program execution starts at ROM address 0x0000 after a reset. Although this looks like interrupt vector 0, there is an important
difference. Reset processing does NOT push the program counter, carry flag, and zero flag onto program stack. The firmware
reset handler should configure the hardware before the “main” loop of code. Attempting to execute a RET or RETI in the firmware
reset handler causes unpredictable execution results.
7.1Power-On Reset (POR)
When VCC is first applied to the chip, the Power-On Reset (POR) signal is asserted and the CY7C64x13 enters a “semi-suspend”
state. During the semi-suspend state, which is different from the suspend state defined in the USB specifica tion, the oscillator
and all other blocks of the part are functional, except for the CPU. This semi-suspend time ensures that both a valid VCC level is
reached and that the internal PLL has time to stabilize before full operation begins. When the V
2.5V, and the oscillator is stable, the POR is deasserted and the on-chip timer starts counting. The first 1 ms of suspend time is
not interruptible, and the semi-suspend state continues for an additional 95 ms unless the count is bypassed by a USB Bus Reset
on the upstream port. The 95 ms provides time for V
If a USB Bus Reset occurs on the upstream port during the 95-ms semi-suspend time, the semi-suspend state is aborted and
program execution begins immediately from address 0x0000. In this case, the Bus Reset inte rrupt is pending but not serviced
until firmware sets the USB Bus Reset Interrupt Enable bit (bit 0 of register 0x20) and enables interrupts with the EI command.
The POR signal is asserted whenever V
again. Behavior is the same as described above.
drops below approximately 2.5V , and remains asserted until VCC rises above this level
CC
to stabilize at a valid operating voltage before the chip executes code.
CC
has risen above approximately
CC
7.2Watchdog Reset (WDR)
The Watchdog Timer Reset (WDR) occurs when the internal Watchdog timer rolls over. Writing any value to the write-only
Watchdog Restart Register at address 0x26 clears the timer. The timer rolls over and WDR occurs if it is not cleared within t
(8 ms minimum) of the last cl ear. Bi t 6 of the Processor S tatus and Control Register is set to record this event (the register contents
are set to 010X0001 by the WDR). A Watchdog Timer Reset lasts for 2 ms, after which the microcontroller begins execution at
ROM address 0x0000.
Document #: 38-08001 Rev. *APage 17 of 51
WATCH
CY7C64013
CY7C64113
t
WATCH
Last write to
Watchdog Timer
Register
The USB transmitter is disabled by a Watchdog Reset because the USB Device Address Register is cleared (see Section 18.1).
Otherwise, the USB Controller would respond to all address 0 transactions.
It is possible for the WDR bit of the Processor Status and Control Register (0xFF) to be set following a POR event. The WDR bit
should be ignored If the firmware interrogates the Processor Status and Control Register for a Set condition on the WDR bit and
if the POR (bit 3 of register 0xFF) bit is set.
No write to WDT
register, so WDR
goes HIGH
Figure 7-1. Watchdog Reset (WDR)
2 ms
Execution begins at
Reset Vector 0x0000
8.0 Suspend Mode
The CY7C64x13 can be placed into a low-power state by setti ng the Suspend bit of the Processor Status and Control register.
All logic blocks in the device are turned off except the GPIO interrupt logic and the USB receiver. The clock oscillator and PLL,
as well as the free-running and Watchdog timers, are shut down. Only the occurrence of an enabled GPIO interrupt or non-idle
bus activity at a USB upstream or downstream port wakes the part out of suspend. The Run bit in the Processor Status and
Control Register must be set to resume a part out of suspend.
The clock oscillator restarts immediately after exiting suspend mode. The microcontroller returns to a fully functional state 1 ms
after the oscillator is stable. The microcontroller executes the instruction following the I/O write that placed the device into suspend
mode before servicing any interrupt requests.
The GPIO interrupt allows the controller to wake-up periodically and poll system components while maintaining a very low average
power consumption. T o achieve the lowest possible current during suspend mode, all I/O should be held at V
applies to internal port pins that may not be bonded in a particular package.
Typical code for entering suspend is shown below:
...; All GPIO set to low-power state (no floating pins)
...; Enable GPIO interrupts if desired for wake-up
mov a, 09h; Set suspend and run bits
iowr FFh; Write to Status and Control Register - Enter suspend, wait for USB activity (or GPIO Interrupt)
nop; This executes before any ISR
...; Remaining code for exiting suspend routine
or Gnd. This also
CC
Document #: 38-08001 Rev. *APage 18 of 51
9.0 General-Purpose I/O (GPIO) Ports
GPIO
CFG
OE
mode
2-bits
Q1
CY7C64013
CY7C64113
V
CC
Q2
Internal
Data Bus
Port Write
Port Read
Reg_Bit
STRB
(Latch is Transparent
except in HAPI mode)
Interrupt
Enable
Interrupt
Controller
Data
Out
Latch
Data
In
Latch
Data
Interrupt
Latch
Control
Control
14 kΩ
Q3*
GPIO
PIN
*Port 0,1,2: Low I
Port 3: High I
sink
sink
Figure 9-1. Block Diagram of a GPIO Pin
There are up to 32 GPIO pins (P0[7:0], P1[7:0], P2[7:0], and P3[7:0]) for the hardware interface. The number of GPIO pins
changes based on the package type of the chip. Each port can be configured as inputs with internal pull-ups, open drain outputs,
or traditional CMOS outputs. Port 3 offers a higher current drive, with typical current sink capability of 12 mA. The data for each
GPIO port is accessible through the data registers. Port data registers are shown in Figure 9-2 through Figure 9-5, and are set
to 1 on reset.
Port 0 DataADDRESS 0x00
Bit #76543210
Bit NameP0.7P0.6P0.5P0.4P0.3P0.2P0.1P0.0
Read/WriteR/WR/WR/WR/WR/WR/WR/WR/W
Reset 11111111
Figure 9-2. Port 0 Data
Port 1 DataADDRESS 0x01
Bit #76543210
Bit NameP1.7P1.6P1.5P1.4P1.3P1.2P1.1P1.0
Read/WriteR/WR/WR/WR/WR/WR/WR/WR/W
Reset11111111
Figure 9-3. Port 1 Data
Port 2 DataADDRESS 0x02
Bit #76543210
Bit NameP2.7P2.6P2.5P2.4P2.3P2.2P2.1P2.0
Read/WriteR/WR/WR/WR/WR/WR/WR/WR/W
Reset11111111
Figure 9-4. Port 2 Data
Document #: 38-08001 Rev. *APage 19 of 51
CY7C64013
Port 3 DataADDRESS 0x03
Bit #76543210
Bit NameP3.7P3.6P3.5P3.4P3.3P32P3.1P3.0
Read/WriteR/WR/WR/WR/WR/WR/WR/WR/W
Reset11111111
Figure 9-5. Port 3 Data
Special care should be taken with any unused GPIO data bits. An unused GPIO data bit, either a pin on the chip or a port bit that
is not bonded on a particular package, must not be left floating when the device enters the suspend state. If a GPIO data bit is
left floating, the leakage current caused by the floating bit may violate the suspend current limitation specified by the USB
Specifications. If a ‘1’ is written to the unused data bit and the port is configured with open drain outputs, the unused data bit
remains in an indeterminate state. Therefore, if an unused port bit is programmed in ope n-drain mode, it must be written wi th a
‘0.’ Notice that the CY7C64013 part always requires that the data bits P1[7:3], P2[7,1,0], and P3[7:3] be written with a ‘0.’
In normal non-HAPI mode, reads from a GPIO port always return the present state of the voltage at the pin, independent of the
settings in the Port Data Registers. If HAPI mode is activated for a port, reads of that port return latched data as controlled by the
HAPI signals (see Section 14.0). During reset, all of the GPIO pins are set to a high-impedance input state (‘1’ in open drain
mode). Writing a ‘0’ to a GPIO pin drives the pin LOW. In this state, a ‘0’ is always read on that GPIO pin unless an external source
overdrives the internal pull-down device.
9.1GPIO Configuration Port
Every GPIO port can be programmed as inputs with internal pull-ups, outputs LOW or HIGH, or Hi-Z (floating, the pin is not driven
internally). In addition, the interrupt polarity for each port can be programmed. The Port Configuration bits (Figure 9-6) and the
Interrupt Enable bit (Figure 9-7 through Figure 9-10) determine the interrupt polarity of the port pins.
CY7C64113
GPIO ConfigurationADDRESS 0x08
Bit #76543210
Bit NamePort 3
Read/WriteR/WR/WR/WR/WR/WR/WR/WR/W
Reset00000000
Config Bit 1
Port 3
Config Bit 0
Port 2
Config Bit 1
Port 2
Config Bit 0
Port 1
Config Bit 1
Port 1
Config Bit 0
Port 0
Config Bit 1
Port 0
Config Bit 0
Figure 9-6. GPIO Configuration Register
As shown in T able 9-1 below , a positive polarity on an input pin represents a rising edge interrupt (LOW to HIGH), and a negative
polarity on an input pin represents a falling edge interrupt (HIGH to LOW).
The GPIO interrupt is generated when all of the following conditions are met: the Interrupt Enable bi t of the associated Port
Interrupt Enable Register is enabled, the GPIO Interrupt Enable bit of the Global Interrupt Enable Register ( Figure 16-1) is
enabled, the Interrupt Enable Sense (bit 2, Figure 15-1) is set, and the GPIO pin of the port sees an event matching the interrupt
polarity.
The driving state of each GPIO pin is determined by the value written to the pin’s Data Register (Figure 9-2 through Figure 9-5)
and by its associated Port Configuration bits as shown in the GPIO Configuration Register (Figure 9-6 ). These ports are configured
on a per-port basis, so all pins in a given port are configured together. The possible port configurations are detailed in T able 9-1.
As shown in this table below, when a GPIO port is configured with CMOS outputs, interrupts from that port are disabled.
During reset, all of the bits in the GPIO Configuration Register are written with ‘0’ to select Hi-Z mode for all GPIO ports as the
default configuration.
Table 9-1. GPIO Port Output Control T ruth Table and Interrupt Polarity
Port Config Bit 1 Port Config Bit 0 Data Register Output Drive Strength Interrupt Enable BitInterrupt Polarity
110Output LOW0Disabled
1Resistive1– (Falling Edge)
100Output LOW0Disabled
1Output HIGH1Disabled
010Output LOW0Disabled
1Hi-Z1– (Falling Edge)
000Output LOW0Disabled
1Hi-Z1+ (Rising Edge)
Document #: 38-08001 Rev. *APage 20 of 51
CY7C64013
Q1, Q2, and Q3 discussed below are the transistors referenced in Figure 9-1. The available GPIO drive strength are:
• Output LOW Mode: The pin’s Data Register is set to ‘0’
Writing ‘0’ to the pin’s Data Register puts the pin in output LOW mode, regardless of the contents of the Port Configuration Bits[1:0]. In
this mode, Q1 and Q2 are OFF. Q3 is ON. The GPIO pin is driven LOW through Q3.
• Output HIGH Mode: The pin’s Data Register is set to 1 and the Port Configuration Bits[1:0] is set to ‘10’
In this mode, Q1 and Q3 are OFF. Q2 is ON. The GPIO is pulled up through Q2. The GPIO pin is capable of sourcing... of current.
• Resistive Mode: The pin’s Data Register is set to 1 and the Port Configuration Bits[1:0] is set to ‘11’
Q2 and Q3 are OFF. Q1 is ON. The GPIO pin is pulled up with an int ernal 14kΩ resistor. In resistive mod e, the pin may serve as an input.
Reading the pin’s Data Register returns a logic HIGH if the pin is not driven LOW by an external source.
• Hi-Z Mode: The pin’s Data Register is set to1 and Port Configuration Bits[1:0] is set either ‘00’ or ‘01’
Q1, Q2, and Q3 are all OFF. The GPIO pin is not driven internally. In this mode, the pin may serve as an input. Reading the Port Data
Register returns the actual logic value on the port pins.
9.2GPIO Interrupt Enable Ports
Each GPIO pin can be individually enabled or disabled as an interrupt source. The Port 0–3 Interrupt Enable reg isters provide
this feature with an interrupt enable bit for each GPIO pin. When HAPI mode (discussed in Section 14.0) is enabled the GPIO
interrupts are blocked, including ports not used by HAPI, so GPIO pins cannot be used as interrupt sources.
During a reset, GPIO interrupts are disabled by clearing all of the GPIO interrupt enable ports. Writing a ‘1’ to a GPIO Interrupt
Enable bit enables GPIO interrupts from the corresponding input pin. All GPIO pins share a common interrupt, as discussed in
Section 16.7
The CY7C64113 features a programmable current sink 4 bit port which is also known as a DAC port. Each of these port I/O pins
have a programmable current sink. Writing a ‘1’ to a DAC I/O pin disables the output current sink (Isink DAC) and drives the I/O
pin HIGH through an integrated 14-kΩ resistor. When a ‘0’ is written to a DAC I/O pin, the Isink DAC is enabled and the pull-up
resistor is disabled. This causes the I
DAC port pin.
DAC to sink current to drive the output LOW. Figure 10-1 shows a block diagram of the
sink
Document #: 38-08001 Rev. *APage 21 of 51
CY7C64013
V
CC
CY7C64113
Internal
Data Bus
Data
Out
Latch
DAC Write
Suspend
(Bit 3 of Register 0xFF)
Q1
14 kΩ
DAC
I/O Pin
4 bits
Isink
DAC
to Interrupt
Controller
Interrupt
Enable
Interrupt
Polarity
Internal
Buffer
DAC Read
Isink
Register
Interrupt Logic
Figure 10-1. Block Diagram of a DAC Pin
The amount of sink current for the DAC I/O pin is programmable over 16 values based on the contents of the DAC Isink Register
for that output pin. DAC[1:0] are high-current outputs that are programmable from 3.2 mA to 16 mA (typical). DAC[7:2] are lowcurrent outputs, programmable from 0.2 mA to 1.0 mA (typical).
When the suspend bit in Processor Status and Control Register (see Figure 15-1) is set, the Isink DAC block of the DAC circuitry
is disabled. Special care should be taken when the CY7C64x13 device is placed in the suspend mode. The DAC Port Data
Register (see Figure 10-2) should normally be loaded with all ‘1’s (0xFF) before setting the suspend bit. If any of the DAC bits
are set to ‘0’ when the device is suspended, that DAC input will float. The floating pin could result in excessive current consumption
by the device, unless an external load places the pin in a deterministic state.
DAC Port Data ADDRESS 0x30
Bit #76543210
Bit NameDAC[7]ReservedReservedReservedReservedDAC[2]DAC[1]DAC[0]
Read/WriteR/WR/WR/WR/WR/WR/WR/WR/W
Reset11111111
Figure 10-2. DAC Port Data
Bit [1..0]: High Current Output 3.2 mA to 16 mA typical
1= I/O pin is an output pulled HGH through the 14-kΩ resistor. 0 = I/O pin is an input with an internal 14-kΩ pull-up resistor
Bit [3..2]: Low Current Output 0.2 mA to 1 mA typical
1= I/O pin is an output pulled HGH through the 14-kΩ resistor. 0 = I/O pin is an input with an internal 14-kΩ pull-up resistor
10.1DAC Isink Registers
Each DAC I/O pin has an associated DAC Isink register to program the output sink current when the output is driven LOW. The
first Isink register (0x38) controls the current for DAC[0], the second (0x39) for DAC[1], and so on until the Isink register at 0x3F
controls the current to DAC[7].
DAC Sink RegisterADDRESS 0x38 -0x3F
Bit #76543210
Bit NameReservedReservedReservedReservedIsink[3]Isink[2]Isink[1]Isink[0]
Read/WriteWWWW
Reset----0000
Figure 10-3. DAC Sink Register
Document #: 38-08001 Rev. *APage 22 of 51
CY7C64013
Bit [4..0]: Isink [x] (x= 0..4)
Writing all ‘0’s to the Isink register causes 1/5 of the max current to flow through the DAC I/O pin. Writing all ‘1’s to the
Isink register provides the maximum current flow through the pin. The other 14 states of the DAC sink current are evenly
spaced between these two values.
Bit [7..5]: Reserved
10.2DAC Port Interrupts
A DAC port interrupt can be enabled/disable d for each pin individually. The DAC Port Interrupt Enable register provides this
feature with an interrupt enable bit for each DAC I/O pin.All of the DAC Port Interrupt Enable register bits are cleared to ‘0’ during
a reset. All DAC pins share a common interrupt, as explained in Section 16.6.
DAC Port InterruptADDRESS 0x31
Bit #76543210
Bit NameEnable Bit 7ReservedReservedReservedReservedEnable Bit 2Enable Bit 1Enable Bit 0
Read/WriteWWWWWWWW
Reset00000000
Figure 10-4. DAC Port Interrupt Enable
Bit [7..0]: Enable bit x (x= 0..2, 7)
1= Enables interrupts from the corresponding bit position; 0= Disables interrupts from the corresponding bit position
As an additional benefit, the interrupt polarity fo r each DAC pin is p rogrammable with the DAC Port Interrupt Polarity reg ister.
Writing a ‘0’ to a bit selects negative polarity (falling edge) that causes an interrupt (if enabled) if a falling edge transition occurs
on the corresponding input pin. Writing a ‘1’ to a bit in this register selects positive polarity (rising edge) that causes an interrupt
(if enabled) if a rising edge transition occurs on the corresponding input pin. All of the DAC Port Interrupt Polarity register bits are
cleared during a reset.
DAC Port Interrupt Polarity ADDRESS 0x32
Bit #76543210
Bit NameEnable Bit 7ReservedReservedReservedReservedEnable Bit 2Enable Bit 1Enable Bit 0
Read/WriteWWWWWWWW
Reset00000000
CY7C64113
Figure 10-5. DAC Port Interrupt Polarity
Bit [7..0]: Enable bit x (x= 0..2, 7)
1= Selects positive polarity (rising edge) that causes an interrupt (if enabled);
0= Selects negative polarity (falling edge) that causes an interrupt (if enabled)
11.0 12-Bit Free-Running Timer
The 12-bit timer provides two interrupts (128-µs and 1.024-ms) and a llows the firmware to di rectly time events that are up to 4
ms in duration. The lower 8 bits of the timer can be read directly by the firmware. Reading the lo wer 8 bits latches the upper 4
bits into a temporary register. When the firmware reads the upper 4 bits of the timer, it is accessing the count stored in the
temporary register. The effect of this logic is to ensure a stable 12-bit timer value can be read, even when the two reads are
separated in time.
Timer LSBADDRESS 0x24
Bit #76543210
Bit NameTimer Bit 7Timer Bit 6Timer Bit 5Timer Bit 4Timer Bit 3Timer Bit 2Timer Bit 1Timer Bit 0
Read/WriteRRRRRRRR
Reset00000000
Figure 11-1 . Timer LSB Register
Bit [7:0]: Timer lower 8 bits
Document #: 38-08001 Rev. *APage 23 of 51
CY7C64013
Timer MSBADDRESS 0x25
Bit #76543210
Bit NameReservedReservedReservedReservedTimer Bit 11Timer Bit 10Timer Bit 9Timer Bit 8
Read/Write----RRRR
Reset00000000
Figure 11-2. Timer MSB Register
Bit [3:0]: Timer higher nibble
Bit [7:4]: Reserved
1.024-ms Interrupt
128-
CY7C64113
µs Interrupt
10978
6432
5
1011
1-MHz Clock
L1L0L2L3
D3 D2D1 D0D7 D6D5 D4D3 D2 D1 D0
To Timer Register
8
Figure 11-3. Timer Block Diagram
12.0 I2C and HAPI Configuration Register
Internal hardware supports communication with external devices through two interfaces: a two-wire I2C-compatible interface, and
a HAPI for 1, 2, or 3 byte transfers. The I
14.0, share a common configuration register (see Figure 12-1). All bits of this register are cleared on reset.
2
I
C ConfigurationADDRESS 0x09
Bit #76543210
Bit NameI
Read/WriteR/W-R/WR/WRRR/WR/W
Reset00000000
2
C PositionReservedLEMPTY
2
C-compatible interface and HAPI functions, discussed in detail in Sections 13.0 and
Polarity
DRDY
Polarity
Latch
Empty
Data
Ready
HAPI Port Width
Bit 1
HAPI Port Width
Bit 0
Figure 12-1. HAPI/I2C Configuration Register
Note: I2C-compatible function must be separately enabled as described in Section 13.0
Bits [7,1:0] of the HAPI/I
Bits [5:2] are used in HAPI mode only, and are described in Section 14.0. Table 12-1 shows the HAPI port configurations, and
Table 12-2 shows I
packages, and to allow simultaneous HAPI and I
HAPI operation is enabled whenever either HAPI Port Width Bit (Bit 1 or 0) is non-zero. This affect s GPIO operation as described
in Section 14.0. I
2
2
C Configuration Register control the pin out configuration of the HAPI and I2C-compatible interfaces.
2
C pin location configuration options. These I2C-compatible options exist due to pin limitations in certain
2
C-compatible operation.
C-compatible blocks must be separately enabled as described in Section 13.0.
The I2C-compatible block provides a versatile two-wire communication with external devices, supporting master , slave, and multimaster modes of operation. The I
interrupts as needed to allow firmware to take appropriate action during transactions. While waiting for firmware response, the
hardware keeps the I2C-compatible bus idle if necessary.
The I2C-compatible block generates an interrupt to the microcontroller at the end of each received or transmitted byte, when a
stop bit is detected by the slave when in receive mode, or when arbitration is lost. Details of the interrupt responses are given in
Section 16.8.
The I
(Figure 13-2). The Data Register is implemented as separate read and write registers. Generally, the I
Register should only be monitored after the I
read misleading bit status if a transaction is underway.
The I
1 or GPIO port 2. Refer to Section 12.0 for the bit definitions and fu nctionality of the HAPI/I
used to set the locations of the configurable I
0 of the I
regardless of the settings of the GPIO Configuration Register.The electrical characteristics of the I
same as that of GPIO ports 1 and 2. Note that the I
All control of the I
I2C DataADDRESS 0x29
Bit #76543210
Bit Name I
Read/WriteR/WR/WR/WR/WR/WR/WR/WR/W
ResetXXXXXXXX
2
C Port Configuration
2
C Position (Bit[7])Port Width (Bit[1]) I2C Position
I
2
X1I
00I
10I
2
C-compatible block functions by handling the low-level signaling in hardware, and issuing
2
C-compatible interface consists of two registers, an I2C Data Register (Figure 13-1) and an I2C Status and Control Register
2
C interrupt, as all bits are valid at that time. Polling this register at other times could
2
C SCL clock is connected to bit 0 of GPIO port 1 or GPIO port 2, and the I2C SDA data is connected to bit 1 of GPIO port
2
2
C Status & Control Register, the two LSB bits ([1:0]) of the corresponding GPIO port are placed in Open Drain mode,
2
C clock and data lines is performed by the I2C-compatible block.
2
C Data 7 I2C Data 6 I2C Data 5 I2C Data 4 I2C Data 3 I2C Data 2 I2C Data 1 I2C Data 0
C-compatible pins. Once the I2C-compatible functionality is enabled by setting bit
(max) is 2 mA @ V
OL
= 2.0 V for ports 1 and 2.
OL
C on P2[1:0], 0:SCL, 1:SDA
2
C on P1[1:0], 0:SCL, 1:SDA
2
C on P2[1:0], 0:SCL, 1:SDA
2
C Configuration Register, which is
2
C-compatible interface is the
CY7C64113
2
C Status and Control
Figure 13-1. I2C Data Register
Bits [7..0] : I2C Data
2
Contains the 8 bit data on the I
I2C Status and Control
Bit #76543210
Bit NameMSTR ModeContinue/BusyXmit ModeACKAddrARB
Read/WriteR/WR/WR/WR/WR/WR/WR/WR/W
Reset00000000
C Bus
Lost/Restart
Received StopI
2
C Enable
Figure 13-2. I2C Status and Control Register
The I2C Status and Control register bits are defined in Table 14-1, with a more detailed description following.
Document #: 38-08001 Rev. *APage 25 of 51
CY7C64013
CY7C64113
Table 13-1. I
2
C Status and Control Register Bit Definitions
BitNameDescription
2
0I
C EnableWhen set to ‘1’, the I2C-compatible function is enabled. When cleared, I2C GPIO pins
operate normally.
1Received StopReads 1 only in slave receive mode, when I2C Stop bit detected (unless firmware did not
ACK the last transaction).
2ARB Lost/RestartReads 1 to indicate master has lost arbitration. Reads 0 otherwise.
Write to 1 in master mode to perform a restart sequence (also set Continue bit).
3AddrReads 1 during first byte after start/restart in slave mode, or if master loses arbitration.
Reads 0 otherwise. This bit should always be written as 0.
4ACKIn receive mode, write 1 to generate ACK, 0 for no ACK.
In transmit mode, reads 1 if ACK was received, 0 if no ACK received .
5Xmit ModeWrite to 1 for transmit mode, 0 for receive mode.
6Continue/BusyWrite 1 to indicate ready for next transaction.
Reads 1 when I
2
C-compatible block is busy with a transaction, 0 when transaction is
complete.
7MSTR ModeWrite to 1 for master mode, 0 for slave mode. This bit is cleared if master loses arbitration.
Clearing from 1 to 0 generates Stop bit.
Bit 7 : MSTR Mode
2
Setting this bit to 1 causes the I
C-compatible block to initiate a master mode transaction by sending a start bit and transmitting the first
data byte from the data register (this typically holds the target address and R/W bit). Subsequent bytes are initiated by setting the
Continue bit, as described below.
Clearing this bit (set to 0) causes the GPIO pins to operate normally
In master mode, the I
receive state. The I
2
C-compatible block generates the clock (SCK), and drives the data line as required depending on transmit or
2
C-compatible block performs any required arbitration and clock synchronization. IN the event of a loss of arbitration, this MSTR bit is cleared, the ARB Lost bit is set, and an interrupt is generated by the microcontroller. If the chip is the target of
an external master that wins arbitration, then the interrupt is held off until the transaction from the external master is completed.
When MSTR Mode is cleared from 1 to 0 by a firmware write, an I
2
C Stop bit is generated.
Bit 6 : Continue / Busy
This bit is written by the firmware to indicate that the firmware is ready for the next byte transaction to begin. In other words, the bit
has responded to an interrupt request and has completed the required update or read of the data register . During a read this bit indicates
if the hardware is busy and is locking out additional writes to the I
complete certain operations that may require an extended period of time. Following an I
2
C Status and Control register. This locking allows the hardware to
2
C interrupt, the I2C-compatible block does
not return to the Busy state until firmware sets the Continue bit. This allows the firmware to make one control register write without
the need to check the Busy bit.
Bit 5 : Xmit Mode
This bit is set by firmware to enter transmit mode and perform a data tr ansmit in m aster or slave mode. Cle aring this b it sets the pa rt in
receive mode. Firmware generally determines the value of this bit from the R/W bit associated with the I
2
C address packet. The Xmit
Mode bit state is ignored when initially writing the MSTR Mode or the Restart bits, as these cases always cause transmit mode for the
first byte.
Bit 4 : ACK
This bit is set or cleared by firmware during receive operation to indicate if the hardware should generate an ACK signal on the I
compatible bus. Writing a 1 to this bit generates an ACK (SDA LOW) on the I
2
C-compatible bus at the ACK bit time. During transmits
(Xmit Mode = 1), this bit should be cleared.
Bit 3 : Addr
This bit is set by the I
2
C-compatible block during the first byte of a slave receive transa ct ion, aft er an I2C start or restart. The Addr bit
is cleared when the firmware sets the Continue bit. This b it a ll o ws t he firmware to recognize when the master has lost arbitra tion, and
in slave mode it allows the firmware to recognize that a start or restart has occurred.
Bit 2 : ARB Lost/Restart
This bit is valid as a status bit (ARB Lost) after master mode transactions. In master mode, set this bit (along with the Continue and
MSTR Mode bits) to perform an I
2
C restart sequence. The I2C target address for the restart must be written to the data register before
setting the Continue bit. To prevent false ARB Lost signals, the Restart bit is cleared by hardware during the restart sequence.
2
C-
Document #: 38-08001 Rev. *APage 26 of 51
CY7C64013
Bit 1 : Receive Stop
This bit is set when the slave is in receive mode and det ects a stop bit on the bus. The Receive Stop bit is not set if the firmware terminates
2
the I
C transaction by not acknowledging the previous byte transmitted on the I2C-compatible bus, e.g. in receive mode if firmware
sets the Continue bit and clears the ACK bit.
2
Bit 0 : I
14.0 Hardware Assisted Parallel Interface (HAPI)
The CY7C64x13 processor provides a hardware assisted parallel interface for bus widths of 8, 16, or 24 bits, to accommodate
data transfer with an external microcontroller or similar device. Control bits for selecting the byte width are in the H API/I
Configuration Register (Figure 12-1), bits 1 and 0.
Signals are provided on Port 2 to control the HAPI interface. Table 14-1 describes these signals and the HAPI control bits in the
HAPI/I
overridden. The Port 2 output pins are in CMOS output mode and Port 2 input pins are in input mode (open drain mode with Q3
OFF in Figure 9-1).
Table 14-1. Port 2 Pin and HAPI Configuration Bit Definitions
P2[2]LatEmptyPinOutReady for more input data from external interface.
P2[3]DReadyPinOutOutput data ready for external interface.
P2[4]STB
P2[5]OE
P2[6]CS
2Data ReadyRAsserted after firmware writes data to Port 0, until OE
3Latch EmptyRAsserted after firmware reads data from Port 0, until STB driven LOW.
4DRDY PolarityR/WDetermines polarity of Data Ready bit and DReadyPin:
5LEMPTY PolarityR/WDetermines polarity of Latch Empty bit and LatEmptyPin:
C Enable
Set this bit to override GPIO definition with I
pins are free to function as GPIOs. In I
configuration setting.
2
C Configuration Register. Enabling HAPI causes the GPIO setting in the GPIO Configuration Register (0x08) to be
PinNameDirectionDescription (Port 2 Pin)
InStrobe signal for latching incoming data.
InOutput Enable, causes chip to output data.
InChip Select (Gates STB and OE).
2
C-compatible function on the two I2C-compatible pins. When this bit is cleared, these
2
C-compatible mode, the two pins operate in open drain mode, independent of the GPIO
If 0, Data Ready is active LOW, DReadyPin is active HIGH.
If 1, Data Ready is active HIGH, DReadyPin is active LOW.
If 0, Latch Empty is active LOW, LatEmptyPin is active HIGH.
If 1, Latch Empty is active HIGH, LatEmptyPin is active LOW.
CY7C64113
2
driven LOW.
C
HAPI Read by External Device from CY7C64x13:
In this case (see Figure 24-3), firmware writes data to the GPIO ports. If 16-bit or 24-bit transfers are being made, Port 0 should
be written last, since writes to Port 0 asserts the Data Ready bit and the DReady Pin to signal the external device that data is
available.
The external device then drives the OE
When OE
for the next output, again writing Port 0 last.
The Data Ready bit reads the opposite state from the external DReadyPin on pin P2[3]. If the DRDY Polarity bit is 0, DReadyPin
is active HIGH, and the Data Ready bit is active LOW.
HAPI Write by External Device to CY7C64x13:
In this case (see Figure 24-4), the external device drives the STB
port pins. When this happens, the internal latches become full, which causes the Latch Empty bit to be deasserted. Whe n STB
is returned HIGH (inactive), the HAPI/GPIO interrupt is generated. Firmware then reads the parallel ports to empty the HAPI
latches. If 16-bit or 24-bit transfers are being made, Port 0 should be read last because reads from Port 0 assert the Latch Empty
bit and the LatEmptyPin to signal the external device for more data.
The Latch Empty bit reads the opposite state from the external LatEmptyPin on pin P2[2]. If the LEMPTY Polarity bit is 0,
LatEmptyPin is active HIGH, and the Latch Empty bit is active LOW.
Document #: 38-08001 Rev. *APage 27 of 51
is returned HIGH (inactive), the HAPI/GPIO interrupt is generated. At that point, firmware can reload the HAPI latches
and CS pins active (LOW), which causes the HAPI data to be output on the port pins.
and CS pins active (LOW) when it drives new data onto the
CY7C64013
15.0 Processor Status and Control Register
Processor Status and ControlADDRESS 0xFF
Bit #76543210
Bit NameIRQ
Read/WriteRR/WR/WR/WR/WRR/WR/W
Reset00010001
Pending
Bit 0: Run
This bit is manipulated by the HALT instruction. When Halt is executed, all the bits of the Processor Status and Control Register are
cleared to 0. Since the run bit is cleared, the processor stops at the end of the current instruction. The processor remains halted until an
appropriate reset occurs (power-on or Watchdog). This bit should normally be written as a ‘1.’
Bit 1: Reserved
Bit 1 is reserved and must be written as a zero.
Bit 2: Interrupt Enable Sense
This bit indicates whether interrupts are enabled or disabled. Firmware has no direct control over this bit as writing a zero or one to this
bit position has no effect on interrupts. A ‘0’ indicates that interrupts are masked of f a nd a ‘1’ ind icate s tha t the in terr upts are e nabl ed.
This bit is further gated with the bit settings of the Global Interrupt Enable Register (Figure 16-1) and USB End Point Interrupt Enable
Register (Figure 16-2). Instructions DI, EI, and RETI manipulate the state of this bit.
Bit 3: Suspend
Writing a ‘1’ to the Suspe nd bit halts the processor and cause the microcontroller to enter the suspend mode that significantly reduces
power consumption. A pending, enabled interrupt or USB bus activity causes the device to come out of suspend. After coming out of
suspend, the device resumes firmware execution at the instruction following the IOWR which put the part into suspend. An IOWR
attempting to put the part into suspend is ignored if USB bus activity is present. See Section 8.0 for more details on suspend mode
operation.
Bit 4: Power-On Reset
The Power-On Reset is set to ‘1’ during a power-on reset. T he firmware can check bit s 4 and 6 in the reset han dler to determine whether
a reset was caused by a power-on condition or a W atchdog timeout. A POR event may be fo llowed by a W atchdog reset before firmware
begins executing, as explained below.
Bit 5: USB Bus Reset Interrupt
The USB Bus Reset Interrupt bit is set when the USB Bus Reset is detected on rece iving a USB Bus Reset signal o n the upstream p ort.
The USB Bus Reset signal is a single-ended zero (SE0) that lasts from 12 to 16 µs. An SE0 is defined as the condition in which both
the D+ line and the D– line are LOW at the same time..
Bit 6: Watchdog Reset
The Watchdog Reset is set during a reset initiated by the Watchdog Timer. This indicates the Watchdog Timer went for more than
t
(8 ms minimum) between W atchdog clears. This can occur with a POR event, as noted below.
WATCH
Bit 7: IRQ Pending
The IRQ pending, when set, indicates that one or more of the interrupts has been recognized as active. An interrupt remains pending
until its interrupt enable bit is set (Figure 16-1, Figure 16-2) and interrupts are globally enabled. At that point, the internal interrupt
handling sequence clears this bit until another interrupt is detected as pending.
During power-up, the Processor Status and Control Register is set to 00010001, which indicates a POR (bit 4 set) has occurred
and no interrupts are pending (bit 7 clear). During the 96 ms suspend at start-up (explained in Section 7.1), a Watchdog Reset
also occurs unless this suspend is aborted by an upstream SE0 before 8 ms. If a WDR occurs during the p ower-up suspend
interval, firmware reads 01010001 from the Status and Control Register after power-up. Normally, the POR bit should be cleared
so a subsequent WDR can be clearly identified. If an upstream bus reset is received before firmware examines this register , the
Bus Reset bit may also be set.
During a Watchdog Reset, the Processor Status and Control Register(Figure 15-1) is set to 01XX0001b, which indicates a
Watchdog Reset (bit 6 set) has occurred and no interrupts are pending (bit 7 clear). The Watchdog Reset does not effect the
state of the POR and the Bus Reset Interrupt bits.
Watchdog
Reset
USB Bus Reset
Interrupt
Power-On
Reset
SuspendInterrupt
Figure 15-1. Processor Status and Control Register
Enable Sense
CY7C64113
ReservedRun
Document #: 38-08001 Rev. *APage 28 of 51
CY7C64013
16.0 Interrupts
Interrupts are generated by the GPIO/DAC pins, the internal timers, I2C-compatible interface or HAPI operation, or on various
USB traffic conditions. All interrupts are maskable by the Global Interrupt Enable Register and the USB End Point Interrupt Enable
Register. Writing a ‘1’ to a bit position enables the interrupt associated with that bit position.
Global Interrupt Enable RegisterADDRESS 0X20
Bit #76543210
2
Bit NameReservedI
Read/Write-R/WR/W-R/WR/WR/WR/W
Reset-00X0000
C Interrupt
Enable
Bit 0 : USB Bus RST Interrupt Enable
1= Enable Interrupt on a USB Bus Reset; 0 = Disable interrupt on a USB Bus Reset (Refer to section 16.3)
Bit 1 :128-µs Interrupt Enable
1 = Enable Timer interrupt every 128 µs; 0 = Disable Timer Interrupt for every 128 µs.
Bit 2 : 1.024-ms Interrupt Enable
1= Enable Timer interrupt every 1.024 ms ; 0 = Disable Timer Interrupt every 1.024 ms.
1 = Enable Interrupt on falling/rising edge on any GPIO; 0 = Disable Interrupt on falling/rising edge on any GPIO (Refer to section
14.7, 9.1 and 9.2.)
2
Bit 6 : I
C Interrupt Enable
1= Enable Interrupt on I2C related activity; 0 = Disable I2C related activity interrupt. (Refer to section 16.8).
Bit 7 : Reserved
USB Endpoint Interrupt Enable ADDRESS 0X21
Bit #76543210
Bit NameReservedReserved Reserved EPB1 Interrupt
Read/Write--- R/WR/WR/WR/WR/W
Reset- --00000
Figure 16-2. USB Endpoint Interrupt Enable Register
GPIO Interrupt
Enable
DAC Interrupt
enable
Reserved1.024-ms
Figure 16-1. Global Interrupt Enable Register
Enable
EPB0 Interrupt
Enable
Interrupt Enable
EPA2 Interrupt
Enable
CY7C64113
128-µs Interrupt
Enable
EPA1 Interrupt
Enable
USB Bus RST
Interrupt Enable
EPA0 Interr upt
Enable
Bit 0: EPA0 Interrupt Enable
1= Enable Interrupt on data activity through endpoint A0; 0= Disable Interrupt on data activity through endpoint A0
Bit 1: EPA1 Interrupt Enable
1= Enable Interrupt on data activity through endpoint A1; 0= Disable Interrupt on data activity through endpoint A1
Bit 2: EPA2 Interrupt Enable
1= Enable Interrupt on data activity through endpoint A2; 0= Disable Interrupt on data activity through endpoint A2.
Bit 3: EPB0 Interrupt Enable
1= Enable Interrupt on data activity through endpoint B0; 0= Disable Interrupt on data activity through endpoint B0
Bit 4: EPB1 Interrupt Enable
1= Enable Interrupt on data activity through endpoint B1; 0= Disable Interrupt on data activity through endpoint B1
Bit [7..5] : Reserved
During a reset, the contents the Global Interrupt Enable Reg ister and USB End Point Interrupt Enable Register are cleared,
effectively , disabling all interrupts
Document #: 38-08001 Rev. *APage 29 of 51
CY7C64013
The interrupt controller contains a separate flip-flop for each interrupt. See Figure 16-3 for the logic block diagram of the interrupt
controller. When an interrupt is generated, it is first registered as a pending interrupt. It stays pending until it is serviced or a reset
occurs. A pending interrupt only generates an interrupt request if it is enabled by the corresponding bit in the interrupt enab le
registers. The highest priority interrupt request is serviced following the completion of the currently executing instruction.
When servicing an interrupt, the hardware does the following
1. Disables all interrupts by clearing the Global Interrupt Enable bit in the CPU (the state of this bit can be read at Bit 2 of the Processor S tatus
and Control Register, Figure 15-1).
2. Clears the flip-flop of the current interrupt.
3. Generates an automatic CALL instruction to the ROM address associated with the interrupt being serviced (i.e., the Interrupt Vector, see
Section 16.1).
The instruction in the interrupt table is typically a JMP instruction to the address of the Interrupt Service Routine (ISR). The user
can re-enable interrupts in the interrupt service routine by executing an EI instruction. Interrupts can be nested to a level limited
only by the available stack space.
The Program Counter value as well as the Carry and Zero flags (CF, ZF) are stored onto the Program Stack by the automatic
CALL instruction generated as part of the interrupt acknowledge process. The user firmware is responsible for ensuring that the
processor state is preserved and restored during an interrupt. The PUSH A instruction sho uld typically be used as the first
command in the ISR to save the accumulator value and the POP A instruction should be used to restore the accumulator value
just before the RETI instruction. The program counter CF and ZF are restored an d interrupts are enabled when the RETI
instruction is executed.
The DI and EI instructions can be used to disable and enable interrupts, respectively. These instructions affect only the Global
Interrupt Enable bit of the CPU. If desired, EI can be used to re-enable interrupts while inside an ISR, instead of waiting for the
RETI that exists the ISR. While the global interrupt enable bit is cleared, the presence of a pending interrupt can be detected by
examining the IRQ Sense bit (Bit 7 in the Processor Status and Control Register).
CY7C64113
16.1Interrupt Vectors
The Interrupt Vectors supported by the USB Controller are listed in Table 16-1. The lowest-numbered interrupt (USB Bus Reset
interrupt) has the highest priority, and the highest-numbered interrupt (I
USB Reset Clear
1
USB Reset Int
1
AddrA ENP2 Int
I2C Int
CLR
D
Q
Enable [0]
Q
Enable [2]
(Reg 0x21)
Q
(Reg 0x20)
(Reg 0x20)
Enable [6]
CLK
CLR
D
CLK
CLR
1
D
CLK
USB Reset IRQ
128-µs CLR
128-µs IRQ
1-ms CLR
1-ms IRQ
AddrA EP0 CLR
AddrA EP0 IRQ
AddrA EP1 CLR
AddrA EP1 IRQ
AddrA EP2 CLR
AddrA EP2 IRQ
AddrB EP0 CLR
AddrB EP0 IRQ
AddrB EP1 CLR
AddrB EP1 IRQ
Hub CLR
Hub IRQ
DAC CLR
DAC IRQ
GPIO CLR
GPIO IRQ
2
I
C CLR
2
C IRQ
I
Interrupt Priority Encoder
2
C interrupt) has the lowest priority.
Interrupt
Vector
To CPU
CPU
IRQout
Global
Interrupt
Enable
Bit
CLR
Interrupt
Acknowledge
IRQ Sense
Int Enable
Sense
Controlled by DI, EI, and
RETI Instructions
IRQ
Figure 16-3. Interrupt Controller Function Diagram
Although Reset is not an interrupt, the first instruction executed after a reset is at PROM address 0x0000h—which corresponds
to the first entry in the Interrupt Vector T able. Because the JMP instruction is two bytes long, the interrupt vectors occupy two bytes.
Document #: 38-08001 Rev. *APage 30 of 51
CY7C64013
Table 16-1. Interrupt Vector Assignments
Interrupt Vector NumberROM AddressFunction
Not Applicable0x0000Execution after Reset begins here
10x0002USB Bus Reset interrupt
20x0004128-µs timer interrupt
30x00061.024-ms timer interrupt
40x0008USB Address A Endpoint 0 interrupt
50x000AUSB Address A Endpoint 1 interrupt
60x000CUSB Address A Endpoint 2 interrupt
70x000EUSB Address A Endpoint 3 interrupt
80x0010USB Address A Endpoint 4 interrupt
Interrupt latency can be calculated from the following equation:
Interrupt latency =(Number of clock cycles remaining in the current instruction) + (10 clock cycles for the CALL instruction) +
(5 clock cycles for the JMP instruction)
For example, if a 5 clock cycle instruction such as JC is being executed when an interrupt occurs, the first instruction of the
Interrupt Service Routine executes a minimum of 16 clocks (1+10+5) or a maximum of 20 clocks (5+10+5) after the interrupt is
issued. For a 12-MHz internal clock (6-MHz crystal), 20 clock periods is 20 / 12 MHz = 1.667 µs.
2
C interrupt
CY7C64113
16.3USB Bus Reset Interrupt
The USB Controller recognizes a USB Reset when a Single Ended Zero (SE0) condition persists on the upstream USB port for
12–16 µs (the Reset may be recognized for an SE0 as short as 12 µs, but is always recognized for an SE0 longer than 16 µs).
SE0 is defined as the condition in which both the D+ line and the D– line are LOW. Bit 5 of the Status and Control Register is set
to record this event. The interrupt is asserted at the e nd of the Bus Reset. If the USB reset occurs during the start-up delay
following a POR, the delay is aborted as described in Section 7.1. The USB Bus Reset Interrupt is generated when the SE0 state
is deasserted.
A USB Bus Reset clears the following registers:
SIE Section:USB Device Address Registers (0x10, 0x40)
16.4Timer Interrupt
There are two periodic timer interrupts: the 128-µs interrupt and the 1.024-ms interrupt. The user should disable both timer
interrupts before going into the suspend mode to avoid possible conflicts between servicing the timer interrupts first or the suspend
request first.
16.5USB Endpoint Interrupts
There are five USB endpoint interrupts, one per endpoint. A USB endpoint interrupt is generated after the USB host writes to a
USB endpoint FIFO or after the USB controller sends a packet to the USB host. The interrupt is generated on the last packet of
the transaction (e.g., on the host’s ACK during an IN, or on the device ACK during on OUT). If no ACK is received during an IN
transaction, no interrupt is generated.
16.6DAC Interrupt
Each DAC I/O pin can generate an interrupt, if enabled. The interrupt polarity for each DAC I/O pin is programmable. A positive
polarity is a rising edge input while a negative polarity is a falling edge input. All of the DAC pins share a single interrup t vector,
which means the firmware needs to read the DAC port to determine which pin or pins caused an interrupt.
If one DAC pin has triggered an interrupt, no other DAC pins can cause a DAC interrupt until that pin has returned to its inactive
(non-trigger) state or the corresponding interrupt enable bit is cleared. The USB Controller does not assign interrupt priority to
different DAC pins and the DAC Interrupt Enable Register is not cleared during the interrupt acknowledge process.
Document #: 38-08001 Rev. *APage 31 of 51
CY7C64013
16.7GPIO/HAPI Interrupt
Each of the GPIO pins can generate an interrupt, if enabled. The interrupt polarity can be prog rammed for each GPIO port as
part of the GPIO configuration. All of the GPIO pins share a single interrupt vector, which means the firmware needs to read the
GPIO ports with enabled interrupts to determine which pin or pins caused an in terrupt. A block diagram of the GPIO interrupt
logic is shown in Figure 16-4. Refer to Sections 9.1 and 9.2 for more information of setting GPIO interrupt polarity and enabling
individual GPIO interrupts.
If one port pin has triggered an interrupt, no other port pins can cause a GPIO interrupt until that port pin has returned to its inactive
(non-trigger) state or its corresponding port interrupt enable bit is cleared. The USB Controller does not assign interrupt pri ority
to different port pins and the Port Interrupt Enable Registers are not cleared during the interrupt acknowledge process.
Port
GPIO
Pin
Configuration
Register
M
U
X
OR Gate
(1 input per
GPIO pin)
GPIO Interrupt
Flip Flop
D
1
CLR
Q
CY7C64113
Interrupt
Priority
Encoder
IRQout
Interrupt
Vector
1 = Enable
0 = Disable
IRA
Port Interrupt
Enable Register
1 = Enable
0 = Disable
Global
GPIO Interrupt
Enable
(Bit 5, Register 0x20)
Figure 16-4. GPIO Interrupt Structure
When HAPI is enabled, the HAPI logic takes over the interrupt vector and blocks any interrupt from the GPIO bits, including
ports/bits not being used by HAPI. Operation of the HAPI interrupt is independent of the GPIO specific bit interrupt enables, and
is enabled or disabled only by bit 5 of the Global Interrupt Enable Register (Figure 16-1) when HAPI is enabled. The settings of
the GPIO bit interrupt enables on ports/bits not used by HAPI still effect the CMOS mode operation of those ports/bits. The effect
of modifying the interrupt bits while the Port Config bits are set to “10” is shown in Table 9-1. The events that generate HAPI
interrupts are described in Section 14.0.
16.8I2C Interrupt
The I2C interrupt occurs after vari ous events on the I2C-compatible bus to signal the need for firmware interaction. This generally
involves reading the I
2
C Data Register as appropriate, and finally writing the Status and Control Register to initiate the subsequent transaction. The
I
interrupt indicates that status bits are stable and it is safe to read and write the I
2
the I
C registers.
When enabled, the I
bits are in the I
1. In slave receive mode, after the slave receives a byte of data: The Addr bit is set, if this is the first byte since a start or rest art signal was
sent by the external master . Firmware mus t read or write the data register as nec essary, then set the ACK, Xmit MODE, and Continue/Busy
bits appropriately for the next byte.
2. In slave receive mode, after a stop bit is detec ted: The Received Stop bit is set, if the stop bit follows a sla ve receive t ransact ion where the
ACK bit was cleared to 0, no stop bit detection occurs.
3. In slave transmit mode, after the slave tra nsmits a byte of da ta: The ACK bit indicates if the master th at requested the byte acknowledged
the byte. If more bytes are to be sent, firmware writes the next byte into the Data Register and then sets the Xmit MODE and Continue/Busy
bits as required.
4. In master transmit mode, after the master sends a byte of data. Firmware should load the Data Register if necessary, and set the Xmit
MODE, MSTR MODE, and Continue/Busy bits appropriately. Clearing the MSTR MODE bit issues a stop signal to the I
and return to the idle state.
2
C Status and Control Register (Figure 13-2) to determine the cause of the interrupt, loading/reading the
2
C registers. Refer to Section 13.0 for details on
2
C-compatible state machines generate interrupts on completion of the following conditions. The referenced
2
C Status and Control Register.
2
C-compatible bus
Document #: 38-08001 Rev. *APage 32 of 51
CY7C64013
5. In master receive mode, after the master receives a byte of data: Firmware should read the data and set the ACK and Continue/Busy bits
appropriately for the next byte. Clearing the MSTR MODE bit at the same time causes the master state machine to issue a stop signal to
the I2C-compatible bus and leave the I2C-compatible hardware in the idle state.
6. When the master loses arbitration: This condition clears the MSTR MODE bit and sets the ARB Lost/Restart bit immediately and then waits
for a stop signal on the I
The Continue/Busy bit is cleared by hardware prior to interrupt conditions 1 to 4. Once the Data Register has been read or written,
firmware should configure the other control bits and set the Continue/Busy bit for subsequent transactions. Following an interrupt
from master mode, firmware should perform only one write to the Status and Control Register that sets the Continue/Busy bit,
without checking the value of the Continue/Busy bit. The Busy bit may otherwise be a ctive and I
changed by the hardware during the transaction, until the I
17.0 USB Overview
The USB hardware consists of the logic for a full-speed USB Port. The full-speed se rial interface engine (SIE) interfaces the
microcontroller to the USB bus. An external series resistor (R
the corresponding pins as possible, to meet the USB driver requirements of the USB specifications.
17.1USB Serial Interface Engine (SIE)
The SIE allows the CY7C64x13 microcontroller to communicate with the USB host. The SIE simplifies the interface between the
microcontroller and USB by incorporating hardware that handles the following USB bus activity inde pendently of the micro controller:
• Bit stuffing/unstuffing
• Checksum generation/checking
•ACK/NAK/STALL
• Token type identification
• Address checking
Firmware is required to handle the following USB interface tasks:
• Coordinate enumeration by responding to SETUP packets
• Fill and empty the FIFOs
• Suspend/Resume coordination
• Verify and select DATA toggle values
2
C-compatible bus to generate the interrupt.
2
C interrupt occurs.
ext
2
C register contents may be
) must be placed in series with the D+ and D– lines, as close to
CY7C64113
17.2USB Enumeration
The USB device is enumerated under firmwa re control. The followin g is a brief summary of the typical enumeration process of
the CY7C64x13 by the USB host. For a detailed description of the enumeration process, refer to the USB specification.
In this description, ‘Firmware’ refers to embedded firmware in the CY7C64x13 controller.
1. The host computer sends a SETUP packet followed by a DATA packet to USB address 0 requesting the Device descriptor.
2. Firmware decodes the request and retrieves its Device descriptor from the program memory tables.
3. The host computer performs a control read sequence and Firmware responds by sending the Device descriptor over the USB bus, via the
on-chip FIFOs.
4. After receiving the descriptor, the host sends a SETUP packet followed by a DATA packet to address 0 assigning a new USB address to
the device.
5. Firmware stores the new address in its USB Device Address Register after the no-data control sequence completes.
6. The host sends a request for the Device descriptor using the new USB address.
7. Firmware decodes the request and retrieves the Device descriptor from program memory tables.
8. The host performs a control read sequence and Firmware responds by sending its Device descriptor over the USB bus.
9. The host generates control reads from the device to request the Configuration and Report descriptors.
10.Once the device receives a Set Configuration request, its functions may now be used.
17.3USB Upstream Port Status and Control
USB status and control is regulated by the USB Status and Control Register, as shown in Figure 17-1. All bits in the register are
cleared during reset.
Document #: 38-08001 Rev. *APage 33 of 51
CY7C64013
USB Status and ControlADDRESS 0x1F
Bit #76543210
Bit NameEndpoint SizeEndpoint ModeD+ UpstreamD– UpstreamBus ActivityControl Action
Read/WriteR/WR/WRRR/WR/WR/WR/W
Reset00000000
Figure 17-1. USB Status and Control Register
Bits[2..0] : Control Action
Set to control action as per Table 17-1.The three control bits allow the upstream port to be driven manually by firmware. For normal
USB operation, all of these bits must be cleared. Table 17-1 shows how the control bits affect the upstream port.
Table 17-1. Control Bit Definition for Upstream Port
This is a “sticky” bit that indicates if any non-idle USB event has occurred on the upstream USB port. Firmware should check and clear
this bit periodically to detect any loss of bus activity. Writing a ‘0’ to the Bus Activity bit clears it, while writing a ‘1’ preserves the
current value. In other words, the firmware can clear the Bus Activity bit, but only the SIE can set it.
Bits 4 and 5 : D– Upstream and D+ Upstream
These bits give the state of each upstream port pin individually: 1 = HIGH, 0= LOW.
Bit 6 : Endpoint Mode
This bit used to configure the number of USB endpoints. See Section 18.2 for a detailed description.
Bit 7 : Endpoint Size
This bit used to configure the number of USB endpoints. See Section 18.2 for a detailed description.
18.0 USB Serial Interface Engine Operation
USB Device Address A includes up to five endpoints: EPA0, EPA1, EPA2, EPA3, and EPA4. Endpoint (EPA0) allows the USB
host to recognize, set-up, and control the device. In particular, EPA0 is used to receive and transmit control (including set-up)
packets.
18.1USB Device Address
The USB Controller provides one USB Device Address with five en dpoints. The USB Device Address Register contents are
cleared during a reset, setting the USB device address to zero and marking this address as disabled. Figure 18-1 shows the
format of the USB Address Registers.
USB Device Address ADDRESSES 0x10
Bit #76543210
Bit NameDevice Address
Read/WriteR/WR/WR/WR/WR/WR/WR/WR/W
Reset00000000
Enable
Device Address
Bit 6
Device Address
Bit 5
Device Address
Bit 4
Device Address
Bit 3
Device Address
Bit 2
Device Address
Bit 1
Device Address
Bit 0
Figure 18-1. USB Device Address Registers
Document #: 38-08001 Rev. *APage 34 of 51
CY7C64013
Bits[6..0] :Device Address
Firmware writes this bits during the USB enumeration process to the non-zero address assigned by the USB host.
Bit 7:Device Address Enable
Must be set by firmware before the SIE can respond to USB traffic to the Device Address.
Bit 7 (Device Address Enable) in the USB Device Address Register must be set by firmware before the SIE can respond to USB traffic to this
address. The Device Addresses in bits [6:0] are set by firmware during the USB enumeration process to the non-zero address assigned by the
USB host.
18.2USB Device Endpoints
The CY7C64x13 controller supports one USB device address and five endpoints for communication with the host. The configuration of these endpoints, and associated FIFOs, is controlled by bits [7,6 ] o f the USB Status and Control Register (0x1F). Bit 7
controls the size of the endpoints and bit 6 controls the number of endpoints. These configuration options are detailed in Table18-1. The “unused” FIFO areas in the following table can be used by the firmware as additional user RAM space.
Table 18-1. Memory Allocation for Endpoints
USB Status And Control Register (0x1F) Bits [7, 6]
When the SIE writes data to a FIFO, the internal data bus is driven by the SIE; not the CPU. This causes a short delay in the
CPU operation. The delay is three clock cycles per byte. For example, an 8-byte data write by the SIE to the FIFO generates a
delay of 2 µs (3 cycles/byte * 83.33 ns/cycle * 8 bytes).
18.3USB Control Endpoint Mode Register
All USB devices are required to have a Control Endpoint 0 (EPA0) that is used to initialize and control each USB address. Endpoint
0 provides access to the device configuration information and allows generic USB status and control accesses. Endpoint 0 is
bidirectional to both receive and transmit data. The other endpoints are unidirectional, but selectable by the user as IN or OUT
endpoints.
The endpoint mode register is cleared during reset. The endpoint zero EPA0 mode register uses the format shown in Figure 18-2.
USB Device Endpoint Zero Mode ADDRESSES 0x12)
Bit #76543210
Bit NameEndpoint 0 SETUP
Read/WriteR/WR/WR/WR/WR/WR/WR/WR/W
Reset00000000
Received
Bits[3..0] : Mode
These sets the mode which control how the control endpoint responds to traffic.
Bit 4 : ACK
This bit is set whenever the SIE engages in a transaction to the register’s endpoint that completes with an ACK packet.
Bit 5: Endpoint 0 OUT Received
1= Token received is an OUT token. 0= Token received is not an OUT token. This bit is set by the SIE to report the type of token
received by the corresponding device address is an OUT token. The bit must be cleared by firmware as part of the USB processing.
Bit 6: Endpoint 0 IN Received
1= Token received is an IN token. 0= Token received is not an IN token. This bit is set by the SIE to report the type of token received
by the corresponding device address is an IN token. The bit must be cleared by firmware as part of the USB processing.
Endpoint 0 IN
Received
Endpoint 0 OUT
Received
ACKMode Bit 3Mode Bit 2Mode Bit 1Mode Bit 0
Figure 18-2. USB Device Endpoint Zero Mode Registers
Document #: 38-08001 Rev. *APage 35 of 51
CY7C64013
Bit 7: Endpoint 0 SETUP Received
1= Token received is a SETUP token. 0= Token received is not a SETUP token. This bit is set ONLY by the SIE to report the type of
token received by the corresponding device address is a SETUP token. Any write to this bit by the CPU will clear it (set it to 0). The
bit is forced HIGH from the start of the data packet phase of the SETUP transaction until the start of the ACK packet returned by the
SIE. The CPU should not clear this bit during this interval, and subsequently, until the CPU first does an IORD to this endpoint 0 mode
register. The bit must be cleared by firmware as part of the USB processing.
Bits[6:0] of the endpoint 0 mode register are locked from CPU write operations whenever the SIE has updated one of these bits,
which the SIE does only at the end of the token phase of a transaction (SETUP... Data... ACK, OUT ... Data... ACK, or IN... Data...
ACK). The CPU can unlock these bits by doing a subsequent read of this register. Only endpoint 0 mode registers are locked
when updated. The locking mechanism does not apply to the mode registers of other endpoints.
Because of these hardware locking feat ures, firmware must perform an IORD afte r an IOWR to an endpoint 0 register . This verifies
that the contents have changed as desired, and that the SIE has not updated these values.
While the SETUP bit is set, the CPU cannot write to the endpoint zero FIFOs. This prevents firmware from overwriting an incoming
SETUP transaction before firmware has a chance to read the SETUP data. Refer to Table 18-1 for the appropriate endpoint zero
memory locations.
The Mode bits (bits [3:0]) control how the endpoint responds to USB bus traffic. The mode bit encoding is shown in Table 19-1.
Additional information on the mode bits can be found inTable 19-2.
18.4USB Non-Control Endpoint Mode Registers
The format of the non-control endpoint mode register is shown in Figure 18-3.
USB Non-Control Device Endpoint ModeADDRESSES 0x14, 0x16, 0x42, 0x44
Bit #76543210
Bit NameSTALLReservedReservedACKMode Bit 3Mode Bit 2Mode Bit 1Mode Bit 0
Read/WriteR/WR/WR/WR/WR/WR/WR/WR/W
Reset00000000
CY7C64113
Figure 18-3. USB Non-Control Device Endpoint Mode Registers
Bits[3..0] : Mode
These sets the mode which control how the control endpoint responds to traffic. The mode bit encoding is shown in Table 19-1
Bit 4 : ACK
This bit is set whenever the SIE engages in a transaction to the register’s endpoint that completes with an ACK packet.
Bits[6..5] : Reserved
Must be written zero during register writes.
Bit 7 : STALL
If this STALL is set, the SIE stalls an OUT p acket if the mode bits are set to ACK-IN, and the SIE st alls an IN packet if the
mode bits are set to ACK-OUT. For all other modes, the STALL bit must be a LOW.
18.5USB Endpoint Counter Registers
There are five Endpoint Counter registers, with identical formats for both control and non-control endpoints. Th ese registers
contain byte count information for USB transactions, as well as bits for data packet status. The format of these registers is shown
in Figure 18-4:
USB Endpoint CounterADDRESSES 0x11, 0x13, 0x15, 0x41, 0x43
Bit #76543210
Bit NameData 0/1 ToggleData ValidByte Count Bit 5 Byte Count Bit 4 Byte Count Bit 3 Byte Count Bit 2 Byte Count Bit 1 Byte Count Bit 0
Read/WriteR/WR/WR/WR/WR/WR/WR/WR/W
Reset00000000
Figure 18-4. USB Endpoint Counter Registers
Bits[5..0] : Byte Count
These counter bits indicate the numbe r of dat a bytes in a tran saction. For IN tra nsactions, fi rmware load s the count wi th the n umber of
bytes to be transmitted to the host from the endpoint FIFO. Valid values are 0 to 32, inclusive. For OUT or SETUP transactions, the
count is updated by hardware to the number of data bytes received, plus 2 for the CRC bytes. Valid values are 2 to 34, inclusive.
Bit 6 :Data Valid
Document #: 38-08001 Rev. *APage 36 of 51
CY7C64013
This bit is set on receiving a proper CRC when the endpoint FIFO buffer is loaded with data during transactions. Th is bit is used OUT
and SETUP tokens only. If the CRC is not correct, the endpoint interrupt occurs, but Data Valid is cleared to a zero.
Bit 7 : Data 0/1 Toggle
This bit selects the DA TA packet’ s toggle state: 0 for DATA0, 1 for DATA1. For IN transactions, firmware must set this bit to the desired
state. For OUT or SETUP transactions, the hardware sets this bit to the state of the received Data Toggle bit.
Whenever the count updates from a SETUP or OUT transaction on endpoint 0, the counter register locks and cannot be written
by the CPU. Reading the register unlocks it. This prevents firmware from overwriting a status update on incoming SETUP or OUT
transactions before firmware has a chance to read the data. Only endpoint 0 counter register is locked when updated. The locking
mechanism does not apply to the count registers of other endpoints.
18.6Endpoint Mode/Count Registers Update and Locking Mechanism
The contents of the endpoint mode and counter registers are updated, based on the packet flow diagram in Figure 18-5. Two
time points, UPDATE and SETUP, are shown in the same figure. The following activities occur at each time point:
SETUP:
The SETUP bit of the endpoint 0 mode register is forced HIGH at this time. This bit is forced HIGH by the SIE until the end of the
data phase of a control write transfer. The SETUP bit can not be cleared by firmware during this time.
The affected mode and counter registers of endpoint 0 are locked from any CPU writes once they are updated. These registers
can be unlocked by a CPU read, only if the read operation occu rs after the UPDAT E. The firmware nee ds to perform a register
read as a part of the endpoint ISR processing to unlock the effecte d registers. The locking mechanism on mode and counter
registers ensures that the firmware recognizes the changes that the SIE might have made since the p revious IO read of that
register.
UPDATE:
1. Endpoint Mode Register – All the bits are updated (except the SETUP bit of the endpoint 0 mode register).
2. Counter Registers – All bits are updated.
3. Interrupt – If an interrupt is to be generated as a result of the transaction, the interrupt flag for the corresponding endpoint is set at this time.
For details on what conditions are required to generate an endpoint interrupt, refer to Table 19-2.
4. The contents of the updated endpoint 0 mode and counter registers are locked, except the SETUP bit of the endpoint 0 mode register which
was locked earlier.
CY7C64113
Document #: 38-08001 Rev. *APage 37 of 51
1. IN Token
CY7C64013
CY7C64113
H
O
S
T
Host To DeviceDevice To Host
S
Y
N
C
S
Y
N
C
A
D
IN
D
R
Token PacketData Packet
Host To Device
A
D
IN
D
R
Token Packet
E
N
D
P
E
N
D
P
C
R
C
5
C
R
C
5
UPDATE
D
S
A
Y
T
N
A
C
1/0
Device To Host
S
Y
NAK/STALL
N
C
Data Packet
Data
2. OUT or SETUP Token without CRC error
Host To Device
Host To Device
C
R
C
16
Host To Device
S
A
Y
C
N
K
C
Hand
Shake
Packet
UPDATE
Device To Host
D
E
V
I
C
S
Y
N
C
O
U
A
T
D
/
D
Set
R
up
Token Packet
C
E
R
N
C
D
5
P
SETUP
S
Y
N
C
D
A
T
A
1/0
Data Packet
Data
3. OUT or SETUP Token with CRC error
Host To Device
O
S
U
Y
T
N
/
C
Set
up
Token Packet
A
D
D
R
C
E
R
N
C
D
5
P
Figure 18-5. Token/Data Packet Flow Diagram
Host To Device
D
S
A
Y
T
N
A
C
1/0
Data Packet
Data
C
R
C
16
UPDATE
C
R
C
16
UPDATE only if FIFO is
S
Y
N
C
written
ACK,
NAK,
STAL
Hand
Shake
Packet
E
Document #: 38-08001 Rev. *APage 38 of 51
CY7C64013
19.0 USB Mode Tables
Table 19-1. USB Register Mode Encoding
ModeMode Bits SETUPINOUTComments
Disable0000ignoreignoreignore Ignore all USB traffic to this endpoint
Nak In/Out0001acceptNAKNAKForced from Setup on Control endpoint, from modes other than
0000
Status Out Only0010acceptstallcheck For Control endpoints
Stall In/Out0011acceptstallstallFor Control endpoints
Ignore In/Out0100acceptignoreignore For Control endpoints
Isochronous Out0101ign oreignorealways For Isochronous endpoints
Status In Only0110accept TX 0 BYtestallFor Control Endpoints
Isochronous In0111ignoreTX Countignore For Isochronous endpoints
Nak Out1000ignoreignoreNAKIs set by SIE on an ACK from mode 1001 (Ack Out)
Ack
Out(STALL
Ack
Out(STALL
Nak Out - Status In1010accept TX 0 BYteNAKIs set by SIE on an ACK from mode 1011 (Ack Out- Status In)
Ack Out - Status In1011accept TX 0 BYteACKOn issuance of an ACK this mode is changed by SIE to 1010
Nak In1100ignoreNAKignore Is set by SIE on an ACK from mode 1101 (Ack In)
Ack
IN(STALL
Ack
IN(STALL
Nak In - Status Out1110acceptNAKcheck Is set by SIE on an ACK from mode 1111 (Ack In - Status Out)
Ack In - Status Out111 1acceptTX Countcheck On issuance of an ACK this mode is changed by SIE to 1110
[3]
[3]
[3]
[3]
=0)
=1)
=0)
=1)
1001
1001
1101
1101
ignore
ignore
ignore
ignore
ignore
ignore
TX Count
stall
ACK
stall
ignore
ignore
On issuance of an ACK this mode is changed by SIE to 1000
(NAK Out)
(NAK Out - Status In)
On issuance of an ACK this mode is changed by SIE to 1100
(NAK In)
(NAK In - Status Out)
CY7C64113
Mode
This lists the mnemonic given to the different modes that can be set in the Endpoint Mode Register by writing to the lower nibble
(bits 0..3). The bit settings for different modes are covered in the colu mn marked “Mode Bits”. The Status IN and Status OUT
represent the Status stage in the IN or OUT transfer involving the control endpoint.
Mode Bits
These column lists the encoding for different modes by setting Bits[3..0] of the Endpoint Mode register. This modes represents
how the SIE responds to different tokens sent by the host to an endpoint. For instance, if the mode bits are set to “0001” (NAK
IN/OUT), the SIE will respond with an
• ACK on receiving a SETUP token from the host
• NAK on receiving an OUT token from the host
• NAK on receiving an IN token from the host
Refer to section 13.0 for more information on the SIE functioning
SETUP, IN and OUT
These columns shows the SIE’s response to the host on receiving a SETUP, IN and OUT token depending on the mode set in
the Endpoint Mode Register.
A “Check” on the OUT token column, implies that on receiving an OUT token the SIE checks to see whether the OUT packet is
of zero length and has a Data Toggle (DTOG) set to ‘1.’ If the DTOG bit is set and the received OUT Packet has zero length, the
OUT is ACKed to complete the transaction. If either of this condition is not met the SIE will respond with a ST ALLL or just ignore
the transaction.
A “TX Count” entry in the IN column implies that the SIE transmit the number of bytes specified in the Byte Count (bits 3..0 of the
Endpoint Count Register) to the host in response to the IN token received.
A “TX0 Byte” entry in the IN column implies that the SIE transmit a zero length byte packet in response to the IN token received
from the host.
Document #: 38-08001 Rev. *APage 39 of 51
CY7C64013
An “Ignore” in any of the columns means that the device will not send any handshake tokens (no ACK) to the host.
An “Accept” in any of the columns means that the device will respond with an ACK to a valid SETUP transaction tot he host.
Comments
Some Mode Bits are automatically changed by the SIE in response to certain USB transactions. For example, if the Mode Bits
[3:0] are set to '1111' which is ACK IN-Status OUT mode as shown in table 22-1, the SIE will change the endpoint Mode Bits [3:0]
to NAK IN-Status OUT mode (1110) after ACK’ing a valid status stage OUT token. The firmware needs to update the mode for
the SIE to respond appropriately. See T able 18-1 for more details on what modes will be changed by the SIE. A disabled endpoint
will remain disabled until changed by firmware, and all endpoints reset to the disabled mode (0000). Firmware normally enables
the endpoint mode after a SetConfiguration request.
Any SETUP packet to an enabled endpoint with mode set to accept SETUPs will be changed by the SIE to 0001 (NAKing INs
and OUTs). Any mode set to accept a SETUP will send an ACK handshake to a valid SETUP token.
The control endpoint has three status bits for identifying the token type received (SETUP, IN, or OUT), but the endpoint must be
placed in the correct mode to function as such. Non-Control endpoints should not be placed into modes that accept SETUPs.
Note that most modes that control transactions involving an ending ACK, are changed by the SIE to a corresponding mode which
NAKs subsequent packets following the ACK. Exceptions are modes 1010 and 1110.
Note: The SIE offers an “Ack out–Status in” mode and not an “Ack out–Nak in” mode. Therefore, if following the status stage of
a Control Write transfer a USB host were to immediately start the next transfer, the new Setup packet could override the data
payload of the data stage of the previous Control Write.
CY7C64113
Properties of
Incoming Packets
3 2 1 0
Endpoint Mode
encoding
Legend:TX : transmitUC : unchanged
TokencountbufferdvalDTOGDVALCOUNTSetupInOutACK3 2 1 0 Response Int
Received Token
(SETUP/IN/OUT)
The validity of the received data
The quality status of the DMA buffer
The number of received bytesAcknowledge phase completed
RX : receiveTX0 :Transmit 0 length packet
available for Control endpoint only
x: don’t care
Changes to the Internal Register made by t he SIE on receiving an incoming packe t
Byte Count (bits 0..5, Figure 17-4)
Data Valid (bit 6, Figure 17-4)
Data0/1 (bit7 Figure 17-4)
from the hostInterrupt
PID Status Bits
(Bit[7..5], Figure 17-2)
Endpoint Mode bits
Changed by the SIE
SIE’s Response
to the Host
The response of the SIE can be summarized as follows:
1. The SIE will only respond to valid transactions, and will ignore non-valid ones.
2. The SIE will generate an interrupt when a valid transaction is completed or when the FIFO is corrupted. FIFO corruption occurs during
an OUT or SETUP transaction to a valid internal address, that ends with a non-valid CRC.
3. An incoming Data packet is valid if the count is <
Endpoint Size + 2 (includes CRC) and passes all error checking;
4. An IN will be ignored by an OUT configured endpoint and visa versa.
5. The IN and OUT PID status is updated at the end of a transaction.
6. The SETUP PID status is updated at the beginning of the Data packet phase.
7. The entire Endpoint 0 mode register and the Count register are locked to CPU writes at the end of any transaction to that endpoint in which
an ACK is transferred. These registers are only unlocked by a CPU read of the register , which should be done by the firmware only after
the transaction is complete. This represents about a 1-µs window in which the CPU is locked from register writes to the se USB regi sters.
Document #: 38-08001 Rev. *APage 40 of 51
CY7C64013
Normally the firmware should perform a register read at the beginning of the Endpoint ISRs to unlock and get the mode register information.
The interlock on the Mode and Count registers ensures that the firmware recognizes the changes that the SIE might have made during th e
previous transaction. Note that the setup bit of the mode register is NOT locked. This means that before writing to the mode register,
firmware must first read the register to make sure that the setup bit is not set (which indicates a setup was received, while processing the
current USB request). This read will of course unlock the register. So care must be taken not to overwrite the register elsewhere.
Table 19-2. Details of Modes for Differing Traffic Conditions (see Table 19-1 for the decode legend)
SETUP (if accepting SETUPs)
Properties of Incoming PacketChanges made by SIE to Internal Registers and Mode Bits
Mode Bitstokencount bufferdvalDTOGDVALCOUNT SetupInOut ACKMode Bits ResponseIntr
See Table 19-1 Setup<= 10 datavalidupdates 1updates 1UCUC10 0 0 1 ACKyes
See Table 19-1 Setup> 10junkxupdatesupdates updates 1UC UCUCNoChange ignoreyes
See Table 19-1 Setupxjunkinvalidupdates0updates 1UC UCUCNoChange ignoreyes
Properties of Incoming PacketChanges made by SIE to Internal Registers and Mode Bits
Mode Bitstokencount bufferdvalDTOGDVALCOUNT SetupInOut ACKMode Bits ResponseIntr
CONTROL WRITE
Properties of Incoming PacketChanges made by SIE to Internal Registers and Mode Bits
Mode Bitstokencount bufferdvalDTOGDVALCOUNT SetupInOut ACKMode Bits ResponseIntr
Normal Out/premature status In
1011Out<= 10 datavalidupdates1updates UCUC111 0 1 0 ACKyes
1011Out> 10junkxupdatesupdates updates UCUC1UCNoChange ignoreyes
1011Outxjunkinvalidupdates0updates UCUC 1UCNoChange ignoreyes
1011InxUCxUCUCUCUC1UC1NoChange TX 0yes
NAK Out/premature status In
1010Out<= 10UCvalidUCUCUCUCUC1UCNoChange NAKyes
1010Out> 10UCxUCUCUCUCUCUCUCNoChange ignoreno
1010OutxUCinvalidUCUCUCUCUCUCUCNoChange ignoreno
1010InxUCxUCUCUCUC1UC1NoChange TX 0yes
Status In/extra Out
0110Out<= 10UCvalidUCUCUCUCUC1UC0 0 1 1 Stallyes
0110Out> 10UCxUCUCUCUCUCUCUCNoChange ignoreno
0110OutxUCinvalidUCUCUCUCUCUCUCNoChange ignoreno
0110InxUCxUCUCUCUC1UC1NoChange TX 0yes
CONTROL READ
Properties of Incoming PacketChanges made by SIE to Internal Registers and Mode Bits
Mode Bitstokencount bufferdvalDTOGDVALCOUNT SetupInOut ACKMode Bits ResponseIntr
Normal In/premature status Out
1111Out2UCvalid11updates UCUC 11NoChange ACKyes
1111Out2UCvalid01updates UCUC 1UC0 0 1 1 Stallyes
1111Out!=2UCvalidupdates1updates UCUC1UC0 0 1 1 Stallyes
1111Out> 10UCxUCUCUCUCUCUCUCNoChange ignoreno
1111OutxUCinvalidUCUCUCUCUCUCUCNoChange ignoreno
1111InxUCxUCUCUCUC1UC11 1 1 0 ACK (back)yes
Nak In/premature status Out
1110Out2UCvalid11updates UCUC 11NoChange ACKyes
CY7C64113
Document #: 38-08001 Rev. *APage 41 of 51
CY7C64013
Table 19-2. Details of Modes for Differing Traffic Conditions (see Table 19-1 for the decode legend) (continued)
OUT ENDPOINT
Properties of Incoming PacketChanges made by SIE to Internal Registers and Mode Bits
Mode Bitstokencount bufferdvalDTOGDVALCOUNT SetupInOut ACKMode Bits ResponseIntr
IN ENDPOINT
Properties of Incoming PacketChanges made by SIE to Internal Registers and Mode Bits
Mode Bitstokencount bufferdvalDTOGDVALCOUNT SetupInOut ACKMode Bits ResponseIntr
Normal In/erroneous Out
1101OutxUCxUCUCUCUCUCUCUCNoChange ignoreno
0x09HAPI/I2C Configuration I2C Position Reserved Reserved Reserved Reserved ReservedI2C Port
C
2
I
HAPI
0x10USB Device Address ADevice
0x11EP A0 Counter
Register
0x12EP A0 Mode RegisterEndpoint0
0x13EP A1 Counter
CONFIGURATION
ENDPOINT A0, AI AND A2
CS
USB
INTERRUPT
TIMER
C
2
I
DAC PORT
0x38- 0x3F DAS Isinkxx6xxx 3x2xxWWWWWWWW
CONFIGURATION
ENDPOINT A3, A4
Register
0x14EP A1 Mode RegisterSTALL--ACKMode Bit 3 Mode Bit 2 Mode Bit 1 Mode Bit 0BBBBBBBB00000000
0x15EP A2 Counter
Register
0x16EP A2 Mode RegisterSTALL--ACKMode Bit 3 Mode Bit 2 Mode Bit 1 Mode Bit 0BBBBBBBB00000000
0x1FUSB Status and Control Endpoint
0x20Global Interrupt Enable ReservedI2C
0x21Endpoint Interrupt
Enable
0x24Timer (LSB)Timer Bit 7 Timer Bit 6 Timer Bit 5 Timer Bit 4 Timer Bit 3 Timer Bit 2 Timer Bit 1 Timer Bit 0RRRRRRRR00000000
0x25Timer (MSB)Reserved Reserved Reserved Reserved Timer Bit 11 Timer Bit 10 Time Bit 9 Timer Bit 8----rrrr----0000
0x26WDT Clearxx6xxx 3x2xxWWWWWWWWxxxxxxxx
0x28I2C Control and StatusMSTR
0x29I2C Data I2C Data 7 I2C Data 6 I2C Data 5 I2C Data 4 I2C Data 3 I2C Data 2 I2C Data 1 I2C Data 0BBBBBBBBXXXXXXXX
0x30DAC DataTimer Bit 7 Timer Bit 6 Timer Bit 5 Timer Bit 4 Timer Bit 3 Timer Bit 2 Timer Bit 1 Timer Bit 0RRRRRRRR00000000
0x31DAC Interrupt Enable)Reserved Reserved Reserved Reserved Timer Bit 11 Timer Bit 10 Time Bit 9 Timer Bit 8----rrrr----0000
0x32DAC Interrupt Polarity
0x40ReservedReservedReserved Reserved Reserved ReservedReservedReservedReservedBBBBBBBB00000000
0x41EP A3 Counter Register Data 0/1
0x42EP A3 Mode RegisterEndpoint 0
0x43EP A4 Counter Register Data 0/1
0x44EP A4 Mode RegisterSTALL--ACKMode Bit 3 Mode Bit 2 Mode Bit 1 Mode Bit 0
Enable
Enable
Enable
Config Bit 1
Address A
Enable
Data 0/1
Toggle
SETUP
Received
Data 0/1
Toggle
Data 0/1
Toggle
Reserved ReservedReservedEPB1
Mode
Toggle
SETUP
Received
Toggle
P0.6 Intr
P1.6 Intr
P2.6 Intr
Config Bit 0
Address A
Data Valid Byte Count
Endpoint0
Received
Data Valid Byte Count
Data Valid Byte Count
Endpoint
Size
Interrupt
Continue/
Data Valid Byte Count
Endpoint 0
Received
Data Valid Byte Count
IN
IN
P0.5 Intr
Enable
P1.5 Intr
Enable
P2.5 Intr
Enable
Port 2
Config Bit 1
Device
Address A
Endpoint0
Received
GPIO
Interrupt
Enable
Mode
Endpoint 0
Received
Enable
Enable
Enable
Port 3
Device
Bit 6
ModeD+UpstreamD–Upstream
Enable
Busy
Bit 5
Bit 5
OUT
Bit 5
Bit 5
Xmit
Bit 5
OUT
Bit 5
P0.4 Intr
Enable
P1.4 Intr
Enable
P2.4 Intr
Enable
Port 2
Config Bit 0
Device
Address A
Bit 4
Byte Count
Bit 4
ACKMode Bit 3 Mode Bit 2 Mode Bit 1 Mode Bit 0BBBBBBBB00000000
Byte Count
Bit 4
Byte Count
Bit 4
Reserved USB Hub
Interrupt
Enable
ACKAddrARB Lost/
Byte Count
Bit 4
ACKMode Bit 3 Mode Bit 2 Mode Bit 1 Mode Bit 0
Byte Count
Bit 4
P0.3 Intr
Enable
ReservedP1.2 Intr
P2.3 Intr
Enable
Port 1
Config Bit 1
Device
Address A
Bit 3
Byte Count
Bit 3
Byte Count
Bit 3
Byte Count
Bit 3
Bus ActivityControl
Interrupt
Enable
EPB0
Interrupt
Enable
Byte Count
Bit 3
Byte Count
Bit 3
P0.2 Intr
Enable
Enable
ReservedReservedReservedWWWWWWWW00000000
Port 1
Config Bit 0
Device
Address A
Bit 2
Byte Count
Bit 2
Byte Count
Bit 2
Byte Count
Bit 2
Bit 2
1.024-ms
Interrupt
Enable
EPA2
Interrupt
Enable
Restart
Byte Count
Bit 2
Byte Count
Bit 2
P0.1 Intr
Enable
P1.1 Intr
Enable
Enable
Port 0
Config Bit 1
Width
Device
Address A
Bit 1
Byte Count
Bit 1
Byte Count
Bit 1
Byte Count
Bit 1
Control
Bit 1
128-µs
Interrupt
Enable
EPA1
Interrupt
Enable
Received
Stop
Byte Count
Bit 1
Byte Count
Bit 1
P0.0 Intr
Enable
P1.0 Intr
Enable
P3.0 Intr
Enable
Port 0
Config Bit 0
ReservedBBBBBBBB00000000
Device
Address A
Bit 0
Byte Count
Bit 0
Byte Count
Bit 0
Byte Count
Bit 0
Control
Bit 0
USB Bus
RESET
Interrupt
Enable
EPA0
Interrupt
Enable
I2C
Enable
Byte Count
Bit 0
Byte Count
Bit 0
Both/-
BBBBBBBB11111111
BBBBBBBB11111111
WWWWWWWW00000000
WWWWWWWW00000000
WWWWWWWW00000000
BBBBBBBB00000000
BBBBBBBB00000000
BBBBBBBB00000000
BBBBBBBB00000000
BBBBBBBB00000000
BBRRBBBB-0xx0000
-BBBBBBB-0000000
---BBBBB---00000
BBBBBBBB00000000
BBBBBBBB00000000
BBBBBBBB00000000
BBBBBBBB00000000
BBBBBBBB00000000
Read/Write/
Default/
Reset
Document #: 38-08001 Rev. *APage 43 of 51
CY7C64013
CY7C64113
Address Register Name Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
0x52ReservedReservedReserved Reserved Reserved ReservedReservedR eservedReservedReserved00000000
0xFFProcess Status &
Note:
B: Read and Write
W: Write
R: Read
Control
IRQ
Pending
Watchdog
Reset
USB Bus
Reset
Interrupt
Power-On
Reset
SuspendInterrupt
Enable
Sense
ReservedRunRBBBBRBB00010001
Both/-
21.0 Sample Schematic
Read/Write/
USB-B
Vbus
DD+
GND
SHELL
Optional
2.2 uF
Vref
4.7 nF
250VAC
10M
1.5K
(R
0V
UUP
)
Vbus
22x2(R
3.3V Regulator
IN
OUT
GND
0V
)
ext
D0D0+
XTALO
6.000 MHz
XTALI
GND
GND
Vpp
.01 uF
Vcc
0V
Vref
2.2 uF
.01 uF
0V
Vref
Default/
Reset
0V
Document #: 38-08001 Rev. *APage 44 of 51
CY7C64013
22.0 Absolute Maximum Ratings
Storage Temperature .................................–65°C to +150°C
Ambient Temperature with Power Applied........0°C to +70°C
Supply voltage on V
DC Input Voltage................................... –0.5V to +VCC+0.5V
DC Voltage Applied to Outputs in High Z State –0.5V to +V
Power Dissipation.....................................................500 mW
Static Discharge Voltage ...........................................>2000V
Latch-up Current ..................... ... ... ......................... >200 mA
Max Output Sink Current into Port 0, 1, 2, 3, and DAC[1:0] Pins 60 mA
Max Output Sink Current into DAC[7:2] Pins.............. 10 mA
23.0 Electrical Characteristics
f
= 6 MHz; Operating Temperature = 0 to 70°C, VCC = 4.0V to 5.25V
OSC
ParameterDescriptionConditionsMin.Max.Unit
V
REF
V
pp
I
CC
I
SB1
I
ref
I
il
V
di
V
cm
V
se
C
in
I
lo
R
ext
R
UUP
t
vccs
V
UOH
V
UOL
Z
O
R
up
V
ITH
V
H
V
OL
V
OH
Notes:
4. Power-on Reset occurs whenever the voltage on V
5. This is based on transitions every 2 full-speed bit times on average.
relative to VSS...........–0.5V to +7.0V
CC
+0.5V
CC
General
Reference Voltage3.3V ±5%3.153.45V
Programming Voltage (disabled)–0.40.4V
VCC Operating CurrentNo GPIO source current50mA
Supply Current—Suspend Mode50µA
V
Operating CurrentNote 530mA
REF
Input Leakage CurrentAny pin1µA
USB Interface
Differential Input Sensitivity | (D+)–(D–) |0.2V
Differential Input Common Mode Range0.82.5V
Single Ended Receiver Threshold0.82.0V
Transceiver Capacitanc e20pF
Hi-Z State Data Line Leakage0 V < V
< 3.3 V–1010µA
in
External USB Series ResistorIn se ries with each USB pin1921Ω
External Upstream USB Pull-up Resistor 1.5 kΩ ±5%, D+ to V
REG
Power On Reset
VCC Ramp RateLinear ramp 0V to V
CC
[4]
USB Upstream
Static Output High15 kΩ ±5% to Gnd2.83.6V
Static Output Low1.5 kΩ ±5% to V
USB Driver Output ImpedanceIncluding R
REF
Resistor 2844Ω
ext
General Purpose I/O (GPIO)
Pull-up Resistance (typical 14 kΩ)8.024.0kΩ
Input Threshold VoltageAll ports, LOW to HIGH edge20%40%V
Input Hysteresis VoltageA ll ports, HIGH to LOW edge2%8%V
Port 0,1,2,3 Output Low VoltageIOL = 3 mA
= 8 mA
I
OL
Output High VoltageIOH = 1.9 mA (all ports 0,1,2,3) 2.4V
is below approximately 2.5V.
CC
CY7C64113
1.4251.575kΩ
0100ms
0.3V
0.4
2.0
CC
CC
V
V
Document #: 38-08001 Rev. *APage 45 of 51
CY7C64013
23.0 Electrical Characteristics (continued)
f
= 6 MHz; Operating Temperature = 0 to 70°C, VCC = 4.0V to 5.25V
OSC
ParameterDescriptionConditionsMin.Max.Unit
DAC Interface
R
up
I
sink0(0)
I
sink0(F)
I
sink1(0)
I
sink1(F)
I
range
T
ratio
I
sinkDAC
I
lin
DAC Pull-up Resistance (typical 14 kΩ)8.024.0kΩ
DAC[7:2] Sink current (0)V
DAC[7:2] Sink current (F)V
DAC[1:0] Sink current (0) V
DAC[1:0] Sink current (F)V
Programmed Isink Ratio: max/minV
Tracking Ratio DAC[1:0] to DAC[7:2]V
DAC Sink CurrentV
Differential NonlinearityDAC Port
= 2.0V DC 0.10.3mA
out
= 2.0V DC 0.51.5mA
out
= 2.0V DC1.64.8mA
out
= 2.0V DC 824mA
out
= 2.0V DC
out
= 2.0V
out
= 2.0V DC 1.64.8mA
out
[6]
[7]
[8]
CY7C64113
46
1422
0.6LSB
24.0 Switching Characteristics (f
= 6.0 MHz)
OSC
ParameterDescriptionMin.Max.Unit
Clock Source
f
OSC
t
cyc
t
CH
t
CL
t
rfs
t
ffs
t
rfmfs
t
dratefs
Clock Rate6 ±0.25%MHz
Clock Period166.25167.08ns
Clock HIGH time0.45 t
Clock LOW time0.45 t
USB Full Speed Signaling
[9]
CYC
CYC
Transition Rise Time420ns
Transition Fall Time420ns
Rise / Fall Time Matching; (tr/tf)90111%
Full Speed Date Rate12 ±0.25%Mb/s
DAC Interface
t
sink
Current Sink Response Time0.8µs
HAPI Read Cycle Timing
t
RD
t
OED
t
OEZ
t
OEDR
Read Pulse Width15ns
OE LOW to Data Valid
OE HIGH to Data High-Z
OE LOW to Data_Ready Deasserted
[10, 11]
[11]
[10, 11]
40ns
20ns
060ns
HAPI Write Cycle Timing
t
WR
t
DSTB
t
STBZ
t
STBLE
Write Strobe Width15ns
[10, 11]
[11]
[11]
5ns
15ns
050ns
Data Valid to STB HIGH (Data Set-up Time)
STB HIGH to Data High-Z (Data Hold Time)
STB LOW to Latch_Empty Deasserted
Timer Signals
t
watch
Notes:
6. Irange: I
7. T
8. I
9. Per Table 7-6 of revision 1.1 of USB specification.
10. For 25-pF load.
11. Assumes chip select CS
sinkn
= I
ratio
sink1
measured as largest step size vs. nominal according to measured full scale and zero programmed values.
lin
Watchdog Timer Period8.19214.336ms
(15)/ I
[1:0](n)/I
(0) for the same pin.
sinkn
[7:2](n) for the same n, programmed.
sink0
is asserted (LOW).
ns
ns
Document #: 38-08001 Rev. *APage 46 of 51
CY7C64013
t
CYC
t
CH
CLOCK
t
CL
Figure 24-1. Clock Timing
CY7C64113
D+
D−
Interrupt Generated
CS (P2.6, input)
OE (P2.5, input)
DATA (output)
(P2.4, input)
STB
DReadyPin (P2.3, output)
(Shown for DRDY Polarity=0)
t
r
OED
90%
t
RD
90%
10%
Figure 24-2. USB Data Signal Timing
t
t
OEDR
(Ready)
t
r
10%
D[23:0]
t
Int
OEZ
Internal Write
Internal Addr
Figure 24-3. HAPI Read by External Interface from USB Microcontroller
Document #: 38-08001 Rev. *APage 47 of 51
Port0
CY7C64013
CY7C64113
Interrupt Generated
CS
(P2.6, input)
STB
(P2.4, input)
DATA (input)
OE (P2.5, input)
LEmptyPin (P2.2, output)
(Shown for LEMPTY Polarity=0)
Internal Read
Internal Addr
Figure 24-4. HAPI Write by Extern al Device to USB Microcontroller
Document Title: CY7C64013, CY7C64113 Full-Speed USB (12 Mbps) Function
Document Number: 38-08001
REV.ECN NO.
**10996212/16/01SZVChange from Spec number: 38-00626 to 38-08001
*A12971502/05/04MONAdded register bit definitions
Issue
Date
Orig. of
ChangeDescription of Change
Added default bit state of each register
Corrected the Schematic (location of the Pull up on D+)
Added register summary
Modified tables 19-1 and 19-2
Provided more explanation regarding locking/unlocking mechanism of the
mode register.
CY7C64013
CY7C64113
Document #: 38-08001 Rev. *APage 51 of 51
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.