Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > USB Controllers > how to renew the data in endpoint 4

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



how to renew the data in endpoint 4
Moderator:
RSKV

Post Reply
Follow this topic



how to renew the data in endpoint 4

mrjun posted on 08 Jun 2011 11:46 PM PST
Senior Member
17 Forum Posts

I try to  transmit the data from endpoint 4 (out) to ram ,and then to endpoint 8(IN).according the debug,data can be passed rightly one to one,but if receive not in time, I can't get the latest data.

for example:4(in) transmit: 90 (512bytes)  8(IN) get 90 to FF,then from 00 to 8F (that's right);

                 then 4(in) transmit: 93 (512bytes)  8(IN) get 93 to FF,then from 00 to 92 (that's right);

                 then 4(in) transmit: 95 (512bytes)  8(IN) get 95 to FF,then from 00 to 94 (that's right);

but if I transmit 90(512bytes),then 93(512bytes),then 95(512bytes), I only can get the old data 90 to 8f and 93 to 92, but the latest data is lost.how can I ignore the old data and get latest one?

here's the code,debug by consle

 

void test()
{
  WORD i;
  WORD count;
 WORD j=0;
 BYTE cmdcode;
  if(!(EP2468STAT & bmEP4EMPTY))  
     {
     count = (EP4BCH << 8) + EP4BCL;
  cmdcode= EP4FIFOBUF[0];

        // loop EP4OUT buffer data to RAMBUF
        for( i = 0x0000; i < count; i++ )
        {
         RAMBUF(0x200+i)=EP4FIFOBUF[i];
        }
   RAMBUF(0x3FE) =1;
        SYNCDELAY; 
 

 if(cmdcode>=0x71)

  {
   
   for( i = 0x00; i < count; i++ ) 
         {
       EP8FIFOBUF[i]=cmdcode+i;   
    
         }  
      SYNCDELAY;    
          
   EP8BCH = 0x02;
      SYNCDELAY;                //
      EP8BCL = 0x00;
      SYNCDELAY;
    }
else INPKTEND=0X88;//    
 }   
  OUTPKTEND=0X84; 
   SYNCDELAY;  
    
  }




Re: how to renew the data in endpoint 4

aasi posted on 08 Jun 2011 12:25 AM PST
Cypress Employee
1090 Forum Posts

mrjun,

What is the FIFO configuration you're using i.e. EP2 double buffered 512, EP4 double buffered 512 etc etc?

Or better yet can you post your initialization part of the code.

Regards,

Anand



Re: how to renew the data in endpoint 4

mrjun posted on 08 Jun 2011 02:19 AM PST
Senior Member
17 Forum Posts

thanks to assi's reply.

here's the configuration of ep4 and ep8:

SYNCDELAY;                   
  EP4CFG = 0xB0;//interrupt mode
  SYNCDELAY; 
  EP8CFG = 0xE0;//bulk mode

  SYNCDELAY;
 OUTPKTEND=0X84; // according the pdf of 68013A, ep4buffer is 1024 and then I re-arm twice, is that right?
 SYNCDELAY;
 OUTPKTEND=0X84;

I have tried ep4 and ep8 both in bulk or interrupt mode,the problem still   exist.



Re: how to renew the data in endpoint 4

aasi posted on 08 Jun 2011 02:41 AM PST
Cypress Employee
1090 Forum Posts

mrjun,

You're not using a valid FIFO configuration that is the reason behind the issue. In the latest FX2LP TRM please go to "EZ-USB Endpoint Buffers" section in page 30. This shows the 12 possible configurations that the FIFO buffers can be configured in.

Looking at your initialization statement, configuration 9 would be suitable for you.

Regards,

Anand



Re: how to renew the data in endpoint 4

mrjun posted on 08 Jun 2011 05:03 AM PST
Senior Member
17 Forum Posts

thanks to aasi's reply again.

for some expanding application in the future, I think the configuration 1 might be better.

if I obey the configuration 1,according "Table 8-2.  Endpoint Configuration Registers" in page 102 and the table in 262, "ep4 and ep8 always are 512 bytes, double-buffered in high-speed mode", the b3 to b0 in their configuration of register must set to 0.

where am I wrong? I can't see it, would you please explain more?



Re: how to renew the data in endpoint 4

aasi posted on 08 Jun 2011 06:01 AM PST
Cypress Employee
1090 Forum Posts

From the initialization code that you attached my understanding is that you're configuring just EP4 and EP8.

In case you are configuring EP2 and EP6 as well and in a valid FIFO configuration, are you ARMing all the OUT endpoints?

 

In your buffer filling logic you're seeing if there is a packet in EP4 and then filling EP8 and then discarding EP4 data but you are not checking if EP8 is free. So say when you send 3 packets, based on first 2 packets EP8 is filled and the 2 packets of EP4 discarded. When the 3rd packet is processed (assuming you've not read EP8 by then) there is no space in EP8 and you cannot write to the committed buffer space but your logic will still discard the 3rd EP4 packet. This is most probably the mystery behind the missing packet :D

You might want to introduce code to EP8 has space and then based on that process and discard EP4 data if only if the packet has been processed.

Regards,

Anand

 



Re: how to renew the data in endpoint 4

mrjun posted on 08 Jun 2011 06:13 AM PST
Senior Member
17 Forum Posts

according "cmdcode= EP4FIFOBUF[0]", if the data in ep4 buffer don't read out, the latest data will be ignored. but how can I throw away the dirty data and pass the useful data (in this code is "if(cmdcode>=0x71)" correctly?



Re: how to renew the data in endpoint 4

aasi posted on 08 Jun 2011 09:56 AM PST
Cypress Employee
1090 Forum Posts

Now you lost me.

My understanding was that the 3rd packet that you sent was not getting processed. What you mean when you say dirty data?

Would it be possible to post your entire code here?

Regards,

Anand



Re: how to renew the data in endpoint 4

mrjun posted on 09 Jun 2011 02:05 AM PST
Senior Member
17 Forum Posts

thanks for aasi's reply

you're right .for I am not using ep2 and EP6 now and  I have masked configuring EP2 and EP6 . do you mean that in a valid FIFO configuration, I can't do that?

my logic actually really discard the 3rd EP4 packet when the 3rd packet is processed and I have not read EP8 by then, but I want to discard 1st ep4 packet when that had happened. to me, the latest data is more useful. at that time, the 1st to mean is not important.

in other word, can I find a way to make ep8 valid by firmware instead throngh PC reading ep8 (ep8 in)?

I don't mean to post my entire code here, I just need  2nd and 3rd, and the 1st can be discarded.



Re: how to renew the data in endpoint 4

aasi posted on 09 Jun 2011 03:38 AM PST
Cypress Employee
1090 Forum Posts

mrjun,

Yes. You should not disable EP2 and EP6 just because you're not using it. You've to be in a valid FIFO configuration irrespective of whether you're using the endpoint at that point of time or not.

 

I've a vague idea of what you're trying to implement

I assume test() is being called within a while(1) loop i.e. it is called from time to time.

Here is what I want you to try

Put the following part of your code

<b> if(!(EP2468STAT & bmEP4EMPTY))  
     {
     count = (EP4BCH << 8) + EP4BCL;
  cmdcode= EP4FIFOBUF[0];

        // loop EP4OUT buffer data to RAMBUF
        for( i = 0x0000; i < count; i++ )
        {
         RAMBUF(0x200+i)=EP4FIFOBUF[i];
        }
   RAMBUF(0x3FE) =1;
        SYNCDELAY; 
 

 if(cmdcode>=0x71)

  {
   
   for( i = 0x00; i < count; i++ ) 
         {
       EP8FIFOBUF[i]=cmdcode+i;   
    
         }  
      SYNCDELAY;    
          
   EP8BCH = 0x02;
      SYNCDELAY;                //
      EP8BCL = 0x00;
      SYNCDELAY;
    }
else INPKTEND=0X88;//    
 }   
  OUTPKTEND=0X84; 
   SYNCDELAY;</b>

inside the following if statement

if(!(EP2468STAT & bmEP8FULL))  
{

}

This way you should see all 3 packets getting processed.

Regards,

Anand



Re: how to renew the data in endpoint 4

mrjun posted on 10 Jun 2011 01:20 AM PST
Senior Member
17 Forum Posts

aasi,following your suggest, I configure the ep2 and ep6 as below:

EP2CFG = 0xA2;// 1010 0010 valid out bulk 512 0 x2 

 EP6CFG = 0xE2; //valid in bulk 512 0 x2

I  debug the code as you give, more problems happen.

e.g.

ep4 out  80(512bytes),81(512bytes),82(512bytes),83(512bytes),84(failed)--- why 4 times?

then ep8 in  80 to 7f (right); in again,81 to 80 then failed and out failed too.

that means the last 1024 bytes have strucked in buffer and I still can't get the latest data.

if I remain 512 bytes for ep4 (ep4 out 83(512bytes)after ep8 in instead before) ,the data in ep8 as above. 

in my opinion, if there's not a instruction to clear ep4 buffer directly, to keep data in ep4 buffer newest is very hard, even impossible. by transmitting,only when old data transmit that I can get the newest.( I am not sure that  is right or not)

another question, in this situation , need I configure ep4 and ep8 the same mode, both bulk or interrupt?

and what's the diffrence between " INPKTEND=0X88" and " INPKTEND=0X08"? the former firmware will skip ep8 and the latter will commit. but why when I read ep8, the frmer is failed and the latter return "0000"?



Re: how to renew the data in endpoint 4

aasi posted on 10 Jun 2011 02:02 AM PST
Cypress Employee
1090 Forum Posts

Mrjun,

The modification I suggested won't skip the EP4 packet if the packet hasn't been processed.

The 4 times is because of this, 2 packets (EP8 double-buffered) of EP4 are processed and skipped. Then 2 more packets are accepted by EP4 (double-buffered). If test() is not run in a while loop (I clearly stated my assumption in the previous response) the 2 packets in EP4 won't be processed that is why you are seeing EP8 failing after 2 transfers.

I'm not able to get the full picture of your application. Can you please post your entire code here?

Regards,

Anand



Re: how to renew the data in endpoint 4

mrjun posted on 18 Jun 2011 06:36 AM PST
Senior Member
17 Forum Posts

aasi, I'm sorry for out so many days and can't reply your request in time. I don't think it wise to pose it here ,can I email it to you. besides, what're your need, the whole project or just the part of the function(a  c file)?



Re: how to renew the data in endpoint 4

aasi posted on 24 Jun 2011 06:09 AM PST
Cypress Employee
1090 Forum Posts

Mrjun,

Sorry for the delay. Missed this thread somehow.

If it is not safe to post the code here it would be a good idea to open a tech support case (MyAccount -> MyCases) so that one of our engineers can help you with this.

Regards,

Anand

 






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: KXP; Secondary Owner: VWA; Sunset Date: 01/01/20