fx2 can read 5039104 bytes

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

cross mob
Anonymous
Not applicable

Hello,I am using fx2 to read data from a image sensor with 2592*1944 bytes ,I  got data up to 4194304 bytes correctly and rest of the bytes were zeros. Is there any maximum limit for the receiving data in the Slave fifo mode or in the xferdata function.

Best regards,

Sandeep

0 Likes
1 Solution

Hello Sandeep,

Please use the latest version of Cypress USB Control Center available with the FX3 SDK. I have attached the screenshots from the older version as well as the newer version of the USB Control Center. As you had mentioned, the older version returned 0's after 4MB whereas the newer version works fine.

pastedImage_0.png

pastedImage_1.png

Best regards,

Srinath S

View solution in original post

0 Likes
28 Replies
SrinathS_16
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Hello Sandeep,

- The XferData() API does not pad up any 0's at the end of the transfer. It either returns success or failure depending on the number of bytes that is being transferred. In case the XferData() API fails for a large amount of data transfer, increase the timeout value by specifying the TimeOut parameter of the corresponding endpoint.

- Are you using Control Center to perform the data transfer. If not, please try using the same.

- Is the image sensor configured properly? How are the FV and LV signals communicated to the FX2LP? Please share a part of the schematic containing the slave FIFO part of the FX2LP.

Best regards,

Srinath S

0 Likes
Anonymous
Not applicable

Hello srinath,

I checked data in the control center application ,control center application data  and schematic are  attached herewith .

Best regards,

SandeepCyconsole_SS.JPGSchematic.JPG

0 Likes

Hello Sandeep,

- Please let me know what is the value driven on the PA1 pin.

- Also, probe the SLWR# and FD[7:0] lines during the failure and check if there is any data transfer happening between the FX2LP and the image sensor.

Best regards,

Srinath S

0 Likes
Anonymous
Not applicable

Hello srinath,

my TDpoll function Fx2 code is

void TD_Poll( void )

{

    if(Single)

  {

        FIFOADR0=0;    //pA1 selecting  Ep6  

       SYNCDELAY;

       FIFORESET = 0x80;     // activate NAK-ALL to avoid race conditions

      SYNCDELAY;

     EP6FIFOCFG = 0x00;    //switching to manual mode

     SYNCDELAY;

     FIFORESET = 0x06;     // Reset FIFO 6

     SYNCDELAY;

     FIFORESET = 0x00;     //Release NAKALL

     SYNCDELAY;

     while(IOA & 0x01);     // wait until FV,PA0 Becomes low

     while (!(IOA & 0x01)); // wait until FV,PA0 Becomes High

     EP6FIFOBUF[0]=0xFF;    // 5bytes of Header used by the Preview Utility         to detect the Start of Transmission

     EP6FIFOBUF[1]=0x00;

     EP6FIFOBUF[2]=0x0F;

     EP6FIFOBUF[3]=0x00;

     EP6FIFOBUF[4]=0xFF;

     EP6BCH=0x02;        //512 bytes committed

     SYNCDELAY;

     EP6BCL=0x00;

     SYNCDELAY;

     FIFORESET = 0x80;      // activate NAK-ALL to avoid race conditions

     SYNCDELAY;

     EP6FIFOCFG = 0x00;     // switching to manual mode

     SYNCDELAY;

     FIFORESET = 0x06;      // Reset FIFO 6

     SYNCDELAY;

     EP6FIFOCFG = 0x0C;     // switching to auto mode

    SYNCDELAY;

    FIFORESET = 0x00;      //  Release NAKALL

    SYNCDELAY;

    Single=FALSE; 

}

  }

i checked LV,SLWR# in the CRO

how to check the failure condition ?

Best regards,

Sandeep N C

0 Likes

Hello Sandeep,

Please probe the FD[7:0] pins along with FV and LV and share the screenshot of the same.

Best regards,

Srinath S

0 Likes
Anonymous
Not applicable

Hello srinath,

u mean connect FD[7:0] ,FV and LV in the logic analyzer ?

Best regards,

Sandeep

0 Likes

Hello Sandeep,

Yes. I would like to see these traces together when you are receiving continuous 0's on the host application.

Best regards,

Srinath S

0 Likes
Anonymous
Not applicable

Hello srinath,

I don't have logic analyzer. Is there any other option to check the FD[7-0] ?

Best regards,

Sandeep

0 Likes

Hello Sandeep,

- Probing the data lines would be helpful. It would help identify if the data is not being received by the FX2LP or if there is an issue with the FX2LP firmware.

- Also, does the continuous 0's occur after the same number of bytes are transferred?

Best regards,

Srinath S

0 Likes
Anonymous
Not applicable

Hello srinath ,

The continuous zeros occur after every 4194303(0x3FFFFF) bytes.Is there any connection with 8192 packets (4194303=8192*512 packets).

Please suggest any logical analyzer with 10 or 12 channel for troubleshooting these kinds of problems.

Best regards,

Sandeep

0 Likes

Hello Sandeep,

FX2LP has not got any restrictions with respect to the data transfer. I am able to transfer 5038592 bytes of data using the Control Center with the BulkSrc example firmware loaded into FX2LP. So, this should be because the data lines from the image sensor is sending 0's.

You can use Saleae Logic analyzer to capture the digital traces of the data lines.

Best regards,

Srinath S

0 Likes
Anonymous
Not applicable

Hello srinath ,

Please check my TD poll fuction .

void TD_Poll( void )

{

    if(Single)

  {

        FIFOADR0=0;    //pA1 selecting  Ep6 

       SYNCDELAY;

       FIFORESET = 0x80;     // activate NAK-ALL to avoid race conditions

      SYNCDELAY;

     EP6FIFOCFG = 0x00;    //switching to manual mode

     SYNCDELAY;

     FIFORESET = 0x06;     // Reset FIFO 6

     SYNCDELAY;

     FIFORESET = 0x00;     //Release NAKALL

     SYNCDELAY;

     while(IOA & 0x01);     // wait until FV,PA0 Becomes low

     while (!(IOA & 0x01)); // wait until FV,PA0 Becomes High

     EP6FIFOBUF[0]=0xFF;    // 5bytes of Header used by the Preview Utility         to detect the Start of Transmission

     EP6FIFOBUF[1]=0x00;

     EP6FIFOBUF[2]=0x0F;

     EP6FIFOBUF[3]=0x00;

     EP6FIFOBUF[4]=0xFF;

     EP6BCH=0x02;        //512 bytes committed

     SYNCDELAY;

     EP6BCL=0x00;

     SYNCDELAY;

     FIFORESET = 0x80;      // activate NAK-ALL to avoid race conditions

     SYNCDELAY;

     EP6FIFOCFG = 0x00;     // switching to manual mode

     SYNCDELAY;

     FIFORESET = 0x06;      // Reset FIFO 6

     SYNCDELAY;

     EP6FIFOCFG = 0x0C;     // switching to auto mode

    SYNCDELAY;

    FIFORESET = 0x00;      //  Release NAKALL

    SYNCDELAY;

    Single=FALSE;

}

  }

   when i removed the section after selecting  manual mode

     FIFORESET = 0x80;      // activate NAK-ALL to avoid race conditions

     SYNCDELAY;

     EP6FIFOCFG = 0x00;     // switching to manual mode

     SYNCDELAY;

     FIFORESET = 0x06;      // Reset FIFO 6

     SYNCDELAY;

     FIFORESET = 0x00;      //  Release NAKALL

    SYNCDELAY;

  Header comes correctly in the initial value of the received buffer.

please send me a code to read data from the image sensor .

Best regards,

Sandeep

0 Likes

Hello Sandeep,

Please use the below code in TD_Poll() function block.

void TD_Poll( void )

{

  if(Single)

  {

    FIFOADR0=0;    //pA1 selecting  Ep6

    SYNCDELAY;

    FIFORESET = 0x80;    // activate NAK-ALL to avoid race conditions

    SYNCDELAY;

    EP6FIFOCFG = 0x00;    //switching to manual mode

    SYNCDELAY;

    FIFORESET = 0x06;    // Reset FIFO 6

    SYNCDELAY;

   

    while(IOA & 0x01);    // wait until FV,PA0 Becomes low

    while (!(IOA & 0x01)); // wait until FV,PA0 Becomes High

    EP6FIFOBUF[0]=0xFF;    // 5bytes of Header used by the Preview Utility        to detect the Start of Transmission

    EP6FIFOBUF[1]=0x00;

    EP6FIFOBUF[2]=0x0F;

    EP6FIFOBUF[3]=0x00;

    EP6FIFOBUF[4]=0xFF;

    EP6BCH=0x02;        //512 bytes committed

    SYNCDELAY;

    EP6BCL=0x00;

    SYNCDELAY;

  

    EP6FIFOCFG = 0x0C;     // switching to auto mode

    SYNCDELAY;

    FIFORESET = 0x00;      //  Release NAKALL

    SYNCDELAY;

    Single=FALSE;

  }

}

In the above code, please let me know how the value of variable 'Single' gets updated. I understand that you are trying to stream video continuously using the FX2LP but your code indicates that you are trying to read only a single frame of data. Please correct me if my understanding is wrong.

Best regards,

Srinath S

0 Likes
Anonymous
Not applicable

Hello Srinath,

Thank you for the reply.when i select the LIVE in the Host code the value of the Single is Updated  , Host code works in a while loop  sends vendor command, single is updated  and read xfer data . I changed my code with your TD poll code ,image header works fine but some part is missing .Image is attached here Capture_with header.JPG

The image with my previous code is attached here  in which missing occurs rarely.Full_image_without_heaader.JPG

0 Likes

Hello Sandeep,

Please use the below code. I have modified the EP6BC to 5 bytes instead of 512 bytes. Kindly, check and let me know.

void TD_Poll( void )

{

  if(Single)

  {

    FIFOADR0=0;    //pA1 selecting  Ep6

    SYNCDELAY;

    FIFORESET = 0x80;    // activate NAK-ALL to avoid race conditions

    SYNCDELAY;

    EP6FIFOCFG = 0x00;    //switching to manual mode

    SYNCDELAY;

    FIFORESET = 0x06;    // Reset FIFO 6

    SYNCDELAY;

   

    while(IOA & 0x01);    // wait until FV,PA0 Becomes low

    while (!(IOA & 0x01)); // wait until FV,PA0 Becomes High

    EP6FIFOBUF[0]=0xFF;    // 5bytes of Header used by the Preview Utility        to detect the Start of                            //  Transmission

    EP6FIFOBUF[1]=0x00;

    EP6FIFOBUF[2]=0x0F;

    EP6FIFOBUF[3]=0x00;

    EP6FIFOBUF[4]=0xFF;

    EP6BCH=0x00;        //5 bytes committed

    SYNCDELAY;

    EP6BCL=0x05;

    SYNCDELAY;

 

    EP6FIFOCFG = 0x0C;    // switching to auto mode

    SYNCDELAY;

    FIFORESET = 0x00;      //  Release NAKALL

    SYNCDELAY;

    Single=FALSE;

  }

}

Best regards,

Srinath S

0 Likes
Anonymous
Not applicable

Hello Srinath ,

I used new  code and  5 header bytes were received  correctly and rest of the bytes were zeros.

Best regards,

Sandeep N C

0 Likes

Hello Sandeep,

The host application that you are using should be modified to look for the header data and skip this packet of data and treat the packets after this as part of the image frame. Kindly, try it out this way and update me.

Best regards,

Srinath S

0 Likes
Anonymous
Not applicable

Hello Srinath,

I changed my host code to

bool startframe = false;

totalBytesToRead = 614400; // to read the data 2 times (640*480*2=614400)

int framecnt = 0;

var g = SelectedDevice.BulkInEndPt.XferData(ref readBytes, ref totalBytesToRead);   

  for (var i = 0; i < 614400; i++)

{

if ((readBytes == 255)&&(readBytes[i+1]==0)&&(readBytes[i+2]==15)&&(readBytes[i+3]==0)&&(readBytes[i+4]==255))

   {

       startframe = true;

       framecnt = i+5;

       break;

    }

  }

      if (startframe)

  {

      for (var pixnum= 0; pixnum< 307200; pixnum++)

    {

        pixelDatas[pixnum] = readBytes[framecnt];

        framecnt++;

     }

    }

       return pixelDatas;

  is this code  correct ?

Best regards,

Sandeep

0 Likes

Hello Sandeep,

Use the below modification and let me know the results.

if ((readBytes == 255)&&(readBytes[i+1]==0)&&(readBytes[i+2]==15)&&(readBytes[i+3]==0)&&(readBytes[i+4]==255))

  {

      startframe = true;

     framecnt = i+512;

      break;

  }

Best regards,

Srinath S

0 Likes
Anonymous
Not applicable

Hello,sreenath,

I changed the code as frame count=i+512;and read the data with TD poll code

void TD_Poll( void ) // updated code

{

    if(Single)

  {

    FIFOADR0=0;    //pA1 selecting  Ep6

    SYNCDELAY;

    FIFORESET = 0x80;    // activate NAK-ALL to avoid race conditions

    SYNCDELAY;

    EP6FIFOCFG = 0x00;    //switching to manual mode

    SYNCDELAY;

    FIFORESET = 0x06;    // Reset FIFO 6

    SYNCDELAY;

    while(IOA & 0x01);    // wait until FV,PA0 Becomes low

    while (!(IOA & 0x01)); // wait until FV,PA0 Becomes High

    EP6FIFOBUF[0]=0xFF;    // 5bytes of Header used by the Preview Utility        to detect the Start of                            //  Transmission

    EP6FIFOBUF[1]=0x00;

    EP6FIFOBUF[2]=0x0F;

    EP6FIFOBUF[3]=0x00;

    EP6FIFOBUF[4]=0xFF;

    EP6BCH=0x02;        //512 bytes committed

    SYNCDELAY;

    EP6BCL=0x00;

    SYNCDELAY;

    EP6FIFOCFG = 0x0C;    // switching to auto mode

    SYNCDELAY;

    FIFORESET = 0x00;      //  Release NAKALL

    SYNCDELAY;

    Single=FALSE;

}

}

Images are attaching

  Actual frame

actual_frame.JPG

Error frame Error-frame.JPG

Best regards,

Sandeep

0 Likes

Hello Sandeep,

Apologies. There was an error in the code that I mentioned previously.

Please make the following changes.

FW:

void TD_Poll( void ) // updated code

{

    if(Single)

  {

    FIFOADR0=0;    //pA1 selecting  Ep6

    SYNCDELAY;

    FIFORESET = 0x80;    // activate NAK-ALL to avoid race conditions

    SYNCDELAY;

    EP6FIFOCFG = 0x00;    //switching to manual mode

    SYNCDELAY;

    FIFORESET = 0x06;    // Reset FIFO 6

    SYNCDELAY;

    while(IOA & 0x01);    // wait until FV,PA0 Becomes low

    while (!(IOA & 0x01)); // wait until FV,PA0 Becomes High

   EP6FIFOBUF[507]=0xFF;    // 5bytes of Header used by the Preview Utility        to detect the Start of                                                     //  Transmission

    EP6FIFOBUF[508]=0x00;

    EP6FIFOBUF[509]=0x0F;

    EP6FIFOBUF[510]=0x00;

    EP6FIFOBUF[511]=0xFF;

    EP6BCH=0x02;        //512 bytes committed

    SYNCDELAY;

    EP6BCL=0x00;

    SYNCDELAY;

    EP6FIFOCFG = 0x0C;    // switching to auto mode

    SYNCDELAY;

    FIFORESET = 0x00;      //  Release NAKALL

    SYNCDELAY;

    Single=FALSE;

}

}

Host Application:

if ((readBytes == 255)&&(readBytes[i+1]==0)&&(readBytes[i+2]==15)&&(readBytes[i+3]==0)&&(readBytes[i+4]==255))

  {

      startframe = true;

   framecnt = i+5;

      break;

  }

In case the image is still distorted, please share the raw image data captured(HEX data) in your host application.

Best regards,

Srinath S

0 Likes
Anonymous
Not applicable

Hello Srinath ,

I changed the header bytes  array index from [507] to [511]  and all the frames are like this.Headerbytes_corrected.JPG

Best regards,

Sandeep N C

0 Likes
Anonymous
Not applicable

Hello srinath,

Thank you very much for your assistance .With the last modification error frames  occurs very rarely but i need to clear it .Please tell me is it possible to use 640*480 resolution using FX2  in above 25 FPS  without FPGA ?

Best regards,

Sandeep

0 Likes

Hello Sandeep,

The resolution/fps that you have mentioned accounts to 15.36MBps (considering 2 bytes per pixel). FX2LP IFCLK can operate at a maximum of 48MHz so the mentioned resolution/fps can work fine without an FPGA.

Best regards,

Srinath S

0 Likes
Anonymous
Not applicable

Hi srinath ,

I checked the speed with time taken for xferdata to read 307200 bytes (one

byte for pixel ) in the synchronous transfer. it takes 0.04 sec to read

307200 bytes means (1/0.04=25FPS). I got 17 FPS in this 640*480 resolution

after the image conversion.Is it possible to get higher FPS in this

transfer.Can I use the Asynchronous method with BeginXferdata(),and

finishxferdata() for my camera application?

Best regards,

Sandeep

0 Likes

Hello Sandeep,

The asynchronous transfer method will provide you with a better bandwidth utilization by queuing up the transfers. The XferData() API also uses the BeginXferData(), WaitForXfer() and FinishDataXfer() APIs but subsequent transfers are not queued up until the current transfer is completed.

As a reference example, please refer to the example applications in the below path that come with the FX3 SDK.

C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\application\cpp\streamer

Also, for further queries related to the host application, please create a new thread as it will be easier for tracking.

Best regards,

Srinath S

0 Likes
Anonymous
Not applicable

Hello srinath,

I got the speed of 31MBPS speed with Cystream code.But the problem with reading data bytes  above 4194304 bytes is still there.I checked this code in the CYconsole application and not with the CMOS sensor board.All Data after 4194304 is Zero.This means only 4MB data is able to send.is it related to fifo memory ? I am using CY7C68013A56pvx IC .

Cyconsole.JPG

Best regards,

Sandeep

0 Likes

Hello Sandeep,

Please use the latest version of Cypress USB Control Center available with the FX3 SDK. I have attached the screenshots from the older version as well as the newer version of the USB Control Center. As you had mentioned, the older version returned 0's after 4MB whereas the newer version works fine.

pastedImage_0.png

pastedImage_1.png

Best regards,

Srinath S

0 Likes