cancel
Showing results for 
Search instead for 
Did you mean: 

cubexmx usb hid code generation for stm32f411

ruairi
Associate
Posted on September 02, 2015 at 23:10

Hi

I have a custom board with a stm32f4 I am trying to use cubmx to generate a usb HID project but the generated code does not work. The board appears as an unrecognized device when I attach it to my computer. My board uses a 16 MHz crystal oscillator attached to PHI and PH0. Clock configuration 0690X00000604WWQAY.png Pin configuration 0690X00000604s6QAA.png

I added a call to USBD_HID_SendReport in the while loop of the main function. supporting this was the only change I made to the generated code from cubemx.

Are there any other changes I need to make to the generated code to make this appear as an HID device on my computer?

int
main(
void
)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USB_DEVICE_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while
(1)
{
USBD_HID_SendReport(&hUsbDeviceFS, testReport,4);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}

5 REPLIES 5
Posted on September 04, 2015 at 16:27

Hi rlong.00,

You should add these three APIs:

-USBD_init()

-USBD_RegisterClass()

-USBD_Start()

For more details, have a look at

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

 (page 19)

-Shahrzad-

ruairi
Associate
Posted on September 16, 2015 at 00:45

Hi shahrzad

The function MX_USB_DEVICE_Init calls those functions you mentioned; It was generated by cubemx and is called in the main function.

Rosiney Silva
Associate II
Posted on September 22, 2015 at 18:26

In

his figure

the

''System

Clock

Mux

''

is set to ''

HSI''

when it should be

''

PLLCLK''

.

rlong
Associate
Posted on September 23, 2015 at 20:53

 Hi Silvva

I switched the clock source.

Now I am seeing this error message in the device manager which I have not seen before.

This device is disabled because the firmware of the device did not give it the required resources. (Code 29)

rlong
Associate
Posted on September 23, 2015 at 20:53

Hi Silvva

I switched the clock source.

Now I am seeing this error message in the device manager which I have not seen before.

This device is disabled because the firmware of the device did not give it the required resources. (Code 29)

________________

Attachments :

clockConfig.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Htk0&d=%2Fa%2F0X0000000aWR%2FG14JZDXbkS.6TCZtfy8RYrm_kkRfFZoG2vEvuEtAGiQ&asPdf=false