cancel
Showing results for 
Search instead for 
Did you mean: 

Optimizing wake up time STM32L0.

TAnde.6
Associate II

I am trying to get an STM32L0 MCU to startup as quickly as possible. The datasheet says 5us wake up time from flash memory, but I am getting nowhere close to this. I loaded a super simple program that just toggles a GPIO and watched it on a logic analyzer (image attached). The top channel is the power while the second channel is the GPIO. It takes more than 10ms to enter the main loop where the GPIO starts toggling. How can I get this to happen quicker? I would like to do a SPI transaction within 10-20us of being powered on. Is that possible?

6 REPLIES 6
TDK
Guru

> The top channel is the power while the second channel is the GPIO. 

From wakeup or from power-up? Your plot suggests the latter, but the "5us wake up time" refers to something else.

The Default_Handler function in the startup script (typically startup_*.s) is what is actually run immediately at reset. This script copies memory and zeroes memory as required by your application. Then main() starts, which has its own startup stuff.

You'll need to modify this script, cut down on the amount of memory needing to be copied/zeroed.

You can toggle GPIO pins at various points during startup to better understand what portions are taking the most amount of time.

One easy thing to do is to immediately increase the clock speed so initialization goes quicker.

10-20us seems a bit optimistic. That would only leave tens of clocks to set up the peripheral and send out data. 1ms should be doable.

If you feel a post has answered your question, please click "Accept as Solution".

Does your super simple code fiddle with clocks, plls, etc?

Initialize and set the GPIO in startup.s at the Reset_Handler, determine how much time all the subsequent stuff is eating.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Which STM32?

For the absolute minimum time after powerup=reset, see Datasheet, Reset temporization parameter. It's usually several milliseconds.

The microseconds times refer to wakeup from low-power modes, i.e. you have to keep the mcu under power.

JW

TAnde.6
Associate II

Ok I have never looked into the startup_*.s file so I'll have to do some digging. I was using HAL to do the toggling, I have heard things about that not being super efficient. It doesn't look like the startup file is in C so that will be interesting. So the suggestion would be to setup and preform my desired operation in the startup file? Thanks for pointing me in the right direction.

Ahhh ok I see what you are saying. I think microsecond powerup/reset is probably out of the question. I will look into the low power modes. Thanks!

Microsecond wake-up is for a stop mode, not standby.