Skip to main content
Associate II
Feb 16, 2026 1:33 PM UTC
Question

SysTick in Standby and Sleep mode

Hi,

I am using Nucleo-L476RG. My I want to send data over SPI every 20000ms and during this 20000ms MCU will goes in sleep/standby mode. I want to keep track time of last 2 SPI data transmission.

But the issue is HAL_GetTick() reset after waking up from standby mode. so not able to track the time between last two data transfer.

5 replies

Andrew Neil
Super User
Feb 16, 2026 1:35 PM UTC

Use the RTC ?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
TDK
Feb 16, 2026 1:37 PM UTC

In sleep mode, data is kept. Should be straightforward doing this.

In standby mode, SRAM data is lost but you can adjust your program to keep SRAM2 and store data there between resets. You'll have to ensure it is not initialized on startup.

TDK_0-1771248967350.png

 

"If you feel a post has answered your question, please click ""Accept as Solution""."
mangesh1Author
Associate II
Feb 16, 2026 2:14 PM UTC

I want to keep track exact time between last 2 data transfer like.
1 data sent at 1ms --> MCU goes sleep/ standby mode for 20000ms --> MCU wake Up --> 2nd data sent at 20001ms --> MCU goes sleep/ standby mode for 20000ms --> MCU wake Up --> 3rd data sent at 20004ms --> MCU goes sleep/ standby mode for 20000ms --> MCU wake Up....

The issue is HAL_GetTick() reset after waking up from standby mode. so not able to track the time between last two data transfer.


 I can't use RTC because it is not battery powered device.


Is there any solution for the same?

Andrew Neil
Super User
Feb 16, 2026 2:23 PM UTC

@mangesh1 wrote:

 I can't use RTC because it is not battery powered device.


Sure, you can use the RTC in a non battery-powered device!

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Gyessine
ST Technical Moderator
Feb 17, 2026 8:33 AM UTC

Hello @mangesh1 
If using STOP mode is an available option, you can use LPTIMER to track the time between each 2 data transfers.
BR
Gyessine

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.