Firmware Development of USB2.0 Interface Chip CY7C68013

Publisher:灵感发电站Latest update time:2012-04-23 Keywords:USB2.0 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Abstract: USB2.0 interface technology provides a flexible and efficient bidirectional data channel between peripherals and hosts. It can be widely used in data acquisition, industrial control and consumer digital. This paper briefly introduces the structure of the interface chip CY7C68013 that supports the USB2.0 protocol. The structure of the firmware program framework of the CY7C68013 chip is analyzed. The method of how to use C language to develop firmware programs under this firmware program framework is given. Keywords : USB2.0, interface, firmware program Introduction:


Modern industrial production and scientific research have increasing requirements for data acquisition. In some high-speed and high-precision measurements such as transient signal measurement and image processing, high-speed data acquisition is required. The USB2.0 interface has gradually replaced the traditional ISA and PCI data buses with its advantages such as high speed and flexibility. At the same time, as a flexible and low-cost interface technology, the USB interface has become the preferred interface for various PC peripherals with its hot-swappable characteristics. Therefore, the development of USB2.0 has become a hot topic at present.
The following will take the Cypress CY7C68013 chip as an example to discuss the development of firmware programs that support the USB2.0 protocol.


1. Introduction to the interface chip CY7C68013:
The CY7C68013 chip is a powerful interface chip in the EZ-USB FX2 series of Cypress that meets both the USB2.0 protocol and is compatible with the USB1.1 protocol. Its structure is shown in the figure below [2]:

Figure 1 CY7C68013 interface chip structure


The chip has the following features [2]:
1) Integrated with an enhanced 8051 core
Compared with the ordinary 8051 microprocessor, this enhanced processor has the following improvements:
l Only 4 clock cycles are needed to complete each instruction cycle;
l The clock frequency can be soft-configured to 12/24/48MHz;
2) Integrated with a serial interface engine (SIE) and a USB2.0 transceiver
Since the USB2.0 transceiver and the serial interface engine complete the USB protocol's packetization and unpacking functions, the electrical characteristics of the underlying signal are shielded.
3) Supports soft configuration:
Using the re-enumeration technology, the firmware program can be saved on the host, and the firmware is downloaded to the chip RAM through the USB interface after each power-on. It has great flexibility.
4) General Programmable Interface (GPIF):
GPIF provides programmable interface timing, so that it can connect to peripheral chips such as DSP, ASIC, etc. without additional logic (glue logic), and also supports bus standards such as ATAPI and EPP.
5) Four programmable ports (Endpoint):
CY7C68013 has a total of 7 input and output ports: EP0, EP1OUT, EP1IN, EP2, EP4, EP6, EP8. EP2, EP4, EP6, EP8 can be configured as batch/interrupt/synchronous transmission mode, and the transmission direction can be configured as out/in.
6) Programmable buffer (Buffer) depth:
The buffer size of ports EP2 and EP6 can be programmed to 512 or 1024 bytes, and the depth can be programmed to 2/3/4 times the size; the buffer size of ports EP4 and EP8 is fixed to 512 bytes, and the depth is 2 times. Use different configuration methods to achieve data transmission with specific bandwidth and rate requirements.


2. Development Tools:


The Cypress website (http://www.cypress.com) provides a download of the CY7C68013 chip development kit. The development kit provides some resources required for developing firmware programs: Keil uVision2 integrated development environment (limited version); Cypress C51 firmware framework program and some example programs.
Keil uVision2 is a powerful integrated development environment that integrates a series of tools such as the C51 compiler, A51 assembler, and BL link locator, as well as simulation and debuggers. Therefore, it can support projects that mix C programs and assembly programs, bringing great convenience to software development [5].
Keil C51 is a high-efficiency C language compiler designed specifically for 8051 microcontrollers. It complies with ANSI standards. The generated program code runs at an extremely high speed and requires very little storage space, which is completely comparable to assembly language. At the same time, C51 has a rich library of functions, with more than 100 functional functions. Therefore, using C as the development language and Keil uVision2 as the engineering development platform to complete source code writing, simulation, and debugging will significantly reduce the difficulty of firmware development and improve development efficiency [4].


3. Firmware structure and composition:


Although the functions of the firmware program are complex and require a large number of functions when writing, its basic structure is relatively simple and includes the following parts:
3.1 Device Descriptor Table:
Before each USB device establishes data communication with the host, it must first inform the host of its specific configuration, including the manufacturer of the device, product identification number (VID, PID), power supply mode of the device, energy consumption and other important information. And this information about the device is notified to the host through the device descriptor table, so that the host can establish a connection with the device in an appropriate manner. Its structure is as follows:
DeviceDscr:
db 18;; The length of the descriptor (in bytes)
db DSCR_DEVICE;; Descriptor type
...
db 1;; There are several configurations (1 type)
3.2 Firmware program framework source code:
This file provides a firmware program framework structure, which is suitable for general data transmission control. This structure provides a program interface open to developers, and developers implement the required functions by adding appropriate code to these interface functions.
Its workflow is shown in Figure 2. Figure 2 Firmware program framework workflow


3.3 Interface functions:
The firmware framework provides a function interface. By adding self-developed code to these interface functions, specific functions can be implemented and the difficulty of firmware development can be greatly reduced, thus accelerating the USB system development process. These interface functions are divided into three categories: task allocation, standard device request execution, and USB bus interrupt processing [3]. The following will introduce these interface functions and their uses in turn.
3.3.1 Task allocation
TD_Init()
Description: This function is mainly used to complete the initialization of FX2. It is called before FX2 enumerates again and starts task allocation. Its purpose is to initialize each port and the first-in first-out buffer of each port.
TD_Poll()
Description: This function is called repeatedly when the device is running. It should include code to complete a special task. Before this function returns, the high-priority task may have been completed. However, if it returns a false value, FX2 will not affect the device request and USB bus device suspend event. If a large amount of processing time is required, FX2 will divide the time by calling the TD_Poll() function multiple times.
TD_Suspend()
Description: This function is called before the device enters the suspended state. Developers add appropriate code to configure the working state of the device, which can put the device in a low-power state and return a true value. However, developers can modify the program code of TD_Suspend() to return false, so that FX2 does not enter the suspended state.
TD_Resume()
Description: When an external request to restart is made (for example, a Wakeup interrupt is generated by the outside world or there is a transmission activity on the USB bus), the device will restart the processor by calling this function, which is the reverse operation of the TD_Suspend() function. At this time, the device restarts under normal power supply.
3.3.2 Device Request
The device request function has the following form:
BOOL DR_xxx(void)
{
…… file://device request processing code
return(TURE);
}
It mainly completes the processing of commands and requests from the host, such as configuring ports, etc.
3.3.3 USB Interrupts
The interrupts of FX2 devices include the same interrupts as standard 8051 interrupts, and also include some FX2-specific interrupts. Since the interrupt service routine interface is provided in the firmware program, developers only need to add their own interrupt service code to the interrupt service routine interface to complete the service of the corresponding interrupt request, thus avoiding in-depth research on the logical structure of FX2's interrupt autovectors [2]. The form of these interrupt service routine interface functions is:
void ISR_xxx(void) interrupt 0
{
…… file://Developer interrupt service code
EZUSB_IRQ_CLEAR();
USBIRQ = bmXXX; // Clear the interrupt request
}


4. Summary:


After understanding the Cypress firmware program framework structure, using the Keil uVision2 development environment to develop under the Cypress firmware framework can greatly reduce the difficulty of firmware program development and shorten the development cycle to achieve higher efficiency.

Keywords:USB2.0 Reference address:Firmware Development of USB2.0 Interface Chip CY7C68013

Previous article:The principle of USB dual-machine communication
Next article:Interface circuit diagram of X9628 and PIC16C72

Recommended ReadingLatest update time:2024-11-16 18:08

Video acquisition based on SoC imaging chip MT9M111 and CY7C68013
CMOS image acquisition systems generally have image quality problems. If the image is not processed specifically, the image quality is difficult to guarantee. In recent years, with the rapid development of SoC technology, SoC image sensors have emerged in the field of image acquisition and processing. They integrate CM
[Analog Electronics]
Video acquisition based on SoC imaging chip MT9M111 and CY7C68013
Latest Analog Electronics Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号