cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to make a USB HID mouse from cube mx

lrou13
Associate II
Posted on November 21, 2016 at 07:04

i have tryed to make working an usb hid mouse program (simulating mouse move) from cubemx: usb_otg_fs

folowing youtube stm sample:

https://www.youtube.com/watch?v=XRocqTfUxbo

0690X0000060MoOQAU.gif

my platform is STM32F746DISCO

cubemx 1.5.1

i have also added blinking led: this part is working, the usb part don't do anything, the mouse isn't view when i connect it on the PC (no enumeration) and of course no mouse movement

i have tryed to add # USE_USB_FS in the Precompiler but nothing more!

then i tryed other platform stm32f3 discoand stm32f4disco and it's working!

could you help me please i am out of idea.

3 REPLIES 3
slimen
Senior
Posted on November 21, 2016 at 13:01

Hello,

It seems you are confusing CubeMx/firmware versions: STM32CubeMx version 4.17.0 and

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-embedded-software/stm32cubef7.html

fimware package version 1.5.1

Make sure that you've configured the right pins compared to the datasheet of used 

http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-eval-tools/stm32-mcu-eval-tools/stm32-mcu-discovery-kits/32f746gdiscovery.html

 .

You can refer to your product datasheet and reference manual for more clarification about your product.

I Suggest you start with a working USB example similar to your application for your used discovery to identify what is going wrong in your case. 

In the STM32CubeF7 package, you may find a HID example in this folder: STM32Cube_FW_F7_V1.5.1\Projects\STM32746G-Discovery\Applications

Regards

lrou13
Associate II
Posted on November 23, 2016 at 08:55

hi,

yes sorry for confusion cube mx 4.0 & firmware 1.5.1

i have worked on the usb example (working) i have looked on the configuration of the gpio and dont find difference. i also look the clock seem to be nearly the same.

i have tryed to modify the little things that differ from the sample but no result.

my collegue got the same result on hisbench with another stm32f7disco.

maybe its a configuration in cube mx but dont see where.

i attach the main.c if you want to look.

________________

Attachments :

main.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzKY&d=%2Fa%2F0X0000000bNw%2FlkhZgFAG3UC7PBqmihZfnHw_CI.X7FT.nKsL6SBchb0&asPdf=false
lrou13
Associate II
Posted on November 24, 2016 at 14:32

Eureka!!

i have find the problem: its coming from the usbd_conf.c

2 values are wrong in the file generated by the cube!

USBD_StatusTypeDef

USBD_LL_Init (

USBD_HandleTypeDef

*pdev)

{

/*

Init

USB_IP */

if

(pdev->

id

== DEVICE_FS) {

/* Link The driver to the stack */

hpcd_USB_OTG_FS.

pData

= pdev;

pdev->

pData

= &hpcd_USB_OTG_FS;

hpcd_USB_OTG_FS.

Instance

= USB_OTG_FS;

hpcd_USB_OTG_FS.Init.dev_endpoints = 6;//<--Wrong value should be 4 

hpcd_USB_OTG_FS.

Init

.

speed

= PCD_SPEED_FULL;

hpcd_USB_OTG_FS.

Init

.

dma_enable

=

DISABLE

;

hpcd_USB_OTG_FS.

Init

.

ep0_mps

= DEP0CTL_MPS_64;

hpcd_USB_OTG_FS.

Init

.

phy_itface

= PCD_PHY_EMBEDDED;

hpcd_USB_OTG_FS.

Init

.

Sof_enable

=

DISABLE

;

hpcd_USB_OTG_FS.

Init

.

low_power_enable

=

DISABLE

;

hpcd_USB_OTG_FS.

Init

.

lpm_enable

=

DISABLE

;

hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE;//Wrong value should be

 

DISABLE

hpcd_USB_OTG_FS.

Init

.

use_dedicated_ep1

=

DISABLE

;

if

(HAL_PCD_Init(&hpcd_USB_OTG_FS) !=

HAL_OK

)

{

Error_Handler();

}

HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80);

HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x40);

HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x80);

}

return

USBD_OK

;

}