2021-09-13 12:47 PM
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?
2021-09-13 01:18 PM
> 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.
2021-09-13 01:32 PM
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.
2021-09-13 01:53 PM
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
2021-09-13 02:11 PM
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.
2021-09-13 02:22 PM
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!
2021-09-25 02:26 PM
Microsecond wake-up is for a stop mode, not standby.