cancel
Showing results for 
Search instead for 
Did you mean: 

How to use the USB ISO IN Endpoint

loginov
Associate
Posted on June 21, 2012 at 09:40

Hello.

I have a probem with the ISO IN Endpoint. Double buffering is not working.

The STM32F103RD is sending right data only from one buffer. Data from another buffer is wrong.

My code:

  /* Initialize Endpoint 1 */

  SetEPType(ENDP1, EP_ISOCHRONOUS);

  SetEPDblBuffAddr(ENDP1, ENDP1_BUF0Addr, ENDP1_BUF1Addr);

  ClearDTOG_RX(ENDP1);

  ClearDTOG_TX(ENDP1);

  ToggleDTOG_RX(ENDP1);

  SetEPTxStatus(ENDP1, EP_TX_NAK);

  SetEPRxStatus(ENDP1, EP_RX_DIS);

void SOF_Callback(void)

{

  if(bDeviceState == CONFIGURED)

  {

  

  if (GetENDPOINT(ENDP1) & EP_DTOG_RX)

  {

    /*write to ENDP1_BUF0Addr buffer*/

UserToPMABufferCopy(USB_Buf, ENDP1_BUF0Addr, USB_Idx);

SetEPDblBuf0Count(ENDP1,EP_DBUF_IN ,USB_Idx);

  }

  else

  {

    /*write to ENDP1_BUF1Addr buffer*/

   UserToPMABufferCopy(USB_Buf, ENDP1_BUF1Addr, USB_Idx);

SetEPDblBuf1Count(ENDP1,EP_DBUF_IN ,USB_Idx);

  }

  SetEPTxValid(ENDP1); 

  }

}

Is anyone know what is a problem?
1 REPLY 1
tsuneo
Senior
Posted on June 22, 2012 at 21:23

At initialization,

SetEPTxStatus(ENDP1, EP_TX_NAK);  <--- SetEPTxStatus(ENDP1, EP_TX_VALID);

NAK is not allowed on isoc endpoint. Just VALID or DISable.

In SOF_Callback(void),

SetEPTxValid(ENDP1);   <--- FreeUserBuffer(ENDP1, EP_DBUF_IN);

TX status doesn't change after transmission. It stays in VALID. So, doesn't need to make it VALID.

FreeUserBuffer() toggles DTOG_RX

Tsuneo