AnsweredAssumed Answered

cubexmx usb hid code generation for stm32f411

Question asked by rlong.001 on Sep 2, 2015
Latest reply on Sep 23, 2015 by longr
Hi

I have a custom board with a stm32f411. 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


v5mp1MN.png?1


Pin configurationwPCASAg.png?1
   
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 */
 
}

Outcomes