User guide

68 CY3687 MoBL-USB FX2LP18 Development Kit User Guide, Doc. # 001-68582 Rev. *B
MoBL-USB Development Kit Firmware Examples
using endpoint 4 and 8 can also be tested. Since EP2 and EP4 are double-buffered, they can
only contain two packets of data.
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.
8.4 Pingnak Firmware Example
8.4.1 Description
This project illustrates the configuration of MoBL-USB FX2LP18 device to accept bulk data from the
host and loop it back to the host and the use of PING-NAK interrupt. Click on pingnak.Uv2 located
at <Installed_directory>\<Version>\Firmware\pingnak and observe the code. Four endpoints are
configured in TD_init() function of pingnak.c to handle bulk transfer: two OUT endpoints 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 MoBL-USB Technical Reference Man-
ual 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