cancel
Showing results for 
Search instead for 
Did you mean: 

STR7 packet buffer USB limitation

francesco23
Associate II
Posted on October 30, 2008 at 10:34

STR7 packet buffer USB limitation

11 REPLIES 11
francesco23
Associate II
Posted on May 09, 2006 at 08:54

Hi guys,

I have a doubt about the capabilities of STR710 to reach the maximum frame rate for USB expected in Full Speed:

could you confirm this below sentence:

by STR7 reference manual, I read that packet buffer is 512 byte limited, but the packet buffer contains data that PC and STR7 exchange through EndPoint; by this I deduce that for Bulk transfer, I can exchange 512 byte max per frame, this mean 512KByte/sec less than 1500KByte/sec of Full Speed Specification !!!

Is it correct all that I explained or there is a way ables to encrease this limitation?

Thank a lot,

Bassof

anis23
Associate II
Posted on May 10, 2006 at 07:15

Hi,

There is no limitation with the Packet Memory Area (PMA) in the STR710 µc. In fact, according to the USB specification the maximum packet size of one bulk transaction in full speed mode is only 64Bytes, but a PC host can perform 19 bulk transactions (with 64Bytes each) in one single frame. That means a maximum Bandwidth equal to 1216000 Bytes/s (please see the USB 2.0 specification chapter 5 (section 5.8.4)). With the STR710 we have 512Bytes of PMA so we can use more than one Bulk Endpoint with the maximum transaction size (64Bytes) and -theoretically- with the maximum Bandwidth (it depends only on the execution time of your implemented code).

Regards,

AnisAS

francesco23
Associate II
Posted on May 10, 2006 at 11:10

Thanks a lot AnisAs,

by your answear, I understand that for transfer 512 byte (from STR710x uC to PC) in Bulk Mode, I have divide 512 Byte in 8 packet of 64Byte each one ... my question is:

does a similar (below) C code have to be implemented?

for (i=0; i

{

// RBuffer already filled

UserToPMABufferCopy(RBuffer, DATA_IN_EP4_ADDR, 0x1C0);

//enable endpoint for transmission

SetEPTxAddr(ENDP2, DATA_IN_EP2_ADDR);

SetEPTxCount(ENDP2, 0x40);

SetEPTxValid(ENDP2);

}

If not, could you provide me a elementary C code to transfer 512Byte (STR710x uC to PC) in Bulk Mode?

Once more thanks

Bassof

anis23
Associate II
Posted on May 10, 2006 at 12:50

Hi Bassof,

In fact your code will not works because you have to write the data in PMA using the function ''UserToPMABufferCopy ()'' with a size of 64 bytes maximum. So you have to divide your 512bytes of data into 8 packets and copy them one by one in the PMA.

Please see below an elementary example of C code.

i=1;

EP2_Callback ()

{

if (i

{

// RBuffer already filled

UserToPMABufferCopy(RBuffer+i*64, DATA_IN_EP2_ADDR, 0x40);

// enable endpoint for transmission

SetEPTxAddr(ENDP2, DATA_IN_EP2_ADDR);

SetEPTxCount(ENDP2, 0x40);

SetEPTxValid(ENDP2);

i++;

}

}

Note:

1- As you know, the USB IP of the STR71x is based on interrupt mode (not on polling mode) so this kind of C code shall not be executed using a ''for'' loop... this routine shall be called after a correct transfer interrupt.

2- you have to provide the copy of the first 64bytes of data in PMA and set the endpoint as valid to enable the first transaction and after the achievement of this transaction the function ''EP2_Callback ()'' will provide the management of the next 7 transactions one by one.

Regards,

AnisAS

francesco23
Associate II
Posted on May 11, 2006 at 06:54

Hi AnisAs,

I tried your C code in my firmware, but to ensure the correct transfer of all 512 Byte, I must manage the 8 64byte-Packet transfer by High Level SoftWare by performing 8 reading of Bulk type 64 Byte long ... my question is: by acting in such a way, 8 single transfering will be performed in 8 msec? Does is it correct my doubt or not?

how you would make by High Level software (PC side) this transfer?

Best regards,

Bassof

anis23
Associate II
Posted on May 11, 2006 at 10:38

Hi Bassof,

I’m sorry, I didn’t have a big idea on PC software side. All my focus is in the Firmware development. But according to my knowledge in the USB specification, the PC host can perform more than one bulk transaction in a single frame (so more than one transaction per msec, in fact I think you can read all the 512bytes in one frame if your firmware can perform the 8 copy operations into the PMA in less then 1msec). You can see the example of any mass storage device: in fact this class uses the bulk transfer and the native windows driver can send a number of IN (or OUT) up to 19 per frame (in full speed mode).

Regards,

AnisAS

francesco23
Associate II
Posted on May 11, 2006 at 12:38

Hi AnisAs,

thanks for your answear, but I resolved my previous doubt, infact, PC host can performs more transaction in 1 msec (for Bulk transfer mode up to 19).

New problems concern Write Operation (PC to STR7):

I'm manage this operation like Read (STR7 to PC) operation, below you can read a minimal C code:

void EP3_calback(void)

{

if (PacketIndex < PacketCount) // PacketCount = 0x08;

{

PMAToUserBufferCopy(buffer + PacketIndex*0x40, DATA_OUT_EP3_ADDR, 0x40);

PacketIndex ++;

SetEPRxAddr (ENDP3, DATA_OUT_EP3_ADDR);

SetEPRxCount(ENDP3, 0x40);

SetEPRxValid(ENDP3);

}

}

with this code, only first 64 byte it comes transfered ... after, STR7 does not respond to interrupt (EP3_calback routine does not come called).

Could you provide me another precious help?

Infinite thanks,

Bassof

(note: are you ST engineer ?)

anis23
Associate II
Posted on May 12, 2006 at 06:03

Hi Bassof,

Did you initialize the ''PacketIndex ? are you sure about the transaction from the PC side?

I have also some remarks about your code:

1- you don’t have to specify the Rx address in each interruption (function ''SetEPRxAddr()''). You have to specify this address only ones in the reset interrupt and it is also the case for IN endpoint.

2- With OUT endpoint you don’t have to set the count of the endpoint (except ones in the reset interrupt to specify the range or the maximum data expected by the endpoint). This field is set automatically by the hardware after receiving the data from the host and according to the number of bytes received.

Regards,

AnisAS

francesco23
Associate II
Posted on May 12, 2006 at 08:45

Hi AnisAs,

Thanks for your answear, last question I promise :D

what do you mean with '' reset interrupt ''? how can I heandle this interrupt? Could you provide me an example (project or a minimal C code) to explain this?

All your suggestions are been precious,

Thanks a lot,

Francesco dot Basso @ st dot com (are you my colleague?) 😉