cancel
Showing results for 
Search instead for 
Did you mean: 

Enable USB Clock Source Freezes Execution

Richard Lowe
Senior III
Posted on April 30, 2018 at 14:43

Simple demo application on the Nucleo-L476RG generated in CubeMX with HAL version 1. Nothing but USB Host and a few GPIOs for LEDs enabled.

When it comes to the `SystemClock_Config()` it freezes when enabling the clock source for the USB.

if(PeriphClkInit->UsbClockSelection == RCC_USBCLKSOURCE_PLLSAI1)
 {
 /* PLLSAI1 input clock, parameters M, N & Q configuration and clock output (PLLSAI1ClockOut) */
 ret = RCCEx_PLLSAI1_Config(&(PeriphClkInit->PLLSAI1), DIVIDER_Q_UPDATE);
 if(ret != HAL_OK)�?�?�?�?�?�?

`ret` is always `HAL_ERROR` which causes an infinite loop at:

if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
 {
 _Error_Handler(__FILE__, __LINE__);
 }�?�?�?�?

Just wondering if I have a hardware issue or something I missed in clock initialization.

#clock #usb #bug #cubemx
1 ACCEPTED SOLUTION

Accepted Solutions
Richard Lowe
Senior III
Posted on May 03, 2018 at 09:17

Same issue as

https://community.st.com/0D50X00009Xkb5hSAB

so guess I'm not alone now.

View solution in original post

7 REPLIES 7
Posted on April 30, 2018 at 15:17

Just wondering if I have a hardware issue or something I missed in clock initialization.

Why don't you step through

RCCEx_PLLSAI1_Config 

to find out?

JW

Richard Lowe
Senior III
Posted on April 30, 2018 at 19:58

Thanks, waclawek.jan, done that. Crashes at this macro:

 (((READ_BIT(RCC->PLLCFGR, RCC_PLLCFGR_PLLM) >> RCC_PLLCFGR_PLLM_Pos) + 1U) != PllSai1->PLLSAI1M)�?

Found in `stm32l4xx_hal_rcc_ex.c` on line 2969

Richard Lowe
Senior III
Posted on April 30, 2018 at 20:41

Looks like this might be a CubeMX generation issue on the L4. When not using the PLLSAI1Q as a clock source all works fine.

Posted on May 01, 2018 at 00:07

This line says, that you attempted to change the already set M divider.

JW

Richard Lowe
Senior III
Posted on May 02, 2018 at 17:31

Bug found!

CubeMX HAL framework 1.11 omits the M divider from project generation.

Add the following to the clock init function and you are off to the races.

`

RCC_OscInitStruct.

PLL

.

PLLM

=

1

;`  

Richard Lowe
Senior III
Posted on May 03, 2018 at 09:17

Same issue as

https://community.st.com/0D50X00009Xkb5hSAB

so guess I'm not alone now.

Nawres GHARBI
ST Employee
Posted on May 16, 2018 at 19:11

Hi

Lowe.Richard

Please update to the 4.1