boot_fw\gpiftousb BULK IN transfer failed with Error Code:997 when changing GPIF state machine

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Ahmedms
Level 3
Level 3
First like given 25 sign-ins 5 questions asked

Hi, 

  • In my application, some values should be written to GPIF, then the GPIF switches to read and transfer what was read to USB.
  • I used this example (C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\boot_fw\gpiftousb) to build my application, and changed the cyfxgpif2config.h to the one generated from GPIF II Designer (shown below)
  • Once this file is switched, the USB streaming fails with error 997
  • is there a reason for that?

 

/*
 * Project Name: AD7381-4 Interface to USB3.cyfx
 * Time : 11/19/2022 18:51:09
 * Device Type: FX3
 * Project Type: GPIF2
 *
 *
 *
 *
 * This is a generated file and should not be modified
 * This file need to be included only once in the firmware
 * This file is generated by Gpif2 designer tool version - 1.0.1198.2
 * 
 */

#ifndef _INCLUDED__
#define _INCLUDED__
#include "cyu3types.h"
//#include "cyu3gpif.h"

/* Summary
   Number of states in the state machine
 */
#define CY_NUMBER_OF_STATES 4

/* Summary
   Mapping of user defined state names to state indices
 */
#define START 0
#define CONFIG_ADC 1
#define ACTIVE_READ 2
#define IDLE 3


/* Summary
   Initial value of early outputs from the state machine.
 */
#define ALPHA_START 0x13


/* Summary
   Transition function values used in the state machine.
 */
uint16_t CyFxGpifTransition[]  = {
    0x0000, 0xFFFF
};

/* Summary
   Table containing the transition information for various states. 
   This table has to be stored in the WAVEFORM Registers.
   This array consists of non-replicated waveform descriptors and acts as a 
   waveform table. 
 */
CyU3PGpifWaveData CyFxGpifWavedata[]  = {
    {{0x1E739C01,0x04000000,0x86000800},{0x00000000,0x00000000,0x00000000}},
    {{0x1E739C03,0x00000500,0x80400000},{0x00000000,0x00000000,0x00000000}},
    {{0x1E739C02,0x20000000,0xC7800800},{0x00000000,0x00000000,0x00000000}}
};

/* Summary
   Table that maps state indices to the descriptor table indices.
 */
uint8_t CyFxGpifWavedataPosition[]  = {
    0,1,1,2
};

/* Summary
   GPIF II configuration register values.
 */
uint32_t CyFxGpifRegValue[]  = {
    0x800083B0,  /*  CY_U3P_PIB_GPIF_CONFIG */
    0x00000003,  /*  CY_U3P_PIB_GPIF_BUS_CONFIG */
    0x00000000,  /*  CY_U3P_PIB_GPIF_BUS_CONFIG2 */
    0x00000052,  /*  CY_U3P_PIB_GPIF_AD_CONFIG */
    0x00000000,  /*  CY_U3P_PIB_GPIF_STATUS */
    0x00000000,  /*  CY_U3P_PIB_GPIF_INTR */
    0x00000000,  /*  CY_U3P_PIB_GPIF_INTR_MASK */
    0x00000082,  /*  CY_U3P_PIB_GPIF_SERIAL_IN_CONFIG */
    0x00000782,  /*  CY_U3P_PIB_GPIF_SERIAL_OUT_CONFIG */
    0x00000001,  /*  CY_U3P_PIB_GPIF_CTRL_BUS_DIRECTION */
    0x0000FFFF,  /*  CY_U3P_PIB_GPIF_CTRL_BUS_DEFAULT */
    0x00000001,  /*  CY_U3P_PIB_GPIF_CTRL_BUS_POLARITY */
    0x00000000,  /*  CY_U3P_PIB_GPIF_CTRL_BUS_TOGGLE */
    0x00000000,  /*  CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
    0x00000000,  /*  CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
    0x00000000,  /*  CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
    0x00000000,  /*  CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
    0x00000000,  /*  CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
    0x00000000,  /*  CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
    0x00000000,  /*  CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
    0x00000000,  /*  CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
    0x00000000,  /*  CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
    0x00000000,  /*  CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
    0x00000000,  /*  CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
    0x00000000,  /*  CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
    0x00000000,  /*  CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
    0x00000000,  /*  CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
    0x00000000,  /*  CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
    0x00000000,  /*  CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */
    0x00000006,  /*  CY_U3P_PIB_GPIF_CTRL_COUNT_CONFIG */
    0x00000000,  /*  CY_U3P_PIB_GPIF_CTRL_COUNT_RESET */
    0x0000FFFF,  /*  CY_U3P_PIB_GPIF_CTRL_COUNT_LIMIT */
    0x0000010A,  /*  CY_U3P_PIB_GPIF_ADDR_COUNT_CONFIG */
    0x00000000,  /*  CY_U3P_PIB_GPIF_ADDR_COUNT_RESET */
    0x0000FFFF,  /*  CY_U3P_PIB_GPIF_ADDR_COUNT_LIMIT */
    0x00000000,  /*  CY_U3P_PIB_GPIF_STATE_COUNT_CONFIG */
    0x0000FFFF,  /*  CY_U3P_PIB_GPIF_STATE_COUNT_LIMIT */
    0x0000010A,  /*  CY_U3P_PIB_GPIF_DATA_COUNT_CONFIG */
    0x00000000,  /*  CY_U3P_PIB_GPIF_DATA_COUNT_RESET */
    0x0000FFFF,  /*  CY_U3P_PIB_GPIF_DATA_COUNT_LIMIT */
    0x00000000,  /*  CY_U3P_PIB_GPIF_CTRL_COMP_VALUE */
    0x00000000,  /*  CY_U3P_PIB_GPIF_CTRL_COMP_MASK */
    0x00000000,  /*  CY_U3P_PIB_GPIF_DATA_COMP_VALUE */
    0x00000000,  /*  CY_U3P_PIB_GPIF_DATA_COMP_MASK */
    0x00000000,  /*  CY_U3P_PIB_GPIF_ADDR_COMP_VALUE */
    0x00000000,  /*  CY_U3P_PIB_GPIF_ADDR_COMP_MASK */
    0x00000000,  /*  CY_U3P_PIB_GPIF_DATA_CTRL */
    0x00000000,  /*  CY_U3P_PIB_GPIF_INGRESS_DATA */
    0x00000000,  /*  CY_U3P_PIB_GPIF_INGRESS_DATA */
    0x00000000,  /*  CY_U3P_PIB_GPIF_INGRESS_DATA */
    0x00000000,  /*  CY_U3P_PIB_GPIF_INGRESS_DATA */
    0x00000000,  /*  CY_U3P_PIB_GPIF_EGRESS_DATA */
    0x00000000,  /*  CY_U3P_PIB_GPIF_EGRESS_DATA */
    0x00000000,  /*  CY_U3P_PIB_GPIF_EGRESS_DATA */
    0x00000000,  /*  CY_U3P_PIB_GPIF_EGRESS_DATA */
    0x00000000,  /*  CY_U3P_PIB_GPIF_INGRESS_ADDRESS */
    0x00000000,  /*  CY_U3P_PIB_GPIF_INGRESS_ADDRESS */
    0x00000000,  /*  CY_U3P_PIB_GPIF_INGRESS_ADDRESS */
    0x00000000,  /*  CY_U3P_PIB_GPIF_INGRESS_ADDRESS */
    0x00000000,  /*  CY_U3P_PIB_GPIF_EGRESS_ADDRESS */
    0x00000000,  /*  CY_U3P_PIB_GPIF_EGRESS_ADDRESS */
    0x00000000,  /*  CY_U3P_PIB_GPIF_EGRESS_ADDRESS */
    0x00000000,  /*  CY_U3P_PIB_GPIF_EGRESS_ADDRESS */
    0x80010400,  /*  CY_U3P_PIB_GPIF_THREAD_CONFIG */
    0x80010401,  /*  CY_U3P_PIB_GPIF_THREAD_CONFIG */
    0x80010402,  /*  CY_U3P_PIB_GPIF_THREAD_CONFIG */
    0x80010403,  /*  CY_U3P_PIB_GPIF_THREAD_CONFIG */
    0x00000000,  /*  CY_U3P_PIB_GPIF_LAMBDA_STAT */
    0x00000000,  /*  CY_U3P_PIB_GPIF_ALPHA_STAT */
    0x00000000,  /*  CY_U3P_PIB_GPIF_BETA_STAT */
    0x00130000,  /*  CY_U3P_PIB_GPIF_WAVEFORM_CTRL_STAT */
    0x00000000,  /*  CY_U3P_PIB_GPIF_WAVEFORM_SWITCH */
    0x00000000,  /*  CY_U3P_PIB_GPIF_WAVEFORM_SWITCH_TIMEOUT */
    0x00000000,  /*  CY_U3P_PIB_GPIF_CRC_CONFIG */
    0x00000000,  /*  CY_U3P_PIB_GPIF_CRC_DATA */
    0xFFFFFFC1  /*  CY_U3P_PIB_GPIF_BETA_DEASSERT */
};

/* Summary
   This structure holds all the configuration inputs for the GPIF II. 
 */
const CyU3PGpifConfig_t CyFxGpifConfig  = {
    (uint16_t)(sizeof(CyFxGpifWavedataPosition)/sizeof(uint8_t)),
    CyFxGpifWavedata,
    CyFxGpifWavedataPosition,
    (uint16_t)(sizeof(CyFxGpifTransition)/sizeof(uint16_t)),
    CyFxGpifTransition,
    (uint16_t)(sizeof(CyFxGpifRegValue)/sizeof(uint32_t)),
    CyFxGpifRegValue
};

#endif   /* _INCLUDED__ */

 

0 Likes
1 Solution
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi,

BootGpifDemo can be used for the application. However, GpifToUsb in the application firmware folder is built on RTOS and has a simpler implementation when compared to the BootGpifDemo application firmware. Debugging and understanding the GpifToUsb firmware would be way easier than the BootGpifDemo example.

Considering a DMA channel with CPU as one of the socket, interrupts on the CPU socket wont be handled by the DMAinterruptHandler function and getSckConfig and the sendSocketEvent for this channel has to be done out of the DMAinterruptHandler within the infinite for loop. Hence, I would recommend you to use the GpifToUsb firmware with APIs based on RTOS. This would help speed up the developmental process due to easy implementation.

Best Regards,
AliAsgar

 

View solution in original post

0 Likes
7 Replies
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi,

BULK IN transfer fails with error 997, denoting a timeout error. This error occurs when the host is waiting for data from the device, but the device does not respond with data. 
In your case, this error could have possibly occurred, if the data read by GPIF does not fill a DMA buffer, or if a partially filled DMA buffer is not committed to the USB.

1. Is there any particular reason to use the boot_fw examples for your application? Can the gpifToUsb from application firmware examples be used (C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\basic_examples\cyfxgpiftousb)?

2. Could you share with us the firmware project and GPIF Designer project?

Best Regards,
AliAsgar

0 Likes

Hi AliAsgar, 

First of all, I'm new to EZ USB chip,

1- My application is to interface this AD7381-4 ADC with the EZ USB chip. For that, the GPIF interface should configure the ADC, then read from it as per these timing diagrams, and send the results to USB 3 interface:
Write (Configure):

Ahmedms_1-1669302221489.png


then Read:

Ahmedms_0-1669302157930.png

2- For that, I built the state transitions of GPIF-II as shown:

Ahmedms_2-1669302309096.pngAhmedms_3-1669302331429.pngAhmedms_4-1669302366813.png

 

3- Finally, the measurement should happen at a GPIO LOW signal received from another device (i.e. like a button press)

 

My procedure was:

1- I started from bootGpifDemo, Should I start from gpif2usb better?

2- I add a GPIO condition for the GPIF read and transmission to the DMA as shown, it works fine on the logic analyzer

3- The usb is only throwing this error I mentioned when adding the new GPIF statemachine

4- The next step (after we fix the USB), I'll be working on writing the particular data in the config state that should appear on the bus

Here is the firmware project (attached)

0 Likes
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi,

BootGpifDemo can be used for the application. However, GpifToUsb in the application firmware folder is built on RTOS and has a simpler implementation when compared to the BootGpifDemo application firmware. Debugging and understanding the GpifToUsb firmware would be way easier than the BootGpifDemo example.

Considering a DMA channel with CPU as one of the socket, interrupts on the CPU socket wont be handled by the DMAinterruptHandler function and getSckConfig and the sendSocketEvent for this channel has to be done out of the DMAinterruptHandler within the infinite for loop. Hence, I would recommend you to use the GpifToUsb firmware with APIs based on RTOS. This would help speed up the developmental process due to easy implementation.

Best Regards,
AliAsgar

 

0 Likes

Great thanks, I followed your advise and started from GPIFtousb example.

I also set the statemachine to use Thread0 (which was configured wrong) and to wait for DMA_RDY as in the example.

I think now the USB is working, the GPIF transitions looks as I wanted.

For Debug's sake, how to slow down the GPIF clock? where can I set a divider for GPIF's clock only (not for the whole system)

The next step is:

1- What is the best way to trigger this statemachine to run when a GPIO is pressed low (like a push button)? 

2- How can I choose the data to Drive in the ADC_CONFIG Stage?

3- Is there an example or demonstration that explains how to modify the packets received from GPIF before streaming them on USB?

Ahmedms_0-1669864216186.png

 

0 Likes
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi,

Please refer to the KBA: https://community.infineon.com/t5/Knowledge-Base-Articles/Configuring-EZ-USB-FX3-GPIF-II-DLL-KBA2107... for details on how to change the GPIF II clock.

1. I recommend to add a GPIO as a control signal to the GPIF II interface and modify the state machine to account for the assertion of the GPIO.

2. The data in the DMA buffer committed from CPU to GPIF is the data driven. If I have not answered your question correctly, could you please elaborate on what exactly you meant by the question?

3. Please refer to the AN75779 firmware, which demonstrates how the DMA buffers produced from the GPIF is modified before sending it out over the USB. However note that only minimal modifications can be done in the DmaCallback function due to timing criticalities.

Best Regards,
AliAsgar

0 Likes

Hi AliAsgar, 

Thanks for your detailed and precise answers, 

1 and 3 are working now.

 

For 2: I meant, when I have DR_DATA State, how can I send a particular data stream like: 0xA2, 0xB1, 0x89, 0x33 assuming an 8-bit GPIF interface? Where in the code do I load the data into the buffer to be sent on GPIF interface?
Is there an example that demonstrates write_to_GPIF functionality?

0 Likes
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi,

I can think of two methods to send data on the GPIF buffer as you like:

1. A MANUAL OUT DMA channel can be created between CPU_PROD and PIB_CONS. Get an empty buffer and fill it with the contents you want to send. Commit the buffer to the GPIF whenever required. There is no example that demonstrated write_to_GPIF functionality. However, there is an example that demonstrated write_to_usb implementation, very much similar to write_to_gpif. Please refer to USBBulkLoopManualInOut default firmware example project.

2. Use CyU3PGpifWriteDataWords API to send data words in terms of interface width to the P-port. There is no example that demonstrates this implementation. Please refer to API Guide and other FX3 documentation to understand the usage of this API. The document in this thread https://community.infineon.com/t5/USB-superspeed-peripherals/CY-U3P-PIB-GPIF-EGRESS-DATA-or-CyU3PGpi... can help you understand better.

Best Regards,
AliAsgar

0 Likes