AnsweredAssumed Answered

STM32F429 USB Host

Question asked by rusu.mihnea on Nov 1, 2015
Latest reply on Nov 26, 2015 by Hancockst.Neil_st
Hey guys,

I've been trying to create USB FS host drivers for a vendor-specific device on the STM32F429 Discovery board. So far I've not had any luck getting ANY device (be it from the MSC, HID or Vendor classes) to simply enumerate (which doesn't require any special drivers). I'm just plain stuck. Before you ask, yes there is power on the USB port.

I've been using CubeMX to generate the codes and I'm programming using Keil MDK-ARM uVision 5. Initially the main state machine in USBH_Process() (of usb_core.c) would be forever stuck at HOST_IDLE. I fixed this by adding calling USBH_LL_Connect() in USBH_Start(), as this is the function that seemingly changes the device's status to connected. I've also modified the HOST_DEV_WAIT_FOR_ATTACHMENT state to go to HOST_DEV_ATTACHED, otherwise it would do nothing. Now the state machine gets stuck at HOST_DEV_ATTACHED and every status that returns from deeper within the code is USBH_BUSY. 

Below is my clock initialisation, as generated by CubeMX. It seems to be OK (HSE is at 8MHz) but maybe the USB speed is not 48MHz. I read of people having had problems with this in the past, but I don't think it's the case here.

01.void SystemClock_Config(void)
02.{
03. 
04.  RCC_OscInitTypeDef RCC_OscInitStruct;
05.  RCC_ClkInitTypeDef RCC_ClkInitStruct;
06. 
07.  __PWR_CLK_ENABLE();
08. 
09.  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
10. 
11.  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
12.  RCC_OscInitStruct.HSEState = RCC_HSE_ON;
13.  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
14.  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
15.  RCC_OscInitStruct.PLL.PLLM = 8;
16.  RCC_OscInitStruct.PLL.PLLN = 336;
17.  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
18.  RCC_OscInitStruct.PLL.PLLQ = 7;
19.  HAL_RCC_OscConfig(&RCC_OscInitStruct);
20. 
21.  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1
22.                              |RCC_CLOCKTYPE_PCLK2;
23.  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
24.  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
25.  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
26.  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
27.  HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
28. 
29.  HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
30. 
31.  HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
32. 
33.  /* SysTick_IRQn interrupt configuration */
34.  HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
35.}

Please if anyone could help me, I don't know how much hair I have left to pull on this problem... I just want to get a device to enumerate and be able to browse through its enumeration data in the debugger (VID, PID, etc.).

Outcomes