Skip to main content
Calypso 2021
Associate
April 13, 2021
Solved

STM32L0xx Hello. Anybody knows the real startup time of this mcu? It is configured to run on HSI RC +PLL to produce 32MHz clock. But the startup time (at power up) is near 20ms...

  • April 13, 2021
  • 7 replies
  • 1578 views

..

This topic has been closed for replies.
Best answer by waclawek.jan

Just for those who'd wonder, __attribute__((zero_init)) is Keil-specific (i.e. won't work in gcc).

JW

7 replies

waclawek.jan
Super User
April 13, 2021

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

Calypso 2021
Associate
April 14, 2021

Looks like a HAL problem. Without it the MCU starts accurately after temporization time.

waclawek.jan
Super User
April 14, 2021

Then don't use Cube/HAL.

JW

Calypso 2021
Associate
April 20, 2021

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...

waclawek.jan
Super User
April 20, 2021

Startup code initializing variables, see my first post.

JW

Calypso 2021
Associate
April 21, 2021

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.

waclawek.jan
waclawek.janBest answer
Super User
April 21, 2021

Just for those who'd wonder, __attribute__((zero_init)) is Keil-specific (i.e. won't work in gcc).

JW