cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with USB EP6 Tx Double Buffering

rgreenthal
Associate II
Posted on September 26, 2008 at 18:54

Need help with USB EP6 Tx Double Buffering

1 REPLY 1
rgreenthal
Associate II
Posted on May 17, 2011 at 09:55

Please Help!

I have tried everything I can think of & have the Double Buffering working for Rx on EP1, 2, & 4.

I have gotten Simple Tx for this EndPoint working for EP6

And Added all the code to do Double Buffering

When I do an EP_KIND, i.e. SetEPDoubleBuff(ENDP6); // Make a Double buffer endpoint

I also added the IRQ for USBHP_IRQHandler() calling CTR_HP()

It all stops working!

The code STOPS WORKING, I send data to USB Buffers & make them VALID

I also commented out the line

// _ToggleDTOG_RX(ENDP6);

So that I would ALWAYS go to the proper buffers for Simple Tx

Just to help verify all was working, no data is going to the Host/PC

nullI put the Data in the Buffer & That Buffer ALWAYS stays VALID

What am I doing wrong?

The Init code for EP6

// *********************************************

// Initialize Endpoint 6 IN

// Transmit, Kick off the USB data to be sent

// Need to change Packet/Count to > 64

// and set BLsize bit so we can TX to 512 bytes

// WARNING:

// DO NOT do Double Buffering for now

// Simple buffering is working with all code to do Double Buffering

// Do a Double buffer of 512 Bytes, 128 unsigned short

// *********************************************

_SetEPAddress(ENDP6, 6);

// setup USB_EP6R

_SetEPType(ENDP6, EP_BULK);

// Set up USB_Counter6, do Tx for Double Buffered

// set Double Buffer register for larger packets

// SetEPDoubleBuff(ENDP6); // Make a Double buffer endpoint

SetEPDblBuffAddr(ENDP6, ENDP6_TXADDR1, ENDP6_TXADDR2);

SetEPDblBuffCount(ENDP6, EP_DBUF_IN, 0); // Set Count =0 & BLsize

_ClearDTOG_RX(ENDP6);

_ToggleDTOG_RX(ENDP6);

_ClearDTOG_TX(ENDP6);

// Sets the Endpoint Tx Status as Not valid

_SetEPRxStatus(ENDP6, EP_RX_DIS);

_SetEPTxStatus(ENDP6, EP_TX_NAK);

Now the code to load the PMA Buffer & enable it:

// ***********************************

// Check to do Double Buffering

// Ping-Pong between the two Buffers

// ***********************************

if ((_GetENDPOINT(ENDP6) & EP_DTOG_RX) == 0)

{

// THIS IS Working

// Reset buffer 0 Tx

SetEPDblBuf0Count(ENDP6, EP_DBUF_IN, usUSBMirrorTailIndx);

UserToPMABufferCopy(ucUSBMirrorBuffer, ENDP6_TXADDR1, usUSBMirrorTailIndx);

_SetEPTxStatus(ENDP6, EP_TX_VALID); // Data Valid so USB can now Transmit it

}

else

{

// Transmit to buffer 1 Rx

// Reset buffer 1

SetEPDblBuf1Count(ENDP6, EP_DBUF_IN, usUSBMirrorTailIndx);

UserToPMABufferCopy(ucUSBMirrorBuffer, ENDP6_TXADDR2, usUSBMirrorTailIndx);

_SetEPRxStatus(ENDP6, EP_RX_VALID); // Data Valid so USB can now Transmit it

}

// WARNING

// NOT Toggling for NOW

// FreeUserBuffer(ENDP6, EP_DBUF_IN); // Toggle DTOG Status to next Buffer

/* function pointers to non-control endpoints service routines */

void (*pEpInt_IN[9])(void)={

EP1_IN_Callback, // empty routine

EP2_IN_Callback,

EP3_IN_Callback,

EP4_IN_Callback,

EP5_IN_Callback,

EP6_isr, // IN

EP7_IN_Callback,

EP8_IN_Callback,

EP9_IN_Callback,// only 9 endpoint in the STR9

};