cancel
Showing results for 
Search instead for 
Did you mean: 

USB Superspeed Peripherals

EvEv_2610591
New Contributor

I have simple scheme (see pic.) FX3 read 16 bit data from slave FPGA with embedded registers array.

scheme.jpg

I have made GPIF State Machine with GPIF designer (see pic.)

Новый точечный рисунок (3).jpg

st1.jpg

GPIF State Machine starts from state "START" and then I switch to state "RD_START" in Entry function SRamAppThread_Entry  using CyU3PGpifSMSwitch (256, RD_START, 256, 0, 0);

In STATE6 is called interrupt callback function with code:

  {

          CyU3PDmaChannelSetWrapUp(&glChHandleSRamPtoU_48);  

    }

for (;

    {

         // code before

          apiRetStatus = CyU3PGpifSMSwitch (256, RD_START, 256, 0, 0);

          if(apiRetStatus != CY_U3P_SUCCESS){

          CyU3PDebugPrint (CY_FX_DEBUG_PRIORITY, "CyU3PGpifSMSwitch failed, Error code = %d\r\n", apiRetStatus);

         }

          // code after

     }

 

breakpoint set apiRetStatus = CyU3PGpifSMSwitch (256, RD_START, 256, 0, 0);

I want to read one 16 bit word, but I have "zero length" in Control Center window. When I try to read 2 words  I haven't problem and I receive 2 words.

I cant read odd number of words. If I try to read odd number of words - N, I have N-1 words (even numer of words).

Were is my mistake

P.S.

/*------DMA P-Port config (AUTO mode)---------------------------------------------------------------------------------------------*/

dmaCfg.notification = 0;

dmaCfg.cb = NULL;

dmaCfg.prodSckId = CY_FX_PRODUCER_USB_SOCKET_4;

dmaCfg.consSckId = CY_FX_CONSUMER_PPORT_SOCKET;

dmaCfg.count = 1;

apiRetStatus = CyU3PDmaChannelCreate (&glChHandleSRamUtoP_48, CY_U3P_DMA_TYPE_AUTO, &dmaCfg);

if (apiRetStatus != CY_U3P_SUCCESS)

{

   CyU3PDebugPrint (CY_FX_DEBUG_PRIORITY, "CyU3PDmaChannelCreate failed, Error code = %d\n", apiRetStatus);

   CyFxAppErrorHandler(apiRetStatus);

}

dmaCfg.notification = 0;

dmaCfg.cb = NULL;

dmaCfg.prodSckId = CY_FX_PRODUCER_PPORT_SOCKET;

dmaCfg.consSckId = CY_FX_CONSUMER_USB_SOCKET_8;

dmaCfg.count = 1;

apiRetStatus = CyU3PDmaChannelCreate (&glChHandleSRamPtoU_48, CY_U3P_DMA_TYPE_AUTO, &dmaCfg);

if (apiRetStatus != CY_U3P_SUCCESS)

{

   CyU3PDebugPrint (CY_FX_DEBUG_PRIORITY, "CyU3PDmaChannelconfig Failed, Error code = %d\n", apiRetStatus);

   CyFxAppErrorHandler(apiRetStatus);

}

/*-------------------------------------------------------------------------------------------------------------------------*/

0 Likes
8 Replies
SrinathS_16
Moderator
Moderator

Hello Evgen,

- The CyU3PGpifSMSwitch() API is called in the thread main loop which will cause the GPIF state machine to restart from RD_START state upon every iteration. In this case, the number of times the STATE4 gets executed would be random and cannot be determined. So, the number of IN_DATA action that is being performed is also not deterministic.

- Also, in the CPU interrupt callback function, the CyU3PGpifControlSWInput() API is not called which means that the FW_TRG is not happening at all.

- Modify the state machine to implement the switch to RD_STATE only upon a failure.

- Change the transition equation from STATE6 to STATE1 as FW_TRG and implement the same in the CPU interrupt callback function in the firmware.

CyU3PGpifControlSWInput(CyTrue);

CyU3PGpifControlSWInput(CyFalse);

- Change the transition equation from STATE1 to RD_STATE as LOGIC ONE.

Best regards,

Srinath S

EvEv_2610591
New Contributor

Hello Srinath!

FW_TRG not used -  it blocks transition and CyU3PGpifControlSWInput is not needed.

My main loop for (;;) consists of  many commands. I set breakpionts before and after CyU3PGpifSMSwitch. Then I try to receive data using Control Center.

So CyU3PGpifSMSwitch is calld only once.

0 Likes
EvEv_2610591
New Contributor

P.S I use CYFXSRAM example and modify.

0 Likes
SrinathS_16
Moderator
Moderator

Hello Evgen,

- Since you have mentioned that you are setting breakpoints, I understand that you are using JTAG debugging and programming. Please correct me if I am wrong.

- Please share the UART logs that is collected during the process. Include debug prints in the CPU interrupt callback before collecting the logs.

Also, include the GPIF state machine number in the debug prints.

Best regards,

Srinath S

0 Likes
EvEv_2610591
New Contributor

I have 2 breakpoints. The first breakpoint before call CyU3PGpifSMSwitch() function in working loop. Second breakpoint is set in interruption CPU callback before CyU3PDmaChannelSetWrapUp() function.

States definition from cyfxgpif2config.h

/* Summary

   Mapping of user defined state names to state indices

*/

#define START 0

#define EMPTY_STATE 2

#define STATE1 1

#define RD_START 4

#define STATE6 5

#define STATE4 3

0 Likes
SrinathS_16
Moderator
Moderator

Hello Evgen,

- Kindly, share the UART logs that can be collected using a Terminal Emulator like TeraTerm as it can be easier to debug.

- Also, use the CyU3PGpifGetSMState() API to obtain the current state of the GPIF and print the same over the UART.

Best regards,

Srinath S

0 Likes
EvEv_2610591
New Contributor

Hello Srinath!

I have modyfied cb function:

void GpifStopReadDataCb(CyU3PGpifEventType event,  uint8_t  currentState)

{

     CyU3PReturnStatus_t apiRetStatus;

     uint8_t smstate;

     CyU3PGpifGetSMState(&smstate);

     CyU3PDebugPrint (CY_FX_DEBUG_PRIORITY, "SM State = %d\n", smstate);

     if(event==CYU3P_GPIF_EVT_SM_INTERRUPT){

          apiRetStatus = CyU3PDmaChannelSetWrapUp(&glChHandleSRamPtoU_48);

     }

}

    And I have got next UART log:

UART_Log.png

0 Likes
SrinathS_16
Moderator
Moderator

Hello,

Can you please post your firmware source code so that it can be debugged at my end?

Best regards,

Srinath S

0 Likes