Skip to main content
martintramsak9
Visitor II
July 1, 2016
Question

STM32F072 USBD_LL_Transmit problem

  • July 1, 2016
  • 1 reply
  • 1146 views
Posted on July 01, 2016 at 11:04

I'm using STM32F072 MCU in USB Device mode. The USB enumerates nicely creating 1 interface and 2 bulk endpoints. One input and one output. Both with the maximum transfer size 64 bytes.

The problem occurs when I try to transfer more than 16 bytes of data. The transfer data is OK when I transfer less than 16 bytes but gibberish when I transfer more than 16 bytes in a single packet. I am analyzing the stream on a USB analyzer. 

I have opened the endpoints and I transfer data with USBD_LL_Transmit function. 

I am using HAL libraries

Any ideas what I am doing wrong ?

#stmf0 #hal #usb #usb #stm32f0
This topic has been closed for replies.

1 reply

tsuneo
Associate II
July 2, 2016
Posted on July 02, 2016 at 13:56

Hi martin,

Sound like a problem around assignment of endpoint buffer address for the bulk endpoint, using HAL_PCDEx_PMAConfig().

Using ''search files'' function of your editor, find code lines like this one,

  HAL_PCDEx_PMAConfig(&hpcd , 0x00 , PCD_SNG_BUF, 0x18);     // EP0 OUT

  HAL_PCDEx_PMAConfig(&hpcd , 0x80 , PCD_SNG_BUF, 0x58);     // EP0 IN

  HAL_PCDEx_PMAConfig(&hpcd , 0x01 , PCD_SNG_BUF, 0x100);    // EP1 OUT

  HAL_PCDEx_PMAConfig(&hpcd , 0x81 , PCD_SNG_BUF, 0x140);    // EP1 IN

HAL_PCDEx_PMAConfig() assigns starting address of endpoint buffer on USB RAM to each endpoint.

- You should have four lines of HAL_PCDEx_PMAConfig(), for the default EPs (EP0 IN/OUT) and the two bulk EPs.

Above example assumes EP1 IN/OUT for the bulk EPs. To keep 64 bytes buffer for EP1 OUT (starting at 0x100), EP1 IN starts at 0x140. Modify your code like above one.

Tsuneo

yshen.6
Visitor II
October 30, 2018

I Modify my code like above,but the  problem also occurs .what can i do ? the mcu is stm32l433rct.