2021-04-13 10:38 AM
2021-04-21 07:38 AM
Just for those who'd wonder, __attribute__((zero_init)) is Keil-specific (i.e. won't work in gcc).
JW
2021-04-13 01:01 PM
What does the datasheet say on reset time ("temporization")?
What do you mean by "startup time"? Does it include the startup code, i.e. setting the initialized (.data) variables and clearing the uninitialized (.bss) variables? Or does it also include the RCC setup?
If so, those are under your control, so rewrite them as you need.
JW
2021-04-14 06:16 AM
Looks like a HAL problem. Without it the MCU starts accurately after temporization time.
2021-04-14 02:31 PM
Then don't use Cube/HAL.
JW
2021-04-20 10:33 AM
Well. I made two versions: with HAL and without.
The version without HAL starts 5ms faster.
But... People!
Really strange things I discovered.
The startup time magically depends on the program size.
How I measured it.
I have two channel oscilloscope connected to the mcu vcc and some pin on it.
After I made mcu configured (clocks and so on) I toggle mcu pin and measure time passed.
The same source, all the same.
Experiment 1.
Compile, I get code size (6700 bytes).
The time from start till pin toggle is 15ms.
Experiment 2.
I put while(1); after pin toggle. Then compile, I get smaller code size of course (1400 bytes).
The time from start till pin toggle is 5ms.
Experiment 3.
Absolutely empty project, containing gpio configuration gives near 3ms.
How it is possible...
2021-04-20 03:53 PM
Startup code initializing variables, see my first post.
JW
2021-04-20 11:40 PM
Yes.
Already solved.
I used wrong attribute __attribute__( ( section( "NoInit")) ) ;
But now is __attribute__( ( section( "NoInit"),zero_init) ) ;
This prevents my huge arrays from initializing.
So my resume is like this: if you need fast start up then better do not use HAL and check that your RAM arrays are not initialized.
Thanks alot.
2021-04-21 07:38 AM
Just for those who'd wonder, __attribute__((zero_init)) is Keil-specific (i.e. won't work in gcc).
JW