User guide
CY3687 MoBL-USB FX2LP18 Development Kit User Guide, Doc. # 001-68582 Rev. *B 71
MoBL-USB Development Kit Firmware Examples
8.4.5 Testing the pingnak Firmware Functionality
Following are the steps to test the pingnak firmware:
1. After the board has re-enumerated, use CyConsole to send 512 bytes from EP2 to EP6.The data
received should be same as the data sent. 512 bytes of user-defined data can be sent from the
host to Endpoint 2 using CyConsole. For example, select Endpoint 2 OUT in the pipe window
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.
8.5 Bulkloop Example
8.5.1 Description
This project illustrates the configuration of MoBL-USB FX2LP18 to accept bulk data from the host
and loop it back to the host. Click on bulkloop.Uv2 at <Installed_directory>\<Version>\Firm-
ware\Bulkloop and observe the source code. Four endpoints are configured in TD_init() function of
bulkloop.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
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.
SYNCDELAY;
EP2BCL = 0x80;// arm EP2OUT by writing byte count