Skip to main content
Felix1
Associate
November 27, 2018
Question

STM32F302 use USB double buffer, the transmit data will over buffer setting

  • November 27, 2018
  • 1 reply
  • 1743 views

Hi All

Hardware: STM32F302

Software: STM32Cube_FW_F3_V1.10.0

As below is USB descriptor

/* USB Speaker Audio Streaming Descriptor */

 0x07,         /*bLength: Endpoint Descriptor size*/

 USB_DESC_TYPE_ENDPOINT, /*bDescriptorType:*/

 AUDIO_OUT_EP1, /*bEndpointAddress: Endpoint Address (IN)*/

 USBD_EP_TYPE_ISOC,         /*bmAttributes: */

 0xe0, /*wMaxPacketSize: 2 Byte max */

 0x00,

 0x01,         /*bInterval: */

 /* 07 byte*/

      

      /* USB Mic Audio Streaming Descriptor */

 0x07,         /*bLength: Endpoint Descriptor size*/

 USB_DESC_TYPE_ENDPOINT, /*bDescriptorType:*/

 AUDIO_IN_EP1,

 USBD_EP_TYPE_ISOC,         /*bmAttributes: */

 0x80, /*wMaxPacketSiz */

 0x00,

 0x01,         /*bInterval:)*/

 /* 07 byte*/

and double buffer setting

HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , AUDIO_OUT_EP1 , PCD_DBL_BUF, 0x01F80118);

 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , AUDIO_IN_EP1 , PCD_DBL_BUF, 0x031802D8);

When use API USBD_LL_Transmit (pdev,AUDIO_IN_EP1,(uint8_t*)(mic_buffer),0x36);

to transmit data, the data will over my buffer setting, the transmit data around 400 bytes.

How to fixed this problem?

Thanks.​

    This topic has been closed for replies.

    1 reply

    Ben K
    Senior III
    November 27, 2018

    The USB peripheral's HAL driver (PCD) has a known limitation: it directly maps EPnR register numbers with endpoint addresses. This works if all OUT and IN endpoints with the same number (e.g. 0x01 and 0x81) are the same type, and not double buffered. However, isochronous endpoints have to be double buffered, therefore you have to use an endpoint number that's unused in the other direction. E.g. in your case, set AUDIO_OUT_EP1 to 0x01, and AUDIO_IN_EP1 to 0x82. (Or you can drop this USB stack altogether as I did.)

    alfichua
    Visitor II
    November 28, 2018

    Hi,

    I had a similar issue and had used a different endpoint value for the audio out (0x05) and audio in(0x86).

    Could you provide some advise on how to proceed without using the USB stack? If there is any sample, it would be better =)

    Thanks.

    Ben K
    Senior III
    November 28, 2018

    I made this library: https://github.com/IntergatedCircuits/USBDevice

    https://github.com/IntergatedCircuits/USBDevice4Cube

    This lets you use any valid endpoint numbers. However there's no support for Audio class atm.