2018-04-16 02:34 PM
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:
Did i miss something? Or does the GPIO not made for this purpose?
Thanks!
#cubemx #pwm #clock #signal-generation2018-04-18 05:22 PM
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
2018-04-19 12:30 AM
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 ...
2018-04-19 01:25 AM
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.
2018-04-19 01:52 AM
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...
2018-04-19 01:54 AM
Ok, thanks you!
2018-04-19 02:48 AM
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...)
2018-04-19 05:19 AM
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.
2018-04-19 05:21 AM
'
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.
2018-05-03 07:52 AM
4.25.1 fixing this issue will be available by the end of this week