cancel
Showing results for 
Search instead for 
Did you mean: 

High frequency clock signal generation

Félix TREFOU
Associate II
Posted on April 16, 2018 at 23:34

Hi,

I'm facing a problem i can't solve. It seem so simple but i think i need an other point of view.

For a project using a led driver (LED1642GW) i need a clock in 20MHz~30MHz.

I forgot this oscillator in my hardware so i want to generate it with my MCU (and it will be cheaper).

I made the most simple project for my stm32L476VGT:

- HSI (or MSI) speeded up to 80MHz through PLLCLK.

- TIM5 with PWM or CC on Channel 1

- PA0 on Alternate function (TIM5 ch5) with very high speed

Reference manual is saying that internal clock of the timer is APB (so 80MHz).

Despite of my differents trys, i don't managed to get an output signal at 20MHz.

With the example bellow i expected a signal at 80/80 = 1MHz but i only get 400kHz...

Here is some screens:

0690X0000060AYIQA2.png0690X0000060AJIQA2.png0690X0000060AbpQAE.png0690X0000060AcTQAU.png

Did i miss something? Or does the GPIO not made for this purpose?

Thanks!

#cubemx #pwm #clock #signal-generation
18 REPLIES 18
Posted on April 19, 2018 at 00:22

I wouldn't call it Catch22, rather, a good lesson on merits and drawbacks of using 'libraries' and 'configurators'.

There ain't no silver bullet.

JW

Posted on April 19, 2018 at 07:30

It used to be one for named beginners, who stumble over a bug in Cube.

Studying Cube-generated code will confuse them even more, as it is a mixture of peripheral requirements and arbitrary design concepts, often drawn up in a terrible haste.

There ain't no silver bullet.

That much is true.

Cube is fine to attract those beginners, but it's not a good teacher. But we had it all before ...

Nawres GHARBI
ST Employee
Posted on April 19, 2018 at 10:25

Hi Felix, 

As a workaround you can use the LL driver for the RCC, the PLLM will be then well configured. 

This issue has been fixed and will be delivered in the next release. 

Posted on April 19, 2018 at 08:52

In fact i don't consider myself as a 'beginner' i'm used to read datasheet of lots of MCU. Before this try, i've used this code generator one or two time. I found that wasa good solution to get some hardware working fast and have a good overview of it, then make my own code.

Unfortunately it's not foolproof and i loosed time instead of save it. As

Waclawek.Jan

‌ said, I take it as a good lesson!

I think HAL continues to be a good way to start a code. You just have to leave it out when you want to optimize or when you have to work around it too much. Perhaps i'll start all my projects from scratch with more experience...

Posted on April 19, 2018 at 08:54

Ok, thanks you!

Posted on April 19, 2018 at 09:48

In fact i don't consider myself as a 'beginner' i'm used to read datasheet of lots of MCU.

The level of presentation of your problem implied this. But take a good look at all the other questions concerning Cube-generated code...

I think HAL continues to be a good way to start a code.

As long as you don't deviate from the use cases the Cube designers/implementers could imagine.

And I agree it is (would be) a very good tool for rapid prototyping.

If it just worked more reliably (beside of other issues...)

Posted on April 19, 2018 at 12:19

alternatively, you can either fix the bug in auto-generated code, or put your fix in the user code section.

or just completely abandon cube.

Posted on April 19, 2018 at 12:21

'

Cube is fine to attract those beginners'

if it is reasonably bug-free. that's especially true for beginners whose ability to debug the code is limited and even a tiny bug can be insurmountable.

that is the saddest part for things like Cube: when buggy, it is least helpful for people it is designed to help.

Nawres GHARBI
ST Employee
Posted on May 03, 2018 at 16:52

4.25.1 fixing this issue will be available by the end of this week