cancel
Showing results for 
Search instead for 
Did you mean: 

STM32Cube, USB and double buffer

baoshi
Associate
Posted on October 16, 2015 at 04:08

I have been trying STM32Cube software on STM32F072C8T6, specifically on the USB middleware.

My program is as simple as declare an OUT BULK endpoint. I'm toying around the idea of double buffering.

So in USBD_LL_Init I did

HAL_PCDEx_PMAConfig(pdev->pData, 0x01, PCD_DBL_BUF, 0x010000C0);

I'm missing half of the reception now. Here is some findings:

1. in stm32f0xx_hal_pcd.c, function HAL_PCD_EP_Receive, the PMA buffer count setting is PCD_SET_EP_DBUF1_CNT(hpcd->Instance, ep->num, ep->is_in, len);

I believe it should be PCD_SET_EP_DBUF_CNT(hpcd->Instance, ep->num, ep->is_in, len); as referenced from non-cube firmware.

2. In PCD_EP_ISR_Handler, PCD_GET_EP_DBUF1_CNT always give me 0, this can be confirmed by looking at registers in memory 0x4000600E/0x4000600F. Despite the counter problem, the package is actually received and appear at 0x40006100.

3. USB_EP1R always give same RTOG_RX and SW_BUF value (0,0 or 1,1) during toggling. Should this be (1,0) or (0, 1)

Having been trying for 2 days without any success. Any advise will be appreciated.

Baoshi

#stm32cube-usb-double-buffer
1 REPLY 1
baoshi
Associate
Posted on October 21, 2015 at 03:26

I tried same code withSTM32F0x2_USB-FS-Device_Lib V1.0.0, doing

DCD_PMA_Config(pdev, CUSTOM_EPIN_ADDR, USB_SNG_BUF, 0x40);
DCD_PMA_Config(pdev, CUSTOM_EPOUT_ADDR, USB_DBL_BUF, 0x00c00080);
// Open EP IN
DCD_EP_Open(pdev, CUSTOM_EPIN_ADDR, CUSTOM_EPIN_SIZE, USB_EP_BULK);
// Open EP OUT
DCD_EP_Open(pdev, CUSTOM_EPOUT_ADDR, CUSTOM_EPOUT_SIZE, USB_EP_BULK);
// Prepare Out endpoint to receive next packet
DCD_EP_PrepareRx(pdev, CUSTOM_EPOUT_ADDR, RxBuffer, CUSTOM_EPOUT_SIZE);

inside class Init. I observe exact the same thing, count received from DblBuf1 is alway 0 Anyone can help please ?