cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 USB Endpoint question

hohaha0217
Associate II
Posted on August 14, 2015 at 09:35

Hi! 

I used CubeMx to generated USB HID Device example code and  update to F4_Discovery Kit.

The default endpoint address is 0x01 and 0x81. I could send data from PC to STM32F4 via USB. and STM32F4 also could send data to PC.

But. when I modified the endpoint address to 0x02 and 0x82, the PC could not received data form STM32F4.

Is anyone has the same experience can help me solve this issue?

I just modified below defines 

&sharpdefine CUSTOM_HID_EPIN_ADDR                 0x82

&sharpdefine CUSTOM_HID_EPOUT_ADDR                0x02

the file is ''usbd_customhih.h''

Stm32CubeMX version: V4.8.0

STM32CubeF4 Firmware Package V1.6.0 

Thanks.

Chansong

#usb-endpoints-change
6 REPLIES 6
Nesrine M_O
Lead II
Posted on August 14, 2015 at 10:59

Hi lee.chansong,

I tried the example under STM32Cube_FW_F4 package:

STM32Cube_FW_F4_V1.7.0\Projects\STM324x9I_EVAL\Applications\USB_Device\HID_Standalone.

I make the following modifications: 

1. In usbd_hid.h file I modified the endpoint address:

#define HID_EPIN_ADDR       0x82

2. In usbd_conf.c file:

In the function USBD_StatusTypeDefUSBD_LL_Init(USBD_HandleTypeDef *pdev):

I modified:  

HAL_PCDEx_SetTxFiFo(&hpcd, 1, 0x80); =>  HAL_PCDEx_SetTxFiFo(&hpcd, 2, 0x80);

I did a test and it works correctly.

 -Syrine-

Nesrine M_O
Lead II
Posted on August 14, 2015 at 11:26

Have a look to the FIFO RAM allocation paragraph in the

http://www.st.com/st-web-ui/static/active/en/resource/technical/document/reference_manual/DM00031020.pdf?s_searchtype=keyword

, it can be useful.

-Syrine-

hohaha0217
Associate II
Posted on August 14, 2015 at 11:42

Hi! Syring

Thanks for your quickly reply.

I followed your suggestion and it work fine.

I also did another test, to keep ''HAL_PCD_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x80); '', and add ''HAL_PCD_SetTxFiFo(&hpcd_USB_OTG_FS, 2, 0x80); ''

The PC can not received data for USB EP2. What is the reason to cause the PC can not receive USB data?

Thanks

Chansong

Nesrine M_O
Lead II
Posted on August 14, 2015 at 13:01

I don't understand why do you keep ''HAL_PCD_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x80); ''

What is the reason from this modification? What do you think doing?

-Syrine-

hohaha0217
Associate II
Posted on August 17, 2015 at 03:52

Hi!

Because I went to try Implement USB Composite device and declare 2 endpoint.

Does CubeMx can generate USB composite device sample code?

And could you please provide some suggestion about USB composite? 

Thanks

Chansong

stm32cube-t
Senior III
Posted on August 24, 2015 at 15:31

Hello Chansong,

STM32CubeMX does not support code generation for composite classes as it is not yet supported by the USB middleware library coming with STM32Cube embedded software packages.

Best regards.