EasyManua.ls Logo

Cypress CY3684 - Pingnak Firmware Example; Description

Cypress CY3684
117 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
74 EZ-USB Development Kit User Guide, Doc. # 001-66390 Rev. *D
EZ-USB Development Kit Firmware Examples
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.
8.4 Pingnak Firmware Example
8.4.1 Description
This project illustrates the configuration of the EZ-USB device to accept bulk data from the host and
loop it back to the host and the use of the PING-NAK interrupt. Click on pingnak.Uv2 located at
<Installed_directory>\<Version>\Firmware\pingnak and observe the code. Four end-
points are configured in the TD_init() function of pingnak.c to handle bulk transfer: two OUT end-
points and two IN endpoints. The four endpoints defined in the descriptor file have to be configured
in this function. This is done by the following statements:
EP2CFG = 0xA2;
SYNCDELAY;
EP4CFG = 0xA0;
SYNCDELAY;
EP6CFG = 0xE2;
SYNCDELAY;
EP8CFG = 0xE0
The key characteristics of each endpoint are as follows:
Endpoint 2 - OUT, Bulk, double-buffered
Endpoint 4 - OUT, Bulk, double-buffered
Endpoint 6 - IN, Bulk, double-buffered
Endpoint 8 - IN, Bulk, double-buffered
Writing to these registers typically takes more than two clock cycles needed for a MOVX instruction.
Therefore, the SYNCDELAY, already defined, is added. The EZ-USB Technical Reference Manual at
<Installed_directory>\<Version>\Documentation provides the list of registers that need
this delay function when writing to them. The OUT endpoints, after they are configured, need to be
armed to accept packets from the host. Because the endpoints are double-buffered, you must arm
the endpoint twice. Arming is essentially freeing up the buffers and making them available to the host
to receive packets. By writing a 1 to bit7 of the byte count register, the endpoint is armed.
EP2BCL = 0x80; // arm EP2OUT by writing byte count w/skip.
SYNCDELAY;
EP2BCL = 0x80;
SYNCDELAY;
EP4BCL = 0x80; // arm EP4OUT by writing byte count
//w/skip.
SYNCDELAY;
EP4BCL = 0x80;
After configuration, the OUT endpoints are 'armed' to accept data from the host. An OUT endpoint is
said to be armed if it is ready to accept data from the host. Each endpoint is configured as double-
buffered. The OUT endpoints are armed by setting the skip bit in the byte count registers. This
leaves them empty to receive a new packet from the host. It also clears any pending PING-NAK

Table of Contents

Related product manuals