Acquire Devices Electronics Prototyping Company

USB Frequently Asked Questions

We are currently trying to add answers and support to all the questions our customers have. Please send in any questions you may have.

How can I perform USB Data Acquisition with A/D converter and USB?

The EZ-USB FX2 is ideal for data acquisition in slave mode. Any well known analog to digital (A/D) converter can be interfaced with our Pike EZ-USB FX2 Development Board. The EZ-USB has been interfaced with A/D converters from National Semiconductor and Analog Devices. The EZ-USB has also interfaced with microcontrollers, DSC's and DSP's from Microchip, Atmel, and Cypress. For the transfer rates of high speed USB the host can request data much faster than the A/D converter can deliver which ensures the endpoints never reach full capacity when doing digital data transfers.

Can you give me some example 8051 code to renumerate the EZ-USB FX2?

Here is some example 8051 Code that utilizes Timer 0 on the 8051 for renumeration. To renumerate set DISCON=1 and use TIMER0 to give the host time to detect the device has renumerated, then set DISCON=0, and RENUM=1.

RENUMERATE:
MOV DPTR,USBCS
MOV A,#00001010B
MOVX @DPTR,A ; Set DISCON=1 and RENUM=1
MOV CKCON,#00001000B ; Enable T0
MOV TMOD,#00000001B ; Set T0 mode to a 16-bit counters
MOV TL0,#00H ; Set the counter to zero
MOV TH0,#00H ; 0xFFFF/4Mhz/12 ~ 16 msec
CLR TCON.5 ; Clear Timer 0 overflow flag
SETB TCON.4 ; Start Timer 0
RENUM_DELAY:
JNB TCON.5,RENUM_DELAY ; Jump on no overflow
MOV DPTR,USBCS
MOV A,#00000110B
MOVX @DPTR,A ; ReNumerate by setting RENUM=1,DISCON=0, Also b2 = NOSYNSOF

How do I send and receive bytes to a USB Device

USB Devices have endpoints which are memory buffers where bytes are physically sent. Endpoints can have two different directions: IN and OUT, where the direction is in relation to the host. Thus, an IN Endpoint means bytes will be coming into the host. Each endpoint can have one of three different transfer types. These three transfer types are Bulk, Interrupt, and Isochronous. For high speed endpoint transfers the EZ-USB FX2 will first execute code to set up these endpoints, then transfers will be handled automatically. Any host USB API will have a general function to send a given number of bytes to an endpoint. This is where the ease of use of USB comes into play. When the firmware is set-up properly bytes are sent with having no software overhead to handle. A perfect example of this is the usb_bulk_write() function from libUSB where bytes are written directly to the device with no callbacks or associated overhead code. The depending on the number of bytes transferred physical pins on the EZ-USB FX2 device will give the endpoints status, (empty, full, or programmable full). The EZ-USB FX2 8051 will configure the endpoints in firmware, then all high speed transfers will be handled automatically in logic. Please see the libUSB API functions for a good description of what can be done on a USB device. For more information see the USB Specification at the USB Implementors Forum. The specification is well written and easy to understand. Another good description is Beyond Logic's USB in a Nutshell which gives a good all around in-depth understanding of USB. For a full understanding of USB please read Jan Axelson's USB Complete book which explains everything you need to know to develop custom USB peripherals.

I want to write my own firmware for the FX2 what should I know?

Writing firmware from scratch for the EZ-USB FX2 can be quite involved because the Standard USB Device Requests MUST be implemented. The Standard USB Device Requests are sent through a USB control message, and use the Control Endpoint 0 on the EZ-USB FX2. When an IN or OUT USB Control message is sent from a USB host the EZ-USB host will interrupt and will receive the 8 control bytes (bmRequestType, bRequest, wValueL, wValueH, wIndexL, wIndexH, wLengthL, wLengthH) through a memory buffer called SETUPDAT in the EZ-USB FX2. Using these 8 bytes from SETUPDAT the EZ-USB FX2 will have to handle the following requests: Get Status, Set Feature, Clear Feature, Get Descriptor, Set Descriptor, Get Configuration, Set Interface, and Get Interface. See the EZ-USB TRM (Technical Reference Manual) Chapter 2 for more in depth information on handling these standard Requests.

In addition to the firmware needing to handle the Standard USB Device Requests the firmware must also handle ReNumeration a trademark of Cypress Semiconductor, the Vendor Requests, and any initialization of the Endpoint buffers.

Do you have 8051 Assembler Firmware for the EZ-USB FX2?

Because the 8051 microcontroller internal to EZ-USB FX2 has to handle so much functionality most developers avoid writing the firmware in 8051 assembler and stick to SDCC (Small Device C Compiler) or the CY3684 EZ-USB FX2 Development Kit from Cypress semiconductor. However, Acquire Devices currently has working firmware in 8051 assembler and is willing to share any aspects of this firmware with you. We currently do not know of any other available good EZ-USB FX2 firmware written in 8051 besides what we have written. Once the simple 8051 architecture and instruction set is learned writing 8051 assembler code for the 8051 microcontroller is quite easy, and as always the assembly language gives a interaction with the architecture of the 8051 at nearly the lowest level. We are currently working on making either all or parts of the 8051 firmware available to the USB Development community. This firmware is written in the powerful macro assembler for the 8051 microcontroller ASEM-51 from W.W. Heinz.