CY3674 DVK Kit Guide 001-66390
CY3674 DVK Kit Guide 001-66390
Cypress Semiconductor
198 Champion Court
San Jose, CA 95134-1709
Phone (USA): 800.858.1810
Phone (Intnl): 408.943.2600
www.cypress.com
Copyrights
Copyrights
© Cypress Semiconductor Corporation, 2011-2013. The information contained herein is subject to change without notice.
Cypress Semiconductor Corporation assumes no responsibility for the use of any circuitry other than circuitry embodied in a
Cypress product. Nor does it convey or imply any license under patent or other rights. Cypress products are not warranted
nor intended to be used for medical, life support, life saving, critical control or safety applications, unless pursuant to an
express written agreement with Cypress. Furthermore, Cypress does not authorize its products for use as critical components
in life-support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user.
The inclusion of Cypress products in life-support systems application implies that the manufacturer assumes all risk of such
use and in doing so indemnifies Cypress against all charges.
Any Source Code (software and/or firmware) is owned by Cypress Semiconductor Corporation (Cypress) and is protected by
and subject to worldwide patent protection (United States and foreign), United States copyright laws and international treaty
provisions. Cypress hereby grants to licensee a personal, non-exclusive, non-transferable license to copy, use, modify, create
derivative works of, and compile the Cypress Source Code and derivative works for the sole purpose of creating custom soft-
ware and or firmware in support of licensee product to be used only in conjunction with a Cypress integrated circuit as speci-
fied in the applicable agreement. Any reproduction, modification, translation, compilation, or representation of this Source
Code except as specified above is prohibited without the express written permission of Cypress.
Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS MATE-
RIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE. Cypress reserves the right to make changes without further notice to the materials described
herein. Cypress does not assume any liability arising out of the application or use of any product or circuit described herein.
Cypress does not authorize its products for use as critical components in life-support systems where a malfunction or failure
may reasonably be expected to result in significant injury to the user. The inclusion of Cypress’ product in a life-support sys-
tems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all
charges.
Use may be limited by and subject to the applicable Cypress software license agreement.
All trademarks or registered trademarks referenced herein are property of the respective corporations.
1. Introduction 7
1.1 Introduction ..................................................................................................................7
1.2 Kit Contents .................................................................................................................7
1.2.1 Hardware..........................................................................................................7
1.2.2 Software on CD-ROM ......................................................................................7
1.2.3 Required Tools Not Included ............................................................................8
1.2.4 Other Suggested Tools.....................................................................................8
1.3 Document Revision History ........................................................................................8
1.4 Documentation Conventions .......................................................................................8
2. Getting Started 9
2.1 Kit Installation .............................................................................................................9
2.2 Install Hardware.........................................................................................................17
9. Resources 105
9.1 Hardware Resources...............................................................................................105
9.2 Reference Designs ..................................................................................................105
9.2.1 CY4611B - USB 2.0 to ATA Reference Design ............................................105
9.2.2 CY4651 v1.3 - Cypress and AuthenTec Reference Design for Biometric Secu-
rity in External USB Hard Disk Drives106
9.2.3 CY3686 NX2LP-FLEX USB 2.0-to-NAND Reference Design Kit ................106
9.3 Application Notes.....................................................................................................106
A. Appendix 111
A.1 U2 (GAL) code (file is 'FX2LP.ABL')........................................................................111
A.2 Board Layout ...........................................................................................................113
A.3 Schematic................................................................................................................114
A.4 Frequently Asked Questions ...................................................................................115
1.1 Introduction
The EZ-USB® Development Kit (DVK) is a good starting point for developing an EZ-USB based
product. The DVK includes everything you will need to get started: a development board, example
firmware, a Microsoft-certified signed generic USB device driver (cyusb.sys), documentation, and
assorted tools. This section provides an overview of the DVK. The software installation of the kit
includes additional help files and documentation more specific to the various components in the kit.
The DVK is designed to work with the EZ-USB FX2LP and FX1 chips. FX1 is a full-speed only ver-
sion of FX2LP. Other than the absence of a high-speed transceiver, FX1 is identical to FX2LP.
Except where distinction is required, both chips are generically referred to as EZ-USB throughout
this document.
1.2.1 Hardware
■ EZ-USB advanced development board
■ EZ-USB prototyping board (breadboard)
■ USB A-to-B cable
■ RS-232 cable
■ Software installation CD-ROM
■ Three samples: EZ-USB FX1 IC (CY7C64713-128AXC) for the CY3674 kit and EZ-USB FX2LP
IC (CY7C68013A-128AXC) for the CY3684 kit.
■ Quick start guide booklet
This chapter describes the installation of the CY3684 EZ-USB FX2LP DVK software. The process is
similar for the CY3674 EZ-USB FX1 DVK.
Note For EZ-USB FX1, click on Install CY3674 EZ-USB FX1 DVK. If auto-run does not execute,
double-click on the cyautorun.exe file in the root directory of the CD.
3. The InstallShield Wizard screen appears. The default location for setup is shown on the
InstallShield Wizard screen. You can change the location for setup using Change, as shown in
Figure 2-2. Click Next to launch the kit installer.
4. On the Product Installation Overview screen, select the installation type that best suits your
requirement. The drop-down menu has three options - Typical, Complete, and Custom, as
shown in Figure 2-3. In the current installer, all three installation types result in the same set of
software getting installed. Select the default typical installation and click Next.
Figure 2-3. Installation Type Options
5. When the installation begins, all packages are listed on the Installation page. A green check mark
appears adjacent to every package that is downloaded and installed, as shown in Figure 2-4.
Wait until all the packages are downloaded and installed successfully.
Figure 2-4. Installation Page
6. The Keil uVision2 trial version IDE triggers at this stage. If the software is already installed in the
PC, then the installer will not trigger the installation. If the PC does not contain the software, then
the Keil welcome screen appears, as shown in Figure 2-5. Click Next.
7. Enter the user name and company name credentials, as shown in Figure 2-6, to proceed with the
installation.
Figure 2-6. Keil User Information lnput Window
8. The Keil software proceeds with the installation and copies the necessary packages at the default
directory C:\Keil. After completion, click on Finish, as shown in Figure 2-7.
9. The GPIF designer software is triggered after Keil installation.This software is used to create
State machine waveforms to communicate between the EZ-USB device and devices such as
FPGA, image sensors, FIFO, and so on. If the software is already installed in the PC, then the
installer will not trigger the installation. If the PC does not contain the software, then the GPIF
Designer welcome screen appears, as shown in Figure 2-8. Click Next.
Figure 2-8. GPIF Designer Welcome Window
10. Click Next in the subsequent windows and the Finish window appears, as shown in Figure 2-9.
Figure 2-9. GPIF Designer Welcome Window
11. The SuiteUSB 3.4.7 package install shield is triggered after the GPIF designer software installa-
tion. If the software is already installed in the PC, then the installer will not trigger the installation.
If the PC does not contain the software, then the SuiteUSB welcome screen appears, as shown
in Figure 2-10. Click Next and accept the Cypress Software license agreement, as shown in
Figure 2-11.
Figure 2-10. SuiteUSB Welcome Window
12.Enter the user credentials in the SuiteUSB window, as shown in Figure 2-12. Click Next. The
default directory of the SuiteUSB is C:\Cypress\Cypress Suite USB 3.4.7. The default
directory can be changed at this stage. Click Next after selecting the directory. Click the Install
button in the subsequent window. The SuiteUSB package installation progress is shown in the
next window. Finally the SuiteUSB Finish window appears. Click Finish button to complete the
installation process of SuiteUSB.
13.The CY3684 EZ-USB FX2LP development Kit Finish window appears after installing the kit con-
tent, Keil software, GPIF Designer, and the SuiteUSB 3.4.7 package.
3.1 Introduction
The EZ-USB Advanced Development Board provides a compact evaluation and design vehicle for
the EZ-USB family. The board provides expansion and interface signals on six 20-pin headers. A
mating prototype board allows quick construction and testing of USB designs. All ICs on the board
operate at 3.3 V. The board can be powered from the USB connector.
The EZ-USB Advanced Development Board is supplied as part of the Cypress EZ-USB DVK, which
includes an evaluation version of Cypress-customized software development tools from Keil
Software Inc. The Keil 8051 assembler, C compiler, and debugger work with the development board
to provide a complete code development environment. An 8051 debug monitor is typically loaded
into the development board expansion RAM to leave the internal RAM free for code development.
The evaluation version of the Keil tools that ships with the DVK has several restrictions that make it
inappropriate for real-world development. Most significantly, it limits the compiled object size to 4 KB.
The full retail version allows a code of any size.
3.3 Jumpers
Table 3-1. EZ-USB Development Board Jumpers
Jumper Function Default Notes
Connects 3.3 V power to
JP1, JP10 IN (1-2)
the EZ-USB chip.
Powers the on-board 3.3 V To operate the board in self-powered mode, remove
JP2 regulator from USB Vbus IN (1-2) JP2 and supply 4 V to 5 V to JP2-1, and GND to a
pin ground pin (TP1 is a convenient GND point).
U2, the on-board GAL, contains code to use the four
LEDs as software indicators that can be set. To use
Connects four GAL pins to IN (1-2) (3-4) the GAL pins for something else, which requires re-
JP3
LEDS D2, D3, D4, D5 (5-6) (7-8) programming the GAL or to wire the general purpose
indicators D2-D5 to other parts of the board, first
remove the appropriate shorting plug(s).
Supplies 3.3-V power to the board. It can be removed
JP5 3.3 V power IN (1-2) and replaced with ammeter probes in series to mea-
sure board current.
These jumpers select one of the four memory maps
JP6, JP7 Memory map selection OUT (1-2) for U3, the external 128 KB RAM. See Memory Maps
on page 26 for details.
Inserting a shorting plug into JP8 connects an on-
board RC network (R42,C43) to the secondary
remote wakeup pin WU2. This R-C network can be
JP8 Wakeup2 pin OUT (1-2)
used to test the periodic remote wakeup firmware
when this dual-purpose pin (it defaults to PA3) is pro-
grammed as WU2.
The I2C bus SCL and SDA lines can be monitored or
JP9 I2C bus test points N/A
externally connected using JP9.
The EZ-USB chip contains two I2C controllers, a “boot load” controller and an 8051 controller. The
boot load controller operates when EZ-USB comes out of reset, and the 8051 controller operates
under firmware control when the 8051 is running, allowing the 8051 to access general-purpose I2C
devices connected to the SCL and SDA lines. The following section deals with the roles of SW1 and
SW2 in accommodating the various boot load mechanisms.
The EZ-USB bootloader accommodates two EEPROM types, in “Small” and “Large” versions, as
shown in Table 3-2.
Small EEPROMs are typically used to supply custom VID and PID information, allowing the EZ-USB
to enumerate with a driver associated with your EZ-USB design.
Large EEPROMs are typically used to boot-load code into the internal EZ-USB RAM, and then start
up the 8051 to execute this internal code, which performs the enumeration.
The EZ-USB loader determines the EEPROM size by first initiating an I2C transfer to address
1010000 (1010 is the EEPROM-class address, and 000 is the sub-address). If the device supplies
an I2C acknowledge pulse, the EZ-USB loader writes a single EEPROM address byte to initialize the
internal EEPROM address pointer to zero.
If this transfer does not return an ACK pulse, the EZ-USB loader initiates a second I2C transfer, this
time to address 10100001 (1010 = EEPROM, sub-address 001). If an ACK is returned by the I2C
device, the EZ-USB loader writes two EEPROM address bytes to initialize the internal EEPROM
address pointer to 0.
If neither transfer returns an ACK pulse, the EZ-USB loader boots in the ‘generic’ mode.
Three EZ-USB startup sequences and the associated settings for SW1 and SW2, are as follows:
■ Generic: SW2 = No EEPROM, SW1 = either position
When no EEPROM is connected to SCL and SDA, the EZ-USB chip enumerates using its inter-
nal, “hard-wired” VID and PID values. This mode can be selected without removing any socketed
EEPROMs by switching SW2 to the ‘off’ (down) position. This electrically disconnects any
EEPROMs that occupy the EEPROM sockets U5 and U6. The “OFF” mode is useful to start up
EZ-USB in a manner (using internal VID/PID) that binds the development system board to the
Cypress debug tools, such as the Control Panel and Keil. When running, SW2 can be switched to
the ON position to allow 8051 access, for example, to reprogram the EEPROM.
■ C0 Load: SW2 = EEPROM, SW1 = SMALL
A “C0” load provides EZ-USB with external Vendor ID (VID), Product ID (PID), and Device ID
(DID) values, allowing it to enumerate with the EEPROM-supplied VID, PID, and DID. At power-
on, if the EZ-USB chip detects an EEPROM with the hex value ‘C0’ as its first byte, it continues to
load seven additional EEPROM bytes, which correspond to the USB VID, PID, DID, and an EZ-
USB configuration byte. When EZ-USB enumerates, it uses these EEPROM values instead of
the hard-wired internal values.
Because only eight bytes of data are required, a ‘small’ EEPROM is generally used for this mode;
for example, the 16-byte 24LC00.
■ C2 Load: SW2 = EEPROM, SW1 = LARGE
A “C2” load provides a method to load the EZ-USB internal RAM with 8051 firmware before enu-
meration. This boot load mechanism allows EZ-USB to enumerate as a fully custom device,
because the 8051 code handles enumeration using VID/PID values embedded in the code.
At power-on, if the EZ-USB chip detects an EEPROM with the hex value ‘C2’ as its first byte, it
continues to load an EZ-USB configuration byte, followed by blocks of 8051 code. The last byte
loaded takes the 8051 out of reset. This mode usually requires a large EEPROM, such as the
8 KB 24LC64.
Note If an EEPROM is connected to the SCL and SDA lines, but does not contain 0xC0 or 0xC2 as
its first byte, the loader reverts to the ‘generic’ case. In other words, the bootloader operates as
though no EEPROM is connected. However, when the 8051 is running, it has full access to any con-
nected EEPROM because the 8051 I2C controller is completely independent of the boot load logic.
Six 20-pin headers, P1–P6, on the EZ-USB Development Board have pins assigned to be compati-
ble with HP (Agilent) logic analyzers, as shown in Table 3-3.
These six headers serve three purposes:
■ They mate with the prototyping board supplied in the EZ-USB DVK.
■ They allow direct connection of the HP (Agilent) logic analyzer pods (Agilent P/N 01650-63203).
■ They allow general-purpose probing by other logic analyzers or oscilloscopes.
Table 3-3 shows the logic analyzer pod pin designations. The EZ-USB signals on P1–P6 are
arranged to fulfill the following requirements:
■ High-speed EZ-USB strobe signals (PSEN, WR#, CLKOUT, IFCLK, and RD#) are connected to
pin 3 of each of the five connectors for P1–P6. Therefore, they are used as the logic analyzer
clock, CLK1.
■ CLK2 is not used. Instead, each connector brings 3.3-V power from the EZ-USB development
board up to the prototype board using pin 2.
■ The signals are logically grouped. For example, the 8051 address bus is on P5 and the EZ-USB
FIFO data, which shares PORTB and PORTD pins, is on P1.
The 20-pin headers on the prototyping board can be stacked. Therefore, it is possible to build cus-
tom circuitry on the prototyping board, plug the board into the EZ-USB development board, and still
plug the logic analyzer pods to the six connectors P1–P6. Table 3-4 to Table 3-9 show the EZ-USB
pin designations for P1 through P6. The alternate pin names are listed in the last columns.
Note The GAL sets EA=1 for the Ext Flash configuration only, enabling external code memory.
The factory default is to have both MM1 and MM0 jumpers removed. This setting should be used for
all development work using the Keil software tools.
■ The default configuration provides 16 KB of on-chip code and data memory, plus 48 KB of exter-
nal RAM. The 8051 begins execution from internal RAM (the GAL sets EA=0). Although there is
an apparent overlap between the internal 16 KB and the bottom 16 KB of the external RAM,
EZ-USB disables RAM strobes for the bottom 16 KB, so there is no conflict. This EZ-USB decod-
ing allows using a standard 64-KB RAM without requiring external decoding to inhibit access to
the bottom 16 Kb.
■ The second column, “24K gap”, enables the external RAM only for access to its upper 32 KB.
This configuration is useful for systems that add external devices that require memory-mapped
access. As with the default configuration, the 8051 begins execution from internal RAM (the GAL
sets EA=0).
■ The third column, “Ext Flash”, allows a flash memory (or other ROM) to be connected to the 8051
bus. This is the only configuration that starts 8051 execution from external memory (the GAL sets
EA to ‘1’). Because external memory occupies the bottom 16K, the internal EZ-USB RAM is
addressed only as data memory, instead of the combined program/data memory in the other
three configurations.
■ The fourth column, “Single Chip”, disables all external memory. This configuration is useful for
testing the final code to ensure that it does not use external resources present in the develop-
ment environment.
U8 has the group address 0100 and is strapped to the unit address 001. Therefore, to write a value
to the 7-segment readout, 8051 firmware sends a control byte of 01000010 (the least significant bit
(LSB0 indicates a write operation), followed by the data byte.
U10 uses its I/O pins as inputs, connected to S2-S5 according to the following table.
Bit Switch
0 S2
1 S3
2 S4
3 S5
U9 has the group address 0100 and is strapped to unit address 000. Therefore, to read the switch
values, the 8051 firmware sends a control byte of 01000001 (the LSB indicates a read operation),
and then reads the data byte.
The low address byte is “don’t care”. This means you can efficiently add software test points using
the following code:
D5ON: mov MPAGE,#B8h ; turn D5 on
movx a,@r0 ; dummy read
;
D5OFF: mov MPAGE,#B0h ; turn D5 off
movx a,@r0 ; dummy read
This code example uses the 8051 8-bit indirect addressing mode. The MPAGE register (SFR 0x92)
supplies the high address byte and r0 supplies the low address byte. Register r0 does not require ini-
tialization because the low address byte is “don’t care” for the LED decoding.
To turn the LEDs ON and OFF using the C code, declare the external memory locations, and then
read their values into dummy variables:
xdata volatile unsigned char D5ON _at_ 0xB800;
xdata volatile unsigned char D5OFF _at_ 0xB000;
unsigned char dum;
dum = D5ON; // turn D5 on
dum = D5OFF; // turn D5 off
Note Program execution at these addresses do not activate the LEDs.
This section provides a detailed description of the structure and content of the EZ-USB DVK as it
exists on a user PC after installation. The following image shows the root-level tree after DVK instal-
lation. This assumes that all the DVK components are installed (the default installation type is ‘Typi-
cal’). Subsequent sections detail the contents of each sub-directory. The DVK installer installs
several files related to the development board in the Windows directory tree as shown in Figure 4-1.
The default directory for the CY3674 kit is C:\Cypress\USB\CY3674_EZ-USB_FX1_DVK\ and for
the CY3684 kit, it is C:\Cypress\USB\CY3684_EZ-USB_FX2LP_DVK\. In further sections, the
default installation directory is referred to as <Installed_directory>, which refers to the
default directory of the respective EZ-USB kits.
Figure 4-1. CY3684 Development Kit Content Structure
4.1 Bin
This folder contains the following utilities
■ Cyscript.exe: This utility is used to generate script files for the equivalent firmware(.hex) files
■ Hex2bix.exe: This utility is used to convert a firmware image compatible to the RAM memory
(.hex) to an EEPROM image (.iic).
■ Setenv.bat: This is a batch file to set path variables for the Keil compiler and firmware examples.
Click on this batch file to set the environment variables necessary before compiling the firmware
examples of the kit.
4.2 Documentation
This directory contains documentation, which describes the EZ-USB DVK. The following table lists
the summary of the documents in the CY3674 and CY3684 EZ-USB development kits.
Table 4-1. Documents Summary for EZ-USB FX1 and FX2LP Development Kits
Kit Specific/
S.No Common Document Description
Documents
Application note to assist users to
Migrating From AN21XX TO FX1 -
migrate from Older Anchor IC to
AN5040.pdf
EZ-USB FX1
1 FX1(CY3674)
Silicon Errata For EZ-USB™ FX1 Product Errata for EZ-USB FX1 IC
FamilY.pdf
EZ-USB FX1 Datasheet.pdf Datasheet for EZ-USB FX1 IC
Application note to assist users to
Migrating From EZ-USB FX2™ To EZ-
migrate from EZ-USB FX2 to EZ-
USB FX2LP™ - AN4078_C.pdf USB FX2LP
2 FX2LP(CY3684)
EZ-USB® FX2LP Datasheet.pdf Datasheet for EZ-USB FX2LP IC
Errata For The EZUSB-FX2LP.pdf Errata for EZ-USB FX2LP IC
Release Note EZ-USB FX1-EZ-USB Release notes for both EZ-USB
FX2LP™ Development Kit.pdf FX1 and FX2LP development kits
Detailed manual which explains the
EZ-USB® Technical Reference Man- in detail about the entire IP blocks
ual.pdf and registers inside EZ-USB
device.
3 Common documents
EZ-USB FX1-EZ-USB FX2LP™ Develop- Quick start guide for EZ-USB FX1
ment Kit Quick Start Guide.pdf and FX2LP devices.
This guide provides detailed
EZ-USB® Development Kit User instructions on Kit software installa-
Guide.pdf tion, Kit hardware, firmware exam-
ples and PC tools functionality.
4.3 Drivers
This directory contains Microsoft-certified, signed Cypress USB drivers for different Windows OS
platforms, such as Window 2000 (32-bit) and Windows XP, Vista, and 7 in 32- and 64-bit OS plat-
4.4 Firmware
The EZ-USB development kit contains several firmware examples to validate different interfaces of
EZ-USB device. Following is the list of firmware examples.
4.5 GPIF_Designer
This directory contains the GPIF designer software, which allows you to create State machine wave-
forms. These waveforms are useful to communicate with external devices, such as SRAM and
FPGA, using an EZ-USB GPIF interface.
4.6 Hardware
This directory contains the EZ-USB hardware schematic, PCB, Layout, gerber, and PCB BOM files.
Following are the files in this directory.
4.7 SuiteUSB
This folder contains the SuiteUSB 3.4.7 installer package and a sample Cypress Software License
agreement document. The software is installed as part of the EZ-USB Kit installer and the contents
are, by default, located at C:\Cypress\Cypress Suite USB 3.4.7.The package contains C++
and C# .NET application tools to communicate with the EZ-USB device. In addition, it contains
Cypress generic USB drivers (3.4.7). These are unsigned drivers.
4.8 Target
This directory contains the EZ-USB register definition header files, Keil debug monitor, and so on.
Following are the list of files.
4.9 Utilities
This directory contains the hex2bix utility source code in the VC++6 environment. The project code
can be used as a reference to invoke different command line options supported by this utility.
4.10 uV2_4k
This directory contains the Keil uVision2 Trial version IDE. The IDE has the limitation of compiling
the code limit of 4K. All the firmware examples included with the EZ-USB development kit can be
compiled using this IDE.
The firmware frameworks simplify and accelerate USB peripheral development using the EZ-USB
chip. The frameworks implement the 8051 code for EZ-USB chip initialization, USB standard device
request handling, and USB suspend power management services. The user provides a USB
descriptor table and code to implement the peripheral function to complete a fully compliant USB
device. The frameworks provide function hooks and example code to help with this process. The
frameworks use the EZ-USB library to carry out common functions and for EZ-USB register defini-
tions. Most of the firmware examples in the EZ-USB DVK are based on the frameworks.
5.3.1.1 TD_Init()
void TD_Init()
This function is called once during the initialization of the frameworks. It is called before ReNumera-
tion and the Task Dispatcher starts. It is intended for the global state variable and device initializa-
tion.
5.3.1.2 TD_Poll()
void TD_Poll()
This function is called repeatedly during device operation. It should contain a state machine that
implements the user's peripheral function. High-priority tasks can be completed before returning
from this function. However, failure to return from this function prevents frameworks from responding
to device requests and USB suspend events. If a large amount of processing time is required, it must
be split up to execute in multiple calls to TD_Poll().
5.3.1.3 TD_Suspend()
BOOL TD_Suspend()
This function is called before the frameworks enter suspend mode. This function contains code that
places the device in a low-power state and returns TRUE. However, the user code can prevent the
frameworks from entering suspend mode by returning FALSE.
5.3.1.4 TD_Resume()
void TD_Resume()
This function is called after the frameworks has resumed the processor in response to an external
resume event. At this point, the device resumes full-power operation.
5.3.2.1 DR_GetDescriptor()
BOOL DR_GetDescriptor()
This function is called before the frameworks decode and implement the GetDescriptor device
request. The register array SETUPDAT contains the current eight byte setup command. It can be
parsed by the user's code to determine which Get Descriptor command is issued. If TRUE is
returned, the frameworks will parse and implement the command. If FALSE is returned, it will do
nothing.
5.3.2.2 DR_GetInterface()
BOOL DR_GetInterface()
This function is called before the frameworks implement the Get Interface device request. The regis-
ter array SETUPDAT contains the current eight byte setup command. If TRUE is returned, the frame-
works will implement the command. If FALSE is returned, it will do nothing.
5.3.2.3 DR_SetInterface()
BOOL DR_SetInterface()
This function is called before the frameworks implement the Set Interface device request. The regis-
ter array, SETUPDAT, contains the current eight-byte setup command. It is the responsibility of this
routine to save the new interface setting and to do any necessary device configuration. If TRUE is
returned, the frameworks will implement the command. If FALSE is returned, it will do nothing.
5.3.2.4 DR_GetConfiguration()
BOOL DR_GetConfiguration()
This function is called before the frameworks implement the Get Configuration device request. The
register array, SETUPDAT, contains the current eight-byte setup command. If TRUE is returned, the
frameworks will implement the command. If FALSE is returned, it will do nothing.
5.3.2.5 DR_SetConfiguration()
BOOL DR_SetConfiguration()
This function is called before the frameworks implement the Set Configuration device request. The
register array, SETUPDAT, contains the current eight byte setup command. By default, the frame-
works parses the descriptor table to determine the new configuration interface and its endpoints. It
then configures the EZ-USB control registers to reflect these new endpoints. If the configuration is
set to 0 then the frameworks will invalidate all of the endpoints. If TRUE is returned, the frameworks
will implement the command. If FALSE is returned, it will do nothing.
5.3.2.6 DR_GetStatus()
BOOL DR_GetStatus()
This function is called before the frameworks implement the Get Status device request. The register
array, SETUPDAT, contains the current eight-byte setup command. If TRUE is returned, the frame-
works will implement the command. If FALSE is returned, it will do nothing.
5.3.2.7 DR_ClearFeature()
BOOL DR_ClearFeature()
This function is called before the frameworks implement the Clear Feature device request. The reg-
ister array, SETUPDAT, contains the current eight-byte setup command. If TRUE is returned, the
frameworks will implement the command. If FALSE is returned, it will do nothing.
5.3.2.8 DR_SetFeature()
BOOL DR_SetFeature()
This function is called before the frameworks implement the Set Feature device request. The regis-
ter array, SETUPDAT, contains the current eight-byte setup command. If TRUE is returned, the
frameworks will implement the command. If FALSE is returned, it will do nothing.
5.3.2.9 DR_VendorCmnd()
void DR_VendorCmnd()
This function is called when the frameworks determine a vendor specific command has been issued.
The register array, SETUPDAT, contains the current eight-byte setup command. This function has no
return value. The frameworks does not implement any vendor-specific commands. However, the EZ-
USB serial interface engine (SIE) uses vendor-specific command, 0xA0, to implement software
uploads and downloads. Therefore, command 0xA0 will not be passed to the user's code.
5.3.3.1 ISR_Sudav()
void ISR_Sudav(void) interrupt 0
This function is called on receiving the Setup Data Available interrupt. This function needs to set
GotSUD to TRUE so that the device request handler can process the SETUP command.
5.3.3.2 ISR_Sof()
void ISR_Sof(void) interrupt 0
This function is called on receiving the Start of Frame interrupt. It gets called every 1 ms at full-speed
and every 125 uS at high-speed. The only action for this interrupt in the default frameworks code is
to clear the interrupt.
5.3.3.3 ISR_Ures()
void ISR_Ures(void) interrupt 0
This function is called on receiving the USB Reset interrupt. In your custom code, place any house-
keeping that must be done in response to a USB bus reset in this routine. The default frameworks
code updates the configuration descriptor pointers in response to this interrupt. When a USB Reset
occurs, the device is always operating in full-speed (until high-speed chirp completes). Therefore, it
must return its full-speed configuration descriptor in response to a get configuration descriptor
request and must return its high-speed configuration descriptor in response to a get other-speed
descriptor request.
5.3.3.4 ISR_Susp()
void ISR_Susp(void) interrupt 0
This function is called on receiving the USB Suspend interrupt. The default frameworks code sets
the global variable Sleep to TRUE in this routine. This is required for the Task Dispatcher to detect
and handle the suspend event.
5.3.3.5 ISR_Highspeed()
void ISR_Highspeed(void) interrupt 0
This function is called on receiving the USB HISPEED interrupt. In your custom code, place any
housekeeping that must be done in response to a transition to high-speed mode in this routine.
The default frameworks code updates the configuration descriptor pointers in response to this inter-
rupt. When the device switches to high-speed mode, it must return its high-speed configuration
descriptor in response to a get configuration descriptor request and must return its full-speed config-
uration descriptor in response to a get other-speed descriptor request.
5.4.2.2 EZUSB_Discon()
void EZUSB_Discon(BOOL renum)
This function performs a USB disconnect/reconnect. It disconnects the device, delays for 1500 ms,
clears any pending USB interrupts (INT2), reconnects, and then returns. The parameter renum
determines if the EZ-USB renumerate bit is set in the USB control register. If renum is TRUE, the
renumerate bit is set and following a return from this function, the 8051 will be responsible for han-
dling all USB device requests on endpoint 0. If renum is FALSE, the renumerate bit is not modified. If
the renumerate bit is clear, then the EZ-USB serial interface engine handles most of the USB device
requests on endpoint 0.
5.4.2.3 EZUSB_GetStringDscr()
STRINGDSCR xdata * EZUSB_GetStringDscr(BYTE StrIdx)
This function returns a pointer to instance StrIdx of a string descriptor in the descriptor table. The
instance is determined by the StrIdx parameter. If the descriptor table does not contain the given
number of instances, then the function returns a NULL pointer.
5.4.2.4 EZUSB_Susp()
void EZUSB_Susp(void)
This function suspends the processor in response to a USB suspend event. This function will not
return until the suspend is cleared by a USB bus resume or a wake-up event on the EZUSB wake-up
pin. If a suspend event is not pending, this function will return immediately.
5.4.2.5 EZUSB_Resume()
void EZUSB_Resume(void)
This function generates the K-state on the USB bus required for a USB device remote wake-up. This
function should be called following a USB suspend. It automatically determines if the wake-up is
result of a USB resume or a remote wake-up and generates the K-state accordingly.
These functions automate access to I2C devices (such as the EEPROM), 7-segment display and
buttons on the DVK board. See the vend_ax and dev_io firmware examples for details on using
these functions.
This chapter describes the Cypress USB drivers provided along with the kits. The USB-signed driver
package consists of several files to test different features of the EZ-USB (FX1/FX2LP) kits. It also
includes the SuiteUSB installer, which supports a collection of USB Host application tools designed
in C++ and C# .NET framework. These tools are useful to communicate with any Cypress USB 2.0
device.
All these drivers support Windows 2000 (32-bit) and Windows XP, Vista, and 7 in both 32-bit as well
as 64-bit configurations. The following figure summarizes the list of folders specific to each OS.
Figure 6-2. Driver Sub-directory Summary
These folders contain signed driver files for relevant Windows OS platforms. Figure 6-3 shows the
snapshot of one of the signed driver package directories.
7. Select Yes, This time only and click Next. Select Install from a specific location and click
Next.
8. In the subsequent window, select Don't search. I will choose driver to install and select Next.
In the list of Hardware devices, select Universal Serial Bus Controllers and click on Have Disk
button. A new Window pops up for locating the USB driver. Click the Browse button and point to
the following directories for the corresponding Windows PC Host operating system with respect
to <Installed_directory>\<Version>\Drivers\cyusbfx1_fx2lp
a. Windows2000: w2k\x86
b. Windows XP(32-bit): wxp\x86
c. Windows XP(64-bit): wxp\x64
9. The Hardware wizard Window options differ in Windows Vista and Windows 7 OS platforms. If
the hardware wizard window does not pop up, then type devmgmt.msc directly in the vacant box
in Windows Start. Locate the Unknown Device marked in yellow. Right-click on the Unknown
Device and verify in Details > Hardware ID if the VID/PID match the Fuse ROM VID/PID for the
FX1 and FX2LP devices. Then, right-click again on the Unknown Device and select Update
Driver Software. The Windows OS Hardware wizard window will now pop up. If the hardware
wizard window pops up automatically, then the entire process mentioned in this step can be
avoided.
10.Select Browse my computer for driver Software. In the next window, under Browse for the
driver software on your computer, click Browse and select the following directory paths for
Windows Vista and 7 OS:
a. Windows-Vista(32-bit): wlh-vista\x86
b. Windows-Vista(64-bit): wlh-vista\x64
c. Windows-7(32-bit): wlh-win7\x86
d. Windows-7(64-bit): wlh-win7\x64
11. Open the device manager, as mentioned in step 9, and expand the list of USB controllers.
12.Observe the EZ-USB device in the list of USB device controllers. Following are the strings for the
default Fuse ROM VID/PID of EZ-USB devices.
a. EZ-USB FX1:“Cypress EZ-USB FX1 No EEPROM(3.4.5.000)”
b. EZ-USB FX2LP:“Cypress EZ-USB FX2LP No EEPROM(3.4.5.000)”
This completes the entire binding process for the EZ-USB device. The process is similar for any
USB device with its own proprietary drivers.
6.3 Drivers for Firmware and Keil Monitor Automatic Download using
Script Files
The firmware examples provided with the EZ-USB kits can be manually downloaded using Cycon-
sole or CyControlcenter. If you need to automate the firmware downloading process, then script
files can be used. Whenever the EZ-USB board with the relevant VID/PID to the script file is
detected, then the Windows OS automatically downloads the actual firmware inside the script and
the EZ-USB device re-enumerates with new VID/PID defined in the firmware. Following are the rele-
vant driver files provided under the \Drivers directory:
■ CyLoad: This directory contains CyLoad.spt, Cyload.cat, CyLoad.inf, and cyusb.sys.These are
basic files required to automate the process of firmware download using script files and .INF files.
For more details, refer to Firmware Download using CyLoad Driver Package on page 49.
■ CyMonfx1_fx2lp: This directory contains mon.spt cymon.cat, CyMonfx1_fx2lp.inf and
cyusb.sys. The script file mon.spt contains the Keil debug monitor. The Keil debug monitor, after
downloading to EZ-USB RAM memory, enables the user to debug EZ-USB firmware examples
using step-by-step debugging using the UART port at 38400 baud rate. The method to debug
firmware examples using this driver package is explained in Debugging Using Keil Monitor Pro-
gram on page 97.
Verify if the xx.spt file is located in the destination directory. This tool can only generate a script but
cannot play the script. Using Cyconsole or Controlcenter, the generated script file can be loaded
and played to download the firmware inside the script.
1.Connect a USB A-to-B cable between the Windows PC USB Host port and the EZ-USB FX1/
FX2LP board J1 connector. The board should have switch SW2 with the NO EEPROM option
selected.
2.The EZ-USB FX1/FX2LP enumerates with the default Fuse ROM VID/PID.
3.Select the Record Script button
4.In the options menu, select EZ-USB Interface. Select Download in the new pop-up window and
browse to Bulkloop.hex at <Installed_directory>\<Version>\Firmware\Bulkloop
5.Observe the Bulkloop.hex file getting downloaded successfully to the EZ-USB RAM memory. After
firmware download, click the Stop recording button and save the .spt file generated in the local
directory of choice.
6.Select the Load script button and choose the xxx.spt file generated in step 5.
7.Click on Play script. The entire firmware gets downloaded and the EZ-USB FX1/FX2LP re-enu-
merates with VID/PID -0x04B4/0x1004 defined in the firmware.
8.Open the device manager by clicking on Windows Start > Run. Type devmgmt.msc in the Run
box. If cyusbfx1_fx2lp.inf was binded to EZ-USB FX1/FX2LP earlier, as mentioned in Binding
Cypress USB Driver to EZ-USB Development Board on page 45, then the EZ-USB device enumer-
ates as Cypress EZ-USB Example Device(3.4.5.000).
1. Connect a USB A-to-B cable between the Windows PC USB Host port and the EZ-USB FX1/
FX2LP board J1 connector. The board should have SW2 switched to the side, marked as NO
EEPROM.
2. The EZ-USB FX1/FX2LP enumerates with the default Fuse ROM VID/PID.
3. Click the Create Script button and select Bulkloop.hex at <Installed_directory>\<Ver-
sion>\Firmware\Bulkloop. Save the file as Bulkloop.spt to any local directory of choice.
4. Select the Load script button and choose the Bulkloop.spt file generated in step 3.
5. Click on Play script. The entire firmware gets downloaded and the EZ-USB FX1/FX2LP re-enu-
merates with VID/PID -0x04B4/0x1004 defined in the firmware.
6. Open the device manager by clicking on Windows Start > Run. Type devmgmt.msc in the Run
box. In the Windows Vista and 7 OS platforms, type devmgmt.msc directly in the vacant box
near Start button. If cyusbfx1_fx2lp.inf was binded to EZ-USB FX1/FX2LP previously as men-
tioned in section Binding Cypress USB Driver to EZ-USB Development Board chapter on
page 45 then EZ-USB device enumerates as Cypress EZ-USB Example Device(3.4.5.000).
1. CyLoad.cat: These are Windows Catalog files which indicates that the USB driver cyusb.sys
passed Microsoft driver certification (WHQL) process.
2. Cyusb.sys: This is the cypress provided generic USB driver for all USB 2.0
products. The driver version 3.4.5 was used in the driver certification process
3. CyLoad.inf: This driver information file contains details about the CyLoad.spt,
CyLoad.cat and cyusb.sys driver file entries. The corresponding destination directories for driver
file and script file are also mentioned.The .INF file automates the process of firmware loading
using these files.
4. CyLoad.iic: Small EEPROM Image which contains VID/PID -0x04B4/0x0084
matching the VID/PID of Cyload.inf file. After downloading this file to EZ-USB development board
it re-enumerates with this VID/PID and script file is automatically triggered by Windows OS.
5. CyLoad.spt: The script file which automates firmware downloading to a EZ-USB
device.
Following is the snapshot of CyLoad.inf file content located at <Installed_directory>\<Ver-
sion>\Drivers\CyLoad for different Windows PC Host platforms
[Version]
Signature="$Windows NT$"
Class=USB
ClassGUID={36FC9E60-C465-11CF-8056-444553540000}
provider=%CYUSB_Provider%
CatalogFile=CyLoad.cat
DriverVer=01/19/2011,3.04.0005.000
[SourceDisksNames]
1=%Cyload_INSTALL%,,,
[SourceDisksFiles]
CyUsb.sys = 1
CyLoad.spt = 1
[DestinationDirs]
CyLoadFW.Files = 10, System32\CyLoad
CYUSB.Files.Ext = 10, System32\Drivers
[ControlFlags]
ExcludeFromSelect = *
[Manufacturer]
%CYUSB_Provider%=Device, NT, NTx86, NTamd64
[Device.NTx86]
;%VID_XXXX&PID_XXXX.DeviceDesc%=CyLoad, USB\VID_XXXX&PID_XXXX
%VID_04B4&PID_0084.DeviceDesc%=CyLoad, USB\VID_04B4&PID_0084
[CyLoad.HW]
AddReg=CyLoad.AddReg.Guid
[CYLoad.Services]
Addservice = CyLoad, 2,CyLoad.AddService
[CyLoad.NT]
CopyFiles=CyLoadFW.Files
AddReg=CyLoad.AddReg
[CyLoad.NT.HW]
AddReg=CyLoad.AddReg.Guid
[CyLoad.NT.Services]
Addservice = CyLoad,2,CyLoad.AddService
......
[CyLoadFW.Files]
CyLoad.spt
[CyLoad.AddReg.Guid]
HKR,,DriverGUID,,%CyLoad.GUID%
HKR,DriverEXECSCRIPT,,%CyLoad.EXECSCRIPT%
[CYUSB]
CopyFiles=CYUSB.Files.Ext
AddReg=CyUsb.AddReg
[CYUSB.HW]
AddReg=CYUSB.AddReg.Guid
[CYUSB.Services]
Addservice = CYUSB, 2,CYUSB.AddService
[CYUSB.Files.Ext]
CYUSB.sys
[CYUSB.AddReg.Guid]
HKR,,DriverGUID,,%CYUSB.GUID%
6. The Windows hardware wizard pops up prompting user to locate the relevant driver. Follow the
steps 6 through10 explained in section 5.2.1 and point to the following Cyload driver for the rele-
vant CyLoad drivers directory, <Installed_directory>\<Version>\Drivers\CyLoad
a. Windows2000w2k\x86
b. Windows XP(32-bit): \wxp\x86
c. Windows XP(64-bit): wxp\x64
d. Windows-Vista(32-bit): wlh-vista\x86
e. Windows-Vista(64-bit): wlh-vista\x64
f. Windows-7(32-bit): wlh-win7\x86
g. Windows-7(64-bit): wlh-win7\x64\
7. The following files are copied to C:\Windows during binding process
a. CyLoad.spt copied to C:\Windows\system32\Cyload
b. Cyusb.sys copied to C:\Windows\system32\drivers
8. Open the device manager by clicking Start >Run. Type devmgmt.msc in the Run box. In Win-
dows Vista and Windows 7 machines, type the option directly in the vacant box. Expand the list of
USB controllers and observe the following:
a. During script file firmware download the EZ-USB device enumerates as “Cypress EZ-USB
Example Device Firmware Download (3.4.5.000)” due to VID/PID-0x04B4/0x0084 men-
tioned in CyLoad.inf
b. After completely downloading the firmware the EZ-USB device re-enumerates again with
downloaded firmware VID/PID-0x04B4/0x1004.The EZ-USB device updates itself in the
device manager as “Cypress EZ-USB Example Device (3.4.5.000)”. This string confirms
that auto firmware download using CyLoad.spt was successful.
Note The EEPROM image can also be downloaded using CyControlCenter.
6.3.3 Keil Debug Monitor Download using Script and CyMonfx1_fx2lp Driver Package
The Keil debug monitor is used to debug the firmware examples based on the EZ-USB kit.The Keil
monitor program is embedded in script file (mon.spt). The procedure to generate the script file for a
.hex file was explained in section. Using the sample Keil monitor .hex programs located at
<Installed_directory>\<Version>\Target\Monitor, the relevant script file can be gen-
erated. Alternatively, the current script file mon.spt can be used to debug the firmware example. The
detailed list of steps to debug a sample firmware example dev_io is explained in Debugging Using
Keil Monitor Program on page 97.
This chapter describes the USB PC Host utilities provided with the EZ-USB (FX1/FX2LP) kits. Addi-
tionally, the SuiteUSB installer is provided, which supports a collection of USB Host application tools
designed using C++ and C# .NET software design tools. These host applications are used to com-
municate with Cypress USB 2.0 devices, such as EZ-USB FX1 and FX2LP.
The C++ applications use CyAPI.lib to communicate with the Cypress USB device.The C# .NET
framework applications use CyUSB.dll to communicate with the hardware.
Figure 7-1 displays the connected Cypress USB 2.0 device (FX2LP, in this case) and its attributes,
such as USB class, and the list of endpoints it supports.
Prior to firmware download, the Record Script button on the top left corner is used to record the
entire download process, including the firmware binary embedded inside it. After firmware download
is complete, click the Stop Recording button to save the entire download into a script file - xxx.spt.
To verify the script, load it using the Load Script button and play using Play Script. Due to the firm-
ware embedded inside the script getting downloaded, the EZ-USB development board will re-enu-
merate with the new VID/PID defined in the firmware. The process of script download is mentioned
in the section Script File Generation and Play using CyConsole on page 48. Click on Options > EZ-
USB Interface and the window shown in Figure 7-2 pops up.
■ BulkTrans: This button is used transfer data over Bulk IN/OUT endpoints. After the Bulkloop
firmware example is downloaded (Bulkloop.hex), this button is used to send data over Bulk IN/
OUT endpoints using the Bulk Trans button. A sample demonstration is provided in the section
Bulkloop Example on page 77. For more details on Cyconsole, refer to CyConsole.chm and
CyConsole.pdf at C:\Cypress\Cypress Suite USB 3.4.7\CyConsole. A sample demon-
stration of this utility, while using firmware examples, is provided in the section EZ-USB Develop-
ment Kit Firmware Examples chapter on page 65.
■ FileTrans: This button is used to download raw packet data to the EZ-USB device.The sample
files that can be used to transfer are available at <Installed_directory>\<Ver-
sion>\Target\File_Transfer.
■ Firmware Download: After connecting the EZ-USB development board in the NO EEPROM
mode (switch SW2 on board to NO EEPROM), the firmware can be download to RAM, small
EEPROM or the large EEPROM.The procedure to download is explained in EZ-USB Develop-
ment Kit Firmware Examples chapter on page 65 for each of the firmware examples provided
with the kit.
■ Script file generation and automatic firmware download: This utility can be used to generate
the script file for a relevant firmware .hex file and later use the script file to automatically down-
load the firmware using the script. The process of automatic firmware download using scripts is
explained in the section Script Generation and Play using CyControlCenter on page 49.
■ Data transfers: Using the tool, the USB packet data can be transferred over an endpoint. The
procedure is explained in the CyControlCenter.pdf file located at C:\Cypress\Cypress Suite
USB 3.4.7\CyUSB.NET\.
Select the relevant Bulk or Isochronous In/OUT endpoint. Vary the Packets per Xfer and Xfers to
Queue parameters and verify the throughput for different Bulk and Isochronous endpoints across dif-
ferent alternate interfaces.
2.Streamer using C# .NET CYUSB.dll: The throughput can also be measured using this utility
available at C:\Cypress\Cypress Suite USB 3.4.7\CyUSB.NET\examples\Streamer\bin\Release.
Select the relevant Bulk or Isochronous In and OUT endpoints. Vary the Packets per Xfer and Xfers
to Queue parameters and verify the throughput for different Bulk and Isochronous endpoints across
different alternate interfaces.
Note The maximum data allowed per transfer is 64 KB for Bulk and Isochronous transfers.
The EZ-USB development board is connected to the Windows PC Host in the NO EEPROM mode
(SW2 to NO EEPROM side). The utility then detects the board and the relevant buttons on the .exe
are enabled. To program small EEPROM images, such as FX1_C0.iic, FX2LP_CO.iic, and
CyLoad.iic, select the SW2-EEPROM and SW1-SMALL EEPROM settings on board. Press the Pro-
gram Small EEPROM button, and browse and select the relevant image and program the .iic file. To
download bulk firmware images (0xC2 load), select the SW2-EEPROM and SW1-LARGE EEPROM
settings. Press the Program Large EEPROM button, browse to the location of the image, and finally
select the image. The image is automatically downloaded to the external EEPROM connected to the
EZ-USB device.
This chapter explains in detail about firmware example and how to test each firmware example pro-
vided with the kit. The EZ-USB FX1 and FX2LP kits contain a common set of firmware examples to
demonstrate the EZ-USB (FX1 and FX2LP) capabilities along with the various components on-board
(seven-segment LED, push button, RAM memory, EEPROM, and so on). It also explains how to
debug a firmware example using the Keil uVision2 IDE. Table 8-1 lists the firmware examples pro-
vided with the kit, along with their brief description.
Note All the above firmware examples, except hid_kb, use the common VID/PID, 0x04B4/0x1004.
The hid_kb project uses the VID/PID, 0x04B4/0x1005.
The firmware example detects if any of the four push buttons are pressed (on the development
board) and sends the relevant fixed data to the Host PC. For the HID-class devices, such as key-
board and mouse, the USB bandwidth requirements is typically 64 KB/sec. Most of the HID devices
are either low-speed or full-speed devices. Due to this low data rate requirement of the device, only
the endpoint EP1 (64-byte buffer) is selected for both IN and OUT interrupt transfers. The high-
speed data endpoints EP2, EP4, EP6, and EP8 are disabled, as shown in the following code snip-
pet:
EP1OUTCFG = 0xB0; // valid, interrupt OUT, 64 bytes, Single buffered
EP1INCFG = 0XB0; // valid, interrupt IN, 64 bytes, Single buffered
EP2CFG = EP4CFG = EP6CFG = EP8CFG = 0; // disable unused endpoints
For a typical HID device, the data related to events, such as button press, key strokes, and mouse
clicks, are transferred to the Host in the form of Input Reports using an Interrupt IN endpoint. Simi-
larly, the Reports can be requested by the Host PC using the control endpoint or an Interrupt OUT
endpoint. The firmware sets EP1IN and EP1OUT as Interrupt endpoints for data transfers. The fol-
lowing table summarizes the mapping of Push buttons on the FX2LP development board to key-
board buttons.
The function TD_poll () in the firmware (periph.c) is where the periodic checking of a new push but-
ton event is done. Following is the code snippet of this function.
if( !(EP1INCS & bmEPBUSY) ) // Is the EP1INBUF
//available,
{
EZUSB_ReadI2C(BTN_ADDR,0x01,&buttons); // Read button states
buttons &= 0x0F;
if ((oldbuttons - buttons) != 0) //Change in button state
{
if (buttons & 1) //Shift
EP1INBUF[0] = 0;
else
EP1INBUF[0] = 2;
if (buttons & 2) //a
EP1INBUF[2] = 0;
else
EP1INBUF[2] = 4;
if (buttons & 4) //b
EP1INBUF[3] = 0;
else
EP1INBUF[3] = 5;
if (buttons & 8) //c
EP1INBUF[4] = 0;
else
EP1INBUF[4] = 6;
EP1INBUF[1] = 0;
EP1INBC = 5;
}
oldbuttons = buttons;
}
8.2.1 Building Firmware Example Code for EZ-USB Internal RAM and External
EEPROM.
■ Click on Build Target button at the top right corner of the IDE. Figure 8-2 of the Build window of
the Keil IDE shows the successful compilation of the entire project.
Note Observe that the total Code bytes of the hid_kb project is less than the 4-k code limit of Keil
uVision2 IDE provided along with the kit.
■ Firmware for EZ-USB RAM memory: The output of the Build Target is hid_kb.hex. It is the rel-
evant file for downloading to EZ-USB RAM memory.
■ Firmware for external I2C EEPROM: To generate EEPROM compatible firmware image, the
Keil IDE invokes the hex2bix.exe utility to convert the output file hid_kb.hex into hid_kb.iic.
Right-click on Target1 in the Project Window and select Options for Target 'Target1'. This will
pop-up the Keil settings for this project. Select the Output tab and observe at the bottom of the
IDE, the hex2bix utility is invoked as shown in Figure 8-3.
Figure 8-3. hid_kb Project Output Image Settings
Under Run User program#1 section observe the hex2bix utility is invoked in the following manner:
..\..\Bin\hex2bix -i -c 0x00 -f 0xC2 -o hid_kb.iic hid_kb.hex
Refer to the application note, “Using the hex2bix Conversion Utility - AN45197, to know more
details on the hex2bix utility.
Note To download the image to the small EEPROM, follow the instructions in steps 1 to 7. The only
changes are the on-board EEPROM settings in step 2 (SW1-SMALL EEPROM, SW2-EEPROM).
Additionally, the Cyconsole EZ-USB Interface Window selects S EEPROM instead of Lg EEPROM
before download and in CyControlCenter menu, select Program FX2 > small EEPROM instead of
64KB EEPROM.
8.2.4 Binding Cypress USB Driver for the Downloaded Firmware Image
The hib_kb project contains firmware for a HID-class keyboard device (Interface class: HID = 03
and subclass = 00) and uses the Microsoft native HID driver, instead of Cypress generic USB driver.
and 4 are armed to accept data from the host. This data is transferred to endpoint 6 and endpoint 8
respectively. To implement this, endpoint 2 is first checked to see if it has data. This is done by read-
ing the endpoint 2 empty bit in the endpoint status register (EP2468STAT). If endpoint 2 has data
(that is sent from the host), then check if the host has requested data on EP6. This is done by read-
ing the EP6 In-Bulk-Flag bit in the IbnFlag variable. If the host has requested for data on EP6, then
the data is transferred.
This decision is executed by the following statement:
if (!(EP2468STAT & bmEP2EMPTY) && (IbnFlag & bmEP6IBN) )
// if there is new data in EP2FIFOBUF and the IBN flag for EP6 has been
set, //then copy the data from EP2 to EP6
The data transfer is carried out by the execution of the following loop:
for( i = 0x0000; i < count; i++ )
{
// setup to transfer EP2OUT buffer to EP6IN buffer using AUTOPOINTER(s)
EXTAUTODAT2 = EXTAUTODAT1;
}
As auto pointers are enabled, the pointers increment automatically.
EXTAUTODAT2 = EXTAUTODAT1;
After this statement transfers the data, endpoint 2 has to be "rearmed" to accept a new packet from
the host. Endpoint 6 has to be “committed”, that is, make the FIFO buffers available to the host for
reading data from the Endpoint 6.
This is accomplished by the following statements:
EP6BCH = EP2BCH;
SYNCDELAY;
EP6BCL = EP2BCL; // commit EP6IN by specifying the number of bytes the
host can read //from EP6
SYNCDELAY;
EP2BCL = 0x80; // re (arm) EP2OUT
The EP6 In-Bulk-NAK Flag bit in the IbnFlag variable is cleared. The EP6 In-Bulk-NAK interrupt
request is cleared by setting the corresponding bit in the IBNIRQ register. Finally, the EP6 In-Bulk-
NAK interrupt is enabled by setting the corresponding bit in the IBNIE register.
IbnFlag &= ~bmEP6IBN; // clear the IBN flag
IBNIRQ = bmEP6IBN; // clear the IBN IRQ
IBNIE |= bmEP6IBN; // enable the IBN IRQ
The same operation is carried out to implement a data loop with endpoints 4 and 8.
When the host requests an IN packet from an EZ-USB BULK endpoint, the endpoint NAKs (returns
the NAK PID) until the endpoint buffer is filled with data and armed for transfer, at which point the EZ-
USB answers the IN request with data. Until the endpoint is armed, a flood of IN-NAKs can tie up
bus bandwidth. Therefore, if the IN endpoints are not always kept full and armed, it may be useful to
know when the host is "knocking at the door, requesting IN data”. The IN-BULK-NAK (IBN) interrupt
provides this notification. The IBN interrupt fires whenever a Bulk endpoint NAKs an IN request. The
IBNIE/IBNIRQ registers contain individual enable and request bits for each endpoint, and the NAKIE/
NAKIRQ registers each contain a single-bit, IBN, that is the ORd combination of the individual bits in
IBNIE/IBNIRQ, respectively. The EZ-USB firmware framework provides hooks for all the interrupts
that it implements. The example project uses the ISR_Ibn interrupt service routine to handle In-Bulk-
NAK(IBN) interrupt for EP6 and EP8.
void ISR_Ibn(void) interrupt 0
{
int i;
8.3.2 Building Firmware Example Code for EZ-USB RAM and EEPROM
Click on Build Target at the top right corner of the IDE. The firmware example builds successfully
since the total code bytes of IBN firmware example is less than the 4-k code limit Keil µVision2 IDE
provided along with the kit. The output of the Build Target is ibn.hex and ibn.iic files.
8.3.3 Method to Download Firmware Image to EZ-USB Internal RAM and External
EEPROM
Refer to the sections Method to Download Firmware Image to EZ-USB Internal RAM Memory on
page 69 and Method to Download Firmware Image to External I2C EEPROM on page 69 and follow
a similar procedure to download ibn.hex to either the RAM memory or ibn.iic to large EEPROM
using Cyconsole/CyControlCenter. After download, the firmware re-enumerates with the PC using its
internal VID/PID-0x04B4/0x1004.
8.3.4 Binding Cypress USB Driver for the Downloaded Firmware Image
The IBN project uses vendor-class (0xFF) with VID/PID-0x04B4/1004.This example should bind with
the Cypress generic USB driver, cyusb.sys, and the driver information file, cyusbfx1_fx2lp.inf, which
contains the relevant VID/PID of this example. Follow the procedure outlined in Binding Cypress
USB Driver to EZ-USB Development Board on page 45 to manually bind the driver using the Win-
dows Hardware Wizard.
3. On sending a packet to these endpoints when both the buffers are full, the endpoints NAK the
transfer because there is no space available. If an IN transfer is requested on either EP6 or EP8,
the corresponding In-Bulk-NAK interrupt is asserted and data is transferred from EP2 to EP6 or
from EP4 to EP8. This data appears on the EZ-USB Interface Window.
4. The above can be tested by trying to send data to EP2 and EP4 without reading the data out of
EP6 or EP8. After the first two transfers, all the successive OUT transfers fail. This persists until
an IN transfer is made on EP6 or EP8.
5. For the EZ-USB FX1 device, the endpoint size is 64 bytes instead of 512 bytes.
interrupts and enables the PING-NAK interrupt for EP2 and EP4. The loopback is implemented in
the TD_Poll() function that is called repeatedly when the device is idle. Endpoints 2 and 4 are armed
to accept data from the host. This data is transferred to endpoint 6 and endpoint 8 respectively. To
implement this, endpoint 2 is first checked to see if it has data. This is done by reading the endpoint
2 empty bit in the endpoint status register (EP2468STAT). If endpoint 2 has data (that is sent from
the host), the capability of endpoint 6 to receive the data is checked. This is done by reading the end-
point 6 Full bit in the endpoint status register. If endpoint 6 is not full, then the data is transferred.
This decision is executed by the following statements:
if (!(EP2468STAT & bmEP2EMPTY))
{// check EP2 EMPTY (busy) bit in EP2468STAT (SFR), core set's this bit
when
// FIFO is empty
if (!(EP2468STAT & bmEP6FULL))
{// check EP6 FULL (busy) bit in EP2468STAT (SFR), core set's this bit
// when FIFO is full
The data pointers are initialized to the corresponding buffers. The first auto pointer is initialized to the
first byte of the endpoint 2 FIFO buffer. The second auto-pointer is initialized to the first byte of the
endpoint 6 FIFO buffer. The number of bytes to be transferred is read from the byte count registers
of Endpoint 2. The registers EP2BCL, EP2BCH contain the number of bytes written into the FIFO
buffer by the host. These two registers give the byte count of the data transferred to the FIFO in an
OUT transaction as long as the data is not committed to the peripheral side. This data pointer initial-
ization and loading of the count is done in the following statements:
APTR1H = MSB( &EP2FIFOBUF ); // Initializing the first data pointer
APTR1L = LSB( &EP2FIFOBUF );
AUTOPTRH2 = MSB( &EP6FIFOBUF ); // Initializing the second data pointer
AUTOPTRL2 = LSB( &EP6FIFOBUF );
count = (EP2BCH << 8) + EP2BCL; // The count value is loaded from the byte
// count registers
The data transfer is carried out by the execution of the following loop:
for( i = 0x0000; i < count; i++ )
{
// setup to transfer EP2OUT buffer to EP6IN buffer using AUTOPOINTER(s)
EXTAUTODAT2 = EXTAUTODAT1;
}
Because auto pointers have been enabled, the pointers increment automatically, and the statement
EXTAUTODAT2 = EXTAUTODAT1;
transfers data from endpoint 2 to endpoint 6. Each time the above statement is executed, the auto
pointer is incremented. The above statement is executed repeatedly to transfer each byte from end-
point 2 to 6. After the data is transferred, endpoint 2 has to be 'rearmed' to accept a new packet from
the host. Endpoint 6 has to be 'committed', that is, make the FIFO buffers available to the host for
reading data from endpoint 6. This is accomplished by the following statements:
EP6BCH = EP2BCH;
SYNCDELAY;
EP6BCL = EP2BCL; // commit EP6IN by specifying the number of bytes the
host can read //from EP6
SYNCDELAY;
EP2BCL = 0x80; // re (arm) EP2OUT
The same operation is carried out to implement a data loop with endpoints 4 and 8.
High-speed USB implements a PING-NAK mechanism for (Bulk and Control) OUT transfers. When
the host wishes to send an OUT data to an endpoint, and the previous data transfer was responded
by a NYET, it first sends a PING token to see if the endpoint is ready (for example, if it has an empty
buffer). If a buffer is not available, the FX2LP returns a NAK handshake. PING-NAK transactions
continue to occur until an OUT buffer is available, at which time the FX2LP answers a PING with an
ACK handshake and the host sends the OUT data to the endpoint. EZ-USB implements PING-NAK
interrupt as EP0PING, EP1PING, and so on, one for each endpoint. The EPxPING interrupt is
asserted when the host PINGs an endpoint and the FX2LP responds with a NAK because the partic-
ular endpoint buffer memory is not available. The FX2LP firmware framework provides hooks for all
the interrupts that it implements. The example project uses ISR_Ep2pingnak and ISR_Ep4pingnak
interrupt service routines to handle EP2PING and EP4PING interrupts respectively.
void ISR_Ep2pingnak(void) interrupt 0
{
SYNCDELAY; // Re-arm endpoint 2
EP2BCL = 0x80;
EZUSB_IRQ_CLEAR(); // clear the EP2PING interrupt
NAKIRQ = bmEP2PING;
}
The ISR_Ep2pingnak discards the previous data that is stored in one of the buffers of Endpoint 2 by
re-arming the endpoint (that is, EP2BCL = 0x80). Therefore, EP2 can now receive the data that is
currently being sent by the host because there is space available in one of its buffers. It then clears
the interrupt by setting a particular bit in NAKIRQ because it has been serviced. The same operation
is carried to service the EP4PING interrupt in ISR_Ep4pingnak.
8.4.2 Building Firmware Example Code for EZ-USB RAM and EEPROM
Click on Build Target button at the top right corner of the IDE. The total code bytes of the pingnak
firmware example is less than the 4-k code limit Keil µVision2 IDE provided along with the kit. The
output of the Build Target is pingnak.hex and pingnak.iic files.
8.4.3 Method to Download Firmware Image to EZ-USB Internal RAM and External
EEPROM
Refer to Method to Download Firmware Image to EZ-USB Internal RAM Memory on page 69 and
Method to Download Firmware Image to External I2C EEPROM on page 69 and follow a similar pro-
cedure to download pingnak.hex to RAM memory or pingnak.iic to Large EEPROM using the
CyConsole or CyControlCenter. Both images are located at <Installed_directory>\<Ver-
sion>\Firmware\pingnak. After downloading, the firmware re-enumerates with the PC using its
internal VID/PID-0x04B4/0x1004.
8.4.4 Binding Cypress USB Driver for the Downloaded Firmware Image
The pingnak project uses vendor-class (0xFF) with VID/PID-0x04B4/1004. This example should
bind with the Cypress generic USB driver, cyusb.sys, and the driver information file,
cyusbfx1_fx2lp.inf, which contains the relevant VID/PID of this example. Follow the procedure out-
lined in Binding Cypress USB Driver to EZ-USB Development Board on page 45 to manually bind
the driver using Windows Hardware Wizard. If the binding process is performed for anyone of the
firmware example the process can be skipped for this example.
near Bulk Trans button of EZ-USB interface window, enter the length as 512 and HexBytes as
5, and then press the Bulk Trans button.
2. This data can be read back from Endpoint 6 using CyConsole. For example, select Endpoint 6 IN
in the pipe, enter the length as 512, and then press the Bulk Trans button. Similarly, loopback
using endpoint 4 and 8 can also be tested. Because EP2 and EP4 are double-buffered, they can
contain only two packets of data. After sending a packet to these endpoints when both the buffers
are full, the endpoints NAK the transfer because there is no space available. This asserts the
PING-NAK interrupt of the NAKing endpoint.
3. The ISRs that handle the PING-NAK interrupt. (ISR_Ep2pingnak and ISR_Ep4pingnak) discards
the previous data that is stored in one of the endpoint buffers by rearming the endpoint. There-
fore, the endpoints can receive the data that is currently sent by the host because there is space
in one of its buffers.
4. The above can be tested by continuously sending data to EP2 and EP4 without reading the data
out of EP6 or EP8. Because the PING-NAK ISR rearms the endpoints, you can continuously
transmit data to EP2 and EP4 and the transfer always succeeds. The data present in the buffers
of EP2 and EP4 at any point of time will be the latest two packets of data sent from the host.
Note: For EZ-USB FX1 the above steps can be repeated with data transfer length of 64 bytes
instead of 512 bytes.
After the data is transferred, endpoint 2 has to be 'rearmed' to accept a new packet from the host.
Endpoint 6 has to be 'committed', that is, make the FIFO buffers available to the host for reading
data from endpoint 6.
This is accomplished by the following statements:
EP6BCH = EP2BCH;
SYNCDELAY;
EP6BCL = EP2BCL; // commit EP6IN by specifying the number of bytes the
host can read //from EP6
SYNCDELAY;
EP2BCL = 0x80; // re (arm) EP2OUT
The same operation is carried out to implement a data loop with endpoints 4 and 8.
8.5.2 Building Bulkloop Firmware Example Code for EZ-USB RAM and EEPROM
■ Click on Build Target button at the top right corner of the IDE. Following snapshot of the Build
window of the Keil IDE shows the successful compilation of the entire project.
Figure 8-5. Output Window Snapshot of Bulkloop Project Build
Note Observe in Figure 8-5 the total code bytes of the Bulkloop project is less than the 4-k code
limit Keil µVision2 IDE provided along with the kit.
■ Firmware output for EZ-USB RAM memory: The output of the Build Target is bulkloop.hex
relevant for downloading to EZ-USB RAM memory.
■ Firmware output for external EEPROM: To generate EEPROM compatible firmware Image the
Keil IDE invokes hex2bix.exe utility to convert the output file bulkloop.hex into bulkloop.iic.
Right click on Target1 in Project Window and select Options for Target 'Target1'.This will pop-up
keil settings for this project. Select Output tab and observe at the bottom of IDE the hex2bix utility
is invoked under Run User program#1 section and observe the hex2bix utility is invoked in the
following manner
..\..\Bin\hex2bix -i -c 0x00 -f 0xC2 -o bulkloop.iic bulkloop.hex
Refer to the application note, “Using the hex2bix Conversion Utility - AN45197, to know more about
the hex2bix utility.
EZ-USB FX1 and FX2LP. After downloading, the firmware re-enumerates with PC using its internal
VID/PID-0x04B4/0x1004.
8.5.4 Binding Cypress USB Driver for the Downloaded Firmware Image
The Bulkloop firmware uses vendor class (0xFF) with VID/PID-0x04B4/1004. This example should
bind with Cypress generic USB driver cyusb.sys and driver information file cyusbfx1_fx2lp.inf, which
contains the relevant VID/PID of this example. Follow the procedure outlined in section Binding
Cypress USB Driver to EZ-USB Development Board on page 45 to manually bind the driver using
Windows Hardware Wizard. If the binding process is performed for anyone of the previous firmware
examples the process can be skipped for this example.
2. Select EP6 IN as pipe near BulkTrans button and enter length as 512 byte. Click on BulkTrans
button. The data sent on EP2 is loopbacked through EP6. The following figure summarizes the
entire operation. The same sequence can be repeated for EP4-OUT and EP8-IN pair.
Note Step 2-3 can be repeated for EZ-USB FX1 with data transfer length of 64 Bytes
SYNCDELAY; //
EP2BCL = 0x80;
}
Endpoint EP6 is re-armed with an incremental pattern of data starting with 0x2.
// if EP6 IN is available, re-arm it
If(!(EP2468STAT & bmEP6FULL))
{
SYNCDELAY;
EP6BCH = 0x02;
SYNCDELAY;
EP6BCL = 0x00;
}
The contents received from the EP4 OUT endpoint are copied to a temporary buffer, myBuffer[], and
re-armed.
// if there is new data in EP4FIFOBUF, then copy it to a temporary buffer
if(!(EP2468STAT & bmEP4EMPTY))
{
APTR1H = MSB( &EP4FIFOBUF );
APTR1L = LSB( &EP4FIFOBUF );
SYNCDELAY; //
EP4BCL = 0x80; // re(arm) EP4OUT
}
If the EP8 Bulk IN endpoint is empty, then the contents of temporary buffer are transferred to an
AUTO pointer and finally copied to the EP8 IN buffer as shown in the following code.
// if there is room in EP8IN, then copy the contents of the temporary buf-
fer to it
if(!(EP2468STAT & bmEP8FULL) && myBufferCount)
{
APTR1H = MSB( &myBuffer );
APTR1L = LSB( &myBuffer );
SYNCDELAY; //
EP8BCH = MSB(myBufferCount);
SYNCDELAY; //
EP8BCL = LSB(myBufferCount); // arm EP8IN
}
8.6.2 Building Bulksrc Firmware Example Code for EZ-USB RAM Memory and EEPROM
Click on the Build Target button at the top right corner of the IDE. The total code bytes of the Bulk-
src firmware example is less than the 4-k code limit Keil µVision2 IDE provided along with the kit.
The output of the Build Target is the bulksrc.hex and bulksrc.iic files
8.6.3 Method to Download Bulksrc Firmware Image to EZ-USB Internal RAM and
EEPROM
Refer to Method to Download Firmware Image to EZ-USB Internal RAM Memory on page 69 and fol-
low a similar procedure to download bulksrc.hex to the RAM memory and bulksrc.iic to Large
EEPROM using Cyconsole/CyControlCenter. The bulksrc.hex and bulksrc.iic files are located
at <Installed_directory>\<Version>\Firmware\Bulksrc. After downloading, the firm-
ware re-enumerates with the PC using its internal VID/PID-0x04B4/0x1004.
8.6.4 Binding Cypress USB Driver for the Downloaded Firmware Image
The Bulksrc firmware uses vendor class (0xFF) with VID/PID-0x04B4/1004. This example should
bind with the Cypress-generic USB driver, cyusb.sys, and the driver information file,
cyusbfx1_fx2lp.inf, which contains the relevant VID/PID of this example. Follow the procedure out-
lined in Binding Cypress USB Driver to EZ-USB Development Board on page 45 to manually bind
the driver using the Windows Hardware Wizard. If the binding process is performed for any one of
the previous firmware examples, you can skip the process for this example.
■ Select the EP4 and EP8 pairs and repeat the same procedure as mentioned above. Observe that
the data transferred on EP4 is exactly looped back to EP8. Internally, the loopback is performed
through a temporary buffer (myBuffer [512]).
Note For EZ-USB FX1, the above steps can be repeated with a data transfer length of 64 bytes
instead of 512 bytes.
AUTOPTRL2 = 0x00;
// Destination is EP6IN
AUTOPTRH2 = MSB( &EP6FIFOBUF );
AUTOPTRL2 = LSB( &EP6FIFOBUF );
EP6BCH = EP2BCH;
SYNCDELAY;
EP6BCL = EP2BCL; // arm EP6IN
SYNCDELAY;
EP2BCL = 0x80; // re(arm) EP2OUT
}
}
Similarly, endpoint EP4 destination and the EP8 source buffer is commonly defined as the external
RAM memory-0x2A00.
Note For EZ-USB FX1, the above steps can be repeated with a data transfer length of 64 bytes
instead of 512 bytes.
8.7.2 Building Bulkext fIrmware Example Code for EZ-USB RAM Memory and EEPROM
Click on the Build Target button at the top right corner of the IDE. The total code bytes of the
Bulkext firmware example is less than the 4-k code limit Keil µVision2 IDE, provided along with the
kit. The output of the Build Target is the bulkext.hex and bulkext.iic files.
8.7.3 Method to Download Firmware Image to EZ-USB Internal RAM and EEPROM
Refer to Method to Download Firmware Image to EZ-USB Internal RAM Memory on page 69 and fol-
low a similar procedure to download bulkext.hex to the RAM memory and bulkext.iic to Large
EEPROM using Cyconsole/CyControlCenter. The bulkext.hex and bulkext.iic files are located
at <Installed_directory>\<Version>\Firmware\Bulkext. After downloading, the firm-
ware re-enumerates with the PC using its internal VID/PID-0x04B4/0x1004.
8.7.4 Binding Cypress USB Driver for the Downloaded Firmware Image
The Bulkext firmware uses vendor-class (0xFF) with VID/PID-0x04B4/1004. This example should
bind with the Cypress-generic USB driver, cyusb.sys, and driver information file, cyusbfx1_fx2lp.inf
which contains the relevant VID/PID of this example. Follow the procedure outlined in Binding
Cypress USB Driver to EZ-USB Development Board on page 45 to manually bind the driver using
the Windows Hardware Wizard. If the binding process is performed for any one of the previous firm-
ware examples, the process can be skipped for this example.
8.8.2 Building EP_Interrupts Firmware Example Code for EZ-USB RAM and EEPROM
Click on Build Target button at the top right corner of the IDE. The total Code bytes of
EP_Interrupts firmware example is less than 4k code limit Keil uVision2 IDE provided along with the
kit. The output of the Build Target is EP_Interrupts.hex and EP_Interrupts.iic files
8.8.3 Method to Program EP_Interrupts Firmware Image to EZ-USB Internal RAM and
EEPROM
Refer to section Method to Download Firmware Image to EZ-USB Internal RAM Memory on page 69
and Method to Download Firmware Image to External I2C EEPROM on page 69 and follow similar
procedure to download EP_Interrupts.hex to RAM memory and EP_Interrupts.iic to Large
EEPROM using Cyconsole/CyControlCenter.The EP_Interrupts.hex and EP_Interrupts.iic files
are located at <Installed_directory>\<Version>\Firmware\EP_Interrupts. After downloading, the firm-
ware re-enumerates with PC using its internal VID/PID-0x04B4/0x1004.
8.8.4 Binding Cypress USB Driver for the Downloaded Firmware Image
The EP_Interrupts firmware uses vendor class (0xFF) with VID/PID-0x04B4/1004.This example
should bind with Cypress generic USB driver cyusb.sys and driver information file
cyusbfx1_fx2lp.inf, which contains the relevant VID/PID of this example. Follow the procedure out-
lined in section Binding Cypress USB Driver to EZ-USB Development Board on page 45 to manually
bind the driver using Windows Hardware Wizard. If the binding process is performed for anyone of
the previous firmware examples the process can be skipped for this example.
//Clear Flags
EXIF &= 0xBF; // Clear INT4 EXIF.6 Flag
EXIF &= 0x7F; // Clear INT5 EXIF.7 Flag
EICON &= 0xF7; // Clear INT6 EICON.3 Flag
EA = 1; // Enable Global Interrupt
The Interrupt service routines for each of these external interrupts are defined in "isr.c". These rou-
tines clear the interrupt and toggle the relevant port pin and any one of the LEDs from D2 to D5.
void ISR_EXTR4(void) interrupt 10
{
EXIF &= 0xBF; // Clear INT4 EXIF.6 Flag
IOC ^= 0x10; // Toggle pin 4 of PortC
}
The example is compiled using the Keil IDE similar to previous examples and corresponding images
for RAM (extr_intr.hex) and EEPROM (extr_intr.iic) can be generated. Both the images are located
at <Installed_directory>\<version\extr_intr. Download the images using the process
outlined in Method to Download Firmware Image to EZ-USB Internal RAM Memory on page 69 and
Method to Download Firmware Image to External I2C EEPROM on page 69.
The example is compiled using the Keil IDE similar to previous examples and corresponding images
for RAM (vend_ax.hex) and EEPROM (vend_ax.iic) can be generated. Both the images are located
at <Installed_directory>\<version>\vend_ax. Using CyConsole/CyControlCenter
the images can be downloaded as outlined in Method to Download Firmware Image to EZ-USB
Internal RAM Memory on page 69 and Method to Download Firmware Image to External I2C
EEPROM on page 69.
To write the contents to small EEPROM, select Direction = OUT, Req Type = vendor, Target =
Device, Bytes to Transfer = 8 bytes (data to read), and Req Code = 0xA2, and enter data to send
as C0 B4 04 85 00 01 00 00 in the Data to send box. Click on the Transfer Data button and
observe the EEPROM getting programmed. Figure 8-13 summarizes the entire operation.
Figure 8-13. A2 Vendor Command Write Operation using CyControlCenter
To read the contents from RAM memory, select Direction = IN, Req Type = vendor, Target =
Device, Bytes to Transfer = 8 bytes (data to read), and Req Code = 0xA3. Click on the Transfer
Data button and observe that the RAM memory written previously matches with the read data.
Figure 8-15 summarizes the entire operation.
Figure 8-15. A3 Vendor Command Read Operation using CyControlCenter
4. 0xA8 command-EZ-USB
This command is used to disconnect and re-connect the EZ-USB IC using the CPUCS register.
The EZ-USB re-enumerates. Observe the Cypress device disappearing from the CyControlCen-
ter window and re-appearing in the same window. Figure 8-17 summarizes the command trigger
using CyControlCenter.
Figure 8-17. A8 Vendor Command Operation using CyControlCenter
e. mon-int-sio0.hex/ mon-int-sio1.hex: This Keil debug monitor file resides in internal EZ-USB
RAM memory for corresponding SIO-0 and SIO-1 UART ports.
f. mon-int-sio0.spt/mon-int-sio1.spt: This Keil debug monitor script file resides in internal EZ-
USB RAM memory for corresponding SIO-0 and SIO-1 UART ports.
The debug monitor script file mon-ext-sio1-c0.spt is renamed as mon.spt and used as the default
debug monitor script file.
8. Open Keil µVision2 IDE by selecting Start > Programs > Keil µVision2. Open the dev_io project
file at <Installed_directory>\<Version>\Firmware\dev_io, as shown in Figure 8-20
and Figure 8-21.
Figure 8-20. Opening Project File using Keil uVision2 IDE
9. Make sure you use the correct serial port and the baud rate is set correctly. To do this, select
Project > Options for Target 'Target 1' > Debug > Settings.
Note Your PC may have a single serial port. In this case, use the relevant COM port by checking
under Ports (COM and LPT) in the Device Manager (type devmgmt.msc in Windows Start >
Run) as shown in Figure 8-22. Check the box labeled Serial Interrupt.
10.Click on Project > Options for Target 'Target1’ in Keil µVision2 IDE and select the Debug Tab
in the new pop-up window as shown in Figure 8-23 and Figure 8-24.
Figure 8-23. Project Options in Keil uVision2 IDE
11. Select the settings under Keil Monitor-51 Driver and select the relevant COM port for the UART
cable connected to SIO-1 port as shown in Figure 8-25 and Figure 8-26.
Figure 8-25. Settings Button for Keil Debug Monitor
12.Click OK to close Target set up Window and then close the Options for Target "Target 1" win-
dow.
13.Select the Start/Stop Debug Session button on the Keil IDE as shown in the Figure 8-27.
14.The IDE switches to the Debug mode; a yellow arrow indicates the Program Counter location in
the Disassembly window of dev_io project.
Figure 8-28. Disassembly View of dev_io.c file in Keil uVision2 IDE
15.Use the Step Over button to step through the code by selecting View > Debug Toolbar.
Figure 8-29. Enabling Debug Toolbar View in Keil
16.View the output window to verify that you are connected to the monitor and that your program
loaded (it displays a message such as Connected to Monitor-51 V3.0).
17.In the Project Window > Files Tab, click on dev_io.c. Observe the arrow marked in yellow in
Figure 8-30. The yellow arrow in the main indicates that the code execution stopped at that point.
18.Set a breakpoint by selecting the first line in the "case KEY_F2" section (which is in file
dev_io.c). To set or remove a breakpoint, double-click the line or right-click on the line as and
select Insert/Remove Breakpoint shown in Figure 8-31.
Figure 8-31. Setting Breakpoint in Keil uVision2 IDE
19.A red breakpoint indication is seen in the margin next to the new breakpoint as shown in
Figure 8-32. Press the RUN button as shown in Figure 8-33.
Figure 8-32. Breakpoint Indicator in Keil uVision2 IDE
20.Now press F3 on the development board (the KEY_F2 label equates to the F3 button). Program
execution halts in the Keil IDE and the LED does not increment.
21.Press Step Over as shown in Figure 8-34. Then press Run key again on the debugger.
Figure 8-34. Step Over Debug Button in Keil uVision2 IDE
22.Execution proceeds normally until F3 key is pressed on the development board again. When fin-
ished, press the Stop Debugging key and exit the Keil debugger.
9.2.2 CY4651 v1.3 - Cypress and AuthenTec Reference Design for Biometric Security in
External USB Hard Disk Drives
The CY4651 is a third-party reference design from AuthenTec. The design uses the AuthenTec
EntrePad 2510, biometric fingerprint slide sensor, and Cypress's EZ-USB FX2LP microcontroller, the
industry's most popular high-speed USB 2.0 microcontroller, which interfaces with AuthenTec's sen-
sor and delivers data from the HDD to the host computer.
uses the ports mode and bit-bangs the General Purpose IOs to create the SPI interface. The
hardware connection diagram and code listing is included.
■ AN1193 - Using Timer Interrupt in Cypress EZ-USB® FX2LP™ Based Applications
This application note is aimed at helping EZ-USB® FX2LP™ based firmware developers use
timer interrupts in their applications, by providing a framework based timer interrupt program writ-
ten in C. The assumption is made that one has a general understanding of how interrupts work
within the 8051 concept. When this program is run, you should be able to light the seven-seg-
ment LED on the FX2LP Development Board (CY3684) with a 0-9 count, and control the step
rate (1s - 5s) using BULK OUT endpoint transfers from the EZ-USB Control Panel.
■ AN63787 - EZ-USB FX2LP™ GPIF and Slave FIFO Configuration Examples using FX2LP Back-
to-Back Setup
AN63787 discusses how to configure the general programmable interface (GPIF) and slave
FIFO's of EZ-USB FX2LP™ in both manual mode and auto mode, to implement an 8-bit asyn-
chronous parallel interface. This Application Note is tested with two FX2LP development kits con-
nected in back-to-back setup; the first one acting in master mode and the second in slave mode.
■ AN61244 - Firmware Optimization in EZ-USB®
The EZ-USB® family of chips has an 8051 core and uses the standard 8051 instruction set. How-
ever, it has a few enhancements compared to the standard 8051. This application note describes
firmware optimization methods in EZ-USB. Some of these methods are common for any proces-
sor and some specific to the 8051 core of EZ-USB.
■ AN70983 - EZ-USB FX2LP™ Bulk Transfer Application in C# Using SuiteUSB C# Library
(CyUSB.dll)
AN70983 demonstrates how to build an application on Visual C# to send bulk data out and
receive it back over a bulk endpoint of FX2LP, which is developed using Cypress SuiteUSB C#
library (CyUSB.dll) for creating Windows applications using Microsoft Visual Studio. This docu-
ment also explains associated firmware used in FX2LP to implement loopback transfers on bulk
endpoints, and the application is tested with FX2LP Development kit.
■ AN70486 - EZ-USB® FX2LP™ Host Application in VC++ 2008 Using Suite USB Library
(CYUSB.dll)
This application note demonstrates how to build a host application on Microsoft Visual C++ plat-
form, using the Cypress SuiteUSB C# library, CyUSB.dll, to perform USB BULK IN and OUT
transfers with FX2LP and the associated project is tested with FX2LP Development kit.
■ AN74505 - EZ-USB® FX2LP™ - Developing USB Application on MAC OS X using LIBUSB
AN74505 describes a host application built on the MAC OS platform that uses libusb. The host
application (Cocoa Application) communicates with the BULK IN and BULK OUT endpoints of
FX2LP, using the interfaces provided by the APIs of libusb. This host application implements the
transfer only with devices that pass the particular VID/PID(=0x04B4/0x1004) identification.
■ AN6077 - Implementing an 8-Bit Asynchronous Interface with FX2LP™
AN6077 discusses how to configure the general programmable interface (GPIF) and slave FIFOs
of the EZ-USB FX2LP™ to implement an 8-bit asynchronous interface. The GPIF is a program-
mable 8- or 16-bit parallel interface that reduces system costs by providing a glueless interface
between the EZ-USB FX2LP and different types of external peripherals. The GPIF allows the EZ-
USB FX2LP to perform local bus mastering to external peripherals implementing a wide variety of
protocols. For example, EIDE/ATAPI, printer parallel port (IEEE P1284), Utopia, and other inter-
faces are supported using the GPIF block of the EZ-USB FX2LP. In this example, it masters the
slave FIFO interface of another EZ-USB FX2LP.
3.3VC 3.3V
3.3V 5V 5V
TP1 TP2 TP3 TP4 TP5 TP6 3.3V
GND GND GND GND GND GND C12 P1
C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 1 2 C11
+5V CLK2
0805
0805 0805 0805 0805 0805 0805 0805 0805 0805 0805
PSEN# 3 4 PD7 0805
0.1 uFd 0.1 uFd 0.1 uFd 0.1 uFd 0.1 uFd 0.1 uFd 0.1 uFd 0.1 uFd 0.1 uFd 0.1 uFd U3 0.1 uFd PD6 CLK1 D15 PD5 0.1 uFd
5 6
8
24
5V PD4 D14 D13 PD3
7 D12 D11 8
TP7 TP8 PD2 9 10 PD1
3.3V VBUS PD0 D10 D9 PB7
11 12
VDD
VDD
A0 D0 PB6 D8 D7 PB5
PLACE ONE CAP PER EACH VCC PIN ON U1 1 A0 D0 6 13 D6 D5 14
Y1 A1 2 7 D1 PB4 15 16 PB3
R7 A2 A1 D1 D2 PB2 D4 D3 PB1
0805
3 A2 D2 10 17 D2 D1 18
3.3V 3.3V 3.3V 3.3VC A3 4 11 D3 PB0 19 20
C13 24 MHz C14 A4 A3 D3 D4 D0 GND
13 A4 D4 22
1M JP1 JP10 A5 14 23 D5 LOGIC ANALYZER HDR
1
0805 0805 A5 D5
12 pFd 12 pFd A6 15 26 D6
C21 1 1 A6 D6
0805
D9 R1 A7 16 27 D7
D 2 2 A7 D7 D
3.3V A8 17 3.3V
A8
7163
SOT23
1N4148 100K AVCC 3.3V A9 18
4700 pFd 250v R2 A10 A9 RAMCE#
19 A10 CE 5
2
5V A11 20 P2
Schematic
0805
zero R29 A12 A11 WR# C15
21 A12 WE 12 1 +5V CLK2 2
R3 D1 A13 29 3 4 RDY1
26
81
2
43
48
64
68
100
107
14
15
16
12
11
0805 3216 A13 0805
CLK1 D15
0805
+ C16 10K A14 30 28 RAMOE# RDY0 5 6 CTL5 0.1 uFd
JP2 1206 A14 OE D14 D13
A15 31 CTL4 7 8 CTL3
560 BUS PWR 1 uFd 16v RAMA16 A15 CTL2 D12 D11 CTL1
32 9 10
NC1
NC2
NC3
1 3216 A16 D10 D9
RED
VCC1
VCC2
VCC3
VCC4
VCC5
VCC6
VCC7
VCC8
VCC9
C17 + C18 3.3V CTL0 11 12 PA7
2 D8 D7
XTALIN
0805
PA6 13 14 PA5
Vss
Vss
D6 D5
XTALOUT
BUS PWR 2.2 uFd 10v 0.1 uFd PA4 15 16 PA3
PA2 D4 D3 PA1
10 AVCC1 17 D2 D1 18
9
25
VBUS 17 JP8 R42 CY7C1019BV33-12VC PA0 19 20
AVCC2 PA0 WU2 128K x 8 SRAM D0 GND
PA0/INT0# 82
0805
J1 RESET# 99 83 PA1 100K LOGIC ANALYZER HDR
1
2
RESET# PA1/INT1# PA2
VBUS 1 PA2/SLOE 84
2 DM 19 85 PA3
DM DP DMINUS PA3/WU2 PA4 3.3V
DP 3 18 DPLUS PA4/FIFOADR0 89
4 90 PA5 3.3V
GND PA5/FIFOADR1 3216
5 A0 94 91 PA6 + C43
S1 A1 A0 CY7C68013A-128AXC PA6/PKTEND PA7 P3
S2 6 95 A1 PA7/FLAGD 92 0805
A2 2.2 uFd 10v R4 390 D2 1206 LED Red C19
96 A2 (CY3684 FX2LP DVK) 1 +5V CLK2 2
USB B RA A3 97 44 PB0 WR# 3 4 RDY5 0805
A4 A3 PB0/FD0 PB1 JP3 RDY4 CLK1 D15 RDY3 0.1 uFd
117 A4
or PB1/FD1 45 0805
5 D14 D13 6
A5 PB2 PF0 R5 390 D3 1206 LED Red RDY2 BKPT
118 A5 PB2/FD2 46 1 2 7 D12 D11 8
5V A6 119
CY7C64713-128AXC 47 PB3 PF1 RESET# 9 10
A7 A6 PB3/FD3 PB4 PF2 3 4 D10 D9 PC7
120 A7 (CY3674 FX1 DVK) PB4/FD4 54 5 6 0805
11 D8 D7 12
A8 126 55 PB5 5V PF3 R6 390 D4 1206 LED Red PC6 13 14 PC5
R78 A9 A8 PB5/FD5 PB6 7 8 PC4 D6 D5 PC3
127 A9 PB6/FD6 56 15 D4 D3 16
A10 128 57 PB7 LED SELECT 0805
PC2 17 18 PC1
A10 PB7/FD7 D2 D1
0805
10K A11 R8 390 D5 1206 LED Red PC0
21 A11 19 D0 GND 20
S1 A12 22 72 PC0 R80
A13 A12 PC0/GPIFADR0 PC1 LOGIC ANALYZER HDR
1B 1A 23 A13 PC1/GPIFADR1 73
0805
2B 2A A14 24 74 PC2 100K
A15 A14 U1 PC2/GPIFADR2 PC3
FRAME 3 25 A15 PC3/GPIFADR3 75
5V PC4 JP11 5V 3.3V
PC4/GPIFADR4 76
C D0 59 77 PC5 PA7 C
RESET# 3.3V D1 D0 PC5/GPIFADR5 PC6 WP 1
60 D1 PC6/GPIFADR6 78 2
JP5 D2 61 79 PC7 RD# P4
U4 3.3V IN D3 D2 PC7/GPIFADR7 3 3.3V C22
3216
62 D3 1 +5V CLK2 2
C25 + LT1763CS8-3.3 D4 63 102 PD0 C20 CLKOUT 3 4 0805
1
2
D5 D4 CY7C68013A-128AXC PD0/FD8 PD1 R79 EEPROM WP JUMPER 3.3V R46 OE# CLK1 D15 CS# 0.1 uFd
86 103 5 6
0805
10 uFd 16v D6 D5 PD1/FD9 PD2 5V D14 D13
0805
8 1 87 104 7 8 5V
IN OUTPUT D6 PD2/FD10 D12 D11
0805
D7 88 105 PD3 10K zero 0.1 uFd 9 10
D7 PD3/FD11 3.3V D10 D9
0805
2 121 PD4 R47 U2 11 12 D7
28
0805
0805
R30 + C23 R12 R9 RXD0 51 122 PD5 D6 13 14 D5
0805
RXD0 PD5/FD13 D6 D5
0805
5 4 RXD1 53 123 PD6 10K 1 22 D4 15 16 D3
nSHDN BYP zero 10 uFd 16v 100K 390 TXD0 RXD1 PD6/FD14 PD7 NC1 NC4 D2 D4 D3 D1
Vcc
0805
0805
0.01 uFd 108 PE0 JP6 R10 R11 CS# 3 27
GND
GND
GND
T0 PE0/T0OUT PE1 MM0 A11 I1 F9 TV1 SPARE3 LOGIC ANALYZER HDR
29 T0 PE1/T1OUT 109 4 I2 F8 26
T1 30 110 PE2 10K 10K PSEN# 5 25 RAMOE#
2
1
T1 PE2/T2OUT I3 F7
3
6
7
0805
R31 D6 T2 31 111 PE3 TV9 SPARE4 6 24 TV2 SPARE2 3.3V
T2 PE3/RXD0OUT PE4 I4 F6 TV3
112 7 23
1206
NO LOAD PWR 3.3V RD# PE4/RXD1OUT PE5 I5 F5 EA SPARE1
40 RD# PE5/INT6 113 9 I6 F4 21
WR# 41 114 PE6 OE# 10 20 PF3 TV4 3.3V
RED WR# PE6/T2EX PE7 A12 I7 F3 PF2 PF3 R13
PE7/GPIFADR8 115 11 I8 F2 19
A13 PF1
2
1
12 18 TV5
I9 F1
0805
CS# INT5# RDY1/SLWR RDY2 MM1 I11 PF1 IFCLK +5V CLK2 A15
42 CS# RDY2 6 3 CLK1 D15 4 0805
BKPT/MONITOR BKPT34 7 RDY3 TV7 A14 5 6 A13 0.1 uFd
BKPT RDY3 D14 D13
14
GREEN PSEN#
39 8 RDY4 GAL22LV10C-7LJ PF0 A12 7 8 A11
OE# PSEN# RDY4 RDY5 A10 D12 D11 A9
0805
38 OE# RDY5 9 9 D10 D9 10
R15 10K EA 35 A8 11 12 A7
0805 EA 0805 D8 D7
IFCLK R43 22 32 69 R16 22 CTL0 A6 13 14 A5
0805 IFCLK CTL0/FLAGA 0805 D6 D5
3.3V CLKOUT R17 22 1 70 R18 22 CTL1 A4 15 16 A3
CLKOUT CTL1/FLAGB 0805 D4 D3
3.3V WAKEUP# 101 71 R19 22 CTL2 3.3V A2 17 18 A1
WAKEUP# CTL2/FLAGC 0805 D2 D1
66 R20 22 CTL3 A0 19 20
0805 CTL3 0805 D0 GND
TV8 R21 2.2K SCL 36 67 R22 22 CTL4 3.3V
0805 SCL CTL4 0805
0805
R28 WAKEUP# R23 2.2K SDA 37 98 R24 22 CTL5 C27 LOGIC ANALYZER HDR
SDA CTL5
100K
0805
AGND1
AGND2
GND1
GND2
GND3
GND4
GND5
GND6
GND7
GND8
GND9
RESERVED
1 8 22K P6
3216
3 FRAME A0 Vcc
+ C32 2 7 WP 3.3V 1 2 C29
A1 WP +5V CLK2
13
20
27
93
3
49
58
65
80
116
125
33
3 6 SCL RD# 3 4 INT5# 0805
WAKEUP# 10 uFd 16v A2 SCL INT4 CLK1 D15 T2 0.1 uFd
4 Vss SDA 5 5 D14 D13 6
T1 7 8 T0
24LC128-I/P WAKEUP# 9 D12 D11 SDA
D10 D9 10
8-PIN DIP SOCKET
0805
R27 SW1 SW2 SCL 11 12 PE7
EEPROM SELECT EEPROM ENABLE PE6 D8 D7 PE5
13 D6 D5 14
10K SP1 SP2 PE4 15 16 PE3
D4 D3
All other components and layout are similar to the CY3684 kit board.
R32 LARGE EEPROM SOLDER PAD SOLDER PAD PE2 17 18 PE1
D2 D1
0805
3.3V
0.1 uFd
0805
10
A0 Vcc
0805
2 7 WP 22K
A1 WP 0805
0805
2 3.3V C38 PB3 11 12 PD4
U7 0.1 uFd C37
f1 3.3V PB2 DD3 DD12 PD5 C36
6 13 DD2 DD13 14
0805
16
0805
DD1 DD14
0805
1B 1A 0.1 uFd 3.3V PB0 17 18 PD7 0.1 uFd
DD0 DD15
0805
11
PCF8574T U8 0.1 uFd RDY1 21 22
16
VCC
FRAME 3 DMARQ GND
C39 C40 JP9 PCF8574T CTL0 23 24
16
SO16
i2c compatible CTL1 DIOW# GND
0805 0805 f2 SO16
25 DIOR# GND 26
0.1 uFd 0.1 uFd SCL 14 4 0805
RDY0 27 28
VCC
P10 SDA SCL P0 S4 4 SCL R34 390 a U9 CTL2 IORDY CSEL
15 5 14 4 0805
29 30
VCC
13 7 2B 2A 6 2 13 33 34 R69
10
0805
TXD0 INT P3 1 3.3V P2 R37 390 d f a b PA1 DA1 PDIAG# PA3
14 TR1OUT TR1IN 11 P4 9 FRAME 3 13 INT P3 7 0805
3 an1 35 DA0 DA2 36
5 13 12 RXD0 1 10 9 R38 390 e f b 11 g D8 PA4 37 38 PA5 1K
0805 0805
RX1IN RX1OUT A0 P5 P4 R39 390 f g g c R74 390 CS0# CS1#
9 2 A1 P6 11 f3 1 A0 P5 10 0805 c 10 1206
39 DASP# GND 40
4 3 12 2 11 R40 390 g 6 e c 9 dec
A2 P7 0805
TXD1 S5 A1 P6 R41 390 dec e nc d dec d DRIVE RDY ATA CONNECTOR
8 7 10 3 12 7 8
GND
TR2OUT TR2IN RXD1 A2 P7 e d R77
3 8 9 1B 1A
GND
RX2IN RX2OUT
7 2B 2A PCB: PDC-9086 PCA: 121-08600
8
0805
2 HDSP-E101 4.7K
FRAME 3
8
6 2 6
GND
V+ V- CYPRESS SEMICONDUCTOR © 2003
1 f4
C41 C42 Title
15
0805 0805
CY3684 USB 2.0 DEVELOPMENT BOARD
11
0.1 uFd 0.1 uFd SP3
SOLDER PAD Size Document Number Rev
C REF-11637 *B