Skip to main content
CraigMeyers
Associate
April 2, 2022
Solved

STM32L151C8T6A clock configuration in CubeMX

  • April 2, 2022
  • 6 replies
  • 5545 views

The Clock Configuration tab in CubeMX is not happy and I cannot figure out what the problem is exactly. I only want to use HSE a 25MHz external clock source in BYPASS. And I do not intend to use the PLL. Is this a bug in the tool? How can I satisfy this clock configurator?

0693W00000LweunQAB.png

This topic has been closed for replies.
Best answer by TDK

The issue is that USB must be clocked from a crystal, but you're clocking it from HSI16 (by way of the PLL), which isn't accurate enough. Certain families support crystal-less USB, but the STM32L1 is not one of them.

CubeMX could and should be better at explaining why it flagged the error, but it's correct to flag it as an issue.

There's no good solution for you here since 25 MHz is too high for VCOInput. Using a different crystal is an option, but your SYSCLK speed will need to change in order to satisfy USB requirements.

6 replies

TDK
April 2, 2022

Seems like a bug, but maybe there's a reason. What does it do if you click Resolve Clock Issues? Can you attach your IOC?

"If you feel a post has answered your question, please click ""Accept as Solution""."
CraigMeyers
Associate
April 2, 2022

Fails immediately, with dialog box Clock Wizard saying "Cannot found solution for some constraints" and "Searching Solution, Please Wait..." progress bar zipping back and forth.

I've attached the IOC file.

CraigMeyers
Associate
April 2, 2022

screenshot of resolver results...attached.

TDK
TDKBest answer
April 3, 2022

The issue is that USB must be clocked from a crystal, but you're clocking it from HSI16 (by way of the PLL), which isn't accurate enough. Certain families support crystal-less USB, but the STM32L1 is not one of them.

CubeMX could and should be better at explaining why it flagged the error, but it's correct to flag it as an issue.

There's no good solution for you here since 25 MHz is too high for VCOInput. Using a different crystal is an option, but your SYSCLK speed will need to change in order to satisfy USB requirements.

"If you feel a post has answered your question, please click ""Accept as Solution""."
CraigMeyers
Associate
April 3, 2022

I have access to 8MHz oscillator that I can use. Problem is, my system operates on 25MHz clock.

And the datasheet is misleading WRT crystal-less USB:

0693W00000LwhVpQAJ.pngBut I see the USB interface requires a 48MHz clock, which requires the PLL. If I select HSE (of 25MHz), it's too large for VCOInput (limited to 24MHz). And you cannot make a 48MHz clock from a 25MHz clock:0693W00000LwhWKQAZ.png 

Thanks for the answers!!

Swhit.2
Visitor II
April 3, 2022

That was really helpful and brief guide