0
votes

I've been attempting to develop a USB HID device using the STM32F3DISCOVERY board as my basis, generating my project with STM32CubeMX and the HAL library.

I've soldered my external crystal as per the User Manual UM1570, Section 6.10.1, using a 12MHz external crystal oscillator.

When my system clock is configured, STM32CubeMX generates the following lines for the oscillator initialization:

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
  _Error_Handler(__FILE__, __LINE__);
}

My project is built in Atollic TrueStudio, uploaded, and debugged using the ST-LINK interface. I have not changed any of the default configuration settings for either project nor debug. When debugging, the error handler is called.

My assumption at this stage is that due to the HSE bypass required to clock the STM32F3VC device on board, the clock configuration cannot be achieved, for reasons unapparent to me. After flashing, the device is unrecognized by my computer when connecting to USB User, as opposed to the USB ST-LINK interface, so my further assumption is that the clock configuration error, and the lack of USB User interface are linked to one another.

Does anyone know where my error in thinking may lie?

2
Is it valid to switch both the HSI and HSE on? It is certainly unnecessary. Suggest RCC_OscInitStruct.HSIState = RCC_HSI_OFF. Not sure that will solve your problem however.Clifford
... looking at the source, it appear that HSIState is ignored when OscillatorType ==RCC_OSCILLATORTYPE_HSE, so not your problem.Clifford
You have not specified what the configuration error is. The title suggests a configuration error, but the body suggests a runtime error. Which is it? Certainly the clock-tree configuration must be such that the USB peripheral is clocked at exactly 48MHz.Clifford

2 Answers

0
votes

I've resoldered my external oscillator passive components as per the STM32F3DISCOVERY reference manual. The oscillator initialization no longer returns into the error handler and , so I can conclude this was a simple soldering error, and the HSE crystal oscillator now returns the correct values on all buses to operate USB, verifying that the software setup was correct.

-1
votes

Wrong configuration

  RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;

EDIT

Check the RCC register is the HSE is ready and on. enter image description here